aboutsummaryrefslogtreecommitdiff
path: root/deps/raylib/examples/shaders/shaders_texture_drawing.c
diff options
context:
space:
mode:
authorbonmas14 <bonmas14@gmail.com>2025-09-20 22:28:15 +0300
committerbonmas14 <bonmas14@gmail.com>2025-09-20 22:28:15 +0300
commitcdda4c4182c9ee068567529715e4a5c68a8efb58 (patch)
tree38a63f62a64018a2d35fc33354f8589fd33b7514 /deps/raylib/examples/shaders/shaders_texture_drawing.c
downloadc_wizard-cdda4c4182c9ee068567529715e4a5c68a8efb58.tar.gz
c_wizard-cdda4c4182c9ee068567529715e4a5c68a8efb58.zip
Init commit v1.0
Diffstat (limited to 'deps/raylib/examples/shaders/shaders_texture_drawing.c')
-rw-r--r--deps/raylib/examples/shaders/shaders_texture_drawing.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/deps/raylib/examples/shaders/shaders_texture_drawing.c b/deps/raylib/examples/shaders/shaders_texture_drawing.c
new file mode 100644
index 0000000..ada4429
--- /dev/null
+++ b/deps/raylib/examples/shaders/shaders_texture_drawing.c
@@ -0,0 +1,86 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture drawing
+*
+* NOTE: This example illustrates how to draw into a blank texture using a shader
+*
+* Example originally created with raylib 2.0, last time updated with raylib 3.7
+*
+* Example contributed by Michał Ciesielski and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2019-2024 Michał Ciesielski and Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#if defined(PLATFORM_DESKTOP)
+ #define GLSL_VERSION 330
+#else // PLATFORM_ANDROID, PLATFORM_WEB
+ #define GLSL_VERSION 100
+#endif
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
+
+ Image imBlank = GenImageColor(1024, 1024, BLANK);
+ Texture2D texture = LoadTextureFromImage(imBlank); // Load blank texture to fill on shader
+ UnloadImage(imBlank);
+
+ // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
+ Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/cubes_panning.fs", GLSL_VERSION));
+
+ float time = 0.0f;
+ int timeLoc = GetShaderLocation(shader, "uTime");
+ SetShaderValue(shader, timeLoc, &time, SHADER_UNIFORM_FLOAT);
+
+ 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
+ //----------------------------------------------------------------------------------
+ time = (float)GetTime();
+ SetShaderValue(shader, timeLoc, &time, SHADER_UNIFORM_FLOAT);
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ 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);
+ UnloadTexture(texture);
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}