diff options
author | scuri <scuri> | 2009-08-14 11:19:14 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-08-14 11:19:14 +0000 |
commit | 223bda3d2208aae866db173b10f7be1f57e44e65 (patch) | |
tree | 31e460524f4988a8c820fd6b1e926ffaa49293df /html/examples/viewGL.wlua | |
parent | 380fdb5d8c80d094e5a8bc82bfc091bc87e6c43e (diff) |
*** empty log message ***
Diffstat (limited to 'html/examples/viewGL.wlua')
-rw-r--r-- | html/examples/viewGL.wlua | 76 |
1 files changed, 76 insertions, 0 deletions
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 |