actually add vendor folder
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float secondes;
|
||||
|
||||
uniform vec2 size;
|
||||
|
||||
uniform float freqX;
|
||||
uniform float freqY;
|
||||
uniform float ampX;
|
||||
uniform float ampY;
|
||||
uniform float speedX;
|
||||
uniform float speedY;
|
||||
|
||||
void main() {
|
||||
float pixelWidth = 1.0 / size.x;
|
||||
float pixelHeight = 1.0 / size.y;
|
||||
float aspect = pixelHeight / pixelWidth;
|
||||
float boxLeft = 0.0;
|
||||
float boxTop = 0.0;
|
||||
|
||||
vec2 p = fragTexCoord;
|
||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
||||
|
||||
gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
uniform float secondes;
|
||||
|
||||
uniform vec2 size;
|
||||
|
||||
uniform float freqX;
|
||||
uniform float freqY;
|
||||
uniform float ampX;
|
||||
uniform float ampY;
|
||||
uniform float speedX;
|
||||
uniform float speedY;
|
||||
|
||||
void main() {
|
||||
float pixelWidth = 1.0 / size.x;
|
||||
float pixelHeight = 1.0 / size.y;
|
||||
float aspect = pixelHeight / pixelWidth;
|
||||
float boxLeft = 0.0;
|
||||
float boxTop = 0.0;
|
||||
|
||||
vec2 p = fragTexCoord;
|
||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
||||
|
||||
finalColor = texture(texture0, p)*colDiffuse*fragColor;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Texture Waves
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* 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.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLSL_VERSION 330
|
||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||
#define GLSL_VERSION 100
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [shaders] example - texture waves");
|
||||
|
||||
// Load texture texture to apply shaders
|
||||
raylib::Texture2D texture("resources/space.png");
|
||||
|
||||
// Load shader and setup location points and values
|
||||
raylib::Shader shader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
|
||||
|
||||
int secondsLoc = shader.GetLocation("secondes");
|
||||
int freqXLoc = shader.GetLocation("freqX");
|
||||
int freqYLoc = shader.GetLocation("freqY");
|
||||
int ampXLoc = shader.GetLocation("ampX");
|
||||
int ampYLoc = shader.GetLocation("ampY");
|
||||
int speedXLoc = shader.GetLocation("speedX");
|
||||
int speedYLoc = shader.GetLocation("speedY");
|
||||
|
||||
// Shader uniform values that can be updated at any time
|
||||
float freqX = 25.0f;
|
||||
float freqY = 25.0f;
|
||||
float ampX = 5.0f;
|
||||
float ampY = 5.0f;
|
||||
float speedX = 8.0f;
|
||||
float speedY = 8.0f;
|
||||
|
||||
float screenSize[2] = { (float)window.GetWidth(), (float)window.GetHeight() };
|
||||
shader.SetValue(shader.GetLocation("size"), &screenSize, SHADER_UNIFORM_VEC2);
|
||||
shader.SetValue(freqXLoc, &freqX, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(freqYLoc, &freqY, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(ampXLoc, &X, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(ampYLoc, &Y, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(speedXLoc, &speedX, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(speedYLoc, &speedY, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
float seconds = 0.0f;
|
||||
|
||||
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
seconds += GetFrameTime();
|
||||
|
||||
shader.SetValue(secondsLoc, &seconds, SHADER_UNIFORM_FLOAT);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
shader.BeginMode();
|
||||
|
||||
texture.Draw(0, 0, WHITE);
|
||||
texture.Draw(texture.GetWidth(), 0, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user