diff options
| author | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
| commit | 3d7d174c70b2d00fd879ade64c5085d4ff34d4aa (patch) | |
| tree | 3b690948f186f855aa2ee8bab312b3ca28a56200 /examples/web/shaders/shaders_texture_waves.c | |
| parent | 0b56b996bd053ec875c229e9793f7806b666839c (diff) | |
| download | raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.tar.gz raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.zip | |
Review and recompile ALL examples
Diffstat (limited to 'examples/web/shaders/shaders_texture_waves.c')
| -rw-r--r-- | examples/web/shaders/shaders_texture_waves.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/examples/web/shaders/shaders_texture_waves.c b/examples/web/shaders/shaders_texture_waves.c index af8130a..2c53772 100644 --- a/examples/web/shaders/shaders_texture_waves.c +++ b/examples/web/shaders/shaders_texture_waves.c @@ -33,8 +33,8 @@ //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -int screenWidth = 800; -int screenHeight = 450; +const int screenWidth = 800; +const int screenHeight = 450; // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) @@ -65,43 +65,43 @@ float seconds = 0.0f; void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- -// Main Enry Point +// Program Main Entry Point //---------------------------------------------------------------------------------- -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves"); - + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves"); + // Load space texture to apply shaders - texture = LoadTexture("resources/space.png"); - + texture = LoadTexture("resources/space.png"); + // Load shader and setup location points and values shader = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION)); - secondsLoc = GetShaderLocation(shader, "secondes"); - freqXLoc = GetShaderLocation(shader, "freqX"); - freqYLoc = GetShaderLocation(shader, "freqY"); - ampXLoc = GetShaderLocation(shader, "ampX"); - ampYLoc = GetShaderLocation(shader, "ampY"); - speedXLoc = GetShaderLocation(shader, "speedX"); - speedYLoc = GetShaderLocation(shader, "speedY"); + secondsLoc = GetShaderLocation(shader, "secondes"); + freqXLoc = GetShaderLocation(shader, "freqX"); + freqYLoc = GetShaderLocation(shader, "freqY"); + ampXLoc = GetShaderLocation(shader, "ampX"); + ampYLoc = GetShaderLocation(shader, "ampY"); + speedXLoc = GetShaderLocation(shader, "speedX"); + speedYLoc = GetShaderLocation(shader, "speedY"); 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, &X, UNIFORM_FLOAT); - SetShaderValue(shader, ampYLoc, &Y, UNIFORM_FLOAT); - SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT); - SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT); - + SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, UNIFORM_VEC2); + SetShaderValue(shader, freqXLoc, &freqX, UNIFORM_FLOAT); + SetShaderValue(shader, freqYLoc, &freqY, UNIFORM_FLOAT); + SetShaderValue(shader, ampXLoc, &X, UNIFORM_FLOAT); + SetShaderValue(shader, ampYLoc, &Y, UNIFORM_FLOAT); + SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT); + SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT); + #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -113,11 +113,11 @@ int main() //-------------------------------------------------------------------------------------- UnloadShader(shader); // Unload shader UnloadTexture(texture); // Unload texture - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - return 0; + return 0; } //---------------------------------------------------------------------------------- @@ -128,7 +128,7 @@ void UpdateDrawFrame(void) // Update //---------------------------------------------------------------------------------- seconds += GetFrameTime(); - + SetShaderValue(shader, secondsLoc, &seconds, UNIFORM_FLOAT); //---------------------------------------------------------------------------------- @@ -139,10 +139,10 @@ void UpdateDrawFrame(void) ClearBackground(RAYWHITE); BeginShaderMode(shader); - + DrawTexture(texture, 0, 0, WHITE); DrawTexture(texture, texture.width, 0, WHITE); - + EndShaderMode(); EndDrawing(); |
