mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
Update shaders_rounded_rectangle.c
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [shaders] example - Rounded Rectangle
|
* raylib [shaders] example - rounded rectangle
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
* Example complexity rating: [★★★☆] 3/4
|
||||||
*
|
*
|
||||||
@@ -24,9 +24,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Declare custom Structs
|
// Structs definition
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Rounded rectangle data
|
// Rounded rectangle data
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vector4 cornerRadius; // Individual corner radius (top-left, top-right, bottom-left, bottom-right)
|
Vector4 cornerRadius; // Individual corner radius (top-left, top-right, bottom-left, bottom-right)
|
||||||
@@ -54,7 +53,6 @@ typedef struct {
|
|||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Create a rounded rectangle and set uniform locations
|
// Create a rounded rectangle and set uniform locations
|
||||||
static RoundedRectangle CreateRoundedRectangle(Vector4 cornerRadius, float shadowRadius, Vector2 shadowOffset, float shadowScale, float borderThickness, Shader shader);
|
static RoundedRectangle CreateRoundedRectangle(Vector4 cornerRadius, float shadowRadius, Vector2 shadowOffset, float shadowScale, float borderThickness, Shader shader);
|
||||||
|
|
||||||
@@ -71,11 +69,7 @@ int main(void)
|
|||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
const Color rectangleColor = BLUE;
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - rounded rectangle");
|
||||||
const Color shadowColor = DARKBLUE;
|
|
||||||
const Color borderColor = SKYBLUE;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Rounded Rectangle");
|
|
||||||
|
|
||||||
// Load the shader
|
// Load the shader
|
||||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION),
|
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION),
|
||||||
@@ -94,6 +88,10 @@ int main(void)
|
|||||||
// Update shader uniforms
|
// Update shader uniforms
|
||||||
UpdateRoundedRectangle(roundedRectangle, shader);
|
UpdateRoundedRectangle(roundedRectangle, shader);
|
||||||
|
|
||||||
|
const Color rectangleColor = BLUE;
|
||||||
|
const Color shadowColor = DARKBLUE;
|
||||||
|
const Color borderColor = SKYBLUE;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -124,8 +122,6 @@ int main(void)
|
|||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Draw rectangle shadow using shader
|
// Draw rectangle shadow using shader
|
||||||
rec = (Rectangle){ 50, 200, 110, 60 };
|
rec = (Rectangle){ 50, 200, 110, 60 };
|
||||||
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
||||||
@@ -143,8 +139,6 @@ int main(void)
|
|||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Draw rectangle's border using shader
|
// Draw rectangle's border using shader
|
||||||
rec = (Rectangle){ 50, 330, 110, 60 };
|
rec = (Rectangle){ 50, 330, 110, 60 };
|
||||||
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
||||||
@@ -162,8 +156,6 @@ 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, 500, 300 };
|
||||||
DrawRectangleLines((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);
|
DrawRectangleLines((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);
|
||||||
|
Reference in New Issue
Block a user