summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2022-06-19 12:18:09 +0300
committerjussi2022-06-19 12:18:09 +0300
commit1529202e26a02461708784d8830475261893a537 (patch)
tree134f627a4eb131f1daf0b3541fe925b7e5bcc6fb
parent7b26e0aa68fb45612083b8e6b5c970564804803d (diff)
downloadreilua-enhanced-1529202e26a02461708784d8830475261893a537.tar.gz
reilua-enhanced-1529202e26a02461708784d8830475261893a537.tar.bz2
reilua-enhanced-1529202e26a02461708784d8830475261893a537.zip
RLGL line width functions.
-rw-r--r--API.md26
-rw-r--r--doc_parser.lua3
-rw-r--r--examples/platformer/main.lua4
-rw-r--r--include/lrlgl.h5
-rw-r--r--src/core.c4
-rw-r--r--src/lua_core.c5
-rw-r--r--src/models.c3
-rw-r--r--src/rlgl.c41
8 files changed, 84 insertions, 7 deletions
diff --git a/API.md b/API.md
index b0e97ee..958e2d3 100644
--- a/API.md
+++ b/API.md
@@ -955,7 +955,7 @@ OpenGL style 4x4. Identity matrix example
> Rectangle = { 0.0, 0.0, 1.0, 1.0 } or { x = 0.0, y = 0.0, width = 1.0, height = 1.0 }
-{ x, y, w ,h }. Rectangle type
+{ x, y, width ,height }. Rectangle type
---
@@ -2264,7 +2264,7 @@ Set camera up vector ( Rotation over it's axis )
---
-> success = RL_SetCamera3DFovy( camera3D camera, Vector3 fovy )
+> success = RL_SetCamera3DFovy( camera3D camera, float fovy )
Set camera field-of-view apperture in Y ( degrees ) in perspective, used as near plane width in orthographic
@@ -4018,6 +4018,7 @@ Draw a 3d mesh with material and transform
> success = RL_DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances )
Draw multiple mesh instances with material and different transforms
+Note! Untested.
- Failure return false
- Success return true
@@ -6015,3 +6016,24 @@ Send light properties to shader
- Success return true
---
+
+## RLGL - General render state
+
+---
+
+> success = RL_rlSetLineWidth( float width )
+
+Set the line drawing width
+
+- Failure return false
+- Success return true
+
+---
+
+> width = RL_rlGetLineWidth()
+
+Get the line drawing width
+
+- Success return float
+
+---
diff --git a/doc_parser.lua b/doc_parser.lua
index b4dcc3e..41bf5cd 100644
--- a/doc_parser.lua
+++ b/doc_parser.lua
@@ -83,7 +83,7 @@ OpenGL style 4x4. Identity matrix example\n\n---\n" )
apiFile:write( "\n> Color = { 255, 255, 255, 255 } or { r = 255, g = 255, b = 255, a = 255 }\n\
{ r, g, b ,a }. Color type, RGBA (32bit)\n\n---\n" )
apiFile:write( "\n> Rectangle = { 0.0, 0.0, 1.0, 1.0 } or { x = 0.0, y = 0.0, width = 1.0, height = 1.0 }\n\
-{ x, y, w ,h }. Rectangle type\n\n---\n" )
+{ x, y, width ,height }. Rectangle type\n\n---\n" )
apiFile:write( "\n> Image = ImageId\n\
int id. Image type (multiple pixel formats supported). NOTE: Data stored in CPU memory (RAM)\n\n---\n" )
apiFile:write( "\n> Texture = TextureId\n\
@@ -154,6 +154,7 @@ local sourceFiles = {
"src/rmath.c",
"src/rgui.c",
"src/lights.c",
+ "src/rlgl.c",
}
for _, src in ipairs( sourceFiles ) do
diff --git a/examples/platformer/main.lua b/examples/platformer/main.lua
index bef5786..d1160e1 100644
--- a/examples/platformer/main.lua
+++ b/examples/platformer/main.lua
@@ -84,6 +84,7 @@ function init()
local monitorPos = Vec2:new( RL_GetMonitorPosition( monitor ) )
local monitorSize = Vec2:new( RL_GetMonitorSize( monitor ) )
+ RL_SetConfigFlags( FLAG_VSYNC_HINT )
RL_SetWindowTitle( "Platformer" )
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
RL_SetWindowSize( winSize )
@@ -121,6 +122,7 @@ local function tileCollision( entity )
if isTileWall( Vec2:new( tileRect[3], y ) ) then
-- Use new_x to push out of tile.
local new_x = tileRect[3] * TILE_SIZE - ( entity.colRect[1] + entity.colRect[3] )
+
entity.vel.x = new_x - tinyGap
break
@@ -128,7 +130,7 @@ local function tileCollision( entity )
elseif entity.vel.x < 0 then
if isTileWall( Vec2:new( tileRect[1], y ) ) then
local new_x = ( tileRect[1] * TILE_SIZE + TILE_SIZE ) - entity.colRect[1]
- entity.vel.x = new_x + tinyGap, 0
+ entity.vel.x = new_x + tinyGap
break
end
diff --git a/include/lrlgl.h b/include/lrlgl.h
new file mode 100644
index 0000000..4394f00
--- /dev/null
+++ b/include/lrlgl.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* General render state. */
+int lrlglSetLineWidth( lua_State *L );
+int lrlglGetLineWidth( lua_State *L );
diff --git a/src/core.c b/src/core.c
index e83bb35..d549eb0 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2763,7 +2763,7 @@ int lcoreSetCamera3DUp( lua_State *L ) {
}
/*
-> success = RL_SetCamera3DFovy( camera3D camera, Vector3 fovy )
+> success = RL_SetCamera3DFovy( camera3D camera, float fovy )
Set camera field-of-view apperture in Y ( degrees ) in perspective, used as near plane width in orthographic
@@ -2772,7 +2772,7 @@ Set camera field-of-view apperture in Y ( degrees ) in perspective, used as near
*/
int lcoreSetCamera3DFovy( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
- TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetCamera3DFovy( camera3D camera, Vector3 fovy )" );
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetCamera3DFovy( camera3D camera, float fovy )" );
lua_pushboolean( L, false );
return 1;
}
diff --git a/src/lua_core.c b/src/lua_core.c
index d714024..e2b1631 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -10,6 +10,7 @@
#include "rmath.h"
#include "rgui.h"
#include "lights.h"
+#include "lrlgl.h"
static void assignGlobalInt( int value, const char *name ) {
lua_State *L = state->luaState;
@@ -1257,6 +1258,10 @@ void luaRegister() {
/* Basics. */
lua_register( L, "RL_CreateLight", llightsCreateLight );
lua_register( L, "RL_UpdateLightValues", llightsUpdateLightValues );
+ /* RLGL */
+ /* General render state. */
+ lua_register( L, "RL_rlSetLineWidth", lrlglSetLineWidth );
+ lua_register( L, "RL_rlGetLineWidth", lrlglGetLineWidth );
}
/* Lua util functions. */
diff --git a/src/models.c b/src/models.c
index 4e67ff0..ef5e493 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1284,11 +1284,12 @@ int lmodelsDrawMesh( lua_State *L ) {
return 1;
}
-/* TODO Not testet. */
+/* TODO Untested. */
/*
> success = RL_DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances )
Draw multiple mesh instances with material and different transforms
+Note! Untested.
- Failure return false
- Success return true
diff --git a/src/rlgl.c b/src/rlgl.c
new file mode 100644
index 0000000..0ca3383
--- /dev/null
+++ b/src/rlgl.c
@@ -0,0 +1,41 @@
+#include "main.h"
+#include "state.h"
+#include "lua_core.h"
+#include "lrlgl.h"
+
+/*
+## RLGL - General render state
+*/
+
+/*
+> success = RL_rlSetLineWidth( float width )
+
+Set the line drawing width
+
+- Failure return false
+- Success return true
+*/
+int lrlglSetLineWidth( lua_State *L ) {
+ if ( !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_rlSetLineWidth( float width )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ rlSetLineWidth( lua_tonumber( L, -1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> width = RL_rlGetLineWidth()
+
+Get the line drawing width
+
+- Success return float
+*/
+int lrlglGetLineWidth( lua_State *L ) {
+ lua_pushnumber( L, rlGetLineWidth() );
+
+ return 1;
+}