summaryrefslogtreecommitdiff
path: root/iup/srclua5/iuplua_glcanvas.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-04 11:56:41 -0800
committerPixel <pixel@nobis-crew.org>2009-11-04 11:59:33 -0800
commitd577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch)
tree590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/srclua5/iuplua_glcanvas.c
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/srclua5/iuplua_glcanvas.c')
-rwxr-xr-xiup/srclua5/iuplua_glcanvas.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/iup/srclua5/iuplua_glcanvas.c b/iup/srclua5/iuplua_glcanvas.c
new file mode 100755
index 0000000..c50ba8f
--- /dev/null
+++ b/iup/srclua5/iuplua_glcanvas.c
@@ -0,0 +1,82 @@
+/** \file
+ * \brief iupgl binding for Lua 5.
+ *
+ * See Copyright Notice in "iup.h"
+ */
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "iup.h"
+#include "iupgl.h"
+
+#include "iuplua.h"
+#include "iupluagl.h"
+#include "il.h"
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <GL/gl.h>
+
+static int GLIsCurrent(lua_State *L)
+{
+ lua_pushboolean(L, IupGLIsCurrent(iuplua_checkihandle(L,1)));
+ return 1;
+}
+
+static int GLMakeCurrent(lua_State *L)
+{
+ IupGLMakeCurrent(iuplua_checkihandle(L,1));
+
+ iuplua_changeEnv(L);
+ iuplua_regstring(L, (const char*)glGetString(GL_VENDOR), "GL_VENDOR");
+ iuplua_regstring(L, (const char*)glGetString(GL_RENDERER), "GL_RENDERER");
+ iuplua_regstring(L, (const char*)glGetString(GL_VERSION), "GL_VERSION");
+ iuplua_returnEnv(L);
+
+ return 0;
+}
+
+static int GLSwapBuffers(lua_State *L)
+{
+ IupGLSwapBuffers(iuplua_checkihandle(L,1));
+ return 0;
+}
+
+static int GLPalette(lua_State *L)
+{
+ Ihandle *self = iuplua_checkihandle(L,1);
+ int index = luaL_checkint(L,2);
+ float r = (float)luaL_checknumber(L,3);
+ float g = (float)luaL_checknumber(L,4);
+ float b = (float)luaL_checknumber(L,5);
+ IupGLPalette(self, index, r, g, b);
+ return 0;
+}
+
+static int GLUseFont(lua_State *L)
+{
+ Ihandle *self = iuplua_checkihandle(L,1);
+ int first = luaL_checkint(L,2);
+ int count = luaL_checkint(L,3);
+ int list_base = luaL_checkint(L,4);
+ IupGLUseFont(self, first, count, list_base);
+ return 0;
+}
+
+static int GLWait(lua_State *L)
+{
+ IupGLWait(luaL_checkint(L,1));
+ return 0;
+}
+
+void iuplua_glcanvasfuncs_open (lua_State *L)
+{
+ iuplua_register(L, GLSwapBuffers, "GLSwapBuffers");
+ iuplua_register(L, GLIsCurrent, "GLIsCurrent");
+ iuplua_register(L, GLMakeCurrent, "GLMakeCurrent");
+ iuplua_register(L, GLPalette, "GLPalette");
+ iuplua_register(L, GLUseFont, "GLUseFont");
+ iuplua_register(L, GLWait, "GLWait");
+}