Example resize fixes using IsWindowResized()
This commit is contained in:
parent
a36905607c
commit
b16313a2d3
30 changed files with 325 additions and 177 deletions
|
|
@ -30,8 +30,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
||||||
|
|
||||||
|
|
@ -72,6 +72,11 @@ int main(void)
|
||||||
UpdateModelAnimation(model, anims[0], animFrameCounter);
|
UpdateModelAnimation(model, anims[0], animFrameCounter);
|
||||||
if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0;
|
if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0;
|
||||||
}
|
}
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
||||||
|
|
||||||
|
|
@ -50,7 +50,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
// Move player
|
// Move player
|
||||||
if (IsKeyDown(KEY_RIGHT)) playerPosition.x += 0.2f;
|
if (IsKeyDown(KEY_RIGHT)) playerPosition.x += 0.2f;
|
||||||
else if (IsKeyDown(KEY_LEFT)) playerPosition.x -= 0.2f;
|
else if (IsKeyDown(KEY_LEFT)) playerPosition.x -= 0.2f;
|
||||||
|
|
@ -111,7 +115,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Move player with arrow keys to collide", 220, 40, 20, GRAY);
|
DrawText("Move player with arrow keys to collide", screenWidth/2 - 220, 40, 20, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||||
|
|
||||||
|
|
@ -54,6 +54,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading");
|
||||||
|
|
||||||
|
|
@ -69,6 +69,11 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_FIRST_PERSON);
|
UpdateCamera(&camera, CAMERA_FIRST_PERSON);
|
||||||
|
|
@ -132,8 +137,8 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
DrawText("Drag & drop model to load mesh/texture.", 10, screenHeight - 20, 10, DARKGRAY);
|
||||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
if (selected) DrawText("MODEL SELECTED", screenWidth - 110, 10, 10, GREEN);
|
||||||
|
|
||||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
const char* voxFileNames[] = {
|
const char* voxFileNames[] = {
|
||||||
"resources/models/vox/chr_knight.vox",
|
"resources/models/vox/chr_knight.vox",
|
||||||
|
|
@ -126,6 +126,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))
|
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))
|
||||||
{
|
{
|
||||||
const Vector2 mouseDelta = GetMouseDelta();
|
const Vector2 mouseDelta = GetMouseDelta();
|
||||||
|
|
@ -182,11 +187,11 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Display info
|
// Display info
|
||||||
DrawRectangle(10, 400, 340, 60, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(10, screenHeight - 50, 340, 60, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(10, 400, 340, 60, Fade(DARKBLUE, 0.5f));
|
DrawRectangleLines(10, screenHeight - 50, 340, 60, Fade(DARKBLUE, 0.5f));
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, screenHeight - 50 + 10, 10, BLUE);
|
||||||
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, 420, 10, BLUE);
|
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, screenHeight - 50 + 20, 10, BLUE);
|
||||||
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, 430, 10, BLUE);
|
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, screenHeight - 50 + 30, 10, BLUE);
|
||||||
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
|
||||||
|
|
||||||
|
|
@ -78,6 +78,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if(IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
|
|
@ -110,21 +115,21 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(30, screenHeight - 50, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
DrawRectangleLines(30, screenHeight - 50, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE);
|
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, screenHeight - 50 + 10, 10, BLUE);
|
||||||
|
|
||||||
switch (currentModel)
|
switch (currentModel)
|
||||||
{
|
{
|
||||||
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
|
case 0: DrawText("PLANE", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;
|
case 1: DrawText("CUBE", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 2: DrawText("SPHERE", 680, 10, 20, DARKBLUE); break;
|
case 2: DrawText("SPHERE", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break;
|
case 3: DrawText("HEMISPHERE", screenWidth - 160, 10, 20, DARKBLUE); break;
|
||||||
case 4: DrawText("CYLINDER", 680, 10, 20, DARKBLUE); break;
|
case 4: DrawText("CYLINDER", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break;
|
case 5: DrawText("TORUS", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break;
|
case 6: DrawText("KNOT", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break;
|
case 7: DrawText("POLY", screenWidth - 120, 10, 20, DARKBLUE); break;
|
||||||
case 8: DrawText("Custom (triangle)", 580, 10, 20, DARKBLUE); break;
|
case 8: DrawText("Custom (triangle)", screenWidth - 220, 10, 20, DARKBLUE); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
||||||
|
|
||||||
|
|
@ -73,6 +73,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON); // Update camera
|
if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON); // Update camera
|
||||||
|
|
||||||
// Toggle camera controls
|
// Toggle camera controls
|
||||||
|
|
@ -226,7 +231,7 @@ int main(void)
|
||||||
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
DrawText("Right click mouse to toggle camera controls", 10, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - point rendering");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - point rendering");
|
||||||
|
|
||||||
|
|
@ -62,6 +62,11 @@ int main()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) useDrawModelPoints = !useDrawModelPoints;
|
if (IsKeyPressed(KEY_SPACE)) useDrawModelPoints = !useDrawModelPoints;
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
const float sunRadius = 4.0f;
|
const float sunRadius = 4.0f;
|
||||||
const float earthRadius = 0.6f;
|
const float earthRadius = 0.6f;
|
||||||
|
|
@ -66,6 +66,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
earthRotation += (5.0f*rotationSpeed);
|
earthRotation += (5.0f*rotationSpeed);
|
||||||
|
|
@ -112,7 +117,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, MAROON);
|
DrawText("EARTH ORBITING AROUND THE SUN!", screenWidth - 400, 10, 20, MAROON);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
//SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
|
//SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)");
|
||||||
|
|
@ -55,6 +55,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if(IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
// Plane pitch (x-axis) controls
|
// Plane pitch (x-axis) controls
|
||||||
if (IsKeyDown(KEY_DOWN)) pitch += 0.6f;
|
if (IsKeyDown(KEY_DOWN)) pitch += 0.6f;
|
||||||
else if (IsKeyDown(KEY_UP)) pitch -= 0.6f;
|
else if (IsKeyDown(KEY_UP)) pitch -= 0.6f;
|
||||||
|
|
@ -101,11 +106,11 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Draw controls info
|
// Draw controls info
|
||||||
DrawRectangle(30, 370, 260, 70, Fade(GREEN, 0.5f));
|
DrawRectangle(30, screenHeight - 80, 260, 70, Fade(GREEN, 0.5f));
|
||||||
DrawRectangleLines(30, 370, 260, 70, Fade(DARKGREEN, 0.5f));
|
DrawRectangleLines(30, screenHeight - 80, 260, 70, Fade(DARKGREEN, 0.5f));
|
||||||
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 380, 10, DARKGRAY);
|
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, screenHeight - 70, 10, DARKGRAY);
|
||||||
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 400, 10, DARKGRAY);
|
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, screenHeight - 50, 10, DARKGRAY);
|
||||||
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 420, 10, DARKGRAY);
|
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, screenHeight - 30, 10, DARKGRAY);
|
||||||
|
|
||||||
DrawText("(c) WWI Plane Model created by GiaHanLam", screenWidth - 240, screenHeight - 20, 10, DARKGRAY);
|
DrawText("(c) WWI Plane Model created by GiaHanLam", screenWidth - 240, screenHeight - 20, 10, DARKGRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,15 @@ uniform vec4 colDiffuse;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800.0;
|
|
||||||
const float renderHeight = 450.0;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = { 800.0, 450.0 };
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
|
@ -40,7 +36,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
gl_FragColor = vec4(color.rgb, 1.0);
|
gl_FragColor = vec4(color.rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,15 @@ uniform vec4 colDiffuse;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800;
|
|
||||||
const float renderHeight = 450;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = vec2(800.0, 450.0);
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
|
@ -38,7 +34,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
gl_FragColor = vec4(color.rgb, 1.0);;
|
gl_FragColor = vec4(color.rgb, 1.0);;
|
||||||
}
|
}
|
||||||
|
|
@ -13,19 +13,15 @@ out vec4 finalColor;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800;
|
|
||||||
const float renderHeight = 450;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = vec2(800.0, 450.0);
|
||||||
uniform vec2 center = vec2(200.0, 200.0);
|
uniform vec2 center = vec2(200.0, 200.0);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
|
@ -41,7 +37,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
finalColor = vec4(color.rgb, 1.0);;
|
finalColor = vec4(color.rgb, 1.0);;
|
||||||
}
|
}
|
||||||
|
|
@ -82,8 +82,8 @@ int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - basic pbr");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - basic pbr");
|
||||||
|
|
@ -202,6 +202,12 @@ int main()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
// Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f })
|
// Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f })
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
float swirlSize[2] = { (float)screenWidth, (float)screenHeight };
|
||||||
|
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
|
||||||
|
|
@ -62,12 +64,11 @@ int main(void)
|
||||||
|
|
||||||
// Get variable (uniform) location on the shader to connect with the program
|
// 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
|
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||||
|
int swirlSizeLoc = GetShaderLocation(shader, "size");
|
||||||
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
||||||
|
|
||||||
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
|
||||||
|
|
||||||
// Create a RenderTexture2D to be used for render to texture
|
// Create a RenderTexture2D to be used for render to texture
|
||||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
RenderTexture2D target;
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -75,15 +76,27 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
|
// Create a RenderTexture2D to be used for render to texture
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
Vector2 mousePosition = GetMousePosition();
|
Vector2 mousePosition = GetMousePosition();
|
||||||
|
|
||||||
|
swirlSize[0] = screenWidth;
|
||||||
|
swirlSize[1] = screenHeight;
|
||||||
|
SetShaderValue(shader, swirlSizeLoc, swirlSize, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
swirlCenter[0] = mousePosition.x;
|
swirlCenter[0] = mousePosition.x;
|
||||||
swirlCenter[1] = screenHeight - mousePosition.y;
|
swirlCenter[1] = screenHeight - mousePosition.y;
|
||||||
|
|
||||||
// Send new value to the shader to be used on drawing
|
// Send new value to the shader to be used on drawing
|
||||||
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -98,7 +111,7 @@ int main(void)
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
|
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
|
||||||
|
|
||||||
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED);
|
DrawText("TEXT DRAWN IN RENDER TEXTURE", screenWidth - 600, 10, 30, RED);
|
||||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
@ -107,7 +120,7 @@ int main(void)
|
||||||
// Enable shader using the custom uniform
|
// Enable shader using the custom uniform
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2){ 0, 0 }, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
// Draw some 2d text over drawn texture
|
// Draw some 2d text over drawn texture
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - hot reloading");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - hot reloading");
|
||||||
|
|
||||||
|
|
@ -51,9 +51,6 @@ int main(void)
|
||||||
int mouseLoc = GetShaderLocation(shader, "mouse");
|
int mouseLoc = GetShaderLocation(shader, "mouse");
|
||||||
int timeLoc = GetShaderLocation(shader, "time");
|
int timeLoc = GetShaderLocation(shader, "time");
|
||||||
|
|
||||||
float resolution[2] = { (float)screenWidth, (float)screenHeight };
|
|
||||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
|
||||||
|
|
||||||
float totalTime = 0.0f;
|
float totalTime = 0.0f;
|
||||||
bool shaderAutoReloading = false;
|
bool shaderAutoReloading = false;
|
||||||
|
|
||||||
|
|
@ -65,6 +62,14 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
|
float resolution[2] = { (float)screenWidth, (float)screenHeight };
|
||||||
|
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
totalTime += GetFrameTime();
|
totalTime += GetFrameTime();
|
||||||
Vector2 mouse = GetMousePosition();
|
Vector2 mouse = GetMousePosition();
|
||||||
float mousePos[2] = { mouse.x, mouse.y };
|
float mousePos[2] = { mouse.x, mouse.y };
|
||||||
|
|
@ -120,7 +125,7 @@ int main(void)
|
||||||
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : BLACK);
|
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : BLACK);
|
||||||
if (!shaderAutoReloading) DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, 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);
|
DrawText(TextFormat("Shader last modification: %s", asctime(localtime(&fragShaderFileModTime))), 10, screenHeight - 20, 10, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - write depth buffer");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - write depth buffer");
|
||||||
|
|
||||||
|
|
@ -69,12 +70,6 @@ int main(void)
|
||||||
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
||||||
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
|
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
|
||||||
|
|
||||||
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
|
|
||||||
Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
|
|
||||||
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
|
|
||||||
|
|
||||||
// Use Customized function to create writable depth texture buffer
|
|
||||||
RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {
|
Camera camera = {
|
||||||
|
|
@ -87,6 +82,7 @@ int main(void)
|
||||||
|
|
||||||
// Camera FOV is pre-calculated in the camera Distance.
|
// Camera FOV is pre-calculated in the camera Distance.
|
||||||
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
||||||
|
RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -96,6 +92,18 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
// Use Customized function to create writable depth texture buffer
|
||||||
|
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
screenCenter.x = screenWidth/2.0f;
|
||||||
|
screenCenter.y = screenHeight/2.0f;
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
|
||||||
|
}
|
||||||
|
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
// Update Camera Postion in the ray march shader.
|
// Update Camera Postion in the ray march shader.
|
||||||
|
|
@ -133,7 +141,6 @@ int main(void)
|
||||||
// Draw into screen our custom render texture
|
// Draw into screen our custom render texture
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
|
||||||
|
|
@ -71,6 +71,11 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
UpdateCamera(&camera, CAMERA_FREE);
|
UpdateCamera(&camera, CAMERA_FREE);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
|
||||||
|
|
@ -133,6 +133,13 @@ int main(void)
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if(IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
}
|
||||||
BeginTextureMode(target); // Enable drawing to texture
|
BeginTextureMode(target); // Enable drawing to texture
|
||||||
ClearBackground(RAYWHITE); // Clear texture background
|
ClearBackground(RAYWHITE); // Clear texture background
|
||||||
|
|
||||||
|
|
@ -148,7 +155,7 @@ int main(void)
|
||||||
// Render generated texture using selected postprocessing shader
|
// Render generated texture using selected postprocessing shader
|
||||||
BeginShaderMode(shaders[currentShader]);
|
BeginShaderMode(shaders[currentShader]);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2){0, 0}, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
// Draw 2d shapes and text over drawn texture
|
// Draw 2d shapes and text over drawn texture
|
||||||
|
|
@ -158,7 +165,7 @@ int main(void)
|
||||||
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
||||||
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
||||||
DrawText("< >", 540, 10, 30, DARKBLUE);
|
DrawText("< >", 540, 10, 30, DARKBLUE);
|
||||||
DrawFPS(700, 15);
|
DrawFPS(screenWidth - 100, 15);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
const Color rectangleColor = BLUE;
|
const Color rectangleColor = BLUE;
|
||||||
const Color shadowColor = DARKBLUE;
|
const Color shadowColor = DARKBLUE;
|
||||||
|
|
@ -100,6 +100,13 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsWindowResized())
|
||||||
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
}
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
@ -162,12 +169,10 @@ int main(void)
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Draw one more rectangle with all three colors
|
// Draw one more rectangle with all three colors
|
||||||
rec = (Rectangle){ 240, 80, 500, 300 };
|
rec = (Rectangle){ 240, 80, screenWidth - 300, screenHeight - 150 };
|
||||||
DrawRectangleLines((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);
|
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
|
||||||
DrawText("Rectangle with all three combined", (int)rec.x - 30, (int)rec.y - 45, 10, DARKGRAY);
|
DrawText("Rectangle with all three combined", rec.x - 30, rec.y - 45, 10, DARKGRAY);
|
||||||
|
|
||||||
rec.y = screenHeight - rec.y - rec.height;
|
rec.y = screenHeight - rec.y - rec.height;
|
||||||
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue