Texture now can be either Texture or RenderTexture. No need to change texture source anymore.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user