summaryrefslogtreecommitdiff
path: root/src/glfw/context.c
blob: e22533ea2b2d3ab0fc68991a6207a51789a21c36 (plain)
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
#include <lua.h>
#include <lauxlib.h>
#include <GLFW/glfw3.h>
#include "setup.h"


int glfwMakeContextCurrent_bind(lua_State *L)
{
	GLFWwindow ** window = luaL_checkudata(L, 1, glfw_window_tname);
	glfwMakeContextCurrent(*window);
	return 0;
}


int glfwGetCurrentContext_bind(lua_State *L)
{
	GLFWwindow *  bind_result = glfwGetCurrentContext();
	struct h_glfw_window_data_t *data = glfwGetWindowUserPointer(bind_result);
	lua_rawgeti(L, LUA_REGISTRYINDEX, data->self_ref);
	return 1;
}


int glfwSwapInterval_bind(lua_State *L)
{
	int interval = luaL_checkinteger(L, 1);
	glfwSwapInterval(interval);
	return 0;
}


int glfwExtensionSupported_bind(lua_State *L)
{
	const char * extension = luaL_checkstring(L, 1);
	int  bind_result = glfwExtensionSupported(extension);
	lua_pushinteger(L, bind_result);
	return 1;
}


int glfwGetProcAddress_bind(lua_State *L)
{
	const char * procname = luaL_checkstring(L, 1);
	GLFWglproc  bind_result = glfwGetProcAddress(procname);
	lua_pushlightuserdata(L, bind_result);
	return 1;
}