From cddfc09ccc286726736fa436a10919021a177b69 Mon Sep 17 00:00:00 2001 From: jussi Date: Fri, 25 Oct 2024 21:19:42 +0300 Subject: glDepthRange and glPolygonOffset. --- API.md | 26 +++++++++++++++++++++++--- ReiLua_API.lua | 22 +++++++++++++++++++--- changelog | 1 + devnotes | 3 +++ examples/2D_lights/main.lua | 4 ++-- include/lgl.h | 2 ++ include/raygui.h | 4 ++-- src/gl.c | 28 ++++++++++++++++++++++++++++ src/lua_core.c | 4 ++++ src/models.c | 2 +- src/rgui.c | 4 ++-- 11 files changed, 87 insertions(+), 13 deletions(-) diff --git a/API.md b/API.md index c5d5248..5ac494d 100644 --- a/API.md +++ b/API.md @@ -3398,6 +3398,14 @@ If enabled, an offset is added to depth values of a polygon's fragments produced --- +> GL_POLYGON_OFFSET_LINE = 10754 + +--- + +> GL_POLYGON_OFFSET_POINT = 10753 + +--- + > GL_SAMPLE_ALPHA_TO_COVERAGE = 32926 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 @@ -7632,7 +7640,7 @@ Compute mesh tangents > meshData = RL.GetMeshData( Mesh mesh ) -Get mesh data as table. +Get mesh vertex attributes data as table. - Success return Mesh{} @@ -9391,7 +9399,7 @@ Get gui state (global state) --- -> RL.GuiSetSliderDragging() +> RL.GuiSetSliderDragging( bool dragging ) Set guiSliderDragging @@ -9405,7 +9413,7 @@ Get guiSliderDragging --- -> RL.GuiSetSliderActive() +> RL.GuiSetSliderActive( Rectange rect ) Set guiSliderActive @@ -10957,6 +10965,12 @@ Use nil RenderTexture for window framebuffer --- +> RL.glDepthRange( float nearVal, float farVal ) + +Specify mapping of depth values from normalized device coordinates to window coordinates + +--- + > RL.glEnable( int cap ) Enable server-side GL capabilities @@ -10969,6 +10983,12 @@ Disable server-side GL capabilities --- +> RL.glPolygonOffset( float factor, float units ) + +Set the scale and units used to calculate depth values + +--- + > RL.glStencilFunc( int func, int ref, int mask ) Set front and back function and reference value for stencil testing diff --git a/ReiLua_API.lua b/ReiLua_API.lua index b519248..3df128b 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -1181,6 +1181,8 @@ RL.GL_DEPTH_TEST=2929 RL.GL_DITHER=3024 ---If enabled, an offset is added to depth values of a polygon's fragments produced by rasterization. See glPolygonOffset RL.GL_POLYGON_OFFSET_FILL=32823 +RL.GL_POLYGON_OFFSET_LINE=10754 +RL.GL_POLYGON_OFFSET_POINT=10753 ---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 RL.GL_SAMPLE_ALPHA_TO_COVERAGE=32926 ---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 @@ -4811,7 +4813,7 @@ function RL.GetMeshBoundingBox( mesh ) end ---@return any RL.GenMeshTangents function RL.GenMeshTangents( mesh ) end ----Get mesh data as table. +---Get mesh vertex attributes data as table. ---- Success return Mesh{} ---@param mesh any ---@return any meshData @@ -6326,8 +6328,9 @@ function RL.GuiSetState( state ) end function RL.GuiGetState() end ---Set guiSliderDragging +---@param dragging boolean ---@return any RL.GuiSetSliderDragging -function RL.GuiSetSliderDragging() end +function RL.GuiSetSliderDragging( dragging ) end ---Get guiSliderDragging ---- Success return bool @@ -6335,8 +6338,9 @@ function RL.GuiSetSliderDragging() end function RL.GuiGetSliderDragging() end ---Set guiSliderActive +---@param rect any ---@return any RL.GuiSetSliderActive -function RL.GuiSetSliderActive() end +function RL.GuiSetSliderActive( rect ) end ---Get guiSliderActive ---- Success return Rectangle @@ -7730,6 +7734,12 @@ function RL.glBlitFramebuffer( srcTex, dstTex, srcRect, dstRect, mask, filter ) -- OpenGL - State Management +---Specify mapping of depth values from normalized device coordinates to window coordinates +---@param nearVal number +---@param farVal number +---@return any RL.glDepthRange +function RL.glDepthRange( nearVal, farVal ) end + ---Enable server-side GL capabilities ---@param cap integer ---@return any RL.glEnable @@ -7740,6 +7750,12 @@ function RL.glEnable( cap ) end ---@return any RL.glDisable function RL.glDisable( cap ) end +---Set the scale and units used to calculate depth values +---@param factor number +---@param units number +---@return any RL.glPolygonOffset +function RL.glPolygonOffset( factor, units ) end + ---Set front and back function and reference value for stencil testing ---@param func integer ---@param ref integer diff --git a/changelog b/changelog index f197550..b992a0c 100644 --- a/changelog +++ b/changelog @@ -75,6 +75,7 @@ DETAILED CHANGES: - CHANGE: UnloadMaterial can also optionally free textures and shader. - ADDED: FontCopy. - ADDED: GuiSetSliderDragging, GuiGetSliderDragging, GuiSetSliderActive and GuiGetSliderActive. + - ADDED: glDepthRange and glPolygonOffset. ------------------------------------------------------------------------ Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0 diff --git a/devnotes b/devnotes index 9548b61..3c0ee4e 100644 --- a/devnotes +++ b/devnotes @@ -17,6 +17,7 @@ Backlog { * CBuffer * Check endianess. + * SDL2 platform specific functions. * Textures * Try making atlas packer with stbrp_pack_rects. * Examples @@ -32,6 +33,8 @@ Bugs { Notes { * raylib 5.5 * DrawBillboardPro BREAKING CHANGE. + * Some functions for data validation has been renamed from Is**Ready() to Is**Valid(). + } Needs Testing { diff --git a/examples/2D_lights/main.lua b/examples/2D_lights/main.lua index 6b00627..35ea7bf 100644 --- a/examples/2D_lights/main.lua +++ b/examples/2D_lights/main.lua @@ -100,8 +100,8 @@ function RL.init() lightTex = RL.LoadTexture( RL.GetBasePath().."../resources/images/light.png" ) lightTexSize = Vector2:newT( RL.GetTextureSize( lightTex ) ) - RL.SetTextureFilter( tileTex, RL.TEXTURE_FILTER_TRILINEAR ) - RL.SetTextureFilter( lightTex, RL.TEXTURE_FILTER_TRILINEAR ) + RL.SetTextureFilter( tileTex, RL.TEXTURE_FILTER_BILINEAR ) + RL.SetTextureFilter( lightTex, RL.TEXTURE_FILTER_BILINEAR ) createShadowMesh() diff --git a/include/lgl.h b/include/lgl.h index 459ed69..530585b 100644 --- a/include/lgl.h +++ b/include/lgl.h @@ -5,8 +5,10 @@ int lglClear( lua_State* L ); /* Frame Buffers. */ int lglBlitFramebuffer( lua_State* L ); /* State Management. */ +int lglDepthRange( lua_State* L ); int lglEnable( lua_State* L ); int lglDisable( lua_State* L ); +int lglPolygonOffset( lua_State* L ); int lglStencilFunc( lua_State* L ); int lglStencilFuncSeparate( lua_State* L ); int lglStencilMask( lua_State* L ); diff --git a/include/raygui.h b/include/raygui.h index e4d50b1..9348db2 100644 --- a/include/raygui.h +++ b/include/raygui.h @@ -2731,7 +2731,7 @@ int GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED))); } - else GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), BLANK); + else GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_NORMAL))); // Draw text considering index offset if required // NOTE: Text index offset depends on cursor position @@ -2956,7 +2956,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in // Draw control //-------------------------------------------------------------------- - Color baseColor = BLANK; + Color baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_NORMAL)); if (state == STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED)); else if (state == STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED)); 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