diff options
-rw-r--r-- | demo/fancy/main.lua | 10 | ||||
-rw-r--r-- | src/opengl/gl.c | 17 |
2 files changed, 25 insertions, 2 deletions
diff --git a/demo/fancy/main.lua b/demo/fancy/main.lua index 19b3239..3defde6 100644 --- a/demo/fancy/main.lua +++ b/demo/fancy/main.lua @@ -24,6 +24,12 @@ glfw.MakeContextCurrent(w) gl.InitGlad() gl.Enable(gl.DEPTH_TEST) +-- query gl data +print("vendor", gl.GetString(gl.VENDOR)) +print("renderer", gl.GetString(gl.RENDERER)) +print("version", gl.GetString(gl.VERSION)) +print("glsl version", gl.GetString(gl.SHADING_LANGUAGE_VERSION)) + --window.setFramebufferSizeCallback(w, function(_, width, height) -- print(string.format("resize: (%d, %d)", width, height)) -- gl.Viewport(0, 0, width, height) @@ -33,7 +39,7 @@ gl.Enable(gl.DEPTH_TEST) --====== compile shaders ======-- local vertexShaderSource = [[ -#version 330 core +#version 410 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; @@ -53,7 +59,7 @@ void main() ]] local fragmentShaderSource = [[ -#version 330 core +#version 410 core out vec4 FragColor; in vec3 pos; diff --git a/src/opengl/gl.c b/src/opengl/gl.c index 532d818..6643f5f 100644 --- a/src/opengl/gl.c +++ b/src/opengl/gl.c @@ -18,6 +18,7 @@ int glad_init(lua_State *L); int gl_get_error(lua_State *L); int gl_enable(lua_State *L); int gl_disable(lua_State *L); +int glGetString_bind(lua_State *L); void setup_gl(lua_State *L, int honey_index) { @@ -27,6 +28,7 @@ void setup_gl(lua_State *L, int honey_index) H_FUNC("GetError", gl_get_error), H_FUNC("Enable", gl_enable), H_FUNC("Disable", gl_disable), + H_FUNC("GetString", glGetString_bind), /******** enums ********/ /* data types */ @@ -47,6 +49,12 @@ void setup_gl(lua_State *L, int honey_index) H_INT("DEPTH_TEST", GL_DEPTH_TEST), H_INT("CULL_FACE", GL_CULL_FACE), + /* strings */ + H_INT("VENDOR", GL_VENDOR), + H_INT("RENDERER", GL_RENDERER), + H_INT("VERSION", GL_VERSION), + H_INT("SHADING_LANGUAGE_VERSION", GL_SHADING_LANGUAGE_VERSION), + H_END }; create_table(L, tbl); @@ -90,3 +98,12 @@ int gl_disable(lua_State *L) glDisable(cap); return 0; } + + +int glGetString_bind(lua_State *L) +{ + int name = luaL_checkinteger(L, 1); + const char *str = glGetString(name); + lua_pushstring(L, str); + return 1; +} |