This commit is contained in:
Alex Clink 2021-12-20 22:45:08 -05:00
parent f2bccd41da
commit a03670e9f6
4 changed files with 9 additions and 10 deletions

View file

@ -10,18 +10,17 @@ require "../src/3d/*"
class ThreeDee < PF::Game
@projector : PF::Projector
@paused = false
@light : PF::Vec3d(Float64) = PF::Vec3d.new(0.0, 0.0, -1.0).normalized
@speed = 5.0
@camera : PF::Camera
@text = PF::PixelText.new("assets/pf-font.png")
@paused = false
@speed = 5.0
@text = PF::PixelText.new("./assets/pf-font.png")
def initialize(@width, @height, @scale)
super(@width, @height, @scale)
def initialize(*args, **kwargs)
super
@projector = PF::Projector.new(@width, @height)
@camera = @projector.camera
@model = PF::Mesh.load_obj("examples/pixelfaucet.obj")
@model = PF::Mesh.load_obj("./assets/pixelfaucet.obj")
@model.position.z = @model.position.z + 2.0
@controller = PF::Controller(LibSDL::Keycode).new({
@ -112,5 +111,5 @@ class ThreeDee < PF::Game
end
end
engine = ThreeDee.new(200, 160, 4)
engine = ThreeDee.new(320, 200, 4)
engine.run!

View file

@ -23,10 +23,10 @@ module PF
@last_time : Float64 = Time.monotonic.total_milliseconds
@controller : Controller(LibSDL::Keycode)
def initialize(@width, @height, @scale = 1, @title = self.class.name, flags = SDL::Renderer::Flags::PRESENTVSYNC)
def initialize(@width, @height, @scale = 1, @title = self.class.name, flags = SDL::Renderer::Flags::ACCELERATED)
SDL.init(SDL::Init::VIDEO)
@window = SDL::Window.new(@title, @width * @scale, @height * @scale)
@renderer = SDL::Renderer.new(@window, flags: flags) # , flags: SDL::Renderer::Flags::SOFTWARE)
@renderer = SDL::Renderer.new(@window, flags: flags)
@renderer.scale = {@scale, @scale}
@screen = SDL::Surface.new(LibSDL.create_rgb_surface(
flags: 0, width: @width, height: @height, depth: 32,