1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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");
}
|