aboutsummaryrefslogtreecommitdiff
path: root/examples/shaders
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-05-20 16:36:42 +0200
committerRay <raysan5@gmail.com>2019-05-20 16:36:42 +0200
commitb525039e0ab8bcaa2fd6bde34c72a6405f88ae49 (patch)
tree08f1c79bfe693643564ed78202c9474b7eb83a79 /examples/shaders
parenta43a7980a30a52462956b23f2473e8ef8f38d1fb (diff)
downloadraylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.tar.gz
raylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.zip
Review ALL examples
Diffstat (limited to 'examples/shaders')
-rw-r--r--examples/shaders/shaders_custom_uniform.c38
-rw-r--r--examples/shaders/shaders_eratosthenes.c8
-rw-r--r--examples/shaders/shaders_julia_set.c49
-rw-r--r--examples/shaders/shaders_model_shader.c19
-rw-r--r--examples/shaders/shaders_palette_switch.c10
-rw-r--r--examples/shaders/shaders_postprocessing.c44
-rw-r--r--examples/shaders/shaders_raymarching.c12
-rw-r--r--examples/shaders/shaders_shapes_textures.c36
-rw-r--r--examples/shaders/shaders_texture_drawing.c19
-rw-r--r--examples/shaders/shaders_texture_waves.c25
10 files changed, 127 insertions, 133 deletions
diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c
index 74b9e771..1c82bba2 100644
--- a/examples/shaders/shaders_custom_uniform.c
+++ b/examples/shaders/shaders_custom_uniform.c
@@ -24,13 +24,13 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
-
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
@@ -48,20 +48,20 @@ int main()
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
-
+
// Load postprocessing shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/swirl.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
int swirlCenterLoc = GetShaderLocation(shader, "center");
-
+
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
-
+
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
-
+
// Setup orbital camera
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
@@ -80,7 +80,7 @@ int main()
// Send new value to the shader to be used on drawing
SetShaderValue(shader, swirlCenterLoc, swirlCenter, UNIFORM_VEC2);
-
+
UpdateCamera(&camera); // Update camera
//----------------------------------------------------------------------------------
@@ -89,9 +89,9 @@ int main()
BeginDrawing();
ClearBackground(RAYWHITE);
-
+
BeginTextureMode(target); // Enable drawing to texture
-
+
ClearBackground(RAYWHITE); // Clear texture background
BeginMode3D(camera); // Begin 3d mode drawing
@@ -101,21 +101,21 @@ int main()
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
-
+
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();
-
+
// Draw some 2d text over drawn texture
DrawText("(c) Barracks 3D model by Alberto Cano", screenWidth - 220, screenHeight - 20, 10, GRAY);
-
+
DrawFPS(10, 10);
EndDrawing();
diff --git a/examples/shaders/shaders_eratosthenes.c b/examples/shaders/shaders_eratosthenes.c
index bfe516b5..068fc26c 100644
--- a/examples/shaders/shaders_eratosthenes.c
+++ b/examples/shaders/shaders_eratosthenes.c
@@ -31,7 +31,7 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
@@ -46,11 +46,11 @@ int main()
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION));
- SetTargetFPS(60);
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@@ -64,7 +64,7 @@ int main()
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
- ClearBackground(BLACK); // Clear the render texture
+ ClearBackground(BLACK); // Clear the render texture
// Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font white character texture coordinates,
diff --git a/examples/shaders/shaders_julia_set.c b/examples/shaders/shaders_julia_set.c
index ecaa5b6e..e64b622b 100644
--- a/examples/shaders/shaders_julia_set.c
+++ b/examples/shaders/shaders_julia_set.c
@@ -26,7 +26,7 @@
// A few good julia sets
const float POINTS_OF_INTEREST[6][2] =
-{
+{
{ -0.348827, 0.607167 },
{ -0.786268, 0.169728 },
{ -0.8, 0.156 },
@@ -35,7 +35,7 @@ const float POINTS_OF_INTEREST[6][2] =
{ -0.70176, -0.3842 },
};
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
@@ -47,16 +47,16 @@ int main()
// Load julia set shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/julia_set.fs", GLSL_VERSION));
-
+
// c constant to use in z^2 + c
float c[2] = { POINTS_OF_INTEREST[0][0], POINTS_OF_INTEREST[0][1] };
-
+
// Offset and zoom to draw the julia set at. (centered on screen and default size)
float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 };
float zoom = 1.0f;
-
+
Vector2 offsetSpeed = { 0.0f, 0.0f };
-
+
// Get variable (uniform) locations on the shader to connect with the program
// NOTE: If uniform variable could not be found in the shader, function returns -1
int cLoc = GetShaderLocation(shader, "c");
@@ -64,35 +64,34 @@ int main()
int offsetLoc = GetShaderLocation(shader, "offset");
// Tell the shader what the screen dimensions, zoom, offset and c are
- float screenDims[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
+ float screenDims[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2);
-
+
SetShaderValue(shader, cLoc, c, UNIFORM_VEC2);
SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT);
SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2);
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
-
- int incrementSpeed = 0; // Multiplier of speed to change c value
- bool showControls = true; // Show controls
- bool pause = false; // Pause animation
- SetTargetFPS(60); // Set the window to run at 60 frames-per-second
+ int incrementSpeed = 0; // Multiplier of speed to change c value
+ bool showControls = true; // Show controls
+ bool pause = false; // Pause animation
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
-
// Press [1 - 6] to reset c to a point of interest
- if (IsKeyPressed(KEY_ONE) ||
- IsKeyPressed(KEY_TWO) ||
- IsKeyPressed(KEY_THREE) ||
- IsKeyPressed(KEY_FOUR) ||
- IsKeyPressed(KEY_FIVE) ||
+ if (IsKeyPressed(KEY_ONE) ||
+ IsKeyPressed(KEY_TWO) ||
+ IsKeyPressed(KEY_THREE) ||
+ IsKeyPressed(KEY_FOUR) ||
+ IsKeyPressed(KEY_FIVE) ||
IsKeyPressed(KEY_SIX))
{
if (IsKeyPressed(KEY_ONE)) c[0] = POINTS_OF_INTEREST[0][0], c[1] = POINTS_OF_INTEREST[0][1];
@@ -107,7 +106,7 @@ int main()
if (IsKeyPressed(KEY_SPACE)) pause = !pause; // Pause animation (c change)
if (IsKeyPressed(KEY_F1)) showControls = !showControls; // Toggle whether or not to show controls
-
+
if (!pause)
{
if (IsKeyPressed(KEY_RIGHT)) incrementSpeed++;
@@ -121,10 +120,10 @@ int main()
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) zoom -= zoom*0.003f;
Vector2 mousePos = GetMousePosition();
-
+
offsetSpeed.x = mousePos.x -(float)screenWidth/2;
offsetSpeed.y = mousePos.y -(float)screenHeight/2;
-
+
// Slowly move camera to targetOffset
offset[0] += GetFrameTime()*offsetSpeed.x*0.8f;
offset[1] += GetFrameTime()*offsetSpeed.y*0.8f;
@@ -148,7 +147,7 @@ int main()
BeginDrawing();
ClearBackground(BLACK); // Clear the screen of the previous frame.
-
+
// Using a render texture to draw Julia set
BeginTextureMode(target); // Enable drawing to texture
ClearBackground(BLACK); // Clear the render texture
@@ -165,7 +164,7 @@ int main()
BeginShaderMode(shader);
DrawTexture(target.texture, 0, 0, WHITE);
EndShaderMode();
-
+
if (showControls)
{
DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, RAYWHITE);
diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c
index 2717c192..8224a337 100644
--- a/examples/shaders/shaders_model_shader.c
+++ b/examples/shaders/shaders_model_shader.c
@@ -24,13 +24,13 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
-
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
@@ -45,16 +45,16 @@ int main()
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
-
+
// Load shader for model
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
model.materials[0].shader = shader; // Set shader effect to 3d model
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
-
+
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
-
+
SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@@ -81,11 +81,8 @@ int main()
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
-
+
DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY);
-
- DrawText(FormatText("Camera position: (%.2f, %.2f, %.2f)", camera.position.x, camera.position.y, camera.position.z), 600, 20, 10, BLACK);
- DrawText(FormatText("Camera target: (%.2f, %.2f, %.2f)", camera.target.x, camera.target.y, camera.target.z), 600, 40, 10, GRAY);
DrawFPS(10, 10);
diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c
index 4d651412..6bc27827 100644
--- a/examples/shaders/shaders_palette_switch.c
+++ b/examples/shaders/shaders_palette_switch.c
@@ -69,12 +69,12 @@ static const char *paletteText[] = {
"RKBV (2-strip film)"
};
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - color palette switch");
@@ -117,7 +117,7 @@ int main()
BeginShaderMode(shader);
- for (int i = 0; i < COLORS_PER_PALETTE; i++)
+ for (int i = 0; i < COLORS_PER_PALETTE; i++)
{
// Draw horizontal screen-wide rectangles with increasing "palette index"
// The used palette index is encoded in the RGB components of the pixel
@@ -129,7 +129,7 @@ int main()
DrawText("< >", 10, 10, 30, DARKBLUE);
DrawText("CURRENT PALETTE:", 60, 15, 20, RAYWHITE);
DrawText(paletteText[currentPalette], 300, 15, 20, RED);
-
+
DrawFPS(700, 15);
EndDrawing();
diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c
index 7c146419..018b8d11 100644
--- a/examples/shaders/shaders_postprocessing.c
+++ b/examples/shaders/shaders_postprocessing.c
@@ -58,31 +58,31 @@ static const char *postproShaderText[] = {
//"FXAA"
};
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
-
+ const int screenWidth = 800;
+ const int 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
Camera camera = {{ 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
-
+
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
-
+
// Load all postpro shaders
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
// NOTE 2: We load the correct shader depending on GLSL version
Shader shaders[MAX_POSTPRO_SHADERS];
-
+
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
shaders[FX_POSTERIZATION] = LoadShader(0, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION));
@@ -96,12 +96,12 @@ int main()
shaders[FX_SOBEL] = LoadShader(0, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION));
shaders[FX_BLOOM] = LoadShader(0, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION));
shaders[FX_BLUR] = LoadShader(0, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION));
-
+
int currentShader = FX_GRAYSCALE;
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
-
+
// Setup orbital camera
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
@@ -114,10 +114,10 @@ int main()
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update camera
-
+
if (IsKeyPressed(KEY_RIGHT)) currentShader++;
else if (IsKeyPressed(KEY_LEFT)) currentShader--;
-
+
if (currentShader >= MAX_POSTPRO_SHADERS) currentShader = 0;
else if (currentShader < 0) currentShader = MAX_POSTPRO_SHADERS - 1;
//----------------------------------------------------------------------------------
@@ -129,7 +129,7 @@ int main()
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
-
+
ClearBackground(RAYWHITE); // Clear texture background
BeginMode3D(camera); // Begin 3d mode drawing
@@ -139,26 +139,26 @@ int main()
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
-
+
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
-
+
// Render previously generated texture using selected postpro shader
BeginShaderMode(shaders[currentShader]);
-
+
// 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 2d shapes and text over drawn texture
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
-
+
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
-
+
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
DrawText("< >", 540, 10, 30, DARKBLUE);
-
+
DrawFPS(700, 15);
EndDrawing();
@@ -167,10 +167,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
-
+
// Unload all postpro shaders
for (int i = 0; i < MAX_POSTPRO_SHADERS; i++) UnloadShader(shaders[i]);
-
+
UnloadTexture(texture); // Unload texture
UnloadModel(model); // Unload model
UnloadRenderTexture(target); // Unload render texture
diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c
index f68222b5..34091792 100644
--- a/examples/shaders/shaders_raymarching.c
+++ b/examples/shaders/shaders_raymarching.c
@@ -24,13 +24,13 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
-
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes");
Camera camera = { 0 };
@@ -44,7 +44,7 @@ int main()
// Load raymarching shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/raymarching.fs", GLSL_VERSION));
-
+
// Get shader locations for required uniforms
int viewEyeLoc = GetShaderLocation(shader, "viewEye");
int viewCenterLoc = GetShaderLocation(shader, "viewCenter");
@@ -72,7 +72,7 @@ int main()
float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z };
float cameraUp[3] = { camera.up.x, camera.up.y, camera.up.z };
- float deltaTime = GetFrameTime();
+ float deltaTime = GetFrameTime();
runTime += deltaTime;
// Set shader required uniform values
diff --git a/examples/shaders/shaders_shapes_textures.c b/examples/shaders/shaders_shapes_textures.c
index 5ee5d560..cf53bf99 100644
--- a/examples/shaders/shaders_shapes_textures.c
+++ b/examples/shaders/shaders_shapes_textures.c
@@ -24,23 +24,23 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
-
+
Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
// 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 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/grayscale.fs", GLSL_VERSION));
- SetTargetFPS(60);
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -56,19 +56,19 @@ int main()
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);
@@ -77,29 +77,29 @@ int main()
// 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(fudesumi, 500, -30, WHITE); // Using custom shader
-
+
// Activate our default shader for next drawings
EndShaderMode();
-
+
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, GRAY);
-
+
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -108,7 +108,7 @@ int main()
//--------------------------------------------------------------------------------------
UnloadShader(shader); // Unload shader
UnloadTexture(fudesumi); // Unload texture
-
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_texture_drawing.c b/examples/shaders/shaders_texture_drawing.c
index 3a540098..697000bc 100644
--- a/examples/shaders/shaders_texture_drawing.c
+++ b/examples/shaders/shaders_texture_drawing.c
@@ -21,12 +21,12 @@
#define GLSL_VERSION 100
#endif
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
@@ -41,17 +41,18 @@ int main()
int timeLoc = GetShaderLocation(shader, "uTime");
SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT);
- SetTargetFPS(60);
- //--------------------------------------------------------------------------------------
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ // -------------------------------------------------------------------------------------------------------------
- while (!WindowShouldClose())
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
time = GetTime();
SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT);
//----------------------------------------------------------------------------------
-
+
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
@@ -61,13 +62,13 @@ int main()
BeginShaderMode(shader); // Enable our custom shader for next shapes/textures drawings
DrawTexture(texture, 0, 0, WHITE); // Drawing BLANK texture, all magic happens on shader
EndShaderMode(); // Disable our custom shader, return to default shader
-
+
DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
-
+
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadShader(shader);
diff --git a/examples/shaders/shaders_texture_waves.c b/examples/shaders/shaders_texture_waves.c
index e0026d36..07186d37 100644
--- a/examples/shaders/shaders_texture_waves.c
+++ b/examples/shaders/shaders_texture_waves.c
@@ -26,10 +26,7 @@
#define GLSL_VERSION 100
#endif
-// -------------------------------------------------------------------------------------------------------------
-// Main Entry point
-// -------------------------------------------------------------------------------------------------------------
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
@@ -69,13 +66,13 @@ int main()
SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT);
SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT);
- float seconds = 0.0f;
-
- SetTargetFPS(60);
- // -------------------------------------------------------------------------------------------------------------
-
+ float seconds = 0.0f;
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ // -------------------------------------------------------------------------------------------------------------
+
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@@ -86,9 +83,9 @@ int main()
// Draw
//----------------------------------------------------------------------------------
- BeginDrawing();
+ BeginDrawing();
- ClearBackground(RAYWHITE);
+ ClearBackground(RAYWHITE);
BeginShaderMode(shader);
@@ -97,7 +94,7 @@ int main()
EndShaderMode();
- EndDrawing();
+ EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -109,5 +106,5 @@ int main()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
- return 0;
+ return 0;
}