Jon Daniel 3 days ago
committed by GitHub
parent
commit
c8f25362ab
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
29 changed files with 145 additions and 129 deletions
  1. +1
    -1
      examples/models/models_animation.c
  2. +2
    -2
      examples/models/models_box_collisions.c
  3. +3
    -3
      examples/models/models_heightmap.c
  4. +2
    -2
      examples/models/models_loading.c
  5. +5
    -5
      examples/models/models_loading_vox.c
  6. +12
    -12
      examples/models/models_mesh_generation.c
  7. +3
    -3
      examples/models/models_mesh_picking.c
  8. +1
    -1
      examples/models/models_point_rendering.c
  9. +1
    -1
      examples/models/models_rlgl_solar_system.c
  10. +6
    -6
      examples/models/models_yaw_pitch_roll.c
  11. +3
    -7
      examples/shaders/resources/shaders/glsl100/swirl.fs
  12. +4
    -8
      examples/shaders/resources/shaders/glsl120/swirl.fs
  13. +4
    -8
      examples/shaders/resources/shaders/glsl330/swirl.fs
  14. +1
    -1
      examples/shaders/shaders_basic_pbr.c
  15. +19
    -9
      examples/shaders/shaders_custom_uniform.c
  16. +5
    -5
      examples/shaders/shaders_hot_reloading.c
  17. +11
    -8
      examples/shaders/shaders_hybrid_render.c
  18. +2
    -2
      examples/shaders/shaders_model_shader.c
  19. +5
    -3
      examples/shaders/shaders_postprocessing.c
  20. +10
    -10
      examples/shaders/shaders_rounded_rectangle.c
  21. +1
    -1
      examples/shaders/shaders_shadowmap.c
  22. +14
    -11
      examples/shaders/shaders_spotlight.c
  23. +4
    -2
      examples/shaders/shaders_write_depth.c
  24. +2
    -2
      examples/shapes/shapes_bouncing_ball.c
  25. +4
    -4
      examples/shapes/shapes_easings_ball_anim.c
  26. +6
    -1
      examples/shapes/shapes_following_eyes.c
  27. +5
    -5
      examples/shapes/shapes_logo_raylib.c
  28. +4
    -1
      examples/shapes/shapes_logo_raylib_anim.c
  29. +5
    -5
      examples/text/text_draw_3d.c

+ 1
- 1
examples/models/models_animation.c View File

@ -94,7 +94,7 @@ int main(void)
EndMode3D();
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, GRAY);
DrawText("(c) Guy IQM 3D model by @culacant", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------

+ 2
- 2
examples/models/models_box_collisions.c View File

@ -111,7 +111,7 @@ int main(void)
EndMode3D();
DrawText("Move player with arrow keys to collide", 220, 40, 20, GRAY);
DrawText("Move player with arrow keys to collide", n">GetScreenWidth()/2 - 220, 40, 20, GRAY);
DrawFPS(10, 10);
@ -125,4 +125,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 3
- 3
examples/models/models_heightmap.c View File

@ -71,8 +71,8 @@ int main(void)
EndMode3D();
DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE);
DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN);
DrawTexture(texture, GetScreenWidth() - texture.width - 20, 20, WHITE);
DrawRectangleLines(GetScreenWidth() - texture.width - 20, 20, texture.width, texture.height, GREEN);
DrawFPS(10, 10);
@ -89,4 +89,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 2
- 2
examples/models/models_loading.c View File

@ -135,7 +135,7 @@ int main(void)
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 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", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
DrawFPS(10, 10);
@ -152,4 +152,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 5
- 5
examples/models/models_loading_vox.c View File

@ -182,11 +182,11 @@ int main(void)
EndMode3D();
// Display info
DrawRectangle(10, mi">400, 340, 60, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(10, mi">400, 340, 60, Fade(DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, mi">410, 10, BLUE);
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, mi">420, 10, BLUE);
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, mi">430, 10, BLUE);
DrawRectangle(10, n">GetScreenHeight() - 50, 340, 60, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(10, n">GetScreenHeight() - 50, 340, 60, Fade(DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, n">GetScreenHeight() - 50 + 10, 10, BLUE);
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, n">GetScreenHeight() - 50 + 20, 10, BLUE);
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, n">GetScreenHeight() - 50 + 30, 10, BLUE);
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
EndDrawing();

+ 12
- 12
examples/models/models_mesh_generation.c View File

@ -110,21 +110,21 @@ int main(void)
EndMode3D();
DrawRectangle(30, mi">400, 310, 30, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(30, mi">400, 310, 30, Fade(DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, mi">410, 10, BLUE);
DrawRectangle(30, n">GetScreenHeight() - 50, 310, 30, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(30, n">GetScreenHeight() - 50, 310, 30, Fade(DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, n">GetScreenHeight() - 50 + 10, 10, BLUE);
switch (currentModel)
{
case 0: DrawText("PLANE", mi">680, 10, 20, DARKBLUE); break;
case 1: DrawText("CUBE", mi">680, 10, 20, DARKBLUE); break;
case 2: DrawText("SPHERE", mi">680, 10, 20, DARKBLUE); break;
case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break;
case 4: DrawText("CYLINDER", mi">680, 10, 20, DARKBLUE); break;
case 5: DrawText("TORUS", mi">680, 10, 20, DARKBLUE); break;
case 6: DrawText("KNOT", mi">680, 10, 20, DARKBLUE); break;
case 7: DrawText("POLY", mi">680, 10, 20, DARKBLUE); break;
case 8: DrawText("Custom (triangle)", mi">580, 10, 20, DARKBLUE); break;
case 0: DrawText("PLANE", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 1: DrawText("CUBE", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 2: DrawText("SPHERE", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 3: DrawText("HEMISPHERE", n">GetScreenWidth() - 160, 10, 20, DARKBLUE); break;
case 4: DrawText("CYLINDER", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 5: DrawText("TORUS", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 6: DrawText("KNOT", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 7: DrawText("POLY", n">GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
case 8: DrawText("Custom (triangle)", n">GetScreenWidth() - 220, 10, 20, DARKBLUE); break;
default: break;
}

+ 3
- 3
examples/models/models_mesh_picking.c View File

@ -226,9 +226,9 @@ int main(void)
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, mi">430, 10, GRAY);
DrawText("Right click mouse to toggle camera controls", 10, n">GetScreenHeight() - 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", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
DrawFPS(10, 10);
@ -245,4 +245,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 1
- 1
examples/models/models_point_rendering.c View File

@ -125,7 +125,7 @@ int main()
EndMode3D();
// Draw UI text
DrawText(TextFormat("Point Count: %d", numPoints), 20, screenHeight - 50, 40, WHITE);
DrawText(TextFormat("Point Count: %d", numPoints), 20, GetScreenHeight() - 50, 40, WHITE);
DrawText("Up - increase points", 20, 70, 20, WHITE);
DrawText("Down - decrease points", 20, 100, 20, WHITE);
DrawText("Space - drawing function", 20, 130, 20, WHITE);

+ 1
- 1
examples/models/models_rlgl_solar_system.c View File

@ -112,7 +112,7 @@ int main(void)
EndMode3D();
DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, MAROON);
DrawText("EARTH ORBITING AROUND THE SUN!", n">GetScreenWidth() - 400, 10, 20, MAROON);
DrawFPS(10, 10);
EndDrawing();

+ 6
- 6
examples/models/models_yaw_pitch_roll.c View File

@ -101,13 +101,13 @@ int main(void)
EndMode3D();
// Draw controls info
DrawRectangle(30, mi">370, 260, 70, Fade(GREEN, 0.5f));
DrawRectangleLines(30, mi">370, 260, 70, Fade(DARKGREEN, 0.5f));
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, mi">380, 10, DARKGRAY);
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, mi">400, 10, DARKGRAY);
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, mi">420, 10, DARKGRAY);
DrawRectangle(30, n">GetScreenHeight() - 80, 260, 70, Fade(GREEN, 0.5f));
DrawRectangleLines(30, n">GetScreenHeight() - 80, 260, 70, Fade(DARKGREEN, 0.5f));
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, n">GetScreenHeight() - 70, 10, DARKGRAY);
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, n">GetScreenHeight() - 50, 10, DARKGRAY);
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, n">GetScreenHeight() - 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", GetScreenWidth() - 240, GetScreenHeight() - 20, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------

+ 3
- 7
examples/shaders/resources/shaders/glsl100/swirl.fs View File

@ -12,19 +12,15 @@ uniform vec4 colDiffuse;
// 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 angle = 0.8;
uniform vec2 size = { 800.0, 450.0 };
uniform vec2 center;
void main()
{
vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize;
vec2 tc = fragTexCoord*size;
tc -= center;
float dist = length(tc);
@ -40,7 +36,7 @@ void main()
}
tc += center;
vec4 color = texture2D(texture0, tc/tspan>exSize)*colDiffuse*fragColor;;
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
gl_FragColor = vec4(color.rgb, 1.0);
}

+ 4
- 8
examples/shaders/resources/shaders/glsl120/swirl.fs View File

@ -10,19 +10,15 @@ uniform vec4 colDiffuse;
// 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 angle = 0.8;
uniform vec2 size = vec2(800.0, 450.0);
uniform vec2 center;
void main()
{
vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize;
vec2 tc = fragTexCoord*size;
tc -= center;
float dist = length(tc);
@ -38,7 +34,7 @@ void main()
}
tc += center;
vec4 color = texture2D(texture0, tc/tspan>exSize)*colDiffuse*fragColor;;
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
gl_FragColor = vec4(color.rgb, 1.0);;
}
}

+ 4
- 8
examples/shaders/resources/shaders/glsl330/swirl.fs View File

@ -13,19 +13,15 @@ out vec4 finalColor;
// 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 angle = 0.8;
uniform vec2 size = vec2(800.0, 450.0);
uniform vec2 center = vec2(200.0, 200.0);
void main()
{
vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize;
vec2 tc = fragTexCoord*size;
tc -= center;
float dist = length(tc);
@ -41,7 +37,7 @@ void main()
}
tc += center;
vec4 color = texture(texture0, tc/tspan>exSize)*colDiffuse*fragColor;;
vec4 color = texture(texture0, tc/size)*colDiffuse*fragColor;;
finalColor = vec4(color.rgb, 1.0);;
}
}

+ 1
- 1
examples/shaders/shaders_basic_pbr.c View File

@ -253,7 +253,7 @@ int main()
DrawText("Toggle lights: [1][2][3][4]", 10, 40, 20, LIGHTGRAY);
DrawText("(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", screenWidth - 320, screenHeight - 20, 10, LIGHTGRAY);
DrawText("(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", GetScreenWidth() - 320, GetScreenHeight() - 20, 10, LIGHTGRAY);
DrawFPS(10, 10);

+ 19
- 9
examples/shaders/shaders_custom_uniform.c View File

@ -35,8 +35,10 @@ int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
int screenWidth = 800;
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)
@ -62,12 +64,11 @@ int main(void)
// 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
int swirlSizeLoc = GetShaderLocation(shader, "size");
int swirlCenterLoc = GetShaderLocation(shader, "center");
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
// 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
//--------------------------------------------------------------------------------------
@ -75,15 +76,24 @@ int main(void)
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
// Create a RenderTexture2D to be used for render to texture
UnloadRenderTexture(target);
target = LoadRenderTexture(screenWidth, screenHeight);
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_ORBITAL);
Vector2 mousePosition = GetMousePosition();
swirlSize[0] = screenWidth;
swirlSize[1] = screenHeight;
SetShaderValue(shader, swirlSizeLoc, swirlSize, SHADER_UNIFORM_VEC2);
swirlCenter[0] = mousePosition.x;
swirlCenter[1] = screenHeight - mousePosition.y;
// Send new value to the shader to be used on drawing
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
//----------------------------------------------------------------------------------
@ -98,7 +108,7 @@ int main(void)
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
DrawText("TEXT DRAWN IN RENDER TEXTURE", mi">200, 10, 30, RED);
DrawText("TEXT DRAWN IN RENDER TEXTURE", n">screenWidth - 600, 10, 30, RED);
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
BeginDrawing();
@ -107,7 +117,7 @@ int main(void)
// Enable shader using the custom uniform
BeginShaderMode(shader);
// 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();
// Draw some 2d text over drawn texture
@ -128,4 +138,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 5
- 5
examples/shaders/shaders_hot_reloading.c View File

@ -51,9 +51,6 @@ int main(void)
int mouseLoc = GetShaderLocation(shader, "mouse");
int timeLoc = GetShaderLocation(shader, "time");
float resolution[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
float totalTime = 0.0f;
bool shaderAutoReloading = false;
@ -65,6 +62,9 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
float resolution[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
totalTime += GetFrameTime();
Vector2 mouse = GetMousePosition();
float mousePos[2] = { mouse.x, mouse.y };
@ -113,14 +113,14 @@ int main(void)
// We only draw a white full-screen rectangle, frame is generated in shader
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
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, mi">430, 10, BLACK);
DrawText(TextFormat("Shader last modification: %s", asctime(localtime(&fragShaderFileModTime))), 10, n">GetScreenHeight() - 20, 10, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------

+ 11
- 8
examples/shaders/shaders_hybrid_render.c View File

@ -69,12 +69,6 @@ int main(void)
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
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
Camera camera = {
@ -87,6 +81,7 @@ int main(void)
// Camera FOV is pre-calculated in the camera Distance.
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
RenderTexture2D target;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -96,6 +91,14 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
// Use Customized function to create writable depth texture buffer
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
UnloadRenderTexture(target);
target = LoadRenderTextureDepthTex(GetScreenWidth(), GetScreenHeight());
Vector2 screenCenter = {.x = GetScreenWidth()/2.0f, .y = GetScreenHeight()/2.0f};
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
UpdateCamera(&camera, CAMERA_ORBITAL);
// Update Camera Postion in the ray march shader.
@ -115,7 +118,7 @@ int main(void)
// Raymarch Scene
rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
BeginShaderMode(shdrRaymarch);
DrawRectangleRec((Rectangle){0,0, (float)screenWidth, (float)screenHeight},WHITE);
DrawRectangleRec((Rectangle){0,0, (float)GetScreenWidth(), (float)GetScreenHeight()},WHITE);
EndShaderMode();
// Rasterize Scene
@ -134,7 +137,7 @@ int main(void)
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2) { 0, 0 }, WHITE);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------

+ 2
- 2
examples/shaders/shaders_model_shader.c View File

@ -88,7 +88,7 @@ int main(void)
EndMode3D();
DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY);
DrawText("(c) Watermill 3D model by Alberto Cano", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
DrawFPS(10, 10);
@ -106,4 +106,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 5
- 3
examples/shaders/shaders_postprocessing.c View File

@ -133,6 +133,8 @@ int main(void)
// Draw
//----------------------------------------------------------------------------------
UnloadRenderTexture(target);
target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
BeginTextureMode(target); // Enable drawing to texture
ClearBackground(RAYWHITE); // Clear texture background
@ -148,17 +150,17 @@ int main(void)
// Render generated texture using selected postprocessing shader
BeginShaderMode(shaders[currentShader]);
// 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)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2){0, 0}, WHITE);
EndShaderMode();
// Draw 2d shapes and text over drawn texture
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
DrawText("(c) Church 3D model by Alberto Cano", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
DrawText("< >", 540, 10, 30, DARKBLUE);
DrawFPS(mi">700, 15);
DrawFPS(n">GetScreenWidth() - 100, 15);
EndDrawing();
//----------------------------------------------------------------------------------
}

+ 10
- 10
examples/shaders/shaders_rounded_rectangle.c View File

@ -112,7 +112,7 @@ int main(void)
DrawText("Rounded rectangle", rec.x - 20, rec.y - 35, 10, DARKGRAY);
// Flip Y axis to match shader coordinate system
rec.y = screenHeight - rec.y - rec.height;
rec.y = GetScreenHeight() - rec.y - rec.height;
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
// Only rectangle color
@ -121,7 +121,7 @@ int main(void)
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
@ -131,7 +131,7 @@ int main(void)
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
DrawText("Rounded rectangle shadow", rec.x - 20, rec.y - 35, 10, DARKGRAY);
rec.y = screenHeight - rec.y - rec.height;
rec.y = GetScreenHeight() - rec.y - rec.height;
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
// Only shadow color
@ -140,7 +140,7 @@ int main(void)
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
@ -150,7 +150,7 @@ int main(void)
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
DrawText("Rounded rectangle border", rec.x - 20, rec.y - 35, 10, DARKGRAY);
rec.y = screenHeight - rec.y - rec.height;
rec.y = GetScreenHeight() - rec.y - rec.height;
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
// Only border color
@ -159,17 +159,17 @@ int main(void)
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
// Draw one more rectangle with all three colors
rec = (Rectangle){ 240, 80, mi">500, 300 };
rec = (Rectangle){ 240, 80, n">GetScreenWidth() - 300, GetScreenHeight() - 150 };
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
DrawText("Rectangle with all three combined", rec.x - 30, rec.y - 45, 10, DARKGRAY);
rec.y = screenHeight - rec.y - rec.height;
rec.y = GetScreenHeight() - rec.y - rec.height;
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
// All three colors
@ -178,10 +178,10 @@ int main(void)
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
DrawText("(c) Rounded rectangle SDF by Iñigo Quilez. MIT License.", screenWidth - 300, screenHeight - 20, 10, BLACK);
DrawText("(c) Rounded rectangle SDF by Iñigo Quilez. MIT License.", GetScreenWidth() - 300, GetScreenHeight() - 20, 10, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------

+ 1
- 1
examples/shaders/shaders_shadowmap.c View File

@ -176,7 +176,7 @@ int main(void)
EndMode3D();
DrawText("Shadows in raylib using the shadowmapping algorithm!", screenWidth - 320, screenHeight - 20, 10, GRAY);
DrawText("Shadows in raylib using the shadowmapping algorithm!", GetScreenWidth() - 320, GetScreenHeight() - 20, 10, GRAY);
DrawText("Use the arrow keys to rotate the light!", 10, 10, 30, RED);
EndDrawing();

+ 14
- 11
examples/shaders/shaders_spotlight.c View File

@ -85,7 +85,7 @@ int main(void)
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 < GetScreenWidth()/2.0; m++)
{
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
}
@ -124,8 +124,8 @@ int main(void)
// and initialize the shader locations
for (int i = 0; i < MAX_SPOTS; i++)
{
spots[i].position.x = (float)GetRandomValue(64, screenWidth - 64);
spots[i].position.y = (float)GetRandomValue(64, screenHeight - 64);
spots[i].position.x = (float)GetRandomValue(64, GetScreenWidth() - 64);
spots[i].position.y = (float)GetRandomValue(64, GetScreenHeight() - 64);
spots[i].speed = (Vector2){ 0, 0 };
while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
@ -152,6 +152,9 @@ int main(void)
//----------------------------------------------------------------------------------
frameCounter++;
sw = (float)GetScreenWidth();
SetShaderValue(shdrSpot, wLoc, &sw, SHADER_UNIFORM_FLOAT);
// Move the stars, resetting them if the go offscreen
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
@ -162,7 +165,7 @@ int main(void)
{
Vector2 mp = GetMousePosition();
spots[i].position.x = mp.x;
spots[i].position.y = screenHeight - mp.y;
spots[i].position.y = GetScreenHeight() - mp.y;
}
else
{
@ -170,9 +173,9 @@ int main(void)
spots[i].position.y += spots[i].speed.y;
if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
if (spots[i].position.x > (screenWidth - 64)) spots[i].speed.x = -spots[i].speed.x;
if (spots[i].position.x > (GetScreenWidth() - 64)) spots[i].speed.x = -spots[i].speed.x;
if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
if (spots[i].position.y > (GetScreenHeight() - 64)) spots[i].speed.y = -spots[i].speed.y;
}
SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
@ -194,8 +197,8 @@ int main(void)
for (int i = 0; i < 16; i++)
{
DrawTexture(texRay,
(int)((screenWidth/2.0f) + cos((frameCounter + i*8)/51.45f)*(screenWidth/2.2f) - 32),
(int)((screenHeight/2.0f) + sin((frameCounter + i*8)/17.87f)*(screenHeight/4.2f)), WHITE);
(int)((GetScreenWidth()/2.0f) + cos((frameCounter + i*8)/51.45f)*(GetScreenWidth()/2.2f) - 32),
(int)((GetScreenHeight()/2.0f) + sin((frameCounter + i*8)/17.87f)*(GetScreenHeight()/4.2f)), WHITE);
}
// Draw spot lights
@ -204,14 +207,14 @@ int main(void)
// a render texture of the full screen used to do screen
// scaling (slight adjustment to shader would be required
// to actually pay attention to the colour!)
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
EndShaderMode();
DrawFPS(10, 10);
DrawText("Move the mouse!", 10, 30, 20, GREEN);
DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
DrawText("Pitch Black", (int)(GetScreenWidth()*0.2f), GetScreenHeight()/2, 20, GREEN);
DrawText("Dark", (int)(GetScreenWidth()*.66f), GetScreenHeight()/2, 20, GREEN);
EndDrawing();
//----------------------------------------------------------------------------------

+ 4
- 2
examples/shaders/shaders_write_depth.c View File

@ -75,6 +75,8 @@ int main(void)
// Draw
//----------------------------------------------------------------------------------
UnloadRenderTexture(target);
target = LoadRenderTextureDepthTex(GetScreenWidth(), GetScreenHeight());
// Draw into our custom render texture (framebuffer)
BeginTextureMode(target);
ClearBackground(WHITE);
@ -94,7 +96,7 @@ int main(void)
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2) { 0, 0 }, WHITE);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
@ -166,4 +168,4 @@ void UnloadRenderTextureDepthTex(RenderTexture2D target)
// queried and deleted before deleting framebuffer
rlUnloadFramebuffer(target.id);
}
}
}

+ 2
- 2
examples/shapes/shapes_bouncing_ball.c View File

@ -67,7 +67,7 @@ int main(void)
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
// On pause, we draw a blinking message
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", mi">350, 200, 30, GRAY);
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", p">(GetScreenWidth() - 100)/2, (GetScreenHeight()- 50)/2, 30, GRAY);
DrawFPS(10, 10);
@ -81,4 +81,4 @@ int main(void)
//----------------------------------------------------------
return 0;
}
}

+ 4
- 4
examples/shapes/shapes_easings_ball_anim.c View File

@ -48,7 +48,7 @@ int main(void)
if (state == 0) // Move ball position X with easing
{
framesCounter++;
ballPositionX = (int)EaseElasticOut((float)framesCounter, -100, screenWidth/2.0f + 100, 120);
ballPositionX = (int)EaseElasticOut((float)framesCounter, -100, GetScreenWidth()/2.0f + 100, 120);
if (framesCounter >= 120)
{
@ -99,10 +99,10 @@ int main(void)
ClearBackground(RAYWHITE);
if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
if (state >= 2) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
DrawCircle(ballPositionX, 200, (float)ballRadius, Fade(RED, 1.0f - ballAlpha));
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", mi">240, 200, 20, BLACK);
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", n">GetScreenWidth()/2 - 140, (GetScreenHeight()/2 - 10), 20, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
@ -114,4 +114,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 6
- 1
examples/shapes/shapes_following_eyes.c View File

@ -46,6 +46,11 @@ int main(void)
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
scleraLeftPosition.x = GetScreenWidth()/2.0f - 100.0f;
scleraLeftPosition.y = GetScreenHeight()/2.0f;
scleraRightPosition.x = GetScreenWidth()/2.0f + 100.0f;
scleraRightPosition.y = GetScreenHeight()/2.0f;
// Update
//----------------------------------------------------------------------------------
irisLeftPosition = GetMousePosition();
@ -108,4 +113,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 5
- 5
examples/shapes/shapes_logo_raylib.c View File

@ -44,11 +44,11 @@ int main(void)
ClearBackground(RAYWHITE);
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK);
DrawRectangle(GetScreenWidth()/2 - 128, GetScreenHeight()/2 - 128, 256, 256, BLACK);
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, BLACK);
DrawText("this is NOT a texture!", mi">350, 370, 10, GRAY);
DrawText("this is NOT a texture!", n">GetScreenWidth()/2 - 50, GetScreenHeight()/2 + 145, 10, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
@ -60,4 +60,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 4
- 1
examples/shapes/shapes_logo_raylib_anim.c View File

@ -48,6 +48,9 @@ int main(void)
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
logoPositionX = GetScreenWidth()/2 - 128;
logoPositionY = GetScreenHeight()/2 - 128;
// Update
//----------------------------------------------------------------------------------
if (state == 0) // State 0: Small box blinking
@ -151,7 +154,7 @@ int main(void)
}
else if (state == 4)
{
DrawText("[R] REPLAY", mi">340, 200, 20, GRAY);
DrawText("[R] REPLAY", n">GetScreenWidth()/2 - 60, GetScreenHeight()/2 - 25, 20, GRAY);
}
EndDrawing();

+ 5
- 5
examples/text/text_draw_3d.c View File

@ -415,23 +415,23 @@ int main(void)
quads += TextLength(text)*2*layers;
char *tmp = (char *)TextFormat("%2i layer(s) | %s camera | %4i quads (%4i verts)", layers, spin? "ORBITAL" : "FREE", quads, quads*4);
int width = MeasureText(tmp, 10);
DrawText(tmp, screenWidth - 20 - width, 10, 10, DARKGREEN);
DrawText(tmp, GetScreenWidth() - 20 - width, 10, 10, DARKGREEN);
tmp = "[Home]/[End] to add/remove 3D text layers";
width = MeasureText(tmp, 10);
DrawText(tmp, screenWidth - 20 - width, 25, 10, DARKGRAY);
DrawText(tmp, GetScreenWidth() - 20 - width, 25, 10, DARKGRAY);
tmp = "[Insert]/[Delete] to increase/decrease distance between layers";
width = MeasureText(tmp, 10);
DrawText(tmp, screenWidth - 20 - width, 40, 10, DARKGRAY);
DrawText(tmp, GetScreenWidth() - 20 - width, 40, 10, DARKGRAY);
tmp = "click the [CUBE] for a random color";
width = MeasureText(tmp, 10);
DrawText(tmp, screenWidth - 20 - width, 55, 10, DARKGRAY);
DrawText(tmp, GetScreenWidth() - 20 - width, 55, 10, DARKGRAY);
tmp = "[Tab] to toggle multicolor mode";
width = MeasureText(tmp, 10);
DrawText(tmp, screenWidth - 20 - width, 70, 10, DARKGRAY);
DrawText(tmp, GetScreenWidth() - 20 - width, 70, 10, DARKGRAY);
//-------------------------------------------------------------------------
DrawFPS(10, 10);

Loading…
Cancel
Save