From 223bda3d2208aae866db173b10f7be1f57e44e65 Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 14 Aug 2009 11:19:14 +0000 Subject: *** empty log message *** --- html/examples/viewGL.wlua | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 html/examples/viewGL.wlua (limited to 'html/examples') diff --git a/html/examples/viewGL.wlua b/html/examples/viewGL.wlua new file mode 100644 index 0000000..f5ce58a --- /dev/null +++ b/html/examples/viewGL.wlua @@ -0,0 +1,76 @@ +require("iuplua") +require("iupluagl") +require("luagl") +require("imlua") + +iup.key_open() + +texture = 0 + +cnv = iup.glcanvas{buffer="DOUBLE", rastersize = "640x480"} + +function cnv:resize_cb(width, height) + iup.GLMakeCurrent(self) + gl.Viewport(0, 0, width, height) +end + +function cnv:action(x, y) + iup.GLMakeCurrent(self) + gl.PixelStore(gl.UNPACK_ALIGNMENT, 1) + gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT') -- Clear Screen And Depth Buffer + + gl.DrawPixelsRaw (image:Width(), image:Height(), glformat, gl.UNSIGNED_BYTE, gldata) + + iup.GLSwapBuffers(self) +end + +function cnv:k_any(c) + if c == iup.K_q or c == iup.K_ESC then + return iup.CLOSE + end + + if c == iup.K_F1 then + if fullscreen then + fullscreen = false + dlg.fullscreen = "No" + else + fullscreen = true + dlg.fullscreen = "Yes" + end + end + + if c == iup.K_F2 then + fileName = iup.GetFile("*.*") + new_image = im.FileImageLoadBitmap(fileName) + if (not new_image) then + iup.Message("Error", "LoadBitmap failed.") + else + gldata, glformat = new_image:GetOpenGLData() + if (image) then image:Destroy() end + image = new_image + iup.Update(cnv) + end + end + +end + +if arg and arg[1] ~= nil then + fileName = arg[1] +else + fileName = iup.GetFile("*.*") +end + +image = im.FileImageLoadBitmap(fileName) +if (not image) then + error("LoadBitmap failed.") +end +gldata, glformat = image:GetOpenGLData() + +dlg = iup.dialog{cnv; title="LuaGL/IUP/IM Loader"} + +dlg:show() +cnv.rastersize = nil -- reset minimum limitation + +if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then + iup.MainLoop() +end -- cgit v1.2.3