diff options
| author | jussi | 2023-05-01 18:23:36 +0300 |
|---|---|---|
| committer | jussi | 2023-05-01 18:23:36 +0300 |
| commit | acc56fc7c2bedde6eced005eab0a37b6281b9a23 (patch) | |
| tree | 6298f7eeee27469f20d6d992c93118aa162b49a8 /examples | |
| parent | 8b6337446dd79faf226ea9df40d4d06d81c38436 (diff) | |
| download | reilua-enhanced-acc56fc7c2bedde6eced005eab0a37b6281b9a23.tar.gz reilua-enhanced-acc56fc7c2bedde6eced005eab0a37b6281b9a23.tar.bz2 reilua-enhanced-acc56fc7c2bedde6eced005eab0a37b6281b9a23.zip | |
Texture now can be either Texture or RenderTexture. No need to change texture source anymore.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/dungeon_crawler/main.lua | 2 | ||||
| -rw-r--r-- | examples/heightmap/main.lua | 2 | ||||
| -rw-r--r-- | examples/lightmap/main.lua | 38 | ||||
| -rw-r--r-- | examples/pixelated/main.lua | 2 | ||||
| -rw-r--r-- | examples/platformer/main.lua | 5 | ||||
| -rw-r--r-- | examples/snake/main.lua | 4 |
6 files changed, 33 insertions, 20 deletions
diff --git a/examples/dungeon_crawler/main.lua b/examples/dungeon_crawler/main.lua index 3818f67..f8810b1 100644 --- a/examples/dungeon_crawler/main.lua +++ b/examples/dungeon_crawler/main.lua @@ -121,7 +121,5 @@ function RL.draw() RL.EndMode3D() -- RL.EndTextureMode() - -- RL.SetTextureSource( TEXTURE_SOURCE_RENDER_TEXTURE ) -- RL.DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, WHITE ) - -- RL.SetTextureSource( TEXTURE_SOURCE_TEXTURE ) end diff --git a/examples/heightmap/main.lua b/examples/heightmap/main.lua index ae1f6b8..1b194bb 100644 --- a/examples/heightmap/main.lua +++ b/examples/heightmap/main.lua @@ -75,11 +75,9 @@ function RL.init() RL.EndTextureMode() material = RL.LoadMaterialDefault() - RL.SetTextureSource( RL.TEXTURE_SOURCE_RENDER_TEXTURE ) -- RL.GenTextureMipmaps( groundTexture ) -- RL.SetTextureFilter( groundTexture, RL.TEXTURE_FILTER_TRILINEAR ) RL.SetMaterialTexture( material, RL.MATERIAL_MAP_ALBEDO, groundTexture ) - RL.SetTextureSource( RL.TEXTURE_SOURCE_TEXTURE ) matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) ) end diff --git a/examples/lightmap/main.lua b/examples/lightmap/main.lua index 991bc2d..a6a5bde 100644 --- a/examples/lightmap/main.lua +++ b/examples/lightmap/main.lua @@ -1,3 +1,7 @@ +package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua" + +Cam3D = require( "camera3d" ) + local PLANE_SIZE = 8 local monitor = 0 @@ -19,10 +23,18 @@ function RL.init() RL.SetWindowState( RL.FLAG_VSYNC_HINT ) RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } ) - camera = RL.CreateCamera3D() - RL.SetCamera3DPosition( camera, { 0, 8, 16 } ) - RL.SetCamera3DTarget( camera, { 0, 0, 0 } ) - RL.SetCamera3DUp( camera, { 0, 1, 0 } ) + -- camera = RL.CreateCamera3D() + -- RL.SetCamera3DPosition( camera, { 0, 8, 16 } ) + -- RL.SetCamera3DTarget( camera, { 0, 0, 0 } ) + -- RL.SetCamera3DUp( camera, { 0, 1, 0 } ) + camera = Cam3D:new() + + camera:setPosition( { 0, 8, 16 } ) + camera:setTarget( { 0, 0, 0 } ) + camera:setUp( { 0, 1, 0 } ) + camera.mode = camera.MODES.ORBITAL + -- camera.mode = camera.MODES.FREE + -- camera.mode = camera.MODES.FIRST_PERSON local ts = PLANE_SIZE local meshData = { @@ -76,13 +88,25 @@ function RL.init() matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) ) end +function RL.process( delta ) + camera:process( delta ) + + if RL.IsKeyPressed( RL.KEY_SPACE ) then + if camera.mode == camera.MODES.FREE then + camera.mode = camera.MODES.FIRST_PERSON + else + camera.mode = camera.MODES.FREE + end + end +end + function RL.draw() RL.ClearBackground( { 25, 50, 50 } ) -- RL.UpdateCamera3D( camera, RL.CAMERA_ORBITAL ) -- RL.UpdateCamera3D( camera, RL.CAMERA_FREE ) - RL.UpdateCamera3D( camera, RL.CAMERA_FIRST_PERSON ) + -- RL.UpdateCamera3D( camera, RL.CAMERA_FIRST_PERSON ) - RL.BeginMode3D( camera ) + camera:beginMode3D() RL.DrawMesh( mesh, material, matrix ) - RL.EndMode3D() + camera:endMode3D() end diff --git a/examples/pixelated/main.lua b/examples/pixelated/main.lua index 49f5c42..75a9045 100644 --- a/examples/pixelated/main.lua +++ b/examples/pixelated/main.lua @@ -50,7 +50,5 @@ function RL.draw() RL.DrawTriangle( { 0, 32 }, { 32, 16 }, { 0, 0 }, RL.RED ) RL.EndTextureMode() - RL.SetTextureSource( RL.TEXTURE_SOURCE_RENDER_TEXTURE ) RL.DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, { 255, 255, 255 } ) - RL.SetTextureSource( RL.TEXTURE_SOURCE_TEXTURE ) end diff --git a/examples/platformer/main.lua b/examples/platformer/main.lua index f419423..fe594ec 100644 --- a/examples/platformer/main.lua +++ b/examples/platformer/main.lua @@ -288,15 +288,12 @@ end function RL.draw() RL.ClearBackground( RL.RED ) - RL.SetTextureSource( RL.TEXTURE_SOURCE_TEXTURE ) RL.BeginTextureMode( framebuffer ) drawMap() drawPlayer() RL.EndTextureMode() - -- RL.SetTextureSource( RL.TEXTURE_SOURCE_RENDER_TEXTURE ) - -- RL.DrawTexturePro( framebuffer, { 0, 0, res.x, -res.y }, { 0, 0, winSize.x, winSize.y }, { 0, 0 }, 0.0, RL.WHITE ) - -- RL.SetTextureSource( RL.TEXTURE_SOURCE_TEXTURE ) + RL.DrawTexturePro( framebuffer, { 0, 0, res.x, -res.y }, { 0, 0, winSize.x, winSize.y }, { 0, 0 }, 0.0, RL.WHITE ) RL.glBlitFramebuffer( framebuffer, -1, res, winSize, RL.GL_COLOR_BUFFER_BIT, RL.GL_NEAREST ) end diff --git a/examples/snake/main.lua b/examples/snake/main.lua index 0f07317..4bcec1b 100644 --- a/examples/snake/main.lua +++ b/examples/snake/main.lua @@ -216,9 +216,7 @@ function RL.draw() RL.DrawText( 0, "Press Enter to\nrestart", { 10, 10 }, 10, 2, RL.WHITE ) end RL.EndTextureMode() - + -- Draw framebuffer to window. - RL.SetTextureSource( RL.TEXTURE_SOURCE_RENDER_TEXTURE ) RL.DrawTexturePro( framebuffer, { 0, 0, RESOLUTION[1], -RESOLUTION[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, RL.WHITE ) - RL.SetTextureSource( RL.TEXTURE_SOURCE_TEXTURE ) end |
