From 55f8dbc755c2e31d2112e71439fef0d31e8090a6 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 10 Jan 2019 11:25:26 +0100 Subject: WARNING: Redesigned SetShaderValue() --- .../resources/shaders/glsl330/palette-switch.fs | 2 +- examples/shaders/shaders_custom_uniform.c | 2 +- examples/shaders/shaders_palette_switch.c | 24 +++++++++++++--------- examples/shaders/shaders_raymarching.c | 12 +++++------ 4 files changed, 22 insertions(+), 18 deletions(-) (limited to 'examples/shaders') diff --git a/examples/shaders/resources/shaders/glsl330/palette-switch.fs b/examples/shaders/resources/shaders/glsl330/palette-switch.fs index 178c42c5..61b532ed 100644 --- a/examples/shaders/resources/shaders/glsl330/palette-switch.fs +++ b/examples/shaders/resources/shaders/glsl330/palette-switch.fs @@ -16,7 +16,7 @@ out vec4 finalColor; void main() { // Texel color fetching from texture sampler - vec4 texelColor = texture(texture0, fragTexCoord) * fragColor; + vec4 texelColor = texture(texture0, fragTexCoord)*fragColor; // Convert the (normalized) texel color RED component (GB would work, too) // to the palette index by scaling up from [0, 1] to [0, 255]. diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c index de76a376..fbfd82d0 100644 --- a/examples/shaders/shaders_custom_uniform.c +++ b/examples/shaders/shaders_custom_uniform.c @@ -79,7 +79,7 @@ int main() swirlCenter[1] = screenHeight - mousePosition.y; // Send new value to the shader to be used on drawing - SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2); + SetShaderValue(shader, swirlCenterLoc, swirlCenter, UNIFORM_VEC2); UpdateCamera(&camera); // Update camera //---------------------------------------------------------------------------------- diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c index ad09ca73..d0b56190 100644 --- a/examples/shaders/shaders_palette_switch.c +++ b/examples/shaders/shaders_palette_switch.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [shaders] example - Apply a postprocessing shader to a scene +* raylib [shaders] example - Color palette switch * * 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. @@ -9,10 +9,10 @@ * 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 2.x (www.raylib.com) +* This example has been created using raylib 2.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* Copyright (c) 2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -28,7 +28,7 @@ #define COLORS_PER_PALETTE 8 #define VALUES_PER_COLOR 3 -static const int palettes[MAX_PALETTES][COLORS_PER_PALETTE * VALUES_PER_COLOR] = { +static const int palettes[MAX_PALETTES][COLORS_PER_PALETTE*VALUES_PER_COLOR] = { { 0, 0, 0, 255, 0, 0, @@ -74,7 +74,7 @@ int main() int screenWidth = 800; int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - palette-switch shader"); + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - color palette switch"); // 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 @@ -106,9 +106,10 @@ int main() // Send new value to the shader to be used on drawing. // Note that we are sending RGB triplets w/o the alpha channel *only* if the current // palette index has changed (in order to save performances). - if (currentPalette != paletteIndex) { + if (currentPalette != paletteIndex) + { currentPalette = paletteIndex; - SetShaderValueArrayi(shader, paletteLoc, palettes[currentPalette], VALUES_PER_COLOR, COLORS_PER_PALETTE); + SetShaderValueV(shader, paletteLoc, palettes[currentPalette], UNIFORM_IVEC3, COLORS_PER_PALETTE); } //---------------------------------------------------------------------------------- @@ -126,14 +127,17 @@ int main() int leftover = screenHeight % COLORS_PER_PALETTE; int y = 0; - for (int i = 0; i < COLORS_PER_PALETTE; ++i) { + for (int i = 0; i < COLORS_PER_PALETTE; ++i) + { int height = linesPerRectangle; - if (leftover > 0) { + + if (leftover > 0) + { height += 1; leftover -= 1; } - DrawRectangle(0, y, screenWidth, height, CLITERAL{ i, i, i, 255 }); + DrawRectangle(0, y, screenWidth, height, (Color){ i, i, i, 255 }); y += height; } diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c index d1f9d5f8..79868a2a 100644 --- a/examples/shaders/shaders_raymarching.c +++ b/examples/shaders/shaders_raymarching.c @@ -48,7 +48,7 @@ int main() int resolutionLoc = GetShaderLocation(shader, "resolution"); float resolution[2] = { screenWidth, screenHeight }; - SetShaderValue(shader, resolutionLoc, resolution, 2); + SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2); float runTime = 0.0f; @@ -70,11 +70,11 @@ int main() runTime += deltaTime; // Set shader required uniform values - SetShaderValue(shader, viewEyeLoc, cameraPos, 3); - SetShaderValue(shader, viewCenterLoc, cameraTarget, 3); - SetShaderValue(shader, viewUpLoc, cameraUp, 3); - SetShaderValue(shader, deltaTimeLoc, &deltaTime, 1); - SetShaderValue(shader, runTimeLoc, &runTime, 1); + SetShaderValue(shader, viewEyeLoc, cameraPos, UNIFORM_VEC3); + SetShaderValue(shader, viewCenterLoc, cameraTarget, UNIFORM_VEC3); + SetShaderValue(shader, viewUpLoc, cameraUp, UNIFORM_VEC3); + SetShaderValue(shader, deltaTimeLoc, &deltaTime, UNIFORM_FLOAT); + SetShaderValue(shader, runTimeLoc, &runTime, UNIFORM_FLOAT); //---------------------------------------------------------------------------------- // Draw -- cgit v1.2.3