aboutsummaryrefslogtreecommitdiff
path: root/examples/shaders
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-05-17 01:17:40 +0200
committerRay <raysan5@gmail.com>2019-05-17 01:17:40 +0200
commit970f1e8ff15424ca2d96d89bf2871f0246835e9b (patch)
treebc093a8eaee29739e52642c233d0f9102e9db7cf /examples/shaders
parentce87d2ced4dbe60f97d3ed48635231c222482b18 (diff)
downloadraylib-970f1e8ff15424ca2d96d89bf2871f0246835e9b.tar.gz
raylib-970f1e8ff15424ca2d96d89bf2871f0246835e9b.zip
examples review
Diffstat (limited to 'examples/shaders')
-rw-r--r--examples/shaders/shaders_palette_switch.c2
-rw-r--r--examples/shaders/shaders_palette_switch.pngbin0 -> 15463 bytes
-rw-r--r--examples/shaders/shaders_texture_waves.c50
3 files changed, 25 insertions, 27 deletions
diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c
index fa0bafaf..4d651412 100644
--- a/examples/shaders/shaders_palette_switch.c
+++ b/examples/shaders/shaders_palette_switch.c
@@ -81,7 +81,7 @@ int main()
// Load shader to be used on some parts drawing
// NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
// NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
- Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/palette-switch.fs", GLSL_VERSION));
+ Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/palette_switch.fs", GLSL_VERSION));
// 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
diff --git a/examples/shaders/shaders_palette_switch.png b/examples/shaders/shaders_palette_switch.png
new file mode 100644
index 00000000..7eb3eaf3
--- /dev/null
+++ b/examples/shaders/shaders_palette_switch.png
Binary files differ
diff --git a/examples/shaders/shaders_texture_waves.c b/examples/shaders/shaders_texture_waves.c
index bc677c78..e0026d36 100644
--- a/examples/shaders/shaders_texture_waves.c
+++ b/examples/shaders/shaders_texture_waves.c
@@ -38,22 +38,19 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves");
- // Load space texture to apply shaders
- Texture2D space = LoadTexture("resources/space.png");
+ // Load texture texture to apply shaders
+ Texture2D texture = LoadTexture("resources/space.png");
// Load shader and setup location points and values
- Shader wave = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
+ Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
- float screenSizeLoc = GetShaderLocation(wave, "size");
- float secondsLoc = GetShaderLocation(wave, "secondes");
- float freqXLoc = GetShaderLocation(wave, "freqX");
- float freqYLoc = GetShaderLocation(wave, "freqY");
- float ampXLoc = GetShaderLocation(wave, "ampX");
- float ampYLoc = GetShaderLocation(wave, "ampY");
- float speedXLoc = GetShaderLocation(wave, "speedX");
- float speedYLoc = GetShaderLocation(wave, "speedY");
-
- float screenSize[2] = { 800, 450 };
+ int secondsLoc = GetShaderLocation(shader, "secondes");
+ int freqXLoc = GetShaderLocation(shader, "freqX");
+ int freqYLoc = GetShaderLocation(shader, "freqY");
+ int ampXLoc = GetShaderLocation(shader, "ampX");
+ int ampYLoc = GetShaderLocation(shader, "ampY");
+ int speedXLoc = GetShaderLocation(shader, "speedX");
+ int speedYLoc = GetShaderLocation(shader, "speedY");
// Shader uniform values that can be updated at any time
float freqX = 25.0f;
@@ -63,13 +60,14 @@ int main()
float speedX = 8.0f;
float speedY = 8.0f;
- SetShaderValue(wave, screenSizeLoc, &screenSize, UNIFORM_VEC2);
- SetShaderValue(wave, freqXLoc, &freqX, UNIFORM_FLOAT);
- SetShaderValue(wave, freqYLoc, &freqY, UNIFORM_FLOAT);
- SetShaderValue(wave, ampXLoc, &ampX, UNIFORM_FLOAT);
- SetShaderValue(wave, ampYLoc, &ampY, UNIFORM_FLOAT);
- SetShaderValue(wave, speedXLoc, &speedX, UNIFORM_FLOAT);
- SetShaderValue(wave, speedYLoc, &speedY, UNIFORM_FLOAT);
+ float screenSize[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
+ SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, UNIFORM_VEC2);
+ SetShaderValue(shader, freqXLoc, &freqX, UNIFORM_FLOAT);
+ SetShaderValue(shader, freqYLoc, &freqY, UNIFORM_FLOAT);
+ SetShaderValue(shader, ampXLoc, &ampX, UNIFORM_FLOAT);
+ SetShaderValue(shader, ampYLoc, &ampY, UNIFORM_FLOAT);
+ SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT);
+ SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT);
float seconds = 0.0f;
@@ -83,7 +81,7 @@ int main()
//----------------------------------------------------------------------------------
seconds += GetFrameTime();
- SetShaderValue(wave, secondsLoc, &seconds, UNIFORM_FLOAT);
+ SetShaderValue(shader, secondsLoc, &seconds, UNIFORM_FLOAT);
//----------------------------------------------------------------------------------
// Draw
@@ -92,10 +90,10 @@ int main()
ClearBackground(RAYWHITE);
- BeginShaderMode(wave);
+ BeginShaderMode(shader);
- DrawTexture(space, 0, 0, WHITE);
- DrawTexture(space, space.width, 0, WHITE);
+ DrawTexture(texture, 0, 0, WHITE);
+ DrawTexture(texture, texture.width, 0, WHITE);
EndShaderMode();
@@ -105,8 +103,8 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadShader(wave); // Unload shader
- UnloadTexture(space); // Unload texture
+ UnloadShader(shader); // Unload shader
+ UnloadTexture(texture); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------