aboutsummaryrefslogtreecommitdiffstats
path: root/game
diff options
context:
space:
mode:
authorHawkear <Hawkear@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-01-03 02:21:14 +0000
committerHawkear <Hawkear@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-01-03 02:21:14 +0000
commitdee46c9e1faf98750496e04352b5b3411b979d2f (patch)
treee96fb1e18553fa468b49a91ea99c8c18a3d5a581 /game
parent2ec120340f57d3e5d23643828a44418d75ca8fd1 (diff)
downloadusdx-dee46c9e1faf98750496e04352b5b3411b979d2f.tar.gz
usdx-dee46c9e1faf98750496e04352b5b3411b979d2f.tar.xz
usdx-dee46c9e1faf98750496e04352b5b3411b979d2f.zip
Functions from ULog and some from OpenGL available in Lua
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/Lua@1548 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'game')
-rw-r--r--game/LuaCommands.odtbin0 -> 15724 bytes
-rw-r--r--game/main.lua38
2 files changed, 38 insertions, 0 deletions
diff --git a/game/LuaCommands.odt b/game/LuaCommands.odt
new file mode 100644
index 00000000..fcbcc426
--- /dev/null
+++ b/game/LuaCommands.odt
Binary files differ
diff --git a/game/main.lua b/game/main.lua
new file mode 100644
index 00000000..ed12d8ed
--- /dev/null
+++ b/game/main.lua
@@ -0,0 +1,38 @@
+-- Calculate FPS
+FPScounter = 1 + (FPScounter or 0) -- increment FPScounter (which is nil, when undefined, therefore "or 0")
+if os.time() > (LastTime or 0) then
+ LastTime = os.time()
+ print("FPS: " .. FPScounter - (LastFPScounter or 0)) -- print is only displayed, if compiled with DEBUG
+ LastFPScounter = FPScounter
+ -- Show the first 200 Textures
+ TexNum = 1 + (TexNum or 0)
+ if TexNum > 200 then TexNum = 1 end
+ print("TexNum: " .. (TexNum or 0))
+end
+
+-- Draw some rectangles
+gl.Enable("GL_BLEND")
+gl.Color(1, 1, 1, 0.5)
+for i = 1,10 do
+ gl.Begin("GL_LINE_loop")
+ gl.Vertex(0+4*i, 0+4*i);
+ gl.Vertex(0+4*i, 600-4*i);
+ gl.Vertex(800-4*i, 600-4*i);
+ gl.Vertex(800-4*i, 0+4*i);
+ gl.End()
+end
+gl.Disable("GL_BLEND")
+
+-- Display a Texture
+gl.Enable("GL_BLEND")
+gl.Enable("GL_TEXTURE_2D")
+gl.Color(1, 1, 1, 1)
+gl.BindTexture("GL_TEXTURE_2D", TexNum or 0)
+gl.Begin("GL_QUADS")
+gl.TexCoord(0, 0); gl.Vertex(10, 10);
+gl.TexCoord(0, 1); gl.Vertex(10, 110);
+gl.TexCoord(1, 1); gl.Vertex(110, 110);
+gl.TexCoord(1, 0); gl.Vertex(110, 10);
+gl.End()
+gl.Disable("GL_TEXTURE_2D")
+gl.Disable("GL_BLEND")