diff options
| author | jussi | 2023-08-17 18:33:50 +0300 |
|---|---|---|
| committer | jussi | 2023-08-17 18:33:50 +0300 |
| commit | b7b46ada041ad56b1bc84fea3062464b702135c5 (patch) | |
| tree | 6453e7100bdb7c5353d0eb4f5227c0c571533d45 /examples | |
| parent | 5438a70b0a5aac72c071c90650b509cf46e557cb (diff) | |
| download | reilua-enhanced-b7b46ada041ad56b1bc84fea3062464b702135c5.tar.gz reilua-enhanced-b7b46ada041ad56b1bc84fea3062464b702135c5.tar.bz2 reilua-enhanced-b7b46ada041ad56b1bc84fea3062464b702135c5.zip | |
Vertex buffers state and Shader state functions. Vertex buffers management WIP.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/2D_camera/main.lua | 9 | ||||
| -rw-r--r-- | examples/iqm_test/main.lua | 2 | ||||
| -rw-r--r-- | examples/rlgl/main.lua | 56 |
3 files changed, 62 insertions, 5 deletions
diff --git a/examples/2D_camera/main.lua b/examples/2D_camera/main.lua index c47ba18..0723c8b 100644 --- a/examples/2D_camera/main.lua +++ b/examples/2D_camera/main.lua @@ -36,15 +36,15 @@ function RL.process( delta ) cameraPos[2] = cameraPos[2] - cameraSpeed * delta end -- Rotate. - if RL.IsKeyDown( string.byte( "E" ) ) then -- Or RL.IsKeyDown( KEY_E ) + if RL.IsKeyDown( RL.KEY_E ) then -- Or RL.IsKeyDown( KEY_E ) cameraRot = cameraRot + cameraRotSpeed * delta - elseif RL.IsKeyDown( string.byte( "Q" ) ) then + elseif RL.IsKeyDown( RL.KEY_Q ) then cameraRot = cameraRot - cameraRotSpeed * delta end -- Zoom. - if RL.IsKeyDown( string.byte( "R" ) ) then + if RL.IsKeyDown( RL.KEY_R ) then cameraZoom = cameraZoom + cameraZoomSpeed * delta - elseif RL.IsKeyDown( string.byte( "F" ) ) then + elseif RL.IsKeyDown( RL.KEY_F ) then cameraZoom = cameraZoom - cameraZoomSpeed * delta end end @@ -62,6 +62,7 @@ function RL.draw() RL.DrawTextureRec( tileTexture, { 0, 0, 32, 32 }, { x * 32, y * 32 }, RL.WHITE ) end end + -- Draw hero. RL.DrawTextureRec( tileTexture, { 3 * 32, 0, 32, 32 }, { cameraPos[1] - 16, cameraPos[2] - 16 }, RL.WHITE ) RL.EndMode2D() diff --git a/examples/iqm_test/main.lua b/examples/iqm_test/main.lua index a1040ba..e5867a6 100644 --- a/examples/iqm_test/main.lua +++ b/examples/iqm_test/main.lua @@ -85,5 +85,5 @@ function RL.draw() Space: Play animation\ Up arrow: Inreace animation speed\ Down arrow: Decreace animation speed", - { 10, 10 }, 30, 5, RL.WHITE ) + { 10, 10 }, 30, 5, RL.WHITE ) end diff --git a/examples/rlgl/main.lua b/examples/rlgl/main.lua new file mode 100644 index 0000000..7792f75 --- /dev/null +++ b/examples/rlgl/main.lua @@ -0,0 +1,56 @@ +-- Work In Progress! + +local monitor = 0 +local texture = -1 +local vaoId = -1 +local vboId = -1 +local triSize = 32.0 +local vertices = { + 0.0, 0.0, 0.0, + 0.0, 0.0, triSize, + triSize, 0.0, triSize +} +local colors = { + RL.RED, RL.RED, RL.RED, + RL.GREEN, RL.GREEN, RL.GREEN, + RL.BLUE, RL.BLUE, RL.BLUE +} + +function RL.init() + local mPos = RL.GetMonitorPosition( monitor ) + local mSize = RL.GetMonitorSize( monitor ) + local winSize = RL.GetScreenSize() + + RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE ) + RL.SetWindowState( RL.FLAG_VSYNC_HINT ) + RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } ) + + vaoId = RL.rlLoadVertexArray() + + RL.rlEnableVertexArray( vaoId ) + -- vboId = RL.rlLoadVertexBuffer( vertexBuffer, RL.RL_UNSIGNED_BYTE, false ) + vboId = RL.rlLoadVertexBuffer( vertices, RL.RL_FLOAT, false ) + RL.rlSetVertexAttribute( 0, 3, RL.RL_FLOAT, false, 0, 0 ) + RL.rlEnableVertexAttribute( 0 ) + + RL.rlDisableVertexArray() + + -- RL.DrawMesh( ) + + -- print( "vaoId", vaoId ) + -- print( "vboId", vboId ) +end + +function RL.draw() + RL.ClearBackground( { 100, 150, 100 } ) +end + +function RL.exit() + if 0 <= vaoId then + RL.rlUnloadVertexArray( vaoId ) + end + + if 0 <= vboId then + RL.rlUnloadVertexBuffer( vboId ) + end +end
\ No newline at end of file |
