summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/basic_lighting/main.lua2
-rw-r--r--examples/heightmap/main.lua6
-rw-r--r--examples/iqm_test/main.lua20
-rw-r--r--examples/lightmap/main.lua12
-rw-r--r--examples/window/main.lua2
5 files changed, 28 insertions, 14 deletions
diff --git a/examples/basic_lighting/main.lua b/examples/basic_lighting/main.lua
index d7e686a..d85291e 100644
--- a/examples/basic_lighting/main.lua
+++ b/examples/basic_lighting/main.lua
@@ -136,5 +136,5 @@ function RL.draw()
camera:endMode3D()
- RL.DrawText( 0, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY )
+ RL.DrawText( RL.defaultFont, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY )
end
diff --git a/examples/heightmap/main.lua b/examples/heightmap/main.lua
index 1b194bb..aa693fb 100644
--- a/examples/heightmap/main.lua
+++ b/examples/heightmap/main.lua
@@ -9,6 +9,7 @@ local TILE_SIZE = 32
local monitor = 0
local camera = {}
+local groundRenderTexture = -1
local groundTexture = -1
local tilesetTex = -1
local heigthImage = -1
@@ -47,10 +48,11 @@ function RL.init()
mesh = RL.GenMeshHeightmap( heigthImage, { 16, 4, 16 } )
tilesetTex = RL.LoadTexture( RL.GetBasePath().."../resources/images/tiles.png" )
- groundTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } )
+ groundRenderTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } )
+ groundTexture = RL.GetRenderTextureTexture( groundRenderTexture )
-- Draw to ground texture.
- RL.BeginTextureMode( groundTexture )
+ RL.BeginTextureMode( groundRenderTexture )
for x = 1, 16 do
for y = 1, 16 do
diff --git a/examples/iqm_test/main.lua b/examples/iqm_test/main.lua
index e5867a6..229c1c4 100644
--- a/examples/iqm_test/main.lua
+++ b/examples/iqm_test/main.lua
@@ -2,10 +2,10 @@
local monitor = 0
local camera = -1
+local texture = nil
local material = -1
local model = -1
-local animations = -1
-local animationCount = 0
+local animations = {}
local frame = 0
local curAnim = 0
local frameCount = 0
@@ -24,12 +24,14 @@ function RL.init()
RL.SetCamera3DTarget( camera, { 0, 0, 0 } )
RL.SetCamera3DUp( camera, { 0, 1, 0 } )
+ texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" )
+
material = RL.CreateMaterial( {
maps = {
{
RL.MATERIAL_MAP_ALBEDO,
{
- texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" ),
+ texture = texture,
color = RL.WHITE,
},
},
@@ -38,21 +40,19 @@ function RL.init()
model = RL.LoadModel( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
RL.SetModelMaterial( model, 0, material )
- animations, animationCount = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
-
- print( "animationCount", animationCount )
+ animations = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
end
function RL.process( delta )
if RL.IsKeyPressed( RL.KEY_ENTER ) then
curAnim = curAnim + 1
- if animationCount <= curAnim then
+ if #animations <= curAnim then
curAnim = 0
end
frame = 0.0
- frameCount = RL.GetModelAnimationFrameCount( animations, curAnim )
+ frameCount = RL.GetModelAnimationFrameCount( animations[ curAnim + 1 ] )
elseif RL.IsKeyPressed( RL.KEY_UP ) then
animSpeed = animSpeed + 5
elseif RL.IsKeyPressed( RL.KEY_DOWN ) then
@@ -60,7 +60,7 @@ function RL.process( delta )
end
if RL.IsKeyDown( RL.KEY_SPACE ) then
- RL.UpdateModelAnimation( model, animations, curAnim, math.floor( frame ) )
+ RL.UpdateModelAnimation( model, animations[ curAnim + 1 ], math.floor( frame ) )
frame = frame + animSpeed * delta
if frameCount < frame then
@@ -80,7 +80,7 @@ function RL.draw()
RL.DrawModelEx( model, { 0, 0, 0 }, { 1.0, 0.0, 0.0 }, -90.0, { 1.0, 1.0, 1.0 }, RL.WHITE )
RL.EndMode3D()
- RL.DrawText( 0,
+ RL.DrawText( RL.defaultFont,
"Enter: Change animation\
Space: Play animation\
Up arrow: Inreace animation speed\
diff --git a/examples/lightmap/main.lua b/examples/lightmap/main.lua
index 11cd632..6d946a5 100644
--- a/examples/lightmap/main.lua
+++ b/examples/lightmap/main.lua
@@ -55,6 +55,8 @@ function RL.init()
shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs",
RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" )
+ print( "shader", shader )
+
local materialData = {
shader = shader,
maps = {
@@ -77,6 +79,9 @@ function RL.init()
},
}
material = RL.CreateMaterial( materialData )
+
+ print( "material", material )
+
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
end
@@ -102,3 +107,10 @@ function RL.draw()
RL.DrawMesh( mesh, material, matrix )
camera:endMode3D()
end
+
+function RL.exit()
+ material = nil
+ collectgarbage( "collect" )
+ tileTexture = nil
+ collectgarbage( "collect" )
+end \ No newline at end of file
diff --git a/examples/window/main.lua b/examples/window/main.lua
index 2b4a009..ed0227b 100644
--- a/examples/window/main.lua
+++ b/examples/window/main.lua
@@ -32,5 +32,5 @@ end
function RL.draw()
RL.ClearBackground( RL.RAYWHITE )
RL.DrawTexture( texture, { 20, 20 }, RL.WHITE )
- RL.DrawText( RL.fontDefault, text, textPos, 20, 2, textColor )
+ RL.DrawText( RL.defaultFont, text, textPos, 20, 2, textColor )
end