This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Page | |
| # .... | |
| private def render_glyph_to_texture(glyph, width, height) : Nil | |
| bitmap = @face.value.glyph.value.bitmap | |
| buffer = Bytes.new bitmap.buffer, bitmap.width * bitmap.rows | |
| show_pixels bitmap.buffer, bitmap.width, bitmap.rows | |
| @texture.update(bitmap.buffer, bitmap.width, bitmap.rows, 0, 0, 8) | |
| end | |
| def show_pixels(pixels, width, height) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "boleite" | |
| require "./ego/*" | |
| require "./ego/serializers/*" | |
| app = EgoApplication.new # Inherits from Boleite::Application, defines how to get the configuration | |
| app.state_stack.push GameState.new(app) | |
| app.run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "crystal-clear" | |
| class FooBar | |
| invariants do | |
| @val != nil | |
| end | |
| def initialize(@val = nil) | |
| @val = 5 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias Vector4f32 = Boleite::Vector4f32 | |
| alias Vector2f32 = Boleite::Vector2f32 | |
| struct SimpleVertex < Boleite::Vertex | |
| @pos = Vector4f32.zero | |
| @color = Vector4f32.zero | |
| @uv = Vector2f32.zero | |
| def initialize | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if LibGLFW3.init != 0 | |
| error_callback = ->(error : Int32, description : Int8*) { | |
| puts "Error #{error}: #{String.new(description.as(UInt8*))}" | |
| } | |
| LibGLFW3.setErrorCallback(error_callback) | |
| LibGLFW3.windowHint(LibGLFW3::OPENGL_PROFILE, LibGLFW3::OPENGL_CORE_PROFILE) | |
| LibGLFW3.windowHint(LibGLFW3::OPENGL_FORWARD_COMPAT, 1) | |
| LibGLFW3.windowHint(LibGLFW3::CONTEXT_VERSION_MAJOR, 4) | |
| LibGLFW3.windowHint(LibGLFW3::CONTEXT_VERSION_MINOR, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if LibGLFW3.init != 0 | |
| error_callback = ->(error : Int32, description : Int8*) { | |
| puts "Error #{error}: #{String.new(description.as(UInt8*))}" | |
| } | |
| LibGLFW3.setErrorCallback(error_callback) | |
| LibGLFW3.windowHint(LibGLFW3::OPENGL_PROFILE, LibGLFW3::OPENGL_CORE_PROFILE) | |
| LibGLFW3.windowHint(LibGLFW3::OPENGL_FORWARD_COMPAT, 1) | |
| LibGLFW3.windowHint(LibGLFW3::CONTEXT_VERSION_MAJOR, 4) | |
| LibGLFW3.windowHint(LibGLFW3::CONTEXT_VERSION_MINOR, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Glue | |
| abstract def interested?(input) : Bool | |
| abstract def execute(input) : Nil | |
| end | |
| class GlueImp(T, P) < Glue | |
| def initialize(@bar : T, @callback : P) | |
| end | |
| def interested?(input) : Bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| receiver = Boleite::InputReceiver.new | |
| receiver.action_table << Boleite::DefaultAction.new :close | |
| receiver.action_table << Boleite::MoveCameraAction.new :player_camera | |
| receiver.register :close, ->() { puts "Closing!" } | |
| receiver.register :player_camera, ->(x : Float64, y : Float64) { puts "Moving camera!" } | |
| receiver.process Boleite::ClosedEvent.new | |
| receiver.process Boleite::MouseMovedEvent.new(some_x, some_y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Binding code | |
| type Monitor = Void* | |
| type Window = Void* | |
| type Cursor = Void* | |
| # My code | |
| module Boleite | |
| # Forward declaration | |
| class RenderTarget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Boleite | |
| abstract struct Configuration | |
| end | |
| abstract class Application | |
| getter :configuration | |
| @configuration : Configuration | |
| def initialize() |