Remove trail spaces
This commit is contained in:
parent
f92ee46d86
commit
dcf52c132f
61 changed files with 565 additions and 565 deletions
|
@ -69,9 +69,9 @@ int main(void)
|
|||
modelB.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||
modelC.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
// Get some shader loactions
|
||||
shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
|
||||
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
|
||||
|
@ -79,7 +79,7 @@ int main(void)
|
|||
// ambient light level
|
||||
int ambientLoc = GetShaderLocation(shader, "ambient");
|
||||
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
|
||||
|
||||
|
||||
float angle = 6.282f;
|
||||
|
||||
// All models use the same shader
|
||||
|
@ -121,7 +121,7 @@ int main(void)
|
|||
lights[2].position.z = sinf(angle*0.2f)*4.0f;
|
||||
lights[3].position.y = cosf(-angle*0.35f)*4.0f;
|
||||
lights[3].position.z = sinf(-angle*0.35f)*4.0f;
|
||||
|
||||
|
||||
UpdateLightValues(shader, lights[0]);
|
||||
UpdateLightValues(shader, lights[1]);
|
||||
UpdateLightValues(shader, lights[2]);
|
||||
|
@ -160,7 +160,7 @@ int main(void)
|
|||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
||||
DrawText("Use keys RGBW to toggle lights", 10, 30, 20, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
|
@ -172,7 +172,7 @@ int main(void)
|
|||
UnloadModel(modelA); // Unload the modelA
|
||||
UnloadModel(modelB); // Unload the modelB
|
||||
UnloadModel(modelC); // Unload the modelC
|
||||
|
||||
|
||||
UnloadTexture(texture); // Unload the texture
|
||||
UnloadShader(shader); // Unload shader
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Sieve of Eratosthenes");
|
||||
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
|
||||
|
||||
// Load Eratosthenes shader
|
||||
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION));
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {
|
||||
Camera camera = {
|
||||
(Vector3){ 2.0f, 2.0f, 6.0f }, // position
|
||||
(Vector3){ 0.0f, 0.5f, 0.0f }, // target
|
||||
(Vector3){ 0.0f, 1.0f, 0.0f }, // up
|
||||
|
@ -67,7 +67,7 @@ int main(void)
|
|||
modelC.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||
|
||||
// Load shader and set up some uniforms
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/fog.fs", GLSL_VERSION));
|
||||
shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
|
||||
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
|
||||
|
@ -75,7 +75,7 @@ int main(void)
|
|||
// Ambient light level
|
||||
int ambientLoc = GetShaderLocation(shader, "ambient");
|
||||
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
|
||||
|
||||
|
||||
float fogDensity = 0.15f;
|
||||
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
|
||||
SetShaderValue(shader, fogDensityLoc, &fogDensity, SHADER_UNIFORM_FLOAT);
|
||||
|
@ -100,18 +100,18 @@ int main(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera); // Update camera
|
||||
|
||||
if (IsKeyDown(KEY_UP))
|
||||
if (IsKeyDown(KEY_UP))
|
||||
{
|
||||
fogDensity += 0.001;
|
||||
if (fogDensity > 1.0) fogDensity = 1.0;
|
||||
}
|
||||
|
||||
|
||||
if (IsKeyDown(KEY_DOWN))
|
||||
{
|
||||
fogDensity -= 0.001;
|
||||
if (fogDensity < 0.0) fogDensity = 0.0;
|
||||
}
|
||||
|
||||
|
||||
SetShaderValue(shader, fogDensityLoc, &fogDensity, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
// Rotate the torus
|
||||
|
|
|
@ -65,36 +65,36 @@ int main(void)
|
|||
// Set shader required uniform values
|
||||
SetShaderValue(shader, timeLoc, &totalTime, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, mouseLoc, mousePos, SHADER_UNIFORM_VEC2);
|
||||
|
||||
|
||||
// Hot shader reloading
|
||||
if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
|
||||
{
|
||||
long currentFragShaderModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION));
|
||||
|
||||
|
||||
// Check if shader file has been modified
|
||||
if (currentFragShaderModTime != fragShaderFileModTime)
|
||||
{
|
||||
// Try reloading updated shader
|
||||
Shader updatedShader = LoadShader(0, TextFormat(fragShaderFileName, GLSL_VERSION));
|
||||
|
||||
|
||||
if (updatedShader.id != rlGetShaderDefault().id) // It was correctly loaded
|
||||
{
|
||||
UnloadShader(shader);
|
||||
shader = updatedShader;
|
||||
|
||||
|
||||
// Get shader locations for required uniforms
|
||||
resolutionLoc = GetShaderLocation(shader, "resolution");
|
||||
mouseLoc = GetShaderLocation(shader, "mouse");
|
||||
timeLoc = GetShaderLocation(shader, "time");
|
||||
|
||||
|
||||
// Reset required uniforms
|
||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||
}
|
||||
|
||||
|
||||
fragShaderFileModTime = currentFragShaderModTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsKeyPressed(KEY_A)) shaderAutoReloading = !shaderAutoReloading;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
@ -109,10 +109,10 @@ int main(void)
|
|||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
||||
EndShaderMode();
|
||||
|
||||
DrawText(TextFormat("PRESS [A] to TOGGLE SHADER AUTOLOADING: %s",
|
||||
DrawText(TextFormat("PRESS [A] to TOGGLE SHADER AUTOLOADING: %s",
|
||||
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : BLACK);
|
||||
if (!shaderAutoReloading) DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, BLACK);
|
||||
|
||||
|
||||
DrawText(TextFormat("Shader last modification: %s", asctime(localtime(&fragShaderFileModTime))), 10, 430, 10, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
|||
// Load julia set shader
|
||||
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/julia_set.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
RenderTexture2D target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
||||
|
||||
|
@ -74,7 +74,7 @@ int main(void)
|
|||
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
||||
|
||||
|
||||
int incrementSpeed = 0; // Multiplier of speed to change c value
|
||||
bool showControls = true; // Show controls
|
||||
bool pause = false; // Pause animation
|
||||
|
|
|
@ -56,7 +56,7 @@ int main(void)
|
|||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
const int instances = 10000; // Number of instances to display
|
||||
const int instances = 10000; // Number of instances to display
|
||||
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||
|
||||
Matrix *rotations = RL_MALLOC(instances*sizeof(Matrix)); // Rotation state of instances
|
||||
|
@ -69,7 +69,7 @@ int main(void)
|
|||
x = GetRandomValue(-50, 50);
|
||||
y = GetRandomValue(-50, 50);
|
||||
z = GetRandomValue(-50, 50);
|
||||
translations[i] = MatrixTranslate(x, y, z);
|
||||
translations[i] = MatrixTranslate(x, y, z);
|
||||
|
||||
x = GetRandomValue(0, 360);
|
||||
y = GetRandomValue(0, 360);
|
||||
|
@ -83,7 +83,7 @@ int main(void)
|
|||
|
||||
Matrix *transforms = RL_MALLOC(instances*sizeof(Matrix)); // Pre-multiplied transformations passed to rlgl
|
||||
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting_instanced.vs", GLSL_VERSION),
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting_instanced.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
|
||||
|
||||
// Get some shader loactions
|
||||
|
@ -102,7 +102,7 @@ int main(void)
|
|||
Material material = LoadMaterialDefault();
|
||||
material.shader = shader;
|
||||
material.maps[MATERIAL_MAP_DIFFUSE].color = RED;
|
||||
|
||||
|
||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
|
||||
int textPositionY = 300;
|
||||
|
@ -134,10 +134,10 @@ int main(void)
|
|||
if (IsKeyDown(KEY_EIGHT)) groups = 8;
|
||||
if (IsKeyDown(KEY_NINE)) groups = 9;
|
||||
if (IsKeyDown(KEY_W)) { groups = 7; amp = 25; speed = 18; variance = 0.70f; }
|
||||
|
||||
|
||||
if (IsKeyDown(KEY_EQUAL)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
|
||||
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
|
||||
|
||||
|
||||
if (IsKeyDown(KEY_MINUS)) speed = fmaxf(speed*1.02f, speed + 1);
|
||||
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = fmaxf(speed*1.02f, speed + 1);
|
||||
|
||||
|
@ -150,19 +150,19 @@ int main(void)
|
|||
{
|
||||
rotations[i] = MatrixMultiply(rotations[i], rotationsInc[i]);
|
||||
transforms[i] = MatrixMultiply(rotations[i], translations[i]);
|
||||
|
||||
|
||||
// Get the animation cycle's framesCounter for this instance
|
||||
loop = (float)((framesCounter + (int)(((float)(i%groups)/groups)*speed))%speed)/speed;
|
||||
|
||||
|
||||
// Calculate the y according to loop cycle
|
||||
y = (sinf(loop*PI*2))*amp*((1 - variance) + (variance*(float)(i%(groups*10))/(groups*10)));
|
||||
|
||||
|
||||
// Clamp to floor
|
||||
y = (y < 0)? 0.0f : y;
|
||||
|
||||
|
||||
transforms[i] = MatrixMultiply(transforms[i], MatrixTranslate(0.0f, y, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
UpdateCamera(&camera);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
@ -179,35 +179,35 @@ int main(void)
|
|||
|
||||
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, MAROON);
|
||||
DrawText("PRESS KEYS:", 10, textPositionY, 20, BLACK);
|
||||
|
||||
DrawText("1 - 9", 10, textPositionY += 25, 10, BLACK);
|
||||
|
||||
DrawText("1 - 9", 10, textPositionY += 25, 10, BLACK);
|
||||
DrawText(": Number of groups", 50, textPositionY , 10, BLACK);
|
||||
DrawText(TextFormat(": %d", groups), 160, textPositionY , 10, BLACK);
|
||||
|
||||
DrawText("UP", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("UP", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": increase amplitude", 50, textPositionY, 10, BLACK);
|
||||
DrawText(TextFormat(": %.2f", amp), 160, textPositionY , 10, BLACK);
|
||||
|
||||
DrawText("DOWN", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("DOWN", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": decrease amplitude", 50, textPositionY, 10, BLACK);
|
||||
|
||||
DrawText("LEFT", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("LEFT", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": decrease variance", 50, textPositionY, 10, BLACK);
|
||||
DrawText(TextFormat(": %.2f", variance), 160, textPositionY , 10, BLACK);
|
||||
|
||||
DrawText("RIGHT", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("RIGHT", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": increase variance", 50, textPositionY, 10, BLACK);
|
||||
|
||||
DrawText("+/=", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("+/=", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": increase speed", 50, textPositionY, 10, BLACK);
|
||||
DrawText(TextFormat(": %d = %f loops/sec", speed, ((float)fps / speed)), 160, textPositionY , 10, BLACK);
|
||||
|
||||
DrawText("-", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("-", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": decrease speed", 50, textPositionY, 10, BLACK);
|
||||
|
||||
DrawText("W", 10, textPositionY += 15, 10, BLACK);
|
||||
|
||||
DrawText("W", 10, textPositionY += 15, 10, BLACK);
|
||||
DrawText(": Wild setup!", 50, textPositionY, 10, BLACK);
|
||||
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
@ -42,10 +42,10 @@ int main(void)
|
|||
UnloadImage(imBlue);
|
||||
|
||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/color_mix.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
// Get an additional sampler2D location to be enabled on drawing
|
||||
int texBlueLoc = GetShaderLocation(shader, "texture1");
|
||||
|
||||
|
||||
// Get shader uniform for divider
|
||||
int dividerLoc = GetShaderLocation(shader, "divider");
|
||||
float dividerValue = 0.5f;
|
||||
|
@ -60,34 +60,34 @@ int main(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KEY_RIGHT)) dividerValue += 0.01f;
|
||||
else if (IsKeyDown(KEY_LEFT)) dividerValue -= 0.01f;
|
||||
|
||||
|
||||
if (dividerValue < 0.0f) dividerValue = 0.0f;
|
||||
else if (dividerValue > 1.0f) dividerValue = 1.0f;
|
||||
|
||||
|
||||
SetShaderValue(shader, dividerLoc, ÷rValue, SHADER_UNIFORM_FLOAT);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginShaderMode(shader);
|
||||
|
||||
|
||||
// WARNING: Additional samplers are enabled for all draw calls in the batch,
|
||||
// EndShaderMode() forces batch drawing and consequently resets active textures
|
||||
// to let other sampler2D to be activated on consequent drawings (if required)
|
||||
SetShaderValueTexture(shader, texBlueLoc, texBlue);
|
||||
|
||||
|
||||
// We are drawing texRed using default sampler2D texture0 but
|
||||
// an additional texture units is enabled for texBlue (sampler2D texture1)
|
||||
DrawTexture(texRed, 0, 0, WHITE);
|
||||
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
|
||||
DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, GetScreenHeight() - 40, 20, RAYWHITE);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ int main(void)
|
|||
SetShaderValue(shader, viewEyeLoc, cameraPos, SHADER_UNIFORM_VEC3);
|
||||
SetShaderValue(shader, viewCenterLoc, cameraTarget, SHADER_UNIFORM_VEC3);
|
||||
SetShaderValue(shader, runTimeLoc, &runTime, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
|
||||
// Check if screen is resized
|
||||
if (IsWindowResized())
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ int main(void)
|
|||
|
||||
// Load the shader
|
||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/mask.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
// Load and apply the diffuse texture (colour map)
|
||||
Texture texDiffuse = LoadTexture("resources/plasma.png");
|
||||
model1.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texDiffuse;
|
||||
|
@ -131,10 +131,10 @@ int main(void)
|
|||
UnloadModel(model1);
|
||||
UnloadModel(model2);
|
||||
UnloadModel(model3);
|
||||
|
||||
|
||||
UnloadTexture(texDiffuse); // Unload default diffuse texture
|
||||
UnloadTexture(texMask); // Unload texture mask
|
||||
|
||||
|
||||
UnloadShader(shader); // Unload shader
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 Chris Camacho (@chriscamacho - http://bedroomcoders.co.uk/)
|
||||
* Example contributed by Chris Camacho (@chriscamacho - http://bedroomcoders.co.uk/)
|
||||
* and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
|
||||
|
@ -14,13 +14,13 @@
|
|||
*
|
||||
* The shader makes alpha holes in the forground to give the apearance of a top
|
||||
* down look at a spotlight casting a pool of light...
|
||||
*
|
||||
*
|
||||
* The right hand side of the screen there is just enough light to see whats
|
||||
* going on without the spot light, great for a stealth type game where you
|
||||
* have to avoid the spotlights.
|
||||
*
|
||||
*
|
||||
* The left hand side of the screen is in pitch dark except for where the spotlights are.
|
||||
*
|
||||
*
|
||||
* Although this example doesn't scale like the letterbox example, you could integrate
|
||||
* the two techniques, but by scaling the actual colour of the render texture rather
|
||||
* than using alpha as a mask.
|
||||
|
@ -43,12 +43,12 @@
|
|||
#define MAX_STARS 400
|
||||
|
||||
// Spot data
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
Vector2 pos;
|
||||
Vector2 vel;
|
||||
float inner;
|
||||
float radius;
|
||||
|
||||
|
||||
// Shader locations
|
||||
unsigned int posLoc;
|
||||
unsigned int innerLoc;
|
||||
|
@ -75,26 +75,26 @@ int main(void)
|
|||
HideCursor();
|
||||
|
||||
Texture texRay = LoadTexture("resources/raysan.png");
|
||||
|
||||
|
||||
Star stars[MAX_STARS] = { 0 };
|
||||
|
||||
for (int n = 0; n < MAX_STARS; n++) ResetStar(&stars[n]);
|
||||
|
||||
// Progress all the stars on, so they don't all start in the centre
|
||||
for (int m = 0; m < screenWidth/2.0; m++)
|
||||
for (int m = 0; m < screenWidth/2.0; m++)
|
||||
{
|
||||
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
|
||||
}
|
||||
|
||||
int frameCounter = 0;
|
||||
|
||||
|
||||
// Use default vert shader
|
||||
Shader shdrSpot = LoadShader(0, TextFormat("resources/shaders/glsl%i/spotlight.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
// Get the locations of spots in the shader
|
||||
Spot spots[MAX_SPOTS];
|
||||
|
||||
for (int i = 0; i < MAX_SPOTS; i++)
|
||||
for (int i = 0; i < MAX_SPOTS; i++)
|
||||
{
|
||||
char posName[32] = "spots[x].pos\0";
|
||||
char innerName[32] = "spots[x].inner\0";
|
||||
|
@ -103,13 +103,13 @@ int main(void)
|
|||
posName[6] = '0' + i;
|
||||
innerName[6] = '0' + i;
|
||||
radiusName[6] = '0' + i;
|
||||
|
||||
|
||||
spots[i].posLoc = GetShaderLocation(shdrSpot, posName);
|
||||
spots[i].innerLoc = GetShaderLocation(shdrSpot, innerName);
|
||||
spots[i].radiusLoc = GetShaderLocation(shdrSpot, radiusName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Tell the shader how wide the screen is so we can have
|
||||
// a pitch black half and a dimly lit half.
|
||||
unsigned int wLoc = GetShaderLocation(shdrSpot, "screenWidth");
|
||||
|
@ -123,16 +123,16 @@ int main(void)
|
|||
spots[i].pos.x = GetRandomValue(64, screenWidth - 64);
|
||||
spots[i].pos.y = GetRandomValue(64, screenHeight - 64);
|
||||
spots[i].vel = (Vector2){ 0, 0 };
|
||||
|
||||
|
||||
while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
|
||||
{
|
||||
spots[i].vel.x = GetRandomValue(-40, 40)/10.0;
|
||||
spots[i].vel.y = GetRandomValue(-40, 40)/10.0;
|
||||
}
|
||||
|
||||
|
||||
spots[i].inner = 28 * (i + 1);
|
||||
spots[i].radius = 48 * (i + 1);
|
||||
|
||||
|
||||
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
|
||||
|
@ -140,7 +140,7 @@ int main(void)
|
|||
|
||||
SetTargetFPS(60); // Set to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
|
@ -157,23 +157,23 @@ int main(void)
|
|||
if (i == 0)
|
||||
{
|
||||
Vector2 mp = GetMousePosition();
|
||||
spots[i].pos.x = mp.x;
|
||||
spots[i].pos.x = mp.x;
|
||||
spots[i].pos.y = screenHeight - mp.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
spots[i].pos.x += spots[i].vel.x;
|
||||
spots[i].pos.x += spots[i].vel.x;
|
||||
spots[i].pos.y += spots[i].vel.y;
|
||||
|
||||
if (spots[i].pos.x < 64) spots[i].vel.x = -spots[i].vel.x;
|
||||
if (spots[i].pos.x > (screenWidth - 64)) spots[i].vel.x = -spots[i].vel.x;
|
||||
if (spots[i].pos.y < 64) spots[i].vel.y = -spots[i].vel.y;
|
||||
|
||||
if (spots[i].pos.x < 64) spots[i].vel.x = -spots[i].vel.x;
|
||||
if (spots[i].pos.x > (screenWidth - 64)) spots[i].vel.x = -spots[i].vel.x;
|
||||
if (spots[i].pos.y < 64) spots[i].vel.y = -spots[i].vel.y;
|
||||
if (spots[i].pos.y > (screenHeight - 64)) spots[i].vel.y = -spots[i].vel.y;
|
||||
}
|
||||
|
||||
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
|
||||
|
||||
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
|
||||
}
|
||||
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
@ -204,11 +204,11 @@ int main(void)
|
|||
EndShaderMode();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
||||
DrawText("Move the mouse!", 10, 30, 20, GREEN);
|
||||
DrawText("Pitch Black", screenWidth*0.2f, screenHeight/2, 20, GREEN);
|
||||
DrawText("Dark", screenWidth*.66f, screenHeight/2, 20, GREEN);
|
||||
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -229,21 +229,21 @@ int main(void)
|
|||
void ResetStar(Star *s)
|
||||
{
|
||||
s->pos = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
s->vel.x = (float)GetRandomValue(-1000, 1000)/100.0f;
|
||||
s->vel.y = (float)GetRandomValue(-1000, 1000)/100.0f;
|
||||
|
||||
|
||||
} while (!(fabs(s->vel.x) + (fabs(s->vel.y) > 1)));
|
||||
|
||||
|
||||
s->pos = Vector2Add(s->pos, Vector2Multiply(s->vel, (Vector2){ 8.0f, 8.0f }));
|
||||
}
|
||||
|
||||
void UpdateStar(Star *s)
|
||||
{
|
||||
s->pos = Vector2Add(s->pos, s->vel);
|
||||
|
||||
|
||||
if ((s->pos.x < 0) || (s->pos.x > GetScreenWidth()) ||
|
||||
(s->pos.y < 0) || (s->pos.y > GetScreenHeight()))
|
||||
{
|
||||
|
|
|
@ -34,10 +34,10 @@ int main(void)
|
|||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves");
|
||||
|
||||
|
||||
// Load texture texture to apply shaders
|
||||
Texture2D texture = LoadTexture("resources/space.png");
|
||||
|
||||
|
||||
// Load shader and setup location points and values
|
||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
|
||||
|
||||
|
@ -77,7 +77,7 @@ int main(void)
|
|||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
seconds += GetFrameTime();
|
||||
|
||||
|
||||
SetShaderValue(shader, secondsLoc, &seconds, SHADER_UNIFORM_FLOAT);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
@ -88,10 +88,10 @@ int main(void)
|
|||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginShaderMode(shader);
|
||||
|
||||
|
||||
DrawTexture(texture, 0, 0, WHITE);
|
||||
DrawTexture(texture, texture.width, 0, WHITE);
|
||||
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
EndDrawing();
|
||||
|
@ -102,7 +102,7 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(texture); // Unload texture
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue