summaryrefslogtreecommitdiff
path: root/test/lua
diff options
context:
space:
mode:
authorscuri <scuri>2009-08-14 11:19:14 +0000
committerscuri <scuri>2009-08-14 11:19:14 +0000
commit223bda3d2208aae866db173b10f7be1f57e44e65 (patch)
tree31e460524f4988a8c820fd6b1e926ffaa49293df /test/lua
parent380fdb5d8c80d094e5a8bc82bfc091bc87e6c43e (diff)
*** empty log message ***
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/viewGL.wlua76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/lua/viewGL.wlua b/test/lua/viewGL.wlua
new file mode 100644
index 0000000..f5ce58a
--- /dev/null
+++ b/test/lua/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