diff options
Diffstat (limited to 'demo/fancy/main.lua')
-rw-r--r-- | demo/fancy/main.lua | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/demo/fancy/main.lua b/demo/fancy/main.lua index 54472c5..19b3239 100644 --- a/demo/fancy/main.lua +++ b/demo/fancy/main.lua @@ -1,5 +1,6 @@ local gl = honey.gl -local window = honey.window +local glfw = honey.glfw +--local window = honey.window --===== initialize audio =====-- @@ -10,23 +11,23 @@ honey.ma.engine_play_sound(engine, 'example_sound.ogg', nil) --====== initialize opengl ======-- -gl.Init() -window.setHint(window.hintType.contextVersionMajor, 3) -window.setHint(window.hintType.contextVersionMinor, 3) -window.setHint(window.hintType.openGlProfile, window.profileType.openGlCoreProfile) +glfw.Init() +--window.setHint(window.hintType.contextVersionMajor, 3) +--window.setHint(window.hintType.contextVersionMinor, 3) +--window.setHint(window.hintType.openGlProfile, window.profileType.openGlCoreProfile) --====== create window ======-- -local w = window.create(640, 480, 'hello, world!') -window.makeContextCurrent(w) +local w = glfw.CreateWindow(640, 480, 'hello, world!', glfw.monitor_NULL, glfw.window_NULL) +glfw.MakeContextCurrent(w) gl.InitGlad() gl.Enable(gl.DEPTH_TEST) -window.setFramebufferSizeCallback(w, function(_, width, height) - print(string.format("resize: (%d, %d)", width, height)) - gl.Viewport(0, 0, width, height) -end) +--window.setFramebufferSizeCallback(w, function(_, width, height) +-- print(string.format("resize: (%d, %d)", width, height)) +-- gl.Viewport(0, 0, width, height) +--end) --====== compile shaders ======-- @@ -277,8 +278,8 @@ honey.glm.perspective(math.rad(45), 800/600, 0.1, 100, projection) local transform = honey.glm.mat4_create() -while not window.shouldClose(w) do - local time = window.getTime() +while glfw.WindowShouldClose(w) == glfw.FALSE do + local time = glfw.GetTime() gl.ClearColor(0.2, 0.3, 0.3, 1.0) gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT) @@ -306,14 +307,14 @@ while not window.shouldClose(w) do gl.BindVertexArray(suzanne.vertexArr) gl.DrawElements(gl.TRIANGLES, #suzanne.indices, gl.UNSIGNED_INT, 0) - window.swapBuffers(w) - window.pollEvents() + glfw.SwapBuffers(w) + glfw.PollEvents() end --===== shut down =====-- -window.destroy(w) -gl.Terminate() +glfw.DestroyWindow(w) +glfw.Terminate() honey.ma.engine_uninit(engine) --image.surface_destroy(surface) --image.context_destroy(cr) |