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 FooBar | |
| def initialize(@value = 0) | |
| end | |
| def value | |
| @value | |
| end | |
| protected def value=(val) | |
| @value = val |
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
| struct Vector2(Type) | |
| SIZE = 2 | |
| TYPE = Type | |
| ZERO = self.new() | |
| ONE = self.new(1, 1) | |
| property :x, :y | |
| @x : Type | |
| @y : Type |
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
| private macro do_math(operator, times) | |
| self[{{SIZE - times}}].{{operator}}(other[{{SIZE - times}})] | |
| {% if times != 0 %} | |
| , do_math({{operator}}, {{times - 1}}) | |
| {% end %} | |
| end | |
| def +(other : Vector(Type, Size)) | |
| self.class.new(do_math(:+, SIZE)) | |
| 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
| def self.translate(matrix : Matrix(T, 4, 16), translation : Vector(T, 3)) forall T | |
| cpy = matrix.dup | |
| cpy[3, 0] = translation.x | |
| cpy[3, 1] = translation.y | |
| cpy[3, 2] = translation.z | |
| cpy | |
| end | |
| def self.translate(matrix : Matrix(T, 4, 16), translation : Vector(T, 3)) forall T | |
| matrix[3, 0] = translation.x |
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() |
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
| 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
| 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
| 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) |