From cddfc09ccc286726736fa436a10919021a177b69 Mon Sep 17 00:00:00 2001 From: jussi Date: Fri, 25 Oct 2024 21:19:42 +0300 Subject: glDepthRange and glPolygonOffset. --- src/gl.c | 28 ++++++++++++++++++++++++++++ src/lua_core.c | 4 ++++ src/models.c | 2 +- src/rgui.c | 4 ++-- 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gl.c b/src/gl.c index ec27d3b..4082e27 100644 --- a/src/gl.c +++ b/src/gl.c @@ -77,6 +77,20 @@ int lglBlitFramebuffer( lua_State* L ) { ## OpenGL - State Management */ +/* +> RL.glDepthRange( float nearVal, float farVal ) + +Specify mapping of depth values from normalized device coordinates to window coordinates +*/ +int lglDepthRange( lua_State* L ) { + float nearVal = luaL_checknumber( L, 1 ); + float farVal = luaL_checknumber( L, 2 ); + + glDepthRange( nearVal, farVal ); + + return 0; +} + /* > RL.glEnable( int cap ) @@ -103,6 +117,20 @@ int lglDisable( lua_State* L ) { return 0; } +/* +> RL.glPolygonOffset( float factor, float units ) + +Set the scale and units used to calculate depth values +*/ +int lglPolygonOffset( lua_State* L ) { + float factor = luaL_checknumber( L, 1 ); + float units = luaL_checknumber( L, 2 ); + + glPolygonOffset( factor, units ); + + return 0; +} + /* > RL.glStencilFunc( int func, int ref, int mask ) diff --git a/src/lua_core.c b/src/lua_core.c index 94c2134..388dbe1 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -983,6 +983,8 @@ static void defineGlobals() { assignGlobalInt( GL_DEPTH_TEST, "GL_DEPTH_TEST" ); // If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and glDepthRangef assignGlobalInt( GL_DITHER, "GL_DITHER" ); // If enabled, dither color components or indices before they are written to the color buffer assignGlobalInt( GL_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL" ); // If enabled, an offset is added to depth values of a polygon's fragments produced by rasterization. See glPolygonOffset + assignGlobalInt( GL_POLYGON_OFFSET_LINE, "GL_POLYGON_OFFSET_LINE" ); + assignGlobalInt( GL_POLYGON_OFFSET_POINT, "GL_POLYGON_OFFSET_POINT" ); assignGlobalInt( GL_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE" ); // If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value assignGlobalInt( GL_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE" ); // If enabled, the fragment's coverage is ANDed with the temporary coverage value. If GL_SAMPLE_COVERAGE_INVERT is set to GL_TRUE, invert the coverage value. See glSampleCoverage assignGlobalInt( GL_SCISSOR_TEST, "GL_SCISSOR_TEST" ); // If enabled, discard fragments that are outside the scissor rectangle. See glScissor @@ -2323,8 +2325,10 @@ void luaRegister() { /* Frame Buffers. */ assingGlobalFunction( "glBlitFramebuffer", lglBlitFramebuffer ); /* State Management. */ + assingGlobalFunction( "glDepthRange", lglDepthRange ); assingGlobalFunction( "glEnable", lglEnable ); assingGlobalFunction( "glDisable", lglDisable ); + assingGlobalFunction( "glPolygonOffset", lglPolygonOffset ); assingGlobalFunction( "glStencilFunc", lglStencilFunc ); assingGlobalFunction( "glStencilFuncSeparate", lglStencilFuncSeparate ); assingGlobalFunction( "glStencilMask", lglStencilMask ); diff --git a/src/models.c b/src/models.c index 0466812..c2232d0 100644 --- a/src/models.c +++ b/src/models.c @@ -1317,7 +1317,7 @@ int lmodelsGenMeshTangents( lua_State* L ) { /* > meshData = RL.GetMeshData( Mesh mesh ) -Get mesh data as table. +Get mesh vertex attributes data as table. - Success return Mesh{} */ diff --git a/src/rgui.c b/src/rgui.c index f1532a3..befb725 100644 --- a/src/rgui.c +++ b/src/rgui.c @@ -117,7 +117,7 @@ int lguiGuiGetState( lua_State* L ) { } /* -> RL.GuiSetSliderDragging() +> RL.GuiSetSliderDragging( bool dragging ) Set guiSliderDragging */ @@ -143,7 +143,7 @@ int lguiGuiGetSliderDragging( lua_State* L ) { } /* -> RL.GuiSetSliderActive() +> RL.GuiSetSliderActive( Rectange rect ) Set guiSliderActive */ -- cgit v1.2.3