diff options
Diffstat (limited to 'src/gl.c')
| -rw-r--r-- | src/gl.c | 153 |
1 files changed, 149 insertions, 4 deletions
@@ -5,17 +5,17 @@ #include "lgl.h" /* -## OpenGL - Framebuffer management +## OpenGL - Frame Buffers */ /* > RL.glBlitFramebuffer( RenderTexture srcTex, RenderTexture dstTex, Rectangle srcRect, Rectangle dstRect, int mask, int filter ) Copy a block of pixels from one framebuffer object to another. -Use -1 RenderTexture for window framebuffer +Use nil RenderTexture for window framebuffer */ int lglBlitFramebuffer( lua_State* L ) { -#if defined( PLATFORM_DESKTOP ) || defined( PLATFORM_DESKTOP_SDL ) +// #if defined( PLATFORM_DESKTOP ) || defined( PLATFORM_DESKTOP_SDL ) if ( !( lua_isuserdata( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isuserdata( L, 2 ) || lua_isnil( L, 2 ) ) ) { TraceLog( state->logLevelInvalid, "%s", "Argument needs to be RenderTexture or nil" ); lua_pushnil( L ); @@ -53,5 +53,150 @@ int lglBlitFramebuffer( lua_State* L ) { glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); return 1; -#endif +// #endif +} + +/* +## OpenGL - State Management +*/ + +/* +> RL.glEnable( int cap ) + +Enable server-side GL capabilities +*/ +int lglEnable( lua_State* L ) { + int cap = luaL_checkinteger( L, 1 ); + + glEnable( cap ); + + return 0; +} + +/* +> RL.glDisable( int cap ) + +Disable server-side GL capabilities +*/ +int lglDisable( lua_State* L ) { + int cap = luaL_checkinteger( L, 1 ); + + glDisable( cap ); + + return 0; +} + +/* +> RL.glStencilFunc( int func, int ref, int mask ) + +Set front and back function and reference value for stencil testing +*/ +int lglStencilFunc( lua_State* L ) { + int func = luaL_checkinteger( L, 1 ); + int ref = luaL_checkinteger( L, 2 ); + unsigned int mask = luaL_checkinteger( L, 3 ); + + glStencilFunc( func, ref, mask ); + + return 0; +} + +/* +> RL.glStencilFuncSeparate( int face, int func, int ref, int mask ) + +Set front and/or back function and reference value for stencil testing +*/ +int lglStencilFuncSeparate( lua_State* L ) { + int face = luaL_checkinteger( L, 1 ); + int func = luaL_checkinteger( L, 2 ); + int ref = luaL_checkinteger( L, 3 ); + unsigned int mask = luaL_checkinteger( L, 4 ); + + glStencilFuncSeparate( face, func, ref, mask ); + + return 0; +} + +/* +> RL.glStencilMask( int mask ) + +Control the front and back writing of individual bits in the stencil planes +*/ +int lglStencilMask( lua_State* L ) { + unsigned int mask = luaL_checkinteger( L, 1 ); + + glStencilMask( mask ); + + return 0; +} + +/* +> RL.glStencilMaskSeparate( int face, int mask ) + +Control the front and/or back writing of individual bits in the stencil planes +*/ +int lglStencilMaskSeparate( lua_State* L ) { + int face = luaL_checkinteger( L, 1 ); + unsigned int mask = luaL_checkinteger( L, 2 ); + + glStencilMaskSeparate( face, mask ); + + return 0; +} + +/* +> RL.glStencilOp( int sfail, int dpfail, int dppass ) + +Set front and back stencil test actions +*/ +int lglStencilOp( lua_State* L ) { + int sfail = luaL_checkinteger( L, 1 ); + int dpfail = luaL_checkinteger( L, 2 ); + int dppass = luaL_checkinteger( L, 3 ); + + glStencilOp( sfail, dpfail, dppass ); + + return 0; +} + +/* +> RL.glStencilOpSeparate( int face, int sfail, int dpfail, int dppass ) + +Set front and back stencil test actions +*/ +int lglStencilOpSeparate( lua_State* L ) { + int face = luaL_checkinteger( L, 1 ); + int sfail = luaL_checkinteger( L, 2 ); + int dpfail = luaL_checkinteger( L, 3 ); + int dppass = luaL_checkinteger( L, 4 ); + + glStencilOpSeparate( face, sfail, dpfail, dppass ); + + return 0; +} + +/* +## OpenGL - Utility +*/ + +/* +> connection = RL.glGetString( int name, int|nil index ) + +Return a string describing the current GL connection. GL_EXTENSIONS returns the extension string supported by the implementation at index + +- Success return string +*/ +int lglGetString( lua_State* L ) { + int name = luaL_checkinteger( L, 1 ); + + if ( uluaIsNil( L, 2 ) ) { + lua_pushstring( L, glGetString( name ) ); + } + else { + int index = luaL_checkinteger( L, 2 ); + + lua_pushstring( L, glGetStringi( name, index ) ); + } + + return 1; } |
