summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorvictorfisac <[email protected]>2017-03-06 09:40:04 +0100
committervictorfisac <[email protected]>2017-03-06 09:40:04 +0100
commit9261c3b8dc03d093bff5246a18ad9310ae8eaeb3 (patch)
treeaf87165723ac563ee1a7e1c605c7a4df821d74ea /examples
parente8630c78d069a1cba50b1a78108663ebc19e5b9b (diff)
parentb734802743f2089c8d649b27aea48ab71fa653b3 (diff)
downloadraylib-9261c3b8dc03d093bff5246a18ad9310ae8eaeb3.tar.gz
raylib-9261c3b8dc03d093bff5246a18ad9310ae8eaeb3.zip
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile41
-rw-r--r--examples/audio_module_playing.c4
-rw-r--r--examples/audio_module_playing.lua122
-rw-r--r--examples/audio_music_stream.c2
-rw-r--r--examples/audio_music_stream.lua66
-rw-r--r--examples/audio_raw_stream.c29
-rw-r--r--examples/audio_raw_stream.lua97
-rw-r--r--examples/audio_sound_loading.c2
-rw-r--r--examples/audio_sound_loading.lua59
-rw-r--r--examples/audio_standalone.c46
-rw-r--r--examples/core_2d_camera.lua130
-rw-r--r--examples/core_3d_camera_first_person.lua85
-rw-r--r--examples/core_3d_camera_free.lua75
-rw-r--r--examples/core_3d_mode.lua64
-rw-r--r--examples/core_3d_picking.lua98
-rw-r--r--examples/core_basic_window.lua44
-rw-r--r--examples/core_color_select.lua82
-rw-r--r--examples/core_drop_files.lua66
-rw-r--r--examples/core_gestures_detection.lua102
-rw-r--r--examples/core_input_gamepad.lua63
-rw-r--r--examples/core_input_keys.lua51
-rw-r--r--examples/core_input_mouse.lua54
-rw-r--r--examples/core_mouse_wheel.lua50
-rw-r--r--examples/core_oculus_rift.lua73
-rw-r--r--examples/core_random_values.lua56
-rw-r--r--examples/core_storage_values.lua74
-rw-r--r--examples/core_world_screen.lua69
-rw-r--r--examples/models_billboard.lua65
-rw-r--r--examples/models_box_collisions.lua115
-rw-r--r--examples/models_cubicmap.lua79
-rw-r--r--examples/models_geometric_shapes.lua67
-rw-r--r--examples/models_heightmap.lua73
-rw-r--r--examples/models_obj_loading.lua67
-rw-r--r--examples/models_ray_picking.c197
-rw-r--r--examples/physics_demo.c2
-rw-r--r--examples/physics_friction.c2
-rw-r--r--examples/physics_movement.c2
-rw-r--r--examples/physics_restitution.c2
-rw-r--r--examples/physics_shatter.c2
-rw-r--r--examples/resources/audio/sound.wavbin0 -> 97512 bytes
-rw-r--r--examples/resources/audio/tanatana.flacbin0 -> 100733 bytes
-rw-r--r--examples/resources/model/lowpoly-tower.obj456
-rw-r--r--examples/resources/model/lowpoly-tower.pngbin0 -> 24939 bytes
-rw-r--r--examples/rlgl_oculus_rift.c2
-rw-r--r--examples/rlua_execute_file.c91
-rw-r--r--examples/shaders_custom_uniform.lua115
-rw-r--r--examples/shaders_model_shader.c4
-rw-r--r--examples/shaders_model_shader.lua85
-rw-r--r--examples/shaders_postprocessing.lua101
-rw-r--r--examples/shaders_shapes_textures.lua101
-rw-r--r--examples/shaders_standard_lighting.c370
-rw-r--r--examples/shaders_standard_lighting.lua114
-rw-r--r--examples/shapes_basic_shapes.lua64
-rw-r--r--examples/shapes_colors_palette.lua89
-rw-r--r--examples/shapes_logo_raylib.lua48
-rw-r--r--examples/shapes_logo_raylib_anim.lua127
-rw-r--r--examples/text_bmfont_ttf.c8
-rw-r--r--examples/text_bmfont_ttf.lua59
-rw-r--r--examples/text_bmfont_unordered.c6
-rw-r--r--examples/text_font_select.c6
-rw-r--r--examples/text_font_select.lua143
-rw-r--r--examples/text_format_text.lua54
-rw-r--r--examples/text_rbmf_fonts.c6
-rw-r--r--examples/text_rbmf_fonts.lua87
-rw-r--r--examples/text_sprite_fonts.c18
-rw-r--r--examples/text_sprite_fonts.lua72
-rw-r--r--examples/text_ttf_loading.c18
-rw-r--r--examples/text_writing_anim.lua52
-rw-r--r--examples/textures_formats_loading.lua217
-rw-r--r--examples/textures_image_drawing.lua70
-rw-r--r--examples/textures_image_loading.lua55
-rw-r--r--examples/textures_image_processing.lua134
-rw-r--r--examples/textures_logo_raylib.lua49
-rw-r--r--examples/textures_particles_trail_blending.lua113
-rw-r--r--examples/textures_raw_data.lua83
-rw-r--r--examples/textures_rectangle.lua69
-rw-r--r--examples/textures_srcrec_dstrec.lua71
-rw-r--r--examples/textures_to_image.lua60
78 files changed, 1164 insertions, 4430 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 2cb75ff9..98129990 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -147,13 +147,13 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# on XWindow could require also below libraries, just uncomment
- #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
+ LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else
ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev
- LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
+ LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
else
# libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
@@ -236,6 +236,7 @@ EXAMPLES = \
models_obj_loading \
models_heightmap \
models_cubicmap \
+ models_ray_picking \
shaders_model_shader \
shaders_shapes_textures \
shaders_custom_uniform \
@@ -245,6 +246,11 @@ EXAMPLES = \
audio_music_stream \
audio_module_playing \
audio_raw_stream \
+ physics_demo \
+ physics_friction \
+ physics_movement \
+ physics_restitution \
+ physics_shatter \
fix_dylib \
@@ -451,6 +457,10 @@ models_heightmap: models_heightmap.c
models_cubicmap: models_cubicmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+# compile [models] example - model ray picking
+models_ray_picking: models_ray_picking.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
# compile [shaders] example - model shader
shaders_model_shader: shaders_model_shader.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@@ -487,6 +497,33 @@ audio_module_playing: audio_module_playing.c
audio_raw_stream: audio_raw_stream.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+# Linux Fix to timespect from
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+ ifeq ($(PLATFORM_OS),LINUX)
+ CFLAGS += -D_POSIX_C_SOURCE=199309L
+ endif
+endif
+
+# compile [physac] example - physics demo
+physics_demo: physics_demo.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
+
+# compile [physac] example - physics friction
+physics_friction: physics_friction.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
+
+# compile [physac] example - physics movement
+physics_movement: physics_movement.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
+
+# compile [physac] example - physics restitution
+physics_restitution: physics_restitution.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
+
+# compile [physac] example - physics shatter
+physics_shatter: physics_shatter.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
+
# fix dylib install path name for each executable (MAC)
fix_dylib:
ifeq ($(PLATFORM_OS),OSX)
diff --git a/examples/audio_module_playing.c b/examples/audio_module_playing.c
index a9ee4619..08ae2b05 100644
--- a/examples/audio_module_playing.c
+++ b/examples/audio_module_playing.c
@@ -86,7 +86,7 @@ int main()
}
// Get timePlayed scaled to bar dimensions
- timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2;
+ timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40);
// Color circles animation
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
@@ -112,7 +112,7 @@ int main()
//----------------------------------------------------------------------------------
BeginDrawing();
- ClearBackground(WHITE);
+ ClearBackground(RAYWHITE);
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
diff --git a/examples/audio_module_playing.lua b/examples/audio_module_playing.lua
deleted file mode 100644
index 3c5ad641..00000000
--- a/examples/audio_module_playing.lua
+++ /dev/null
@@ -1,122 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [audio] example - Module playing (streaming)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-MAX_CIRCLES = 64
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)")
-
-InitAudioDevice() -- Initialize audio device
-
-local colors = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
- YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE }
-
--- Creates ome circles for visual effect
-local circles = {}
-
-for i = MAX_CIRCLES, 1, -1 do
- circles[i] = {}
- circles[i].alpha = 0.0
- circles[i].radius = GetRandomValue(10, 40)
- circles[i].position = Vector2(0, 0)
- circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius)
- circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius)
- circles[i].speed = GetRandomValue(1, 100)/20000.0
- circles[i].color = colors[GetRandomValue(1, 14)]
-end
-
--- Load postprocessing bloom shader
-local shader = LoadShader("resources/shaders/glsl330/base.vs",
- "resources/shaders/glsl330/bloom.fs")
-
--- Create a RenderTexture2D to be used for render to texture
-local target = LoadRenderTexture(screenWidth, screenHeight)
-
-local xm = LoadMusicStream("resources/audio/mini1111.xm")
-
-PlayMusicStream(xm)
-
-local timePlayed = 0.0
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- for i = MAX_CIRCLES, 1, -1 do
- circles[i].alpha = circles[i].alpha + circles[i].speed
- circles[i].radius = circles[i].radius + circles[i].speed*10.0
-
- if (circles[i].alpha > 1.0) then circles[i].speed = circles[i].speed*-1 end
-
- if (circles[i].alpha <= 0.0) then
- circles[i].alpha = 0.0
- circles[i].radius = GetRandomValue(10, 40)
- circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius)
- circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius)
- circles[i].color = colors[GetRandomValue(1, 14)]
- circles[i].speed = GetRandomValue(1, 100)/20000.0
- end
- end
-
- -- Get timePlayed scaled to bar dimensions
- timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2
-
- UpdateMusicStream(xm) -- Update music buffer with new stream data
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(BLACK)
-
- BeginTextureMode(target) -- Enable drawing to texture
-
- for i = MAX_CIRCLES, 1, -1 do
- DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha))
- end
-
- EndTextureMode() -- End drawing to texture (now we have a texture available for next passes)
-
- BeginShaderMode(shader)
-
- -- NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
- DrawTextureRec(target.texture, Rectangle(0, 0, target.texture.width, -target.texture.height), Vector2(0, 0), WHITE)
-
- EndShaderMode()
-
- -- Draw time bar
- DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY)
- DrawRectangle(20, screenHeight - 20 - 12, timePlayed//1, 12, MAROON)
- DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, WHITE)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadShader(shader) -- Unload shader
-UnloadRenderTexture(target) -- Unload render texture
-
-UnloadMusicStream(xm) -- Unload music stream buffers from RAM
-
-CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
-
-CloseWindow() -- Close window and OpenGL context
--------------------------------------------------------------------------------------------
diff --git a/examples/audio_music_stream.c b/examples/audio_music_stream.c
index dc9d4355..9c1ca4df 100644
--- a/examples/audio_music_stream.c
+++ b/examples/audio_music_stream.c
@@ -58,7 +58,7 @@ int main()
}
// Get timePlayed scaled to bar dimensions (400 pixels)
- timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4;
+ timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400;
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/audio_music_stream.lua b/examples/audio_music_stream.lua
deleted file mode 100644
index 33cf335f..00000000
--- a/examples/audio_music_stream.lua
+++ /dev/null
@@ -1,66 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [audio] example - Music playing (streaming)
---
--- NOTE: This example requires OpenAL Soft library installed
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)")
-
-InitAudioDevice() -- Initialize audio device
-
-local music = LoadMusicStream("resources/audio/guitar_noodling.ogg")
-
-PlayMusicStream(music)
-
-local framesCounter = 0
-local timePlayed = 0.0
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- framesCounter = framesCounter + 1
-
- timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4 -- We scale by 4 to fit 400 pixels
-
- UpdateMusicStream(music) -- Update music buffer with new stream data
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY)
-
- DrawRectangle(200, 250, 400, 12, LIGHTGRAY)
- DrawRectangle(200, 250, timePlayed//1, 12, MAROON)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadMusicStream(music) -- Unload music stream buffers from RAM
-
-CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/audio_raw_stream.c b/examples/audio_raw_stream.c
index c044a7e0..80c83e96 100644
--- a/examples/audio_raw_stream.c
+++ b/examples/audio_raw_stream.c
@@ -16,7 +16,8 @@
#include <stdlib.h> // Required for: malloc(), free()
#include <math.h> // Required for: sinf()
-#define MAX_SAMPLES 20000
+#define MAX_SAMPLES 22050
+#define MAX_SAMPLES_PER_UPDATE 4096
int main()
{
@@ -29,21 +30,20 @@ int main()
InitAudioDevice(); // Initialize audio device
- // Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
- AudioStream stream = InitAudioStream(22050, 32, 1);
+ // Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono)
+ AudioStream stream = InitAudioStream(22050, 16, 1);
- // Fill audio stream with some samples (sine wave)
- float *data = (float *)malloc(sizeof(float)*MAX_SAMPLES);
+ // Generate samples data from sine wave
+ short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
+ // TODO: Review data generation, it seems data is discontinued for loop,
+ // for that reason, there is a clip everytime audio stream is looped...
for (int i = 0; i < MAX_SAMPLES; i++)
{
- data[i] = sinf(((2*PI*(float)i)/2)*DEG2RAD);
+ data[i] = (short)(sinf(((2*PI*(float)i)/2)*DEG2RAD)*32000);
}
- // NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
- // for that reason, there is a clip everytime audio stream is looped
-
- PlayAudioStream(stream);
+ PlayAudioStream(stream); // Start processing stream buffer (no data loaded currently)
int totalSamples = MAX_SAMPLES;
int samplesLeft = totalSamples;
@@ -60,10 +60,13 @@ int main()
//----------------------------------------------------------------------------------
// Refill audio stream if required
+ // NOTE: Every update we check if stream data has been already consumed and we update
+ // buffer with new data from the generated samples, we upload data at a rate (MAX_SAMPLES_PER_UPDATE),
+ // but notice that at some point we update < MAX_SAMPLES_PER_UPDATE data...
if (IsAudioBufferProcessed(stream))
{
int numSamples = 0;
- if (samplesLeft >= 4096) numSamples = 4096;
+ if (samplesLeft >= MAX_SAMPLES_PER_UPDATE) numSamples = MAX_SAMPLES_PER_UPDATE;
else numSamples = samplesLeft;
UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples);
@@ -83,11 +86,11 @@ int main()
DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY);
- // NOTE: Draw a part of the sine wave (only screen width)
+ // NOTE: Draw a part of the sine wave (only screen width, proportional values)
for (int i = 0; i < GetScreenWidth(); i++)
{
position.x = i;
- position.y = 250 + 50*data[i];
+ position.y = 250 + 50*data[i]/32000;
DrawPixelV(position, RED);
}
diff --git a/examples/audio_raw_stream.lua b/examples/audio_raw_stream.lua
deleted file mode 100644
index 070984f9..00000000
--- a/examples/audio_raw_stream.lua
+++ /dev/null
@@ -1,97 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [audio] example - Raw audio streaming
---
--- NOTE: This example requires OpenAL Soft library installed
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-MAX_SAMPLES = 20000
-DEG2RAD = math.pi/180.0
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming")
-
-InitAudioDevice() -- Initialize audio device
-
--- Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
-local stream = InitAudioStream(22050, 32, 1)
-
--- Fill audio stream with some samples (sine wave)
-local data = {}
-
-for i = 1, MAX_SAMPLES do
- data[i] = math.sin(((2*math.pi*i)/2)*DEG2RAD)
-end
-
--- NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
--- for that reason, there is a clip everytime audio stream is looped
-
-PlayAudioStream(stream)
-
-local totalSamples = MAX_SAMPLES
-local samplesLeft = totalSamples
-
-local position = Vector2(0, 0)
-
-SetTargetFPS(30) -- Set our game to run at 30 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
-
- -- Refill audio stream if required
- if (IsAudioBufferProcessed(stream)) then
- local numSamples = 0
-
- if (samplesLeft >= 4096) then numSamples = 4096
- else numSamples = samplesLeft end
-
- UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples)
-
- samplesLeft = samplesLeft - numSamples
-
- -- Reset samples feeding (loop audio)
- if (samplesLeft <= 0) then samplesLeft = totalSamples end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY)
-
- -- NOTE: Draw a part of the sine wave (only screen width)
- for i = 1, GetScreenWidth() do
- position.x = (i - 1)
- position.y = 250 + 50*data[i]
-
- DrawPixelV(position, RED)
- end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseAudioStream(stream) -- Close raw audio stream and delete buffers from RAM
-
-CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/audio_sound_loading.c b/examples/audio_sound_loading.c
index f081e8ed..feb30563 100644
--- a/examples/audio_sound_loading.c
+++ b/examples/audio_sound_loading.c
@@ -24,7 +24,7 @@ int main()
InitAudioDevice(); // Initialize audio device
- Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
+ Sound fxWav = LoadSound("resources/audio/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
SetTargetFPS(60);
diff --git a/examples/audio_sound_loading.lua b/examples/audio_sound_loading.lua
deleted file mode 100644
index 7107eea4..00000000
--- a/examples/audio_sound_loading.lua
+++ /dev/null
@@ -1,59 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [audio] example - Sound loading and playing
---
--- NOTE: This example requires OpenAL Soft library installed
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing")
-
-InitAudioDevice() -- Initialize audio device
-
-local fxWav = LoadSound("resources/audio/weird.wav") -- Load WAV audio file
-local fxOgg = LoadSound("resources/audio/tanatana.ogg") -- Load OGG audio file
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyPressed(KEY.SPACE)) then PlaySound(fxWav) end -- Play WAV sound
- if (IsKeyPressed(KEY.ENTER)) then PlaySound(fxOgg) end -- Play OGG sound
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY)
-
- DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadSound(fxWav) -- Unload sound data
-UnloadSound(fxOgg) -- Unload sound data
-
-CloseAudioDevice() -- Close audio device
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/audio_standalone.c b/examples/audio_standalone.c
index 7688b881..d090bb83 100644
--- a/examples/audio_standalone.c
+++ b/examples/audio_standalone.c
@@ -24,10 +24,52 @@
********************************************************************************************/
#include <stdio.h>
+#if defined(_WIN32)
#include <conio.h> // Windows only, no stardard library
-
+#endif
#include "audio.h"
+#if defined(__linux)
+
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+static int kbhit(void)
+{
+ struct termios oldt, newt;
+ int ch;
+ int oldf;
+
+ tcgetattr(STDIN_FILENO, &oldt);
+ newt = oldt;
+ newt.c_lflag &= ~(ICANON | ECHO);
+ tcsetattr(STDIN_FILENO, TCSANOW, &newt);
+ oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
+ fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
+
+ ch = getchar();
+
+ tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
+ fcntl(STDIN_FILENO, F_SETFL, oldf);
+
+ if(ch != EOF)
+ {
+ ungetc(ch, stdin);
+ return 1;
+ }
+
+ return 0;
+}
+
+static char getch()
+{
+ return getchar();
+}
+
+#endif
+
#define KEY_ESCAPE 27
int main()
@@ -78,4 +120,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-} \ No newline at end of file
+}
diff --git a/examples/core_2d_camera.lua b/examples/core_2d_camera.lua
deleted file mode 100644
index 95302c26..00000000
--- a/examples/core_2d_camera.lua
+++ /dev/null
@@ -1,130 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - 2d camera
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-MAX_BUILDINGS = 100
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera")
-
-local player = Rectangle(400, 280, 40, 40)
-local buildings = {}
-local buildColors = {}
-
-local spacing = 0;
-
-for i = 1, MAX_BUILDINGS do
- buildings[i] = Rectangle(0, 0, 0, 0)
- buildings[i].width = GetRandomValue(50, 200)
- buildings[i].height = GetRandomValue(100, 800)
- buildings[i].y = screenHeight - 130 - buildings[i].height
- buildings[i].x = -6000 + spacing
-
- spacing = spacing + buildings[i].width
-
- buildColors[i] = Color(GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255)
-end
-
-local camera = Camera2D(Vector2(0, 0), Vector2(0, 0), 0.0, 1.0)
-
-camera.target = Vector2(player.x + 20, player.y + 20)
-camera.offset = Vector2(0, 0)
-camera.rotation = 0.0
-camera.zoom = 1.0
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyDown(KEY.RIGHT)) then
- player.x = player.x + 2 -- Player movement
- camera.offset.x = camera.offset.x - 2 -- Camera displacement with player movement
- elseif (IsKeyDown(KEY.LEFT)) then
- player.x = player.x - 2 -- Player movement
- camera.offset.x = camera.offset.x + 2 -- Camera displacement with player movement
- end
-
- -- Camera target follows player
- camera.target = Vector2(player.x + 20, player.y + 20)
-
- -- Camera rotation controls
- if (IsKeyDown(KEY.A)) then camera.rotation = camera.rotation - 1
- elseif (IsKeyDown(KEY.S)) then camera.rotation = camera.rotation + 1
- end
-
- -- Limit camera rotation to 80 degrees (-40 to 40)
- if (camera.rotation > 40) then camera.rotation = 40
- elseif (camera.rotation < -40) then camera.rotation = -40
- end
-
- -- Camera zoom controls
- camera.zoom = camera.zoom + (GetMouseWheelMove()*0.05)
-
- if (camera.zoom > 3.0) then camera.zoom = 3.0
- elseif (camera.zoom < 0.1) then camera.zoom = 0.1
- end
-
- -- Camera reset (zoom and rotation)
- if (IsKeyPressed(KEY.R)) then
- camera.zoom = 1.0
- camera.rotation = 0.0
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin2dMode(camera)
-
- DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY)
-
- for i = 1, MAX_BUILDINGS, 1 do DrawRectangleRec(buildings[i], buildColors[i]) end
-
- DrawRectangleRec(player, RED)
-
- DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN)
- DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN)
-
- End2dMode()
-
- DrawText("SCREEN AREA", 640, 10, 20, RED)
-
- DrawRectangle(0, 0, screenWidth, 5, RED)
- DrawRectangle(0, 5, 5, screenHeight - 10, RED)
- DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED)
- DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED)
-
- DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5))
- DrawRectangleLines( 10, 10, 250, 113, BLUE)
-
- DrawText("Free 2d camera controls:", 20, 20, 10, BLACK)
- DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY)
- DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY)
- DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY)
- DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY)
-
- EndDrawing();
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
--------------------------------------------------------------------------------------------
diff --git a/examples/core_3d_camera_first_person.lua b/examples/core_3d_camera_first_person.lua
deleted file mode 100644
index 800c3c2a..00000000
--- a/examples/core_3d_camera_first_person.lua
+++ /dev/null
@@ -1,85 +0,0 @@
---------------------------------------------------------------------------------------------
---
--- raylib [core] example - 3d camera first person
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
---------------------------------------------------------------------------------------------
-
-MAX_COLUMNS = 20
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person")
-
--- Define the camera to look into our 3d world (position, target, up vector)
-local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 60.0)
-
--- Generates some random columns
-local heights = {}
-local positions = {}
-local colors = {}
-
-for i = 1, MAX_COLUMNS do
- heights[i] = GetRandomValue(1, 12)
- positions[i] = Vector3(GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15))
- colors[i] = Color(GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255)
-end
-
-local playerPosition = Vector3(4.0, 2.0, 4.0) -- Define player position
-
-SetCameraMode(CameraMode.FIRST_PERSON) -- Set a first person camera mode
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera, playerPosition = UpdateCameraPlayer(camera, playerPosition) -- Update camera and player position
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawPlane(Vector3(0.0, 0.0, 0.0), Vector2(32.0, 32.0), LIGHTGRAY) -- Draw ground
- DrawCube(Vector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, BLUE) -- Draw a blue wall
- DrawCube(Vector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, LIME) -- Draw a green wall
- DrawCube(Vector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, GOLD) -- Draw a yellow wall
-
- -- Draw some cubes around
- for i = 1, MAX_COLUMNS do
- DrawCube(positions[i], 2.0, heights[i], 2.0, colors[i])
- DrawCubeWires(positions[i], 2.0, heights[i], 2.0, MAROON)
- end
-
- End3dMode()
-
- DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5))
- DrawRectangleLines( 10, 10, 220, 70, BLUE)
-
- DrawText("First person camera default controls:", 20, 20, 10, BLACK)
- DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY)
- DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_3d_camera_free.lua b/examples/core_3d_camera_free.lua
deleted file mode 100644
index 244aad6b..00000000
--- a/examples/core_3d_camera_free.lua
+++ /dev/null
@@ -1,75 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Initialize 3d camera free
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
---------------------------------------------------------------------------------------------
-
--- Initialization
-----------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
-
--- Define the camera to look into our 3d world
-local camera = {}
-camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
-camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
-camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
-camera.fovy = 45.0 -- Camera field-of-view Y
-
-local cubePosition = Vector3(0.0, 0.0, 0.0)
-
-SetCameraMode(CameraMode.FREE) -- Set a free camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
- DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
-
- DrawGrid(10, 1.0)
-
- End3dMode()
-
- DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5))
- DrawRectangleLines( 10, 10, 320, 133, BLUE)
-
- DrawText("Free camera default controls:", 20, 20, 10, BLACK)
- DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY)
- DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY)
- DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY)
- DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY)
- DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_3d_mode.lua b/examples/core_3d_mode.lua
deleted file mode 100644
index c0f7a038..00000000
--- a/examples/core_3d_mode.lua
+++ /dev/null
@@ -1,64 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Initialize 3d mode
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode")
-
--- Define the camera to look into our 3d world
-local camera = {}
-camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
-camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
-camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
-camera.fovy = 45.0 -- Camera field-of-view Y
-
-local cubePosition = Vector3(0.0, 0.0, 0.0)
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera) -- ERROR: Lua Error: attempt to index a number value (?)
-
- DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
- DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
-
- DrawGrid(10, 1.0)
-
- End3dMode()
-
- DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_3d_picking.lua b/examples/core_3d_picking.lua
deleted file mode 100644
index 1adee67c..00000000
--- a/examples/core_3d_picking.lua
+++ /dev/null
@@ -1,98 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Picking in 3d mode
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")
-
--- Define the camera to look into our 3d world
-local camera = {}
-camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
-camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
-camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
-camera.fovy = 45.0 -- Camera field-of-view Y
-
-local cubePosition = Vector3(0.0, 1.0, 0.0)
-local cubeSize = Vector3(2.0, 2.0, 2.0)
-
-local ray = Ray(Vector3(0, 0, 0), Vector3(0, 0, 0)) -- Picking line ray
-
-local collision = false
-
-SetCameraMode(CameraMode.FREE) -- Set a free camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
-
- if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then
- -- NOTE: This function is NOT WORKING properly!
- ray = GetMouseRay(GetMousePosition(), camera)
-
- -- Check collision between ray and box
- collision = CheckCollisionRayBox(ray,
- BoundingBox(Vector3(cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2),
- Vector3(cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2)))
-
- --print("collision check:", collision)
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- if (collision) then
- DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
- DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
-
- DrawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, GREEN)
- else
- DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
- DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
- end
-
- DrawRay(ray, MAROON)
-
- DrawGrid(10, 1.0)
-
- End3dMode()
-
- DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY)
-
- if (collision) then
- DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30))/2, screenHeight*0.1, 30, GREEN)
- end
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_basic_window.lua b/examples/core_basic_window.lua
deleted file mode 100644
index ea3337a1..00000000
--- a/examples/core_basic_window.lua
+++ /dev/null
@@ -1,44 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Basic window
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_color_select.lua b/examples/core_color_select.lua
deleted file mode 100644
index 2d9c7a96..00000000
--- a/examples/core_color_select.lua
+++ /dev/null
@@ -1,82 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Color selection by mouse (collision detection)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-NUM_RECTANGLES = 21
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)")
-
-local colors = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
- GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
- GREEN, SKYBLUE, PURPLE, BEIGE }
-
-local colorsRecs = {} -- Rectangles array
-local selected = {}
-
--- Fills colorsRecs data (for every rectangle)
-for i = 1, NUM_RECTANGLES do
- colorsRecs[i] = Rectangle(0, 0, 0, 0)
- colorsRecs[i].x = 20 + 100*((i-1)%7) + 10*((i-1)%7)
- colorsRecs[i].y = 60 + 100*((i-1)//7) + 10*((i-1)//7) -- Using floor division: //
- colorsRecs[i].width = 100
- colorsRecs[i].height = 100
- selected[i] = false
-end
-
-local mousePoint = Vector2(0, 0)
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- mousePoint = GetMousePosition()
-
- for i = 1, NUM_RECTANGLES do -- Iterate along all the rectangles
- if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) then
- colors[i].a = 120
- if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then selected[i] = not selected[i] end
- else colors[i].a = 255 end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- for i = 1, NUM_RECTANGLES do -- Draw all rectangles
- DrawRectangleRec(colorsRecs[i], colors[i])
-
- -- Draw four rectangles around selected rectangle
- if (selected[i]) then
- DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE) -- Square top rectangle
- DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE) -- Square left rectangle
- DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE) -- Square right rectangle
- DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE) -- Square bottom rectangle
- end
- end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_drop_files.lua b/examples/core_drop_files.lua
deleted file mode 100644
index 1d27e618..00000000
--- a/examples/core_drop_files.lua
+++ /dev/null
@@ -1,66 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Windows drop files
---
--- This example only works on platforms that support drag & drop (Windows, Linux, OSX)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files")
-
-local count = 0
-local droppedFiles = {}
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsFileDropped()) then
- droppedFiles = GetDroppedFiles()
- count = #droppedFiles
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- if (count == 0) then DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY)
- else
- DrawText("Dropped files:", 100, 40, 20, DARKGRAY)
-
- for i = 0, count-1 do
- if (i%2 == 0) then DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5))
- else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3)) end
-
- DrawText(droppedFiles[i+1], 120, 100 + 40*i, 10, GRAY)
- end
-
- DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY)
- end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-ClearDroppedFiles() -- Clear internal buffers
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_gestures_detection.lua b/examples/core_gestures_detection.lua
deleted file mode 100644
index 9316b990..00000000
--- a/examples/core_gestures_detection.lua
+++ /dev/null
@@ -1,102 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Gestures Detection
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-MAX_GESTURE_STRINGS = 20
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection")
-
-local touchPosition = Vector2(0, 0)
-local touchArea = Rectangle(220, 10, screenWidth - 230, screenHeight - 20)
-
-local gesturesCount = 0
-local gestureStrings = {}
-
-for i = 1, MAX_GESTURE_STRINGS do gestureStrings[i] = "" end
-
-local currentGesture = Gestures.NONE
-local lastGesture = Gestures.NONE
-
---SetGesturesEnabled(0b0000000000001001) -- Enable only some gestures to be detected
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- lastGesture = currentGesture
- currentGesture = GetGestureDetected()
- touchPosition = GetTouchPosition(0)
-
- if (CheckCollisionPointRec(touchPosition, touchArea) and (currentGesture ~= Gestures.NONE)) then
- if (currentGesture ~= lastGesture) then
- -- Store gesture string
- if (currentGesture == Gestures.TAP) then gestureStrings[gesturesCount] = "GESTURE TAP"
- elseif (currentGesture == Gestures.DOUBLETAP) then gestureStrings[gesturesCount] = "GESTURE DOUBLETAP"
- elseif (currentGesture == Gestures.HOLD) then gestureStrings[gesturesCount] = "GESTURE HOLD"
- elseif (currentGesture == Gestures.DRAG) then gestureStrings[gesturesCount] = "GESTURE DRAG"
- elseif (currentGesture == Gestures.SWIPE_RIGHT) then gestureStrings[gesturesCount] = "GESTURE SWIPE RIGHT"
- elseif (currentGesture == Gestures.SWIPE_LEFT) then gestureStrings[gesturesCount] = "GESTURE SWIPE LEFT"
- elseif (currentGesture == Gestures.SWIPE_UP) then gestureStrings[gesturesCount] = "GESTURE SWIPE UP"
- elseif (currentGesture == Gestures.SWIPE_DOWN) then gestureStrings[gesturesCount] = "GESTURE SWIPE DOWN"
- elseif (currentGesture == Gestures.PINCH_IN) then gestureStrings[gesturesCount] = "GESTURE PINCH IN"
- elseif (currentGesture == Gestures.PINCH_OUT) then gestureStrings[gesturesCount] = "GESTURE PINCH OUT"
- end
-
- gesturesCount = gesturesCount + 1
-
- -- Reset gestures strings
- if (gesturesCount >= MAX_GESTURE_STRINGS) then
- for i = 1, MAX_GESTURE_STRINGS do gestureStrings[i] = "\0" end
- gesturesCount = 0
- end
- end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawRectangleRec(touchArea, GRAY)
- DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE)
-
- DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5))
-
- for i = 1, gesturesCount do
- if ((i - 1)%2 == 0) then DrawRectangle(10, 30 + 20*(i - 1), 200, 20, Fade(LIGHTGRAY, 0.5))
- else DrawRectangle(10, 30 + 20*(i - 1), 200, 20, Fade(LIGHTGRAY, 0.3)) end
-
- if (i < gesturesCount) then DrawText(gestureStrings[i], 35, 36 + 20*(i - 1), 10, DARKGRAY)
- else DrawText(gestureStrings[i], 35, 36 + 20*(i - 1), 10, MAROON) end
- end
-
- DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY)
- DrawText("DETECTED GESTURES", 50, 15, 10, GRAY)
-
- if (currentGesture ~= GESTURE_NONE) then DrawCircleV(touchPosition, 30, MAROON) end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_input_gamepad.lua b/examples/core_input_gamepad.lua
deleted file mode 100644
index 78d9b84e..00000000
--- a/examples/core_input_gamepad.lua
+++ /dev/null
@@ -1,63 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Gamepad input
---
--- NOTE: This example requires a Gamepad connected to the system
--- raylib is configured to work with Xbox 360 gamepad, check raylib.h for buttons configuration
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input")
-
-local ballPosition = Vector2(screenWidth/2, screenHeight/2)
-local gamepadMovement = Vector2(0, 0)
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsGamepadAvailable(GAMEPAD.PLAYER1)) then
- gamepadMovement.x = GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_X)
- gamepadMovement.y = GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_Y)
-
- ballPosition.x = ballPosition.x + gamepadMovement.x
- ballPosition.y = ballPosition.y - gamepadMovement.y
-
- if (IsGamepadButtonPressed(GAMEPAD.PLAYER1, GAMEPAD.BUTTON_A)) then
- ballPosition.x = screenWidth/2
- ballPosition.y = screenHeight/2
- end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY)
-
- DrawCircleV(ballPosition, 50, MAROON)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_input_keys.lua b/examples/core_input_keys.lua
deleted file mode 100644
index 523b7317..00000000
--- a/examples/core_input_keys.lua
+++ /dev/null
@@ -1,51 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Keyboard input
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
-
-local ballPosition = Vector2(screenWidth/2, screenHeight/2)
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyDown(KEY.RIGHT)) then ballPosition.x = ballPosition.x + 0.8 end
- if (IsKeyDown(KEY.LEFT)) then ballPosition.x = ballPosition.x - 0.8 end
- if (IsKeyDown(KEY.UP)) then ballPosition.y = ballPosition.y - 0.8 end
- if (IsKeyDown(KEY.DOWN)) then ballPosition.y = ballPosition.y + 0.8 end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY)
-
- DrawCircleV(ballPosition, 50, MAROON)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
--------------------------------------------------------------------------------------------
diff --git a/examples/core_input_mouse.lua b/examples/core_input_mouse.lua
deleted file mode 100644
index 35ca8e73..00000000
--- a/examples/core_input_mouse.lua
+++ /dev/null
@@ -1,54 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Mouse input
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input")
-
-local ballPosition = Vector2(-100.0, -100.0)
-local ballColor = DARKBLUE
-
-SetTargetFPS(60) -- Set target frames-per-second
------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ------------------------------------------------------------------------------------
- ballPosition = GetMousePosition()
-
- if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then ballColor = MAROON
- elseif (IsMouseButtonPressed(MOUSE.MIDDLE_BUTTON)) then ballColor = LIME
- elseif (IsMouseButtonPressed(MOUSE.RIGHT_BUTTON)) then ballColor = DARKBLUE
- end
- ------------------------------------------------------------------------------------
-
- -- Draw
- ------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawCircleV(ballPosition, 40, ballColor)
-
- DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY)
-
- EndDrawing()
- ------------------------------------------------------------------------------------
-end
-
--- De-Initialization
-----------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_mouse_wheel.lua b/examples/core_mouse_wheel.lua
deleted file mode 100644
index 92e0a160..00000000
--- a/examples/core_mouse_wheel.lua
+++ /dev/null
@@ -1,50 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] examples - Mouse wheel
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel")
-
-local boxPositionY = screenHeight/2 - 40
-local scrollSpeed = 4 -- Scrolling speed in pixels
-
-SetTargetFPS(60) -- Set target frames-per-second
-----------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ------------------------------------------------------------------------------------
- boxPositionY = boxPositionY - (GetMouseWheelMove()*scrollSpeed)
- ------------------------------------------------------------------------------------
-
- -- Draw
- ------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON)
-
- DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY)
- DrawText(string.format("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY)
-
- EndDrawing()
- ------------------------------------------------------------------------------------
-end
-
--- De-Initialization
-----------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_oculus_rift.lua b/examples/core_oculus_rift.lua
deleted file mode 100644
index 2626d178..00000000
--- a/examples/core_oculus_rift.lua
+++ /dev/null
@@ -1,73 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Oculus Rift CV1
---
--- NOTE: Example requires linkage with LibOVR
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 1080
-local screenHeight = 600
-
--- NOTE: screenWidth/screenHeight should match VR device aspect ratio
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift")
-
--- NOTE: If device is not available, it fallbacks to default device (simulator)
-InitVrDevice(VrDevice.OCULUS_RIFT_CV1) -- Init VR device (Oculus Rift CV1)
-
--- Define the camera to look into our 3d world
-local camera = {}
-camera.position = Vector3(5.0, 5.0, 5.0) -- Camera position
-camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
-camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
-camera.fovy = 60.0 -- Camera field-of-view Y
-
-local cubePosition = Vector3(0.0, 0.0, 0.0)
-
-SetTargetFPS(90) -- Set our game to run at 90 frames-per-second
-----------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ------------------------------------------------------------------------------------
- UpdateVrTracking()
-
- if (IsKeyPressed(KEY.SPACE)) then ToggleVrMode() end
- ------------------------------------------------------------------------------------
-
- -- Draw
- ------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
- DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
-
- DrawGrid(10, 1.0)
-
- End3dMode()
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ------------------------------------------------------------------------------------
-end
-
--- De-Initialization
-----------------------------------------------------------------------------------------
-CloseVrDevice() -- Close VR device
-
-CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_random_values.lua b/examples/core_random_values.lua
deleted file mode 100644
index b80ab9e2..00000000
--- a/examples/core_random_values.lua
+++ /dev/null
@@ -1,56 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Generate random values
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values")
-
-local framesCounter = 0 -- Variable used to count frames
-
-local randValue = GetRandomValue(-8, 5) -- Get a random integer number between -8 and 5 (both included)
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-----------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ------------------------------------------------------------------------------------
- framesCounter = framesCounter + 1
-
- -- Every two seconds (120 frames) a new random value is generated
- if (((framesCounter/120)%2) == 1) then
- randValue = GetRandomValue(-8, 5)
- framesCounter = 0
- end
- ------------------------------------------------------------------------------------
-
- -- Draw
- ------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON)
-
- DrawText(string.format("%i", randValue), 360, 180, 80, LIGHTGRAY)
-
- EndDrawing()
- ------------------------------------------------------------------------------------
-end
-
--- De-Initialization
-----------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_storage_values.lua b/examples/core_storage_values.lua
deleted file mode 100644
index 878b90e4..00000000
--- a/examples/core_storage_values.lua
+++ /dev/null
@@ -1,74 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - Storage save/load values
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- NOTE: Storage positions must start with 0, directly related to file memory layout
-STORAGE_SCORE = 0
-STORAGE_HISCORE = 1
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values")
-
-local score = 0
-local hiscore = 0
-
-local framesCounter = 0
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyPressed(KEY.R)) then
- score = GetRandomValue(1000, 2000)
- hiscore = GetRandomValue(2000, 4000)
- end
-
- if (IsKeyPressed(KEY.ENTER)) then
- StorageSaveValue(STORAGE_SCORE, score)
- StorageSaveValue(STORAGE_HISCORE, hiscore)
- elseif (IsKeyPressed(KEY.SPACE)) then
- -- NOTE: If requested position could not be found, value 0 is returned
- score = StorageLoadValue(STORAGE_SCORE)
- hiscore = StorageLoadValue(STORAGE_HISCORE)
- end
-
- framesCounter = framesCounter + 1
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText(string.format("SCORE: %i", score), 280, 130, 40, MAROON)
- DrawText(string.format("HI-SCORE: %i", hiscore), 210, 200, 50, BLACK)
-
- DrawText(string.format("frames: %i", framesCounter), 10, 10, 20, LIME)
-
- DrawText("Press R to generate random numbers", 220, 40, 20, LIGHTGRAY)
- DrawText("Press ENTER to SAVE values", 250, 310, 20, LIGHTGRAY)
- DrawText("Press SPACE to LOAD values", 252, 350, 20, LIGHTGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/core_world_screen.lua b/examples/core_world_screen.lua
deleted file mode 100644
index 51f2cdbf..00000000
--- a/examples/core_world_screen.lua
+++ /dev/null
@@ -1,69 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [core] example - World to screen
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local cubePosition = Vector3(0.0, 0.0, 0.0)
-
-local cubeScreenPosition = Vector2(0, 0)
-
-SetCameraMode(CameraMode.FREE) -- Set a free camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-----------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
-
- -- Calculate cube screen space position (with a little offset to be in top)
- cubeScreenPosition = GetWorldToScreen(Vector3(cubePosition.x, cubePosition.y + 2.5, cubePosition.z), camera)
- ------------------------------------------------------------------------------------
-
- -- Draw
- ------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
- DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
-
- DrawGrid(10, 1.0)
-
- End3dMode()
-
- DrawText("Enemy: 100 / 100", cubeScreenPosition.x//1 - MeasureText("Enemy: 100 / 100", 20)//2, cubeScreenPosition.y//1, 20, BLACK)
- DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20))//2, 25, 20, GRAY)
-
- EndDrawing()
- ------------------------------------------------------------------------------------
-end
-
--- De-Initialization
-----------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_billboard.lua b/examples/models_billboard.lua
deleted file mode 100644
index 457198e6..00000000
--- a/examples/models_billboard.lua
+++ /dev/null
@@ -1,65 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Drawing billboards
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(5.0, 4.0, 5.0), Vector3(0.0, 2.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local bill = LoadTexture("resources/billboard.png") -- Our texture billboard
-local billPosition = Vector3(0.0, 2.0, 0.0) -- Position where draw billboard
-
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawBillboard(camera, bill, billPosition, 2.0, WHITE)
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(bill) -- Unload texture
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_box_collisions.lua b/examples/models_box_collisions.lua
deleted file mode 100644
index 4a3107b9..00000000
--- a/examples/models_box_collisions.lua
+++ /dev/null
@@ -1,115 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Detect basic 3d collisions (box vs sphere vs box)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local playerPosition = Vector3(0.0, 1.0, 2.0)
-local playerSize = Vector3(1.0, 2.0, 1.0)
-local playerColor = GREEN
-
-local enemyBoxPos = Vector3(-4.0, 1.0, 0.0)
-local enemyBoxSize = Vector3(2.0, 2.0, 2.0)
-
-local enemySpherePos = Vector3(4.0, 0.0, 0.0)
-local enemySphereSize = 1.5
-
-local collision = false
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
-
- -- Move player
- if (IsKeyDown(KEY.RIGHT)) then playerPosition.x = playerPosition.x + 0.2
- elseif (IsKeyDown(KEY.LEFT)) then playerPosition.x = playerPosition.x - 0.2
- elseif (IsKeyDown(KEY.DOWN)) then playerPosition.z = playerPosition.z + 0.2
- elseif (IsKeyDown(KEY.UP)) then playerPosition.z = playerPosition.z - 0.2 end
-
- collision = false
-
- -- Check collisions player vs enemy-box
- if (CheckCollisionBoxes(
- BoundingBox(Vector3(playerPosition.x - playerSize.x/2,
- playerPosition.y - playerSize.y/2,
- playerPosition.z - playerSize.z/2),
- Vector3(playerPosition.x + playerSize.x/2,
- playerPosition.y + playerSize.y/2,
- playerPosition.z + playerSize.z/2)),
- BoundingBox(Vector3(enemyBoxPos.x - enemyBoxSize.x/2,
- enemyBoxPos.y - enemyBoxSize.y/2,
- enemyBoxPos.z - enemyBoxSize.z/2),
- Vector3(enemyBoxPos.x + enemyBoxSize.x/2,
- enemyBoxPos.y + enemyBoxSize.y/2,
- enemyBoxPos.z + enemyBoxSize.z/2)))) then collision = true
- end
-
- -- Check collisions player vs enemy-sphere
- if (CheckCollisionBoxSphere(
- BoundingBox(Vector3(playerPosition.x - playerSize.x/2,
- playerPosition.y - playerSize.y/2,
- playerPosition.z - playerSize.z/2),
- Vector3(playerPosition.x + playerSize.x/2,
- playerPosition.y + playerSize.y/2,
- playerPosition.z + playerSize.z/2)),
- enemySpherePos, enemySphereSize)) then collision = true
- end
-
- if (collision) then playerColor = RED
- else playerColor = GREEN end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- -- Draw enemy-box
- DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY)
- DrawCubeWires(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, DARKGRAY)
-
- -- Draw enemy-sphere
- DrawSphere(enemySpherePos, enemySphereSize, GRAY)
- DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, DARKGRAY)
-
- -- Draw player
- DrawCubeV(playerPosition, playerSize, playerColor)
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawText("Move player with cursors to collide", 220, 40, 20, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_cubicmap.lua b/examples/models_cubicmap.lua
deleted file mode 100644
index bae3bac2..00000000
--- a/examples/models_cubicmap.lua
+++ /dev/null
@@ -1,79 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Cubicmap loading and drawing
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(16.0, 14.0, 16.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local image = LoadImage("resources/cubicmap.png") -- Load cubicmap image (RAM)
-local cubicmap = LoadTextureFromImage(image) -- Convert image to texture to display (VRAM)
-local map = LoadCubicmap(image) -- Load cubicmap model (generate model from image)
-
--- NOTE: By default each cube is mapped to one part of texture atlas
-local texture = LoadTexture("resources/cubicmap_atlas.png") -- Load map texture
-map.material.texDiffuse = texture -- Set map diffuse texture
-
-local mapPosition = Vector3(-16.0, 0.0, -8.0) -- Set model position
-
-UnloadImage(image) -- Unload cubesmap image from RAM, already uploaded to VRAM
-
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position
-SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawModel(map, mapPosition, 1.0, WHITE)
-
- End3dMode()
-
- DrawTextureEx(cubicmap, (Vector2)(screenWidth - cubicmap.width*4 - 20, 20), 0.0, 4.0, WHITE)
- DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN)
-
- DrawText("cubicmap image used to", 658, 90, 10, GRAY)
- DrawText("generate map 3d model", 658, 104, 10, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(cubicmap) -- Unload cubicmap texture
-UnloadTexture(texture) -- Unload map texture
-UnloadModel(map) -- Unload map model
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_geometric_shapes.lua b/examples/models_geometric_shapes.lua
deleted file mode 100644
index 0ce08e9f..00000000
--- a/examples/models_geometric_shapes.lua
+++ /dev/null
@@ -1,67 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera) -- ERROR: Lua Error: attempt to index a number value
-
- DrawCube(Vector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, RED)
- DrawCubeWires(Vector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, GOLD)
- DrawCubeWires(Vector3(-4.0, 0.0, -2.0), 3.0, 6.0, 2.0, MAROON)
-
- DrawSphere(Vector3(-1.0, 0.0, -2.0), 1.0, GREEN)
- DrawSphereWires(Vector3(1.0, 0.0, 2.0), 2.0, 16, 16, LIME)
-
- DrawCylinder(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, SKYBLUE)
- DrawCylinderWires(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, DARKBLUE)
- DrawCylinderWires(Vector3(4.5, -1.0, 2.0), 1.0, 1.0, 2.0, 6, BROWN)
-
- DrawCylinder(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, GOLD)
- DrawCylinderWires(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, PINK)
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_heightmap.lua b/examples/models_heightmap.lua
deleted file mode 100644
index 4240f8b7..00000000
--- a/examples/models_heightmap.lua
+++ /dev/null
@@ -1,73 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Heightmap loading and drawing
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing")
-
--- Define our custom camera to look into our 3d world
-local camera = Camera(Vector3(18.0, 16.0, 18.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local image = LoadImage("resources/heightmap.png") -- Load heightmap image (RAM)
-local texture = LoadTextureFromImage(image) -- Convert image to texture (VRAM)
-local map = LoadHeightmap(image, Vector3(16, 8, 16)) -- Load heightmap model with defined size
-map.material.texDiffuse = texture -- Set map diffuse texture
-local mapPosition = Vector3(-8.0, 0.0, -8.0) -- Set model position (depends on model scaling!)
-
-UnloadImage(image) -- Unload heightmap image from RAM, already uploaded to VRAM
-
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-----------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- -- NOTE: Model is scaled to 1/4 of its original size (128x128 units)
- DrawModel(map, mapPosition, 1.0, RED)
-
- DrawGrid(20, 1.0)
-
- End3dMode()
-
- DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE)
- DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Unload texture
-UnloadModel(map) -- Unload model
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_obj_loading.lua b/examples/models_obj_loading.lua
deleted file mode 100644
index 7e5c7c4b..00000000
--- a/examples/models_obj_loading.lua
+++ /dev/null
@@ -1,67 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [models] example - Load and draw a 3d model (OBJ)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model
-local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture
-dwarf.material.texDiffuse = texture -- Set dwarf model diffuse texture
-local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- ...
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- DrawGizmo(position) -- Draw gizmo
-
- End3dMode()
-
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Unload texture
-UnloadModel(dwarf) -- Unload model
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/models_ray_picking.c b/examples/models_ray_picking.c
new file mode 100644
index 00000000..c578a185
--- /dev/null
+++ b/examples/models_ray_picking.c
@@ -0,0 +1,197 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Ray picking in 3d mode, ground plane, triangle, mesh
+*
+* This example has been created using raylib 1.7 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2015 Ramon Santamaria (@raysan5)
+* Example contributed by Joel Davis (@joeld42)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+#include "../src/raymath.h"
+
+#include <stdio.h>
+#include <float.h>
+
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d ray picking");
+
+ // Define the camera to look into our 3d world
+ Camera camera;
+ camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+
+ Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
+ Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
+
+ Ray ray; // Picking line ray
+
+ Model tower = LoadModel("resources/model/lowpoly-tower.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/model/lowpoly-tower.png"); // Load model texture
+ tower.material.texDiffuse = texture; // Set model diffuse texture
+
+ Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
+ BoundingBox towerBBox = CalculateBoundingBox( tower.mesh );
+ bool hitMeshBBox = false;
+ bool hitTriangle = false;
+
+ // Test triangle
+ Vector3 ta = (Vector3){ -25.0, 0.5, 0.0 };
+ Vector3 tb = (Vector3){ -4.0, 2.5, 1.0 };
+ Vector3 tc = (Vector3){ -8.0, 6.5, 0.0 };
+
+ Vector3 bary = { 0.0f, 0.0f, 0.0f };
+
+ SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCamera(&camera); // Update camera
+
+ // Display information about closest hit
+ RayHitInfo nearestHit;
+ char *hitObjectName = "None";
+ nearestHit.distance = FLT_MAX;
+ nearestHit.hit = false;
+ Color cursorColor = WHITE;
+
+ // Get ray and test against ground, triangle, and mesh
+ ray = GetMouseRay(GetMousePosition(), camera);
+
+ // Check ray collision aginst ground plane
+ RayHitInfo groundHitInfo = GetCollisionRayGround(ray, 0.0f);
+
+ if ((groundHitInfo.hit) && (groundHitInfo.distance < nearestHit.distance))
+ {
+ nearestHit = groundHitInfo;
+ cursorColor = GREEN;
+ hitObjectName = "Ground";
+ }
+
+ // Check ray collision against test triangle
+ RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, ta, tb, tc);
+
+ if ((triHitInfo.hit) && (triHitInfo.distance < nearestHit.distance))
+ {
+ nearestHit = triHitInfo;
+ cursorColor = PURPLE;
+ hitObjectName = "Triangle";
+
+ bary = Barycenter(nearestHit.hitPosition, ta, tb, tc);
+ hitTriangle = true;
+ }
+ else hitTriangle = false;
+
+ RayHitInfo meshHitInfo;
+
+ // Check ray collision against bounding box first, before trying the full ray-mesh test
+ if (CheckCollisionRayBox(ray, towerBBox))
+ {
+ hitMeshBBox = true;
+
+ // Check ray collision against mesh
+ meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh);
+
+ if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
+ {
+ nearestHit = meshHitInfo;
+ cursorColor = ORANGE;
+ hitObjectName = "Mesh";
+ }
+
+ } hitMeshBBox = false;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ // Draw the tower
+ DrawModel(tower, towerPos, 1.0, WHITE);
+
+ // Draw the test triangle
+ DrawLine3D(ta, tb, PURPLE);
+ DrawLine3D(tb, tc, PURPLE);
+ DrawLine3D(tc, ta, PURPLE);
+
+ // Draw the mesh bbox if we hit it
+ if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME);
+
+ // If we hit something, draw the cursor at the hit point
+ if (nearestHit.hit)
+ {
+ DrawCube(nearestHit.hitPosition, 0.5, 0.5, 0.5, cursorColor);
+ DrawCubeWires(nearestHit.hitPosition, 0.5, 0.5, 0.5, YELLOW);
+
+ Vector3 normalEnd;
+ normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x;
+ normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y;
+ normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z;
+
+ DrawLine3D(nearestHit.hitPosition, normalEnd, YELLOW);
+ }
+
+ DrawRay(ray, MAROON);
+
+ DrawGrid(100, 1.0f);
+
+ End3dMode();
+
+ // Draw some debug GUI text
+ DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK);
+
+ if (nearestHit.hit)
+ {
+ int ypos = 70;
+
+ DrawText(FormatText("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK);
+
+ DrawText(FormatText("Hit Pos: %3.2f %3.2f %3.2f",
+ nearestHit.hitPosition.x,
+ nearestHit.hitPosition.y,
+ nearestHit.hitPosition.z), 10, ypos + 15, 10, BLACK);
+
+ DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f",
+ nearestHit.hitNormal.x,
+ nearestHit.hitNormal.y,
+ nearestHit.hitNormal.z), 10, ypos + 30, 10, BLACK);
+
+ if (hitTriangle) DrawText(FormatText("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
+ }
+
+ DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY);
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/physics_demo.c b/examples/physics_demo.c
index bed7c94d..de8d515e 100644
--- a/examples/physics_demo.c
+++ b/examples/physics_demo.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_friction.c b/examples/physics_friction.c
index 28d3c4b8..a4baad53 100644
--- a/examples/physics_friction.c
+++ b/examples/physics_friction.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_movement.c b/examples/physics_movement.c
index ca18f3df..ee97845f 100644
--- a/examples/physics_movement.c
+++ b/examples/physics_movement.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
#define VELOCITY 0.5f
diff --git a/examples/physics_restitution.c b/examples/physics_restitution.c
index 3543db69..378f6f24 100644
--- a/examples/physics_restitution.c
+++ b/examples/physics_restitution.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_shatter.c b/examples/physics_shatter.c
index 2cb9d195..637a163e 100644
--- a/examples/physics_shatter.c
+++ b/examples/physics_shatter.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/resources/audio/sound.wav b/examples/resources/audio/sound.wav
new file mode 100644
index 00000000..b5d01c9b
--- /dev/null
+++ b/examples/resources/audio/sound.wav
Binary files differ
diff --git a/examples/resources/audio/tanatana.flac b/examples/resources/audio/tanatana.flac
new file mode 100644
index 00000000..dfe735cd
--- /dev/null
+++ b/examples/resources/audio/tanatana.flac
Binary files differ
diff --git a/examples/resources/model/lowpoly-tower.obj b/examples/resources/model/lowpoly-tower.obj
new file mode 100644
index 00000000..ea03a9fc
--- /dev/null
+++ b/examples/resources/model/lowpoly-tower.obj
@@ -0,0 +1,456 @@
+# Blender v2.78 (sub 0) OBJ File: 'lowpoly-tower.blend'
+# www.blender.org
+o Grid
+v -4.000000 0.000000 4.000000
+v -2.327363 0.000000 4.654725
+v 0.000000 0.000000 4.654725
+v 2.327363 0.000000 4.654725
+v 4.000000 0.000000 4.000000
+v -4.654725 0.955085 2.327363
+v -2.000000 0.815050 2.000000
+v 0.000000 0.476341 2.423448
+v 2.000000 0.476341 2.000000
+v 4.654725 0.000000 2.327363
+v -4.654725 1.649076 0.000000
+v -2.423448 1.092402 0.000000
+v 2.423448 0.198579 0.000000
+v 4.654725 0.000000 0.000000
+v -4.654725 1.649076 -2.327363
+v -2.000000 1.092402 -2.000000
+v 0.000000 0.476341 -2.423448
+v 2.000000 -0.012791 -2.000000
+v 4.654725 0.000000 -2.612731
+v -4.000000 0.955085 -4.000000
+v -2.327363 0.955085 -4.654725
+v 0.000000 0.955085 -4.654725
+v 2.327363 0.000000 -4.654725
+v 4.000000 0.000000 -4.000000
+v 2.423448 0.682825 0.000000
+v 2.000000 0.565423 -2.000000
+v -4.654725 -0.020560 2.327363
+v -4.654725 0.000000 0.000000
+v -4.654725 0.000000 -2.327363
+v -4.000000 0.000000 -4.000000
+v -2.327363 0.000000 -4.654725
+v 0.000000 -0.020560 -4.654725
+v 0.000000 0.709880 -1.230535
+v -0.000000 7.395413 0.000000
+v 0.962071 0.709880 -0.767226
+v -0.533909 0.709880 1.108674
+v -1.199683 0.709880 0.273820
+v -0.962071 0.709880 -0.767226
+v 1.506076 0.859071 1.325337
+v 1.199683 0.709880 0.273820
+v 0.533909 0.709880 1.108674
+v 0.000000 1.875340 -1.177842
+v -0.000000 2.293973 -0.649884
+v -0.000000 4.365648 -0.627970
+v 0.000000 6.167194 -0.942957
+v 0.000000 6.232434 -1.708677
+v 1.335898 6.232434 -1.065343
+v 0.737233 6.167195 -0.587924
+v 0.490966 4.365648 -0.391533
+v 0.508100 2.293973 -0.405196
+v 0.920874 1.875340 -0.734372
+v -0.741367 6.232434 1.539465
+v -0.409133 6.167195 0.849574
+v -0.272466 4.365648 0.565781
+v -0.281974 2.293973 0.585526
+v -0.511047 1.875340 1.061199
+v -1.665837 6.232434 0.380217
+v -0.919314 6.167195 0.209828
+v -0.612225 4.365648 0.139736
+v -0.633590 2.293973 0.144613
+v -1.148311 1.875340 0.262095
+v -1.335898 6.232434 -1.065343
+v -0.737233 6.167195 -0.587924
+v -0.490967 4.365648 -0.391533
+v -0.508100 2.293973 -0.405196
+v -0.920874 1.875340 -0.734372
+v 1.665837 6.232434 0.380216
+v 0.919315 6.167195 0.209828
+v 0.612225 4.365648 0.139736
+v 0.633590 2.293973 0.144613
+v 1.148311 1.875340 0.262095
+v 0.741367 6.232434 1.539465
+v 0.409133 6.167195 0.849575
+v 0.272466 4.365648 0.565781
+v 0.281974 2.293973 0.585526
+v 0.511046 1.875340 1.061199
+v 0.000000 5.012550 -0.969733
+v 0.758168 5.012550 -0.604618
+v -0.420751 5.012550 0.873699
+v -0.945419 5.012550 0.215786
+v -0.758168 5.012550 -0.604618
+v 0.945419 5.012550 0.215786
+v 0.420751 5.012550 0.873699
+vt 0.0523 0.5444
+vt 0.1817 0.4284
+vt 0.1641 0.5859
+vt 0.0177 0.4451
+vt 0.1526 0.3090
+vt 0.0189 0.1737
+vt 0.0188 0.3088
+vt 0.0561 0.0762
+vt 0.1757 0.1924
+vt 0.3024 0.4534
+vt 0.3071 0.5902
+vt 0.3413 0.2459
+vt 0.2906 0.1614
+vt 0.4116 0.1801
+vt 0.2834 0.3774
+vt 0.1526 0.0362
+vt 0.2917 0.1622
+vt 0.4446 0.5865
+vt 0.4443 0.2989
+vt 0.3711 0.3021
+vt 0.4396 0.0275
+vt 0.4094 0.1829
+vt 0.4219 0.4255
+vt 0.5474 0.5381
+vt 0.5811 0.4376
+vt 0.5715 0.1505
+vt 0.5811 0.2997
+vt 0.5272 0.0533
+vt 0.2208 0.2194
+vt 0.3456 0.3610
+vt 0.2878 0.0321
+vt 0.2321 0.3392
+vt 0.4432 0.0177
+vt 0.7347 0.7934
+vt 0.7382 0.7595
+vt 0.8982 0.7768
+vt 0.6169 0.7595
+vt 0.6139 0.7879
+vt 0.4951 0.7634
+vt 0.1551 0.6832
+vt 0.2925 0.6268
+vt 0.2925 0.6832
+vt 0.7795 0.6832
+vt 0.6421 0.6268
+vt 0.7795 0.6255
+vt 0.5046 0.7241
+vt 0.6421 0.7241
+vt 0.3986 0.6268
+vt 0.3986 0.6832
+vt 0.5046 0.6268
+vt 0.0177 0.6268
+vt 0.1551 0.6255
+vt 0.8856 0.6268
+vt 0.1899 0.9579
+vt 0.1194 0.8696
+vt 0.2324 0.8696
+vt 0.1899 0.7813
+vt 0.0943 0.7595
+vt 0.0177 0.8206
+vt 0.0177 0.9186
+vt 0.0943 0.9797
+vt 0.2793 0.2349
+vt 0.2304 0.2758
+vt 0.6597 0.0177
+vt 0.6954 0.0993
+vt 0.6367 0.0768
+vt 0.7558 0.0777
+vt 0.7238 0.0440
+vt 0.8840 0.1330
+vt 0.7385 0.1141
+vt 0.9157 0.0886
+vt 0.9781 0.1232
+vt 0.9224 0.1276
+vt 0.2677 0.8141
+vt 0.3463 0.8037
+vt 0.3086 0.8339
+vt 0.6387 0.3550
+vt 0.7130 0.3801
+vt 0.6596 0.4053
+vt 0.7245 0.3245
+vt 0.6919 0.3383
+vt 0.8655 0.3566
+vt 0.7351 0.3577
+vt 0.9770 0.3365
+vt 0.9078 0.3751
+vt 0.9174 0.3282
+vt 0.2677 0.9018
+vt 0.3086 0.8821
+vt 0.6803 0.2948
+vt 0.6251 0.3035
+vt 0.7194 0.2854
+vt 0.8764 0.2832
+vt 0.9221 0.2861
+vt 0.3363 0.9565
+vt 0.3464 0.9122
+vt 0.6751 0.2482
+vt 0.6178 0.2499
+vt 0.7179 0.2431
+vt 0.9823 0.2484
+vt 0.9247 0.2452
+vt 0.3935 0.9014
+vt 0.6755 0.1996
+vt 0.6164 0.1941
+vt 0.7201 0.1992
+vt 0.8793 0.2446
+vt 0.9823 0.2060
+vt 0.9257 0.2051
+vt 0.4598 0.8580
+vt 0.4144 0.8579
+vt 0.6819 0.1498
+vt 0.6222 0.1361
+vt 0.7266 0.1555
+vt 0.8831 0.1684
+vt 0.9252 0.1659
+vt 0.4218 0.7790
+vt 0.3934 0.8145
+vt 0.3363 0.7595
+vt 0.8815 0.2060
+vt 0.8720 0.3208
+vt 0.8825 0.1012
+vt 0.9735 0.0816
+vt 0.9718 0.3817
+vt 0.9807 0.2918
+vt 0.4218 0.9370
+vt 0.9810 0.1644
+vn 0.1035 0.8806 0.4623
+vn 0.0964 0.9481 0.3030
+vn 0.0000 0.9780 0.2088
+vn 0.0659 0.9835 0.1683
+vn 0.2325 0.9320 0.2779
+vn 0.0553 0.9960 -0.0702
+vn 0.2827 0.9564 0.0728
+vn 0.1873 0.9776 -0.0961
+vn 0.2421 0.9703 0.0000
+vn 0.0921 0.9772 -0.1913
+vn -0.0277 0.9947 -0.0993
+vn 0.2308 0.9274 -0.2944
+vn 0.2771 0.9572 -0.0837
+vn 0.3724 0.9074 0.1947
+vn 0.0777 0.9770 -0.1985
+vn -0.1094 0.9539 0.2794
+vn 0.0364 0.9844 0.1721
+vn 0.1683 0.9835 0.0659
+vn 0.0674 0.9901 0.1230
+vn 0.4338 0.8823 0.1829
+vn 0.2845 0.9565 0.0649
+vn 0.0886 0.9961 0.0000
+vn 0.2000 0.9789 0.0424
+vn 0.1417 0.9830 0.1171
+vn 0.3021 0.9524 0.0412
+vn -0.0193 0.9986 -0.0493
+vn 0.0000 0.9777 0.2098
+vn 0.0005 0.9781 -0.2083
+vn 0.1879 0.9782 -0.0887
+vn 0.2249 0.0000 0.9744
+vn 0.9783 0.0000 -0.2071
+vn 0.9783 0.0000 0.2071
+vn 0.0000 0.0000 -1.0000
+vn -1.0000 0.0000 0.0000
+vn -0.3645 0.0000 -0.9312
+vn -0.9312 0.0000 -0.3645
+vn -0.9312 0.0000 0.3645
+vn 0.2615 0.7979 -0.5431
+vn 0.5877 0.7979 -0.1341
+vn 0.4713 0.7979 0.3758
+vn -0.0000 0.7979 0.6028
+vn -0.4713 0.7979 0.3758
+vn -0.5877 0.7979 -0.1341
+vn -0.2615 0.7979 -0.5431
+vn -0.1285 0.9864 -0.1025
+vn 0.0929 0.8937 0.4389
+vn -0.4335 0.0407 -0.9002
+vn -0.2867 0.7507 -0.5952
+vn -0.4339 0.0095 -0.9009
+vn -0.4338 0.0209 -0.9008
+vn -0.0408 -0.9956 -0.0848
+vn -0.9741 0.0407 -0.2223
+vn -0.6441 0.7507 -0.1470
+vn -0.9749 0.0095 -0.2225
+vn -0.9747 0.0209 -0.2225
+vn -0.0918 -0.9956 -0.0209
+vn -0.7812 0.0407 0.6230
+vn -0.5165 0.7507 0.4119
+vn -0.7818 0.0095 0.6235
+vn -0.7817 0.0209 0.6234
+vn -0.0736 -0.9956 0.0587
+vn -0.0000 0.0407 0.9992
+vn 0.0000 0.7507 0.6607
+vn 0.0000 0.0095 1.0000
+vn -0.0000 0.0209 0.9998
+vn -0.0000 -0.9956 0.0941
+vn 0.7812 0.0407 0.6230
+vn 0.5165 0.7507 0.4119
+vn 0.7818 0.0095 0.6235
+vn 0.7817 0.0209 0.6234
+vn 0.0736 -0.9956 0.0587
+vn 0.9741 0.0407 -0.2223
+vn 0.6441 0.7507 -0.1470
+vn 0.9749 0.0095 -0.2225
+vn 0.9747 0.0209 -0.2225
+vn 0.0918 -0.9956 -0.0209
+vn 0.4335 0.0407 -0.9002
+vn 0.2867 0.7507 -0.5952
+vn 0.4339 0.0095 -0.9009
+vn 0.4338 0.0209 -0.9008
+vn 0.0408 -0.9956 -0.0848
+vn 0.3918 -0.4298 -0.8135
+vn 0.8803 -0.4298 -0.2009
+vn 0.7059 -0.4298 0.5630
+vn -0.0000 -0.4298 0.9029
+vn -0.7059 -0.4298 0.5630
+vn -0.8803 -0.4298 -0.2009
+vn -0.3918 -0.4298 -0.8135
+vn 0.0210 0.9998 -0.0048
+vn 0.0482 0.9981 -0.0385
+vn -0.0166 0.9914 -0.1301
+vn -0.0090 0.9904 -0.1379
+vn 0.2820 0.9576 0.0597
+vn -0.0000 0.9846 0.1749
+vn -0.0921 0.9772 -0.1913
+vn -0.1734 0.9794 0.1036
+s off
+f 1/1/1 7/2/1 6/3/1
+f 2/4/2 8/5/2 7/2/2
+f 4/6/3 8/5/3 3/7/3
+f 5/8/4 9/9/4 4/6/4
+f 6/3/5 12/10/5 11/11/5
+f 35/12/6 25/13/6 26/14/6
+f 7/2/7 37/15/7 12/10/7
+f 10/16/8 13/17/8 9/9/8
+f 12/10/9 15/18/9 11/11/9
+f 35/12/10 17/19/10 33/20/10
+f 13/17/11 19/21/11 18/22/11
+f 16/23/12 20/24/12 15/18/12
+f 17/19/13 21/25/13 16/23/13
+f 17/19/14 23/26/14 22/27/14
+f 26/14/15 24/28/15 23/26/15
+f 1/1/16 2/4/16 7/2/16
+f 2/4/3 3/7/3 8/5/3
+f 4/6/17 9/9/17 8/5/17
+f 5/8/18 10/16/18 9/9/18
+f 6/3/19 7/2/19 12/10/19
+f 25/13/20 39/29/20 9/9/20
+f 38/30/21 12/10/21 37/15/21
+f 10/16/22 14/31/22 13/17/22
+f 12/10/23 16/23/23 15/18/23
+f 8/5/24 36/32/24 7/2/24
+f 38/30/25 17/19/25 16/23/25
+f 13/17/22 14/31/22 19/21/22
+f 16/23/26 21/25/26 20/24/26
+f 17/19/27 22/27/27 21/25/27
+f 17/19/28 26/14/28 23/26/28
+f 26/14/29 19/33/29 24/28/29
+f 26/34/30 18/35/30 19/36/30
+f 26/34/31 13/37/31 18/35/31
+f 25/38/32 9/39/32 13/37/32
+f 22/40/33 31/41/33 21/42/33
+f 6/43/34 28/44/34 27/45/34
+f 15/46/34 28/44/34 11/47/34
+f 21/42/35 30/48/35 20/49/35
+f 20/49/36 29/50/36 15/46/36
+f 22/40/33 23/51/33 32/52/33
+f 6/43/37 27/45/37 1/53/37
+f 46/54/38 34/55/38 47/56/38
+f 47/56/39 34/55/39 67/57/39
+f 67/57/40 34/55/40 72/58/40
+f 72/58/41 34/55/41 52/59/41
+f 52/59/42 34/55/42 57/60/42
+f 57/60/43 34/55/43 62/61/43
+f 62/61/44 34/55/44 46/54/44
+f 40/62/45 41/63/45 39/29/45
+f 39/29/46 8/5/46 9/9/46
+f 38/64/47 42/65/47 33/66/47
+f 65/67/48 42/65/48 66/68/48
+f 65/67/49 44/69/49 43/70/49
+f 81/71/50 45/72/50 77/73/50
+f 62/74/51 45/75/51 63/76/51
+f 37/77/52 66/78/52 38/79/52
+f 60/80/53 66/78/53 61/81/53
+f 60/80/54 64/82/54 65/83/54
+f 58/84/55 81/85/55 80/86/55
+f 57/87/56 63/76/56 58/88/56
+f 56/89/57 37/77/57 36/90/57
+f 55/91/58 61/81/58 56/89/58
+f 54/92/59 60/80/59 55/91/59
+f 79/93/60 58/84/60 80/86/60
+f 52/94/61 58/88/61 53/95/61
+f 76/96/62 36/90/62 41/97/62
+f 75/98/63 56/89/63 76/96/63
+f 75/98/64 54/92/64 55/91/64
+f 73/99/65 79/93/65 83/100/65
+f 73/101/66 52/94/66 53/95/66
+f 71/102/67 41/97/67 40/103/67
+f 70/104/68 76/96/68 71/102/68
+f 70/104/69 74/105/69 75/98/69
+f 68/106/70 83/100/70 82/107/70
+f 67/108/71 73/101/71 68/109/71
+f 51/110/72 40/103/72 35/111/72
+f 50/112/73 71/102/73 51/110/73
+f 49/113/74 70/104/74 50/112/74
+f 78/114/75 68/106/75 82/107/75
+f 47/115/76 68/109/76 48/116/76
+f 42/65/77 35/111/77 33/66/77
+f 43/70/78 51/110/78 42/65/78
+f 44/69/79 50/112/79 43/70/79
+f 45/72/80 78/114/80 77/73/80
+f 46/117/81 48/116/81 45/75/81
+f 44/69/82 78/114/82 49/113/82
+f 49/113/83 82/107/83 69/118/83
+f 82/107/84 74/105/84 69/118/84
+f 83/100/85 54/92/85 74/105/85
+f 79/93/86 59/119/86 54/92/86
+f 80/86/87 64/82/87 59/119/87
+f 64/120/88 77/73/88 44/69/88
+f 35/12/89 40/62/89 25/13/89
+f 7/2/90 36/32/90 37/15/90
+f 35/12/91 26/14/91 17/19/91
+f 25/13/92 40/62/92 39/29/92
+f 38/30/93 16/23/93 12/10/93
+f 8/5/94 41/63/94 36/32/94
+f 38/30/95 33/20/95 17/19/95
+f 26/34/31 25/38/31 13/37/31
+f 22/40/33 32/52/33 31/41/33
+f 6/43/34 11/47/34 28/44/34
+f 15/46/34 29/50/34 28/44/34
+f 21/42/35 31/41/35 30/48/35
+f 20/49/36 30/48/36 29/50/36
+f 39/29/96 41/63/96 8/5/96
+f 38/64/47 66/68/47 42/65/47
+f 65/67/48 43/70/48 42/65/48
+f 65/67/49 64/120/49 44/69/49
+f 81/71/50 63/121/50 45/72/50
+f 62/74/51 46/117/51 45/75/51
+f 37/77/52 61/81/52 66/78/52
+f 60/80/53 65/83/53 66/78/53
+f 60/80/54 59/119/54 64/82/54
+f 58/84/55 63/122/55 81/85/55
+f 57/87/56 62/74/56 63/76/56
+f 56/89/57 61/81/57 37/77/57
+f 55/91/58 60/80/58 61/81/58
+f 54/92/59 59/119/59 60/80/59
+f 79/93/60 53/123/60 58/84/60
+f 52/94/61 57/87/61 58/88/61
+f 76/96/62 56/89/62 36/90/62
+f 75/98/63 55/91/63 56/89/63
+f 75/98/64 74/105/64 54/92/64
+f 73/99/65 53/123/65 79/93/65
+f 73/101/66 72/124/66 52/94/66
+f 71/102/67 76/96/67 41/97/67
+f 70/104/68 75/98/68 76/96/68
+f 70/104/69 69/118/69 74/105/69
+f 68/106/70 73/99/70 83/100/70
+f 67/108/71 72/124/71 73/101/71
+f 51/110/72 71/102/72 40/103/72
+f 50/112/73 70/104/73 71/102/73
+f 49/113/74 69/118/74 70/104/74
+f 78/114/75 48/125/75 68/106/75
+f 47/115/76 67/108/76 68/109/76
+f 42/65/77 51/110/77 35/111/77
+f 43/70/78 50/112/78 51/110/78
+f 44/69/79 49/113/79 50/112/79
+f 45/72/80 48/125/80 78/114/80
+f 46/117/81 47/115/81 48/116/81
+f 44/69/82 77/73/82 78/114/82
+f 49/113/83 78/114/83 82/107/83
+f 82/107/84 83/100/84 74/105/84
+f 83/100/85 79/93/85 54/92/85
+f 79/93/86 80/86/86 59/119/86
+f 80/86/87 81/85/87 64/82/87
+f 64/120/88 81/71/88 77/73/88
diff --git a/examples/resources/model/lowpoly-tower.png b/examples/resources/model/lowpoly-tower.png
new file mode 100644
index 00000000..7c9239e2
--- /dev/null
+++ b/examples/resources/model/lowpoly-tower.png
Binary files differ
diff --git a/examples/rlgl_oculus_rift.c b/examples/rlgl_oculus_rift.c
index 39dee99e..30ef6f3b 100644
--- a/examples/rlgl_oculus_rift.c
+++ b/examples/rlgl_oculus_rift.c
@@ -144,7 +144,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateOculusTracking();
+ UpdateOculusTracking(&camera);
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/rlua_execute_file.c b/examples/rlua_execute_file.c
deleted file mode 100644
index f2d7114e..00000000
--- a/examples/rlua_execute_file.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************************
-*
-* raylib [rlua] example - Lua file execution
-*
-* NOTE: This example requires Lua library (http://luabinaries.sourceforge.net/download.html)
-*
-* Compile example using:
-* gcc -o $(NAME_PART).exe $(FILE_NAME) $(RAYLIB_DIR)\raylib_icon /
-* -I../src -I../src/external/lua/include -L../src/external/lua/lib /
-* -lraylib -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -llua53 /
-* -std=c99 -Wl,-allow-multiple-definition -Wl,--subsystem,windows
-*
-* This example has been created using raylib 1.6 (www.raylib.com)
-* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
-*
-* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
-*
-********************************************************************************************/
-
-#include "raylib.h"
-
-#define RLUA_IMPLEMENTATION
-#include "rlua.h"
-
-int main()
-{
- // Initialization
- //--------------------------------------------------------------------------------------
- InitLuaDevice();
- //--------------------------------------------------------------------------------------
-
- ExecuteLuaFile("core_basic_window.lua"); // OK!
- // ExecuteLuaFile("core_input_keys.lua"); // OK!
- // ExecuteLuaFile("core_input_mouse.lua"); // OK!
- // ExecuteLuaFile("core_mouse_wheel.lua"); // OK!
- // ExecuteLuaFile("core_input_gamepad.lua"); // OK!
- // ExecuteLuaFile("core_random_values.lua"); // OK!
- // ExecuteLuaFile("core_color_select.lua"); // OK!
- // ExecuteLuaFile("core_drop_files.lua"); // OK!
- // ExecuteLuaFile("core_storage_values.lua"); // OK!
- // ExecuteLuaFile("core_gestures_detection.lua"); // OK!
- // ExecuteLuaFile("core_3d_mode.lua"); // OK!
- // ExecuteLuaFile("core_3d_picking.lua"); // OK!
- // ExecuteLuaFile("core_3d_camera_free.lua"); // OK!
- // ExecuteLuaFile("core_3d_camera_first_person.lua"); // OK!
- // ExecuteLuaFile("core_2d_camera.lua"); // OK!
- // ExecuteLuaFile("core_world_screen.lua"); // OK!
- // ExecuteLuaFile("core_oculus_rift.lua"); // OK!
- // ExecuteLuaFile("shapes_logo_raylib.lua"); // OK!
- // ExecuteLuaFile("shapes_basic_shapes.lua"); // OK!
- // ExecuteLuaFile("shapes_colors_palette.lua"); // OK!
- // ExecuteLuaFile("shapes_logo_raylib_anim.lua"); // OK! NOTE: Use lua string.sub() instead of raylib SubText()
- // ExecuteLuaFile("textures_logo_raylib.lua"); // OK!
- // ExecuteLuaFile("textures_image_loading.lua"); // OK!
- // ExecuteLuaFile("textures_rectangle.lua"); // OK!
- // ExecuteLuaFile("textures_srcrec_dstrec.lua"); // OK!
- // ExecuteLuaFile("textures_to_image.lua"); // OK!
- // ExecuteLuaFile("textures_raw_data.lua"); // ERROR: LoadImageEx()
- // ExecuteLuaFile("textures_formats_loading.lua"); // OK!
- // ExecuteLuaFile("textures_particles_trail_blending.lua"); // OK!
- // ExecuteLuaFile("textures_image_processing.lua"); // ERROR: GetImageData() --> UpdateTexture()
- // ExecuteLuaFile("textures_image_drawing.lua"); // OK!
- // ExecuteLuaFile("text_sprite_fonts.lua"); // OK!
- // ExecuteLuaFile("text_bmfont_ttf.lua"); // OK!
- // ExecuteLuaFile("text_rbmf_fonts.lua"); // OK!
- // ExecuteLuaFile("text_format_text.lua"); // OK! NOTE: Use lua string.format() instead of raylib FormatText()
- // ExecuteLuaFile("text_font_select.lua"); // OK!
- // ExecuteLuaFile("text_writing_anim.lua"); // OK!
- // ExecuteLuaFile("models_geometric_shapes.lua"); // OK!
- // ExecuteLuaFile("models_box_collisions.lua"); // OK!
- // ExecuteLuaFile("models_billboard.lua"); // OK!
- // ExecuteLuaFile("models_obj_loading.lua"); // OK!
- // ExecuteLuaFile("models_heightmap.lua"); // OK!
- // ExecuteLuaFile("models_cubicmap.lua"); // OK!
- // ExecuteLuaFile("shaders_model_shader.lua"); // OK!
- // ExecuteLuaFile("shaders_shapes_textures.lua"); // OK!
- // ExecuteLuaFile("shaders_custom_uniform.lua"); // OK!
- // ExecuteLuaFile("shaders_postprocessing.lua"); // OK!
- // ExecuteLuaFile("shaders_standard_lighting.lua"); // OK!
- // ExecuteLuaFile("audio_sound_loading.lua"); // OK!
- // ExecuteLuaFile("audio_music_stream.lua"); // OK!
- // ExecuteLuaFile("audio_module_playing.lua"); // OK!
- // ExecuteLuaFile("audio_raw_stream.lua"); // ERROR: UpdateAudioStream()
-
- // De-Initialization
- //--------------------------------------------------------------------------------------
- CloseLuaDevice(); // Close Lua device and free resources
- //--------------------------------------------------------------------------------------
-
- return 0;
-} \ No newline at end of file
diff --git a/examples/shaders_custom_uniform.lua b/examples/shaders_custom_uniform.lua
deleted file mode 100644
index 3a8bbae5..00000000
--- a/examples/shaders_custom_uniform.lua
+++ /dev/null
@@ -1,115 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shaders] example - Apply a postprocessing shader and connect a custom uniform variable
---
--- NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
--- OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
---
--- NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
--- on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
--- raylib comes with shaders ready for both versions, check raylib/shaders install folder
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x (if available)
-
-InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model
-local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture (diffuse map)
-dwarf.material.texDiffuse = texture -- Set dwarf model diffuse texture
-
-local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-
-local shader = LoadShader("resources/shaders/glsl330/base.vs",
- "resources/shaders/glsl330/swirl.fs") -- Load postpro shader
-
--- Get variable (uniform) location on the shader to connect with the program
--- NOTE: If uniform variable could not be found in the shader, function returns -1
-local swirlCenterLoc = GetShaderLocation(shader, "center")
-
-local swirlCenter = { screenWidth/2, screenHeight/2 }
-
--- Create a RenderTexture2D to be used for render to texture
-local target = LoadRenderTexture(screenWidth, screenHeight)
-
--- Setup orbital camera
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- local mousePosition = GetMousePosition()
-
- swirlCenter[1] = mousePosition.x
- swirlCenter[2] = screenHeight - mousePosition.y
-
- -- Send new value to the shader to be used on drawing
- SetShaderValue(shader, swirlCenterLoc, swirlCenter)
-
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- BeginTextureMode(target) -- Enable drawing to texture
-
- Begin3dMode(camera)
-
- DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED)
-
- EndTextureMode() -- End drawing to texture (now we have a texture available for next passes)
-
- BeginShaderMode(shader)
-
- -- NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
- DrawTextureRec(target.texture, Rectangle(0, 0, target.texture.width, -target.texture.height), Vector2(0, 0), WHITE)
-
- EndShaderMode()
-
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadShader(shader) -- Unload shader
-UnloadTexture(texture) -- Unload texture
-UnloadModel(dwarf) -- Unload model
-UnloadRenderTexture(target) -- Unload render texture
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shaders_model_shader.c b/examples/shaders_model_shader.c
index 26de4922..51e9c1b3 100644
--- a/examples/shaders_model_shader.c
+++ b/examples/shaders_model_shader.c
@@ -42,7 +42,7 @@ int main()
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
+ SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -52,7 +52,7 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update camera
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/shaders_model_shader.lua b/examples/shaders_model_shader.lua
deleted file mode 100644
index d1436a7e..00000000
--- a/examples/shaders_model_shader.lua
+++ /dev/null
@@ -1,85 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shaders] example - Apply a shader to a 3d model
---
--- NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
--- OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
---
--- NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
--- on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
--- raylib comes with shaders ready for both versions, check raylib/shaders install folder
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x (if available)
-
-InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model
-local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture
-local shader = LoadShader("resources/shaders/glsl330/base.vs",
- "resources/shaders/glsl330/grayscale.fs") -- Load model shader
-
-dwarf.material.shader = shader -- Set shader effect to 3d model
-dwarf.material.texDiffuse = texture -- Bind texture to model
-
-local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-
--- Setup orbital camera
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadShader(shader) -- Unload shader
-UnloadTexture(texture) -- Unload texture
-UnloadModel(dwarf) -- Unload model
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shaders_postprocessing.lua b/examples/shaders_postprocessing.lua
deleted file mode 100644
index f20f31ec..00000000
--- a/examples/shaders_postprocessing.lua
+++ /dev/null
@@ -1,101 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shaders] example - Apply a postprocessing shader to a scene
---
--- NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
--- OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
---
--- NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
--- on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
--- raylib comes with shaders ready for both versions, check raylib/shaders install folder
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x (if available)
-
-InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model
-local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture (diffuse map)
-dwarf.material.texDiffuse = texture -- Set dwarf model diffuse texture
-
-local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-
-local shader = LoadShader("resources/shaders/glsl330/base.vs",
- "resources/shaders/glsl330/bloom.fs") -- Load postpro shader
-
--- Create a RenderTexture2D to be used for render to texture
-local target = LoadRenderTexture(screenWidth, screenHeight)
-
--- Setup orbital camera
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- BeginTextureMode(target) -- Enable drawing to texture
-
- Begin3dMode(camera)
-
- DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED)
-
- EndTextureMode() -- End drawing to texture (now we have a texture available for next passes)
-
- BeginShaderMode(shader)
-
- -- NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
- DrawTextureRec(target.texture, Rectangle(0, 0, target.texture.width, -target.texture.height), Vector2(0, 0), WHITE)
-
- EndShaderMode()
-
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadShader(shader) -- Unload shader
-UnloadTexture(texture) -- Unload texture
-UnloadModel(dwarf) -- Unload model
-UnloadRenderTexture(target) -- Unload render texture
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shaders_shapes_textures.lua b/examples/shaders_shapes_textures.lua
deleted file mode 100644
index caaeba1a..00000000
--- a/examples/shaders_shapes_textures.lua
+++ /dev/null
@@ -1,101 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shaders] example - Apply a shader to some shape or texture
---
--- NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
--- OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
---
--- NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
--- on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
--- raylib comes with shaders ready for both versions, check raylib/shaders install folder
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders")
-
-local sonic = LoadTexture("resources/texture_formats/sonic.png")
-
--- NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
-local shader = LoadShader("resources/shaders/glsl330/base.vs",
- "resources/shaders/glsl330/grayscale.fs")
-
--- Shader usage is also different than models/postprocessing, shader is just activated when required
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- -- Start drawing with default shader
-
- DrawText("USING DEFAULT SHADER", 20, 40, 10, RED)
-
- DrawCircle(80, 120, 35, DARKBLUE)
- DrawCircleGradient(80, 220, 60, GREEN, SKYBLUE)
- DrawCircleLines(80, 340, 80, DARKBLUE)
-
-
- -- Activate our custom shader to be applied on next shapes/textures drawings
- BeginShaderMode(shader)
-
- DrawText("USING CUSTOM SHADER", 190, 40, 10, RED)
-
- DrawRectangle(250 - 60, 90, 120, 60, RED)
- DrawRectangleGradient(250 - 90, 170, 180, 130, MAROON, GOLD)
- DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE)
-
- -- Activate our default shader for next drawings
- EndShaderMode()
-
- DrawText("USING DEFAULT SHADER", 370, 40, 10, RED)
-
- DrawTriangle(Vector2(430, 80),
- Vector2(430 - 60, 150),
- Vector2(430 + 60, 150), VIOLET)
-
- DrawTriangleLines(Vector2(430, 160),
- Vector2(430 - 20, 230),
- Vector2(430 + 20, 230), DARKBLUE)
-
- DrawPoly(Vector2(430, 320), 6, 80, 0, BROWN)
-
- -- Activate our custom shader to be applied on next shapes/textures drawings
- BeginShaderMode(shader)
-
- DrawTexture(sonic, 380, -10, WHITE) -- Using custom shader
-
- -- Activate our default shader for next drawings
- EndShaderMode()
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadShader(shader) -- Unload shader
-UnloadTexture(sonic) -- Unload texture
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shaders_standard_lighting.c b/examples/shaders_standard_lighting.c
index e539ec47..16cd7ff6 100644
--- a/examples/shaders_standard_lighting.c
+++ b/examples/shaders_standard_lighting.c
@@ -9,15 +9,79 @@
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
*
-* This example has been created using raylib 1.3 (www.raylib.com)
+* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2016 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+#include <stdlib.h> // Required for: NULL
+#include <string.h> // Required for: strcpy()
+#include <math.h> // Required for: vector math
+
+//----------------------------------------------------------------------------------
+// Defines and Macros
+//----------------------------------------------------------------------------------
+#define MAX_LIGHTS 8 // Max lights supported by standard shader
+
+//----------------------------------------------------------------------------------
+// Types and Structures Definition
+//----------------------------------------------------------------------------------
+
+// Light type
+typedef struct LightData {
+ unsigned int id; // Light unique id
+ bool enabled; // Light enabled
+ int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
+
+ Vector3 position; // Light position
+ Vector3 target; // Light direction: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
+ float radius; // Light attenuation radius light intensity reduced with distance (world distance)
+
+ Color diffuse; // Light diffuse color
+ float intensity; // Light intensity level
+
+ float coneAngle; // Light cone max angle: LIGHT_SPOT
+} LightData, *Light;
+
+// Light types
+typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType;
+
+//----------------------------------------------------------------------------------
+// Global Variables Definition
+//----------------------------------------------------------------------------------
+static Light lights[MAX_LIGHTS]; // Lights pool
+static int lightsCount = 0; // Enabled lights counter
+static int lightsLocs[MAX_LIGHTS][8]; // Lights location points in shader: 8 possible points per light:
+ // enabled, type, position, target, radius, diffuse, intensity, coneAngle
+
+//----------------------------------------------------------------------------------
+// Module Functions Declaration
+//----------------------------------------------------------------------------------
+static Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
+static void DestroyLight(Light light); // Destroy a light and take it out of the list
+static void DrawLight(Light light); // Draw light in 3D world
+
+static void GetShaderLightsLocations(Shader shader); // Get shader locations for lights (up to MAX_LIGHTS)
+static void SetShaderLightsValues(Shader shader); // Set shader uniform values for lights
+
+// Vector3 math functions
+static float VectorLength(const Vector3 v); // Calculate vector lenght
+static void VectorNormalize(Vector3 *v); // Normalize provided vector
+static Vector3 VectorSubtract(Vector3 v1, Vector3 v2); // Substract two vectors
+
+
+//https://www.gamedev.net/topic/655969-speed-gluniform-vs-uniform-buffer-objects/
+//https://www.reddit.com/r/opengl/comments/4ri20g/is_gluniform_more_expensive_than_glprogramuniform/
+//http://cg.alexandra.dk/?p=3778 - AZDO
+//https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main()
{
// Initialization
@@ -35,7 +99,12 @@ int main()
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
- Material material = LoadStandardMaterial();
+ Material material;// = LoadStandardMaterial();
+
+ material.shader = LoadShader("resources/shaders/glsl330/standard.vs", "resources/shaders/glsl330/standard.fs");
+
+ // Try to get lights location points (if available)
+ GetShaderLightsLocations(material.shader);
material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
@@ -62,6 +131,12 @@ int main()
pointLight->intensity = 2.0f;
pointLight->diffuse = (Color){100, 100, 255, 255};
pointLight->radius = 3.0f;
+
+ // Set shader lights values for enabled lights
+ // NOTE: If values are not changed in real time, they can be set at initialization!!!
+ SetShaderLightsValues(material.shader);
+
+ //SetShaderActive(0);
// Setup orbital camera
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
@@ -113,8 +188,295 @@ int main()
DestroyLight(dirLight);
DestroyLight(spotLight);
+ // Unload lights
+ if (lightsCount > 0)
+ {
+ for (int i = 0; i < lightsCount; i++) free(lights[i]);
+ lightsCount = 0;
+ }
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
-} \ No newline at end of file
+}
+
+//--------------------------------------------------------------------------------------------
+// Module Functions Definitions
+//--------------------------------------------------------------------------------------------
+
+// Create a new light, initialize it and add to pool
+Light CreateLight(int type, Vector3 position, Color diffuse)
+{
+ Light light = NULL;
+
+ if (lightsCount < MAX_LIGHTS)
+ {
+ // Allocate dynamic memory
+ light = (Light)malloc(sizeof(LightData));
+
+ // Initialize light values with generic values
+ light->id = lightsCount;
+ light->type = type;
+ light->enabled = true;
+
+ light->position = position;
+ light->target = (Vector3){ 0.0f, 0.0f, 0.0f };
+ light->intensity = 1.0f;
+ light->diffuse = diffuse;
+
+ // Add new light to the array
+ lights[lightsCount] = light;
+
+ // Increase enabled lights count
+ lightsCount++;
+ }
+ else
+ {
+ // NOTE: Returning latest created light to avoid crashes
+ light = lights[lightsCount];
+ }
+
+ return light;
+}
+
+// Destroy a light and take it out of the list
+void DestroyLight(Light light)
+{
+ if (light != NULL)
+ {
+ int lightId = light->id;
+
+ // Free dynamic memory allocation
+ free(lights[lightId]);
+
+ // Remove *obj from the pointers array
+ for (int i = lightId; i < lightsCount; i++)
+ {
+ // Resort all the following pointers of the array
+ if ((i + 1) < lightsCount)
+ {
+ lights[i] = lights[i + 1];
+ lights[i]->id = lights[i + 1]->id;
+ }
+ }
+
+ // Decrease enabled physic objects count
+ lightsCount--;
+ }
+}
+
+// Draw light in 3D world
+void DrawLight(Light light)
+{
+ switch (light->type)
+ {
+ case LIGHT_POINT:
+ {
+ DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY));
+
+ DrawCircle3D(light->position, light->radius, (Vector3){ 0, 0, 0 }, 0.0f, (light->enabled ? light->diffuse : GRAY));
+ DrawCircle3D(light->position, light->radius, (Vector3){ 1, 0, 0 }, 90.0f, (light->enabled ? light->diffuse : GRAY));
+ DrawCircle3D(light->position, light->radius, (Vector3){ 0, 1, 0 },90.0f, (light->enabled ? light->diffuse : GRAY));
+ } break;
+ case LIGHT_DIRECTIONAL:
+ {
+ DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY));
+
+ DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY));
+ DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY));
+ } break;
+ case LIGHT_SPOT:
+ {
+ DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY));
+
+ Vector3 dir = VectorSubtract(light->target, light->position);
+ VectorNormalize(&dir);
+
+ DrawCircle3D(light->position, 0.5f, dir, 0.0f, (light->enabled ? light->diffuse : GRAY));
+
+ //DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY));
+ DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY));
+ } break;
+ default: break;
+ }
+}
+
+// Get shader locations for lights (up to MAX_LIGHTS)
+static void GetShaderLightsLocations(Shader shader)
+{
+ char locName[32] = "lights[x].\0";
+ char locNameUpdated[64];
+
+ for (int i = 0; i < MAX_LIGHTS; i++)
+ {
+ locName[7] = '0' + i;
+
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "enabled\0");
+ lightsLocs[i][0] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "type\0");
+ lightsLocs[i][1] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "position\0");
+ lightsLocs[i][2] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "direction\0");
+ lightsLocs[i][3] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "radius\0");
+ lightsLocs[i][4] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "diffuse\0");
+ lightsLocs[i][5] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "intensity\0");
+ lightsLocs[i][6] = GetShaderLocation(shader, locNameUpdated);
+
+ locNameUpdated[0] = '\0';
+ strcpy(locNameUpdated, locName);
+ strcat(locNameUpdated, "coneAngle\0");
+ lightsLocs[i][7] = GetShaderLocation(shader, locNameUpdated);
+ }
+}
+
+// Set shader uniform values for lights
+// NOTE: It would be far easier with shader UBOs but are not supported on OpenGL ES 2.0
+// TODO: Replace glUniform1i(), glUniform1f(), glUniform3f(), glUniform4f():
+//SetShaderValue(Shader shader, int uniformLoc, float *value, int size)
+//SetShaderValuei(Shader shader, int uniformLoc, int *value, int size)
+static void SetShaderLightsValues(Shader shader)
+{
+ int tempInt[8] = { 0 };
+ float tempFloat[8] = { 0.0f };
+
+ for (int i = 0; i < MAX_LIGHTS; i++)
+ {
+ if (i < lightsCount)
+ {
+ tempInt[0] = lights[i]->enabled;
+ SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], lights[i]->enabled);
+
+ tempInt[0] = lights[i]->type;
+ SetShaderValuei(shader, lightsLocs[i][1], tempInt, 1); //glUniform1i(lightsLocs[i][1], lights[i]->type);
+
+ tempFloat[0] = (float)lights[i]->diffuse.r/255.0f;
+ tempFloat[1] = (float)lights[i]->diffuse.g/255.0f;
+ tempFloat[2] = (float)lights[i]->diffuse.b/255.0f;
+ tempFloat[3] = (float)lights[i]->diffuse.a/255.0f;
+ SetShaderValue(shader, lightsLocs[i][5], tempFloat, 4);
+ //glUniform4f(lightsLocs[i][5], (float)lights[i]->diffuse.r/255, (float)lights[i]->diffuse.g/255, (float)lights[i]->diffuse.b/255, (float)lights[i]->diffuse.a/255);
+
+ tempFloat[0] = lights[i]->intensity;
+ SetShaderValue(shader, lightsLocs[i][6], tempFloat, 1);
+
+ switch (lights[i]->type)
+ {
+ case LIGHT_POINT:
+ {
+ tempFloat[0] = lights[i]->position.x;
+ tempFloat[1] = lights[i]->position.y;
+ tempFloat[2] = lights[i]->position.z;
+ SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3);
+
+ tempFloat[0] = lights[i]->radius;
+ SetShaderValue(shader, lightsLocs[i][4], tempFloat, 1);
+
+ //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z);
+ //glUniform1f(lightsLocs[i][4], lights[i]->radius);
+ } break;
+ case LIGHT_DIRECTIONAL:
+ {
+ Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position);
+ VectorNormalize(&direction);
+
+ tempFloat[0] = direction.x;
+ tempFloat[1] = direction.y;
+ tempFloat[2] = direction.z;
+ SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3);
+
+ //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z);
+ } break;
+ case LIGHT_SPOT:
+ {
+ tempFloat[0] = lights[i]->position.x;
+ tempFloat[1] = lights[i]->position.y;
+ tempFloat[2] = lights[i]->position.z;
+ SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3);
+
+ //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z);
+
+ Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position);
+ VectorNormalize(&direction);
+
+ tempFloat[0] = direction.x;
+ tempFloat[1] = direction.y;
+ tempFloat[2] = direction.z;
+ SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3);
+ //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z);
+
+ tempFloat[0] = lights[i]->coneAngle;
+ SetShaderValue(shader, lightsLocs[i][7], tempFloat, 1);
+ //glUniform1f(lightsLocs[i][7], lights[i]->coneAngle);
+ } break;
+ default: break;
+ }
+ }
+ else
+ {
+ tempInt[0] = 0;
+ SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], 0); // Light disabled
+ }
+ }
+}
+
+// Calculate vector lenght
+float VectorLength(const Vector3 v)
+{
+ float length;
+
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
+
+ return length;
+}
+
+// Normalize provided vector
+void VectorNormalize(Vector3 *v)
+{
+ float length, ilength;
+
+ length = VectorLength(*v);
+
+ if (length == 0.0f) length = 1.0f;
+
+ ilength = 1.0f/length;
+
+ v->x *= ilength;
+ v->y *= ilength;
+ v->z *= ilength;
+}
+
+// Substract two vectors
+Vector3 VectorSubtract(Vector3 v1, Vector3 v2)
+{
+ Vector3 result;
+
+ result.x = v1.x - v2.x;
+ result.y = v1.y - v2.y;
+ result.z = v1.z - v2.z;
+
+ return result;
+}
diff --git a/examples/shaders_standard_lighting.lua b/examples/shaders_standard_lighting.lua
deleted file mode 100644
index 2f3700ff..00000000
--- a/examples/shaders_standard_lighting.lua
+++ /dev/null
@@ -1,114 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shaders] example - Standard lighting (materials and lights)
---
--- NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
--- OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
---
--- NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
--- on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
--- raylib comes with shaders ready for both versions, check raylib/shaders install folder
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x (if available)
-
-InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
-
--- Define the camera to look into our 3d world
-local camera = Camera(Vector3(4.0, 4.0, 4.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
-
-local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model
-local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-
-local material = LoadStandardMaterial()
-
-material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model diffuse texture
-material.texNormal = LoadTexture("resources/model/dwarf_normal.png") -- Load model normal texture
-material.texSpecular = LoadTexture("resources/model/dwarf_specular.png") -- Load model specular texture
-material.colDiffuse = WHITE
-material.colAmbient = Color(0, 0, 10, 255)
-material.colSpecular = WHITE
-material.glossiness = 50.0
-
-dwarf.material = material -- Apply material to model
-
-local spotLight = CreateLight(LightType.SPOT, Vector3(3.0, 5.0, 2.0), Color(255, 255, 255, 255))
-spotLight.target = Vector3(0.0, 0.0, 0.0)
-spotLight.intensity = 2.0
-spotLight.diffuse = Color(255, 100, 100, 255)
-spotLight.coneAngle = 60.0
-
-local dirLight = CreateLight(LightType.DIRECTIONAL, Vector3(0.0, -3.0, -3.0), Color(255, 255, 255, 255))
-dirLight.target = Vector3(1.0, -2.0, -2.0)
-dirLight.intensity = 2.0
-dirLight.diffuse = Color(100, 255, 100, 255)
-
-local pointLight = CreateLight(LightType.POINT, Vector3(0.0, 4.0, 5.0), Color(255, 255, 255, 255))
-pointLight.intensity = 2.0
-pointLight.diffuse = Color(100, 100, 255, 255)
-pointLight.radius = 3.0
-
--- Setup orbital camera
-SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode
-SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
-SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- camera = UpdateCamera(camera) -- Update internal camera and our camera
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- Begin3dMode(camera)
-
- DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
-
- DrawLight(spotLight) -- Draw spot light
- DrawLight(dirLight) -- Draw directional light
- DrawLight(pointLight) -- Draw point light
-
- DrawGrid(10, 1.0) -- Draw a grid
-
- End3dMode()
-
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY)
-
- DrawFPS(10, 10)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadMaterial(material) -- Unload material and assigned textures
-UnloadModel(dwarf) -- Unload model
-
--- Destroy all created lights
-DestroyLight(pointLight)
-DestroyLight(dirLight)
-DestroyLight(spotLight)
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shapes_basic_shapes.lua b/examples/shapes_basic_shapes.lua
deleted file mode 100644
index cc943ba3..00000000
--- a/examples/shapes_basic_shapes.lua
+++ /dev/null
@@ -1,64 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing")
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY)
-
- DrawLine(18, 42, screenWidth - 18, 42, BLACK)
-
- DrawCircle(screenWidth/4, 120, 35, DARKBLUE)
- DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE)
- DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE)
-
- DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED)
- DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD)
- DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE)
-
- DrawTriangle(Vector2(screenWidth/4*3, 80),
- Vector2(screenWidth/4*3 - 60, 150),
- Vector2(screenWidth/4*3 + 60, 150), VIOLET)
-
- DrawTriangleLines(Vector2(screenWidth/4*3, 160),
- Vector2(screenWidth/4*3 - 20, 230),
- Vector2(screenWidth/4*3 + 20, 230), DARKBLUE)
-
- DrawPoly(Vector2(screenWidth/4*3, 320), 6, 80, 0, BROWN)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shapes_colors_palette.lua b/examples/shapes_colors_palette.lua
deleted file mode 100644
index e884cd3e..00000000
--- a/examples/shapes_colors_palette.lua
+++ /dev/null
@@ -1,89 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shapes] example - Draw raylib custom color palette
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette")
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("raylib color palette", 28, 42, 20, BLACK)
-
- DrawRectangle(26, 80, 100, 100, DARKGRAY)
- DrawRectangle(26, 188, 100, 100, GRAY)
- DrawRectangle(26, 296, 100, 100, LIGHTGRAY)
- DrawRectangle(134, 80, 100, 100, MAROON)
- DrawRectangle(134, 188, 100, 100, RED)
- DrawRectangle(134, 296, 100, 100, PINK)
- DrawRectangle(242, 80, 100, 100, ORANGE)
- DrawRectangle(242, 188, 100, 100, GOLD)
- DrawRectangle(242, 296, 100, 100, YELLOW)
- DrawRectangle(350, 80, 100, 100, DARKGREEN)
- DrawRectangle(350, 188, 100, 100, LIME)
- DrawRectangle(350, 296, 100, 100, GREEN)
- DrawRectangle(458, 80, 100, 100, DARKBLUE)
- DrawRectangle(458, 188, 100, 100, BLUE)
- DrawRectangle(458, 296, 100, 100, SKYBLUE)
- DrawRectangle(566, 80, 100, 100, DARKPURPLE)
- DrawRectangle(566, 188, 100, 100, VIOLET)
- DrawRectangle(566, 296, 100, 100, PURPLE)
- DrawRectangle(674, 80, 100, 100, DARKBROWN)
- DrawRectangle(674, 188, 100, 100, BROWN)
- DrawRectangle(674, 296, 100, 100, BEIGE)
-
-
- DrawText("DARKGRAY", 65, 166, 10, BLACK)
- DrawText("GRAY", 93, 274, 10, BLACK)
- DrawText("LIGHTGRAY", 61, 382, 10, BLACK)
- DrawText("MAROON", 186, 166, 10, BLACK)
- DrawText("RED", 208, 274, 10, BLACK)
- DrawText("PINK", 204, 382, 10, BLACK)
- DrawText("ORANGE", 295, 166, 10, BLACK)
- DrawText("GOLD", 310, 274, 10, BLACK)
- DrawText("YELLOW", 300, 382, 10, BLACK)
- DrawText("DARKGREEN", 382, 166, 10, BLACK)
- DrawText("LIME", 420, 274, 10, BLACK)
- DrawText("GREEN", 410, 382, 10, BLACK)
- DrawText("DARKBLUE", 498, 166, 10, BLACK)
- DrawText("BLUE", 526, 274, 10, BLACK)
- DrawText("SKYBLUE", 505, 382, 10, BLACK)
- DrawText("DARKPURPLE", 592, 166, 10, BLACK)
- DrawText("VIOLET", 621, 274, 10, BLACK)
- DrawText("PURPLE", 620, 382, 10, BLACK)
- DrawText("DARKBROWN", 705, 166, 10, BLACK)
- DrawText("BROWN", 733, 274, 10, BLACK)
- DrawText("BEIGE", 737, 382, 10, BLACK)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shapes_logo_raylib.lua b/examples/shapes_logo_raylib.lua
deleted file mode 100644
index 4e7f18c4..00000000
--- a/examples/shapes_logo_raylib.lua
+++ /dev/null
@@ -1,48 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shapes] example - Draw raylib logo using basic shapes
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes")
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK)
- DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE)
- DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK)
-
- DrawText("this is NOT a texture!", 350, 370, 10, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/shapes_logo_raylib_anim.lua b/examples/shapes_logo_raylib_anim.lua
deleted file mode 100644
index c6c44995..00000000
--- a/examples/shapes_logo_raylib_anim.lua
+++ /dev/null
@@ -1,127 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [shapes] example - raylib logo animation
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation")
-
-local logoPositionX = screenWidth/2 - 128
-local logoPositionY = screenHeight/2 - 128
-
-local framesCounter = 0
-local lettersCount = 0
-
-local topSideRecWidth = 16
-local leftSideRecHeight = 16
-
-local bottomSideRecWidth = 16
-local rightSideRecHeight = 16
-
-local state = 0 -- Tracking animation states (State Machine)
-local alpha = 1.0 -- Useful for fading
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (state == 0) then -- State 0: Small box blinking
- framesCounter = framesCounter + 1
-
- if (framesCounter == 120) then
- state = 1
- framesCounter = 0 -- Reset counter... will be used later...
- end
- elseif (state == 1) then -- State 1: Top and left bars growing
- topSideRecWidth = topSideRecWidth + 4
- leftSideRecHeight = leftSideRecHeight + 4
-
- if (topSideRecWidth == 256) then state = 2 end
- elseif (state == 2) then -- State 2: Bottom and right bars growing
- bottomSideRecWidth = bottomSideRecWidth + 4
- rightSideRecHeight = rightSideRecHeight + 4
-
- if (bottomSideRecWidth == 256) then state = 3 end
- elseif (state == 3) then -- State 3: Letters appearing (one by one)
- framesCounter = framesCounter + 1
-
- if (framesCounter//12 == 1) then -- Every 12 frames, one more letter!
- lettersCount = lettersCount + 1
- framesCounter = 0
- end
-
- if (lettersCount >= 10) then -- When all letters have appeared, just fade out everything
- alpha = alpha - 0.02
-
- if (alpha <= 0.0) then
- alpha = 0.0
- state = 4
- end
- end
- elseif (state == 4) then -- State 4: Reset and Replay
- if (IsKeyPressed(KEY.R)) then
- framesCounter = 0
- lettersCount = 0
-
- topSideRecWidth = 16
- leftSideRecHeight = 16
-
- bottomSideRecWidth = 16
- rightSideRecHeight = 16
-
- alpha = 1.0
- state = 0 -- Return to State 0
- end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- if (state == 0) then
- if ((framesCounter//15)%2 == 1) then DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK) end
- elseif (state == 1) then
- DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK)
- DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK)
- elseif (state == 2) then
- DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK)
- DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK)
-
- DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK)
- DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK)
- elseif (state == 3) then
- DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha))
- DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha))
-
- DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha))
- DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha))
-
- DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha))
-
- DrawText(string.sub("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha))
- elseif (state == 4) then DrawText("[R] REPLAY", 340, 200, 20, GRAY) end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_bmfont_ttf.c b/examples/text_bmfont_ttf.c
index caece548..4d060915 100644
--- a/examples/text_bmfont_ttf.c
+++ b/examples/text_bmfont_ttf.c
@@ -29,8 +29,8 @@ int main()
Vector2 fontPosition;
- fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2;
- fontPosition.y = screenHeight/2 - fontBm.size/2 - 80;
+ fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.baseSize, 0).x/2;
+ fontPosition.y = screenHeight/2 - fontBm.baseSize/2 - 80;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -49,8 +49,8 @@ int main()
ClearBackground(RAYWHITE);
- DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON);
- DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.size*0.8f, 2, LIME);
+ DrawTextEx(fontBm, msgBm, fontPosition, fontBm.baseSize, 0, MAROON);
+ DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.baseSize*0.8f, 2, LIME);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/text_bmfont_ttf.lua b/examples/text_bmfont_ttf.lua
deleted file mode 100644
index 3b8bf004..00000000
--- a/examples/text_bmfont_ttf.lua
+++ /dev/null
@@ -1,59 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - BMFont and TTF SpriteFonts loading
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading")
-
-local msgBm = "THIS IS AN AngelCode SPRITE FONT"
-local msgTtf = "THIS FONT has been GENERATED from TTF"
-
--- NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
-local fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt") -- BMFont (AngelCode)
-local fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf") -- TTF font
-
-local fontPosition = Vector2(0, 0)
-fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2
-fontPosition.y = screenHeight/2 - fontBm.size/2 - 80
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update variables here...
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON)
- DrawTextEx(fontTtf, msgTtf, Vector2(60.0, 240.0), fontTtf.size, 2, LIME)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadSpriteFont(fontBm) -- AngelCode SpriteFont unloading
-UnloadSpriteFont(fontTtf) -- TTF SpriteFont unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_bmfont_unordered.c b/examples/text_bmfont_unordered.c
index b29c5f8b..6fec3256 100644
--- a/examples/text_bmfont_unordered.c
+++ b/examples/text_bmfont_unordered.c
@@ -45,10 +45,10 @@ int main()
ClearBackground(RAYWHITE);
DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY);
- DrawText(FormatText("Font base size: %i", font.size), 40, 80, 20, GRAY);
- DrawText(FormatText("Font chars number: %i", font.numChars), 40, 110, 20, GRAY);
+ DrawText(FormatText("Font base size: %i", font.baseSize), 40, 80, 20, GRAY);
+ DrawText(FormatText("Font chars number: %i", font.charsCount), 40, 110, 20, GRAY);
- DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.size, 0, MAROON);
+ DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.baseSize, 0, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/text_font_select.c b/examples/text_font_select.c
index fe586db8..5891bef7 100644
--- a/examples/text_font_select.c
+++ b/examples/text_font_select.c
@@ -41,7 +41,7 @@ int main()
const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text
- Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
+ Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1);
Vector2 mousePoint;
@@ -118,7 +118,7 @@ int main()
}
// Text measurement for better positioning on screen
- textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
+ textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1);
//----------------------------------------------------------------------------------
// Draw
@@ -140,7 +140,7 @@ int main()
DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor);
DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2,
- 260 + (70 - textSize.y)/2 }, fonts[currentFont].size*3,
+ 260 + (70 - textSize.y)/2 }, fonts[currentFont].baseSize*3,
1, colors[currentFont]);
EndDrawing();
diff --git a/examples/text_font_select.lua b/examples/text_font_select.lua
deleted file mode 100644
index f6cea881..00000000
--- a/examples/text_font_select.lua
+++ /dev/null
@@ -1,143 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - Font selector
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-local fonts = {} -- SpriteFont array
-
-fonts[1] = LoadSpriteFont("resources/fonts/alagard.rbmf") -- SpriteFont loading
-fonts[2] = LoadSpriteFont("resources/fonts/pixelplay.rbmf") -- SpriteFont loading
-fonts[3] = LoadSpriteFont("resources/fonts/mecha.rbmf") -- SpriteFont loading
-fonts[4] = LoadSpriteFont("resources/fonts/setback.rbmf") -- SpriteFont loading
-fonts[5] = LoadSpriteFont("resources/fonts/romulus.rbmf") -- SpriteFont loading
-fonts[6] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf") -- SpriteFont loading
-fonts[7] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf") -- SpriteFont loading
-fonts[8] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf") -- SpriteFont loading
-
-local currentFont = 1 -- Selected font
-
-local colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }
-
-local fontNames = { "[1] Alagard", "[2] PixelPlay", "[3] MECHA", "[4] Setback",
- "[5] Romulus", "[6] PixAntiqua", "[7] Alpha Beta", "[8] Jupiter Crash" }
-
-local text = "THIS is THE FONT you SELECTED!" -- Main text
-
-local textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1)
-
-local mousePoint
-
-local btnNextOutColor = DARKBLUE -- Button color (outside line)
-local btnNextInColor = SKYBLUE -- Button color (inside)
-
-local framesCounter = 0 -- Useful to count frames button is 'active' = clicked
-
-local positionY = 180 -- Text selector and button Y position
-
-local btnNextRec = Rectangle(673, positionY, 109, 44) -- Button rectangle (useful for collision)
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
-
- -- Keyboard-based font selection (easy)
- if (IsKeyPressed(KEY.RIGHT)) then
- if (currentFont < 8) then currentFont = currentFont + 1 end
- end
-
- if (IsKeyPressed(KEY.LEFT)) then
- if (currentFont > 1) then currentFont = currentFont - 1 end
- end
-
- if (IsKeyPressed(KEY.ZERO)) then currentFont = 0
- elseif (IsKeyPressed(KEY.ONE)) then currentFont = 1
- elseif (IsKeyPressed(KEY.TWO)) then currentFont = 2
- elseif (IsKeyPressed(KEY.THREE)) then currentFont = 3
- elseif (IsKeyPressed(KEY.FOUR)) then currentFont = 4
- elseif (IsKeyPressed(KEY.FIVE)) then currentFont = 5
- elseif (IsKeyPressed(KEY.SIX)) then currentFont = 6
- elseif (IsKeyPressed(KEY.SEVEN)) then currentFont = 7
- end
-
- -- Mouse-based font selection (NEXT button logic)
- mousePoint = GetMousePosition()
-
- if (CheckCollisionPointRec(mousePoint, btnNextRec)) then
- -- Mouse hover button logic
- if (framesCounter == 0) then
- btnNextOutColor = DARKPURPLE
- btnNextInColor = PURPLE
- end
-
- if (IsMouseButtonDown(MOUSE.LEFT_BUTTON)) then
- framesCounter = 20 -- Frames button is 'active'
- btnNextOutColor = MAROON
- btnNextInColor = RED
- end
- else
- -- Mouse not hover button
- btnNextOutColor = DARKBLUE
- btnNextInColor = SKYBLUE
- end
-
- if (framesCounter > 0) then framesCounter = framesCounter - 1 end
-
- if (framesCounter == 1) then -- We change font on frame 1
- currentFont = currentFont + 1
- if (currentFont > 7) then currentFont = 0 end
- end
-
- -- Text measurement for better positioning on screen
- textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1)
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY)
- DrawLine(120, 120, 680, 120, DARKGRAY)
-
- DrawRectangle(18, positionY, 644, 44, DARKGRAY)
- DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY)
- DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK)
- DrawText("< >", 610, positionY + 8, 30, BLACK)
-
- DrawRectangleRec(btnNextRec, btnNextOutColor)
- DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor)
- DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor)
-
- DrawTextEx(fonts[currentFont], text, Vector2(screenWidth/2 - textSize.x/2,
- 260 + (70 - textSize.y)/2), fonts[currentFont].size*3,
- 1, colors[currentFont])
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-for i = 1, 8 do UnloadSpriteFont(fonts[i]) end -- SpriteFont(s) unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_format_text.lua b/examples/text_format_text.lua
deleted file mode 100644
index ba121db3..00000000
--- a/examples/text_format_text.lua
+++ /dev/null
@@ -1,54 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - Text formatting
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting")
-
-local score = 100020
-local hiscore = 200450
-local lives = 5
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText(string.format("Score: %08i", score), 200, 80, 20, RED)
-
- DrawText(string.format("HiScore: %08i", hiscore), 200, 120, 20, GREEN)
-
- DrawText(string.format("Lives: %02i", lives), 200, 160, 40, BLUE)
-
- DrawText(string.format("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_rbmf_fonts.c b/examples/text_rbmf_fonts.c
index b4bd851b..cd5da1fe 100644
--- a/examples/text_rbmf_fonts.c
+++ b/examples/text_rbmf_fonts.c
@@ -50,8 +50,8 @@ int main()
for (int i = 0; i < 8; i++)
{
- positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].size*2, spacings[i]).x/2;
- positions[i].y = 60 + fonts[i].size + 50*i;
+ positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2;
+ positions[i].y = 60 + fonts[i].baseSize + 50*i;
}
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
@@ -76,7 +76,7 @@ int main()
for (int i = 0; i < 8; i++)
{
- DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].size*2, spacings[i], colors[i]);
+ DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
}
EndDrawing();
diff --git a/examples/text_rbmf_fonts.lua b/examples/text_rbmf_fonts.lua
deleted file mode 100644
index 31a733f1..00000000
--- a/examples/text_rbmf_fonts.lua
+++ /dev/null
@@ -1,87 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - raylib bitmap font (rbmf) loading and usage
---
--- NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
--- To view details and credits for those fonts, check raylib license file
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-local fonts = {}
-
-fonts[1] = LoadSpriteFont("resources/fonts/alagard.rbmf") -- rBMF font loading
-fonts[2] = LoadSpriteFont("resources/fonts/pixelplay.rbmf") -- rBMF font loading
-fonts[3] = LoadSpriteFont("resources/fonts/mecha.rbmf") -- rBMF font loading
-fonts[4] = LoadSpriteFont("resources/fonts/setback.rbmf") -- rBMF font loading
-fonts[5] = LoadSpriteFont("resources/fonts/romulus.rbmf") -- rBMF font loading
-fonts[6] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf") -- rBMF font loading
-fonts[7] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf") -- rBMF font loading
-fonts[8] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf") -- rBMF font loading
-
-local messages = { "ALAGARD FONT designed by Hewett Tsoi",
- "PIXELPLAY FONT designed by Aleksander Shevchuk",
- "MECHA FONT designed by Captain Falcon",
- "SETBACK FONT designed by Brian Kent (AEnigma)",
- "ROMULUS FONT designed by Hewett Tsoi",
- "PIXANTIQUA FONT designed by Gerhard Grossmann",
- "ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
- "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" }
-
-local spacings = { 2, 4, 8, 4, 3, 4, 4, 1 }
-
-local positions = {}
-
-for i = 1, 8 do
- positions[i] = Vector2(0, 0)
- positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].size*2, spacings[i]).x/2
- positions[i].y = 60 + fonts[i].size + 45*(i - 1)
-end
-
-local colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, BLACK }
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY)
- DrawLine(220, 50, 590, 50, DARKGRAY)
-
- for i = 1, 8 do
- DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].size*2, spacings[i], colors[i])
- end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-for i = 1, 8 do UnloadSpriteFont(fonts[i]) end -- SpriteFont unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_sprite_fonts.c b/examples/text_sprite_fonts.c
index c73eda85..bded266e 100644
--- a/examples/text_sprite_fonts.c
+++ b/examples/text_sprite_fonts.c
@@ -31,14 +31,14 @@ int main()
Vector2 fontPosition1, fontPosition2, fontPosition3;
- fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.size, -3).x/2;
- fontPosition1.y = screenHeight/2 - font1.size/2 - 80;
+ fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2;
+ fontPosition1.y = screenHeight/2 - font1.baseSize/2 - 80;
- fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.size, -2).x/2;
- fontPosition2.y = screenHeight/2 - font2.size/2 - 10;
+ fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2;
+ fontPosition2.y = screenHeight/2 - font2.baseSize/2 - 10;
- fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.size, 2).x/2;
- fontPosition3.y = screenHeight/2 - font3.size/2 + 50;
+ fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2;
+ fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50;
//--------------------------------------------------------------------------------------
@@ -56,9 +56,9 @@ int main()
ClearBackground(RAYWHITE);
- DrawTextEx(font1, msg1, fontPosition1, font1.size, -3, WHITE);
- DrawTextEx(font2, msg2, fontPosition2, font2.size, -2, WHITE);
- DrawTextEx(font3, msg3, fontPosition3, font3.size, 2, WHITE);
+ DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE);
+ DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE);
+ DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/text_sprite_fonts.lua b/examples/text_sprite_fonts.lua
deleted file mode 100644
index 341e2ffe..00000000
--- a/examples/text_sprite_fonts.lua
+++ /dev/null
@@ -1,72 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - SpriteFont loading and usage
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage")
-
-local msg1 = "THIS IS A custom SPRITE FONT..."
-local msg2 = "...and this is ANOTHER CUSTOM font..."
-local msg3 = "...and a THIRD one! GREAT! :D"
-
--- NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
-local font1 = LoadSpriteFont("resources/fonts/custom_mecha.png") -- SpriteFont loading
-local font2 = LoadSpriteFont("resources/fonts/custom_alagard.png") -- SpriteFont loading
-local font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png") -- SpriteFont loading
-
-local fontPosition1 = Vector2(0, 0)
-local fontPosition2 = Vector2(0, 0)
-local fontPosition3 = Vector2(0, 0)
-
-fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.size, -3).x/2
-fontPosition1.y = screenHeight/2 - font1.size/2 - 80
-
-fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.size, -2).x/2
-fontPosition2.y = screenHeight/2 - font2.size/2 - 10
-
-fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.size, 2).x/2
-fontPosition3.y = screenHeight/2 - font3.size/2 + 50
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update variables here...
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTextEx(font1, msg1, fontPosition1, font1.size, -3, WHITE)
- DrawTextEx(font2, msg2, fontPosition2, font2.size, -2, WHITE)
- DrawTextEx(font3, msg3, fontPosition3, font3.size, 2, WHITE)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadSpriteFont(font1) -- SpriteFont unloading
-UnloadSpriteFont(font2) -- SpriteFont unloading
-UnloadSpriteFont(font3) -- SpriteFont unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/text_ttf_loading.c b/examples/text_ttf_loading.c
index b614023f..10025c2f 100644
--- a/examples/text_ttf_loading.c
+++ b/examples/text_ttf_loading.c
@@ -20,17 +20,22 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading");
- const char msg1[50] = "TTF SpriteFont";
+ const char msg[50] = "TTF SpriteFont";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// TTF SpriteFont loading with custom generation parameters
SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0);
+
+ // Generate mipmap levels to use trilinear filtering
+ // NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
+ GenTextureMipmaps(&font.texture);
- float fontSize = font.size;
+ float fontSize = font.baseSize;
Vector2 fontPosition = { 40, screenHeight/2 + 50 };
Vector2 textSize;
+ SetTextureFilter(font.texture, FILTER_POINT);
int currentFontFilter = 0; // FILTER_POINT
int count = 0;
@@ -59,12 +64,12 @@ int main()
}
else if (IsKeyPressed(KEY_THREE))
{
- // NOTE: Trilinear filter not supported in font because there are not mipmap levels
+ // NOTE: Trilinear filter won't be noticed on 2D drawing
SetTextureFilter(font.texture, FILTER_TRILINEAR);
- //currentFontFilter = 2;
+ currentFontFilter = 2;
}
- textSize = MeasureTextEx(font, msg1, fontSize, 0);
+ textSize = MeasureTextEx(font, msg, fontSize, 0);
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
@@ -94,7 +99,7 @@ int main()
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY);
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY);
- DrawTextEx(font, msg1, fontPosition, fontSize, 0, BLACK);
+ DrawTextEx(font, msg, fontPosition, fontSize, 0, BLACK);
// TODO: It seems texSize measurement is not accurate due to chars offsets...
//DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED);
@@ -106,6 +111,7 @@ int main()
if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK);
else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK);
+ else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/text_writing_anim.lua b/examples/text_writing_anim.lua
deleted file mode 100644
index f4af9f58..00000000
--- a/examples/text_writing_anim.lua
+++ /dev/null
@@ -1,52 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [text] example - Text Writing Animation
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
-
-local message = "This sample illustrates a text writing\nanimation effect! Check it out! )"
-
-local framesCounter = 0
-
-SetTargetFPS(60) -- Set target frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- framesCounter = framesCounter + 1
-
- if (IsKeyPressed(KEY.ENTER)) then framesCounter = 0 end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText(string.sub(message, 0, framesCounter//10), 210, 160, 20, MAROON)
-
- DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_formats_loading.lua b/examples/textures_formats_loading.lua
deleted file mode 100644
index 1ce10492..00000000
--- a/examples/textures_formats_loading.lua
+++ /dev/null
@@ -1,217 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - texture formats loading (compressed and uncompressed)
---
--- NOTE: This example requires raylib OpenGL 3.3+ or ES2 versions for compressed textures,
--- OpenGL 1.1 does not support compressed textures, only uncompressed ones.
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-NUM_TEXTURES = 24
-
-PNG_R8G8B8A8 = 1
-PVR_GRAYSCALE = 2
-PVR_GRAY_ALPHA = 3
-PVR_R5G6B5 = 4
-PVR_R5G5B5A1 = 5
-PVR_R4G4B4A4 = 6
-DDS_R5G6B5 = 7
-DDS_R5G5B5A1 = 8
-DDS_R4G4B4A4 = 9
-DDS_R8G8B8A8 = 10
-DDS_DXT1_RGB = 11
-DDS_DXT1_RGBA = 12
-DDS_DXT3_RGBA = 13
-DDS_DXT5_RGBA = 14
-PKM_ETC1_RGB = 15
-PKM_ETC2_RGB = 16
-PKM_ETC2_EAC_RGBA = 17
-KTX_ETC1_RGB = 18
-KTX_ETC2_RGB = 19
-KTX_ETC2_EAC_RGBA = 20
-ASTC_4x4_LDR = 21
-ASTC_8x8_LDR = 22
-PVR_PVRT_RGB = 23
-PVR_PVRT_RGBA = 24
-
-local formatText = {
- "PNG_R8G8B8A8",
- "PVR_GRAYSCALE",
- "PVR_GRAY_ALPHA",
- "PVR_R5G6B5",
- "PVR_R5G5B5A1",
- "PVR_R4G4B4A4",
- "DDS_R5G6B5",
- "DDS_R5G5B5A1",
- "DDS_R4G4B4A4",
- "DDS_R8G8B8A8",
- "DDS_DXT1_RGB",
- "DDS_DXT1_RGBA",
- "DDS_DXT3_RGBA",
- "DDS_DXT5_RGBA",
- "PKM_ETC1_RGB",
- "PKM_ETC2_RGB",
- "PKM_ETC2_EAC_RGBA",
- "KTX_ETC1_RGB",
- "KTX_ETC2_RGB",
- "KTX_ETC2_EAC_RGBA",
- "ASTC_4x4_LDR",
- "ASTC_8x8_LDR",
- "PVR_PVRT_RGB",
- "PVR_PVRT_RGBA"
-}
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture formats loading")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
-local sonic = {}
-
-sonic[PNG_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic.png")
-
--- Load UNCOMPRESSED PVR texture data
-sonic[PVR_GRAYSCALE] = LoadTexture("resources/texture_formats/sonic_GRAYSCALE.pvr")
-sonic[PVR_GRAY_ALPHA] = LoadTexture("resources/texture_formats/sonic_L8A8.pvr")
-sonic[PVR_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.pvr")
-sonic[PVR_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_R5G5B5A1.pvr")
-sonic[PVR_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_R4G4B4A4.pvr")
-
--- Load UNCOMPRESSED DDS texture data
-sonic[DDS_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.dds")
-sonic[DDS_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_A1R5G5B5.dds")
-sonic[DDS_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_A4R4G4B4.dds")
-sonic[DDS_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic_A8R8G8B8.dds")
-
--- Load COMPRESSED DXT DDS texture data (if supported)
-sonic[DDS_DXT1_RGB] = LoadTexture("resources/texture_formats/sonic_DXT1_RGB.dds")
-sonic[DDS_DXT1_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT1_RGBA.dds")
-sonic[DDS_DXT3_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT3_RGBA.dds")
-sonic[DDS_DXT5_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT5_RGBA.dds")
-
--- Load COMPRESSED ETC texture data (if supported)
-sonic[PKM_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.pkm")
-sonic[PKM_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.pkm")
-sonic[PKM_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm")
-
-sonic[KTX_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.ktx")
-sonic[KTX_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.ktx")
-sonic[KTX_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx")
-
--- Load COMPRESSED ASTC texture data (if supported)
-sonic[ASTC_4x4_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_4x4_ldr.astc")
-sonic[ASTC_8x8_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_8x8_ldr.astc")
-
--- Load COMPRESSED PVR texture data (if supported)
-sonic[PVR_PVRT_RGB] = LoadTexture("resources/texture_formats/sonic_PVRT_RGB.pvr")
-sonic[PVR_PVRT_RGBA] = LoadTexture("resources/texture_formats/sonic_PVRT_RGBA.pvr")
-
-local selectedFormat = PNG_R8G8B8A8
-
-local selectRecs = {}
-
-for i = 1, NUM_TEXTURES do
- if ((i - 1) < NUM_TEXTURES//2) then selectRecs[i] = Rectangle(40, 30 + 32*(i - 1), 150, 30)
- else selectRecs[i] = Rectangle(40 + 152, 30 + 32*((i - 1) - NUM_TEXTURES//2), 150, 30) end
-end
-
--- Texture sizes in KB
-local textureSizes = {
- 512*512*32/8/1024, --PNG_R8G8B8A8 (32 bpp)
- 512*512*8/8/1024, --PVR_GRAYSCALE (8 bpp)
- 512*512*16/8/1024, --PVR_GRAY_ALPHA (16 bpp)
- 512*512*16/8/1024, --PVR_R5G6B5 (16 bpp)
- 512*512*16/8/1024, --PVR_R5G5B5A1 (16 bpp)
- 512*512*16/8/1024, --PVR_R4G4B4A4 (16 bpp)
- 512*512*16/8/1024, --DDS_R5G6B5 (16 bpp)
- 512*512*16/8/1024, --DDS_R5G5B5A1 (16 bpp)
- 512*512*16/8/1024, --DDS_R4G4B4A4 (16 bpp)
- 512*512*32/8/1024, --DDS_R8G8B8A8 (32 bpp)
- 512*512*4/8/1024, --DDS_DXT1_RGB (4 bpp) -Compressed-
- 512*512*4/8/1024, --DDS_DXT1_RGBA (4 bpp) -Compressed-
- 512*512*8/8/1024, --DDS_DXT3_RGBA (8 bpp) -Compressed-
- 512*512*8/8/1024, --DDS_DXT5_RGBA (8 bpp) -Compressed-
- 512*512*4/8/1024, --PKM_ETC1_RGB (4 bpp) -Compressed-
- 512*512*4/8/1024, --PKM_ETC2_RGB (4 bpp) -Compressed-
- 512*512*8/8/1024, --PKM_ETC2_EAC_RGBA (8 bpp) -Compressed-
- 512*512*4/8/1024, --KTX_ETC1_RGB (4 bpp) -Compressed-
- 512*512*4/8/1024, --KTX_ETC2_RGB (4 bpp) -Compressed-
- 512*512*8/8/1024, --KTX_ETC2_EAC_RGBA (8 bpp) -Compressed-
- 512*512*8/8/1024, --ASTC_4x4_LDR (8 bpp) -Compressed-
- 512*512*2/8/1024, --ASTC_8x8_LDR (2 bpp) -Compressed-
- 512*512*4/8/1024, --PVR_PVRT_RGB (4 bpp) -Compressed-
- 512*512*4/8/1024, --PVR_PVRT_RGBA (4 bpp) -Compressed-
-}
-
-SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyPressed(KEY.DOWN)) then
- selectedFormat = selectedFormat + 1
- if (selectedFormat > NUM_TEXTURES) then selectedFormat = 1 end
- elseif (IsKeyPressed(KEY.UP)) then
- selectedFormat = selectedFormat - 1
- if (selectedFormat < 1) then selectedFormat = NUM_TEXTURES end
- elseif (IsKeyPressed(KEY.RIGHT)) then
- if (selectedFormat < NUM_TEXTURES//2) then selectedFormat = selectedFormat + NUM_TEXTURES//2 end
- elseif (IsKeyPressed(KEY.LEFT)) then
- if (selectedFormat > NUM_TEXTURES//2) then selectedFormat = selectedFormat - NUM_TEXTURES//2 end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
-
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- -- Draw rectangles
- for i = 1, NUM_TEXTURES do
- if (i == selectedFormat) then
- DrawRectangleRec(selectRecs[i], SKYBLUE)
- DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE)
- DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)//2, selectRecs[i].y + 11, 10, DARKBLUE)
- else
- DrawRectangleRec(selectRecs[i], LIGHTGRAY)
- DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY)
- DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)//2, selectRecs[i].y + 11, 10, DARKGRAY)
- end
- end
-
- -- Draw selected texture
- if (sonic[selectedFormat].id ~= 0) then DrawTexture(sonic[selectedFormat], 350, -10, WHITE)
- else
- DrawRectangleLines(488, 165, 200, 110, DARKGRAY)
- DrawText("FORMAT", 550, 180, 20, MAROON)
- DrawText("NOT SUPPORTED", 500, 210, 20, MAROON)
- DrawText("ON YOUR GPU", 520, 240, 20, MAROON)
- end
-
- DrawText("Select texture format (use cursor keys):", 40, 10, 10, DARKGRAY)
- DrawText("Required GPU memory size (VRAM):", 40, 427, 10, DARKGRAY)
- DrawText(string.format("%4.0f KB", textureSizes[selectedFormat]), 240, 420, 20, DARKBLUE)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-for i = 1, NUM_TEXTURES do UnloadTexture(sonic[i]) end
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_image_drawing.lua b/examples/textures_image_drawing.lua
deleted file mode 100644
index 0261b243..00000000
--- a/examples/textures_image_drawing.lua
+++ /dev/null
@@ -1,70 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Image loading and drawing on it
---
--- NOTE: Images are loaded in CPU memory (RAM) textures are loaded in GPU memory (VRAM)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
-local cat = LoadImage("resources/cat.png") -- Load image in CPU memory (RAM)
-cat = ImageCrop(cat, Rectangle(100, 10, 280, 380)) -- Crop an image piece
-cat = ImageFlipHorizontal(cat) -- Flip cropped image horizontally
-cat = ImageResize(cat, 150, 200) -- Resize flipped-cropped image
-
-local parrots = LoadImage("resources/parrots.png") -- Load image in CPU memory (RAM)
-
--- Draw one image over the other with a scaling of 1.5f
-parrots = ImageDraw(parrots, cat, Rectangle(0, 0, cat.width, cat.height), Rectangle(30, 40, cat.width*1.5, cat.height*1.5))
-parrots = ImageCrop(parrots, Rectangle(0, 50, parrots.width, parrots.height - 100)) -- Crop resulting image
-
-UnloadImage(cat) -- Unload image from RAM
-
-local texture = LoadTextureFromImage(parrots) -- Image converted to texture, uploaded to GPU memory (VRAM)
-UnloadImage(parrots) -- Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, WHITE)
- DrawRectangleLines(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, texture.width, texture.height, DARKGRAY)
-
- DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY)
- DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_image_loading.lua b/examples/textures_image_loading.lua
deleted file mode 100644
index 05dbce7f..00000000
--- a/examples/textures_image_loading.lua
+++ /dev/null
@@ -1,55 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Image loading and texture creation
---
--- NOTE: Images are loaded in CPU memory (RAM) textures are loaded in GPU memory (VRAM)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
-local image = LoadImage("resources/raylib_logo.png") -- Loaded in CPU memory (RAM)
-local texture = LoadTextureFromImage(image) -- Image converted to texture, GPU memory (VRAM)
-
-UnloadImage(image) -- Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE)
-
- DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_image_processing.lua b/examples/textures_image_processing.lua
deleted file mode 100644
index b7304b37..00000000
--- a/examples/textures_image_processing.lua
+++ /dev/null
@@ -1,134 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Image processing
---
--- NOTE: Images are loaded in CPU memory (RAM) textures are loaded in GPU memory (VRAM)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
---#include <stdlib.h> -- Required for: free()
-
-NUM_PROCESSES = 8
-
--- enum ImageProcess
-local COLOR_NONE = 1
-local COLOR_GRAYSCALE = 2
-local COLOR_TINT = 3
-local COLOR_INVERT = 4
-local COLOR_CONTRAST = 5
-local COLOR_BRIGHTNESS = 6
-local FLIP_VERTICAL = 7
-local FLIP_HORIZONTAL = 8
-
-local processText = {
- "NO PROCESSING",
- "COLOR GRAYSCALE",
- "COLOR TINT",
- "COLOR INVERT",
- "COLOR CONTRAST",
- "COLOR BRIGHTNESS",
- "FLIP VERTICAL",
- "FLIP HORIZONTAL"
-}
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
-local image = LoadImage("resources/parrots.png") -- Loaded in CPU memory (RAM)
-image = ImageFormat(image, TextureFormat.UNCOMPRESSED_R8G8B8A8) -- Format image to RGBA 32bit (required for texture update)
-local texture = LoadTextureFromImage(image) -- Image converted to texture, GPU memory (VRAM)
-
-local currentProcess = COLOR_NONE
-local textureReload = false
-
-local selectRecs = {}
-
-for i = 1, NUM_PROCESSES do selectRecs[i] = Rectangle(40, 50 + 32*i, 150, 30) end
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyPressed(KEY.DOWN)) then
- currentProcess = currentProcess + 1
- if (currentProcess > NUM_PROCESSES) then currentProcess = 1 end
- textureReload = true
- elseif (IsKeyPressed(KEY.UP)) then
- currentProcess = currentProcess - 1
- if (currentProcess < 1) then currentProcess = NUM_PROCESSES end
- textureReload = true
- end
-
- if (textureReload) then
- UnloadImage(image) -- Unload current image data
- image = LoadImage("resources/parrots.png") -- Re-load image data
-
- -- NOTE: Image processing is a costly CPU process to be done every frame,
- -- If image processing is required in a frame-basis, it should be done
- -- with a texture and by shaders
- if (currentProcess == COLOR_GRAYSCALE) then image = ImageColorGrayscale(image)
- elseif (currentProcess == COLOR_TINT) then image = ImageColorTint(image, GREEN)
- elseif (currentProcess == COLOR_INVERT) then image = ImageColorInvert(image)
- elseif (currentProcess == COLOR_CONTRAST) then image = ImageColorContrast(image, -40)
- elseif (currentProcess == COLOR_BRIGHTNESS) then image = ImageColorBrightness(image, -80)
- elseif (currentProcess == FLIP_VERTICAL) then image = ImageFlipVertical(image)
- elseif (currentProcess == FLIP_HORIZONTAL) then image = ImageFlipHorizontal(image)
- end
-
- local pixels = {}
- pixels = GetImageData(image) -- Get pixel data from image (RGBA 32bit)
- texture = UpdateTexture(texture, pixels) -- Update texture with new image data
-
- textureReload = false
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY)
-
- -- Draw rectangles
- for i = 1, NUM_PROCESSES do
- if (i == currentProcess) then
- DrawRectangleRec(selectRecs[i], SKYBLUE)
- DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE)
- DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)//2, selectRecs[i].y + 11, 10, DARKBLUE)
- else
- DrawRectangleRec(selectRecs[i], LIGHTGRAY)
- DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY)
- DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)//2, selectRecs[i].y + 11, 10, DARKGRAY)
- end
- end
-
- DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE)
- DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Unload texture from VRAM
-UnloadImage(image) -- Unload image from RAM
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_logo_raylib.lua b/examples/textures_logo_raylib.lua
deleted file mode 100644
index 3abcd802..00000000
--- a/examples/textures_logo_raylib.lua
+++ /dev/null
@@ -1,49 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Texture loading and drawing
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-local texture = LoadTexture("resources/raylib_logo.png") -- Texture loading
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE)
-
- DrawText("this IS a texture!", 360, 370, 10, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_particles_trail_blending.lua b/examples/textures_particles_trail_blending.lua
deleted file mode 100644
index d2c2518e..00000000
--- a/examples/textures_particles_trail_blending.lua
+++ /dev/null
@@ -1,113 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib example - particles trail blending
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
-MAX_PARTICLES = 200
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending")
-
--- Particles pool, reuse them!
-local mouseTail = {}
-
--- Initialize particles
-for i = 1, MAX_PARTICLES do
- mouseTail[i] = {}
- mouseTail[i].position = Vector2(0, 0)
- mouseTail[i].color = Color(GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255)
- mouseTail[i].alpha = 1.0
- mouseTail[i].size = GetRandomValue(1, 30)/20.0
- mouseTail[i].rotation = GetRandomValue(0, 360)
- mouseTail[i].active = false
-end
-
-local gravity = 3.0
-
-local smoke = LoadTexture("resources/smoke.png")
-
-local blending = BlendMode.ALPHA
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
-
- -- Activate one particle every frame and Update active particles
- -- NOTE: Particles initial position should be mouse position when activated
- -- NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0)
- -- NOTE: When a particle disappears, active = false and it can be reused.
- for i = 1, MAX_PARTICLES do
- if (not mouseTail[i].active) then
- mouseTail[i].active = true
- mouseTail[i].alpha = 1.0
- mouseTail[i].position = GetMousePosition()
- break
- end
- end
-
- for i = 1, MAX_PARTICLES do
- if (mouseTail[i].active) then
- mouseTail[i].position.y = mouseTail[i].position.y + gravity
- mouseTail[i].alpha = mouseTail[i].alpha - 0.01
-
- if (mouseTail[i].alpha <= 0.0) then mouseTail[i].active = false end
-
- mouseTail[i].rotation = mouseTail[i].rotation + 5.0
- end
- end
-
- if (IsKeyPressed(KEY.SPACE)) then
- if (blending == BlendMode.ALPHA) then blending = BlendMode.ADDITIVE
- else blending = BlendMode.ALPHA end
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(DARKGRAY)
-
- BeginBlendMode(blending)
-
- -- Draw active particles
- for i = 1, MAX_PARTICLES do
- if (mouseTail[i].active) then
- DrawTexturePro(smoke, Rectangle(0, 0, smoke.width, smoke.height),
- Rectangle(mouseTail[i].position.x, mouseTail[i].position.y,
- smoke.width*mouseTail[i].size//1, smoke.height*mouseTail[i].size//1),
- Vector2(smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2),
- mouseTail[i].rotation, Fade(mouseTail[i].color, mouseTail[i].alpha)) end
- end
-
- EndBlendMode()
-
- DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK)
-
- if (blending == BlendMode.ALPHA) then DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK)
- else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE) end
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(smoke)
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_raw_data.lua b/examples/textures_raw_data.lua
deleted file mode 100644
index 0bad1771..00000000
--- a/examples/textures_raw_data.lua
+++ /dev/null
@@ -1,83 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Load textures from raw data
---
--- NOTE: Images are loaded in CPU memory (RAM) textures are loaded in GPU memory (VRAM)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
---#include <stdlib.h> -- Required for malloc() and free()
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
--- Load RAW image data (512x512, 32bit RGBA, no file header)
-local sonicRaw = LoadImageRaw("resources/texture_formats/sonic_R8G8B8A8.raw", 512, 512, TextureFormat.UNCOMPRESSED_R8G8B8A8, 0)
-local sonic = LoadTextureFromImage(sonicRaw) -- Upload CPU (RAM) image to GPU (VRAM)
-UnloadImage(sonicRaw) -- Unload CPU (RAM) image data
-
--- Generate a checked texture by code (1024x1024 pixels)
-local width = 1024
-local height = 1024
-
--- Dynamic memory allocation to store pixels data (Color type)
-local pixels = {}
-
-for y = 1, height do
- for x = 1, width do
- if ((((x - 1)/32+(y - 1)//32)//1)%2 == 0) then pixels[(y - 1)*height + x] = DARKBLUE
- else pixels[(y - 1)*height + x] = SKYBLUE end
- end
-end
-
--- Load pixels data into an image structure and create texture
-local checkedIm = LoadImageEx(pixels, width, height)
-local checked = LoadTextureFromImage(checkedIm)
-UnloadImage(checkedIm) -- Unload CPU (RAM) image data
-
--- Dynamic memory must be freed after using it
---free(pixels) -- Unload CPU (RAM) pixels data
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.3))
- DrawTexture(sonic, 330, -20, WHITE)
-
- DrawText("CHECKED TEXTURE ", 84, 100, 30, DARKBLUE)
- DrawText("GENERATED by CODE", 72, 164, 30, DARKBLUE)
- DrawText("and RAW IMAGE LOADING", 46, 226, 30, DARKBLUE)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(sonic) -- Texture unloading
-UnloadTexture(checked) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_rectangle.lua b/examples/textures_rectangle.lua
deleted file mode 100644
index 5f481679..00000000
--- a/examples/textures_rectangle.lua
+++ /dev/null
@@ -1,69 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Texture loading and drawing a part defined by a rectangle
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-local guybrush = LoadTexture("resources/guybrush.png") -- Texture loading
-
-local position = Vector2(350.0, 240.0)
-local frameRec = Rectangle(0, 0, guybrush.width/7, guybrush.height)
-local currentFrame = 0
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- if (IsKeyPressed(KEY.RIGHT)) then
- currentFrame = currentFrame + 1
-
- if (currentFrame > 6) then currentFrame = 0 end
-
- frameRec.x = currentFrame*guybrush.width/7
- end
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(guybrush, 35, 40, WHITE)
- DrawRectangleLines(35, 40, guybrush.width, guybrush.height, LIME)
-
- DrawTextureRec(guybrush, frameRec, position, WHITE) -- Draw part of the texture
-
- DrawRectangleLines(35 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED)
-
- DrawText("PRESS RIGHT KEY to", 540, 310, 10, GRAY)
- DrawText("CHANGE DRAWING RECTANGLE", 520, 330, 10, GRAY)
-
- DrawText("Guybrush Ulysses Threepwood,", 100, 300, 10, GRAY)
- DrawText("main character of the Monkey Island series", 80, 320, 10, GRAY)
- DrawText("of computer adventure games by LucasArts.", 80, 340, 10, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(guybrush) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_srcrec_dstrec.lua b/examples/textures_srcrec_dstrec.lua
deleted file mode 100644
index f94deb3e..00000000
--- a/examples/textures_srcrec_dstrec.lua
+++ /dev/null
@@ -1,71 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Texture source and destination rectangles
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-local guybrush = LoadTexture("resources/guybrush.png") -- Texture loading
-
-local frameWidth = guybrush.width/7
-local frameHeight = guybrush.height
-
--- NOTE: Source rectangle (part of the texture to use for drawing)
-local sourceRec = Rectangle(0, 0, frameWidth, frameHeight)
-
--- NOTE: Destination rectangle (screen rectangle where drawing part of texture)
-local destRec = Rectangle(screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2)
-
--- NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size
-local origin = Vector2(frameWidth, frameHeight)
-
-local rotation = 0
-
-SetTargetFPS(60)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- rotation = rotation + 1
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- -- NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
- -- sourceRec defines the part of the texture we use for drawing
- -- destRec defines the rectangle where our texture part will fit (scaling it to fit)
- -- origin defines the point of the texture used as reference for rotation and scaling
- -- rotation defines the texture rotation (using origin as rotation point)
- DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, WHITE)
-
- DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY)
- DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(guybrush) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file
diff --git a/examples/textures_to_image.lua b/examples/textures_to_image.lua
deleted file mode 100644
index b7a2d4ed..00000000
--- a/examples/textures_to_image.lua
+++ /dev/null
@@ -1,60 +0,0 @@
--------------------------------------------------------------------------------------------
---
--- raylib [textures] example - Retrieve image data from texture: GetTextureData()
---
--- NOTE: Images are loaded in CPU memory (RAM) textures are loaded in GPU memory (VRAM)
---
--- This example has been created using raylib 1.6 (www.raylib.com)
--- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
---
--- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
---
--------------------------------------------------------------------------------------------
-
--- Initialization
--------------------------------------------------------------------------------------------
-local screenWidth = 800
-local screenHeight = 450
-
-InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture to image")
-
--- NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
-
-local image = LoadImage("resources/raylib_logo.png") -- Load image data into CPU memory (RAM)
-local texture = LoadTextureFromImage(image) -- Image converted to texture, GPU memory (RAM -> VRAM)
-UnloadImage(image) -- Unload image data from CPU memory (RAM)
-
-image = GetTextureData(texture) -- Retrieve image data from GPU memory (VRAM -> RAM)
-UnloadTexture(texture) -- Unload texture from GPU memory (VRAM)
-
-texture = LoadTextureFromImage(image) -- Recreate texture from retrieved image data (RAM -> VRAM)
-UnloadImage(image) -- Unload retrieved image data from CPU memory (RAM)
--------------------------------------------------------------------------------------------
-
--- Main game loop
-while not WindowShouldClose() do -- Detect window close button or ESC key
- -- Update
- ---------------------------------------------------------------------------------------
- -- TODO: Update your variables here
- ---------------------------------------------------------------------------------------
-
- -- Draw
- ---------------------------------------------------------------------------------------
- BeginDrawing()
-
- ClearBackground(RAYWHITE)
-
- DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE)
-
- DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY)
-
- EndDrawing()
- ---------------------------------------------------------------------------------------
-end
-
--- De-Initialization
--------------------------------------------------------------------------------------------
-UnloadTexture(texture) -- Texture unloading
-
-CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------- \ No newline at end of file