浏览代码

Update shaders_rounded_rectangle.c

pull/5096/head
Ray 2 个月前
父节点
当前提交
d45b00b191
共有 1 个文件被更改,包括 7 次插入15 次删除
  1. +7
    -15
      examples/shaders/shaders_rounded_rectangle.c

+ 7
- 15
examples/shaders/shaders_rounded_rectangle.c 查看文件

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [shaders] example - Rounded Rectangle
* raylib [shaders] example - rounded rectangle
*
* Example complexity rating: [] 3/4
*
@ -24,9 +24,8 @@
#endif
//------------------------------------------------------------------------------------
// Declare custom Structs
// Structs definition
//------------------------------------------------------------------------------------
// Rounded rectangle data
typedef struct {
Vector4 cornerRadius; // Individual corner radius (top-left, top-right, bottom-left, bottom-right)
@ -54,7 +53,6 @@ typedef struct {
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
// Create a rounded rectangle and set uniform locations
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 screenHeight = 450;
const Color rectangleColor = BLUE;
const Color shadowColor = DARKBLUE;
const Color borderColor = SKYBLUE;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Rounded Rectangle");
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - rounded rectangle");
// Load the shader
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION),
@ -94,6 +88,10 @@ int main(void)
// Update shader uniforms
UpdateRoundedRectangle(roundedRectangle, shader);
const Color rectangleColor = BLUE;
const Color shadowColor = DARKBLUE;
const Color borderColor = SKYBLUE;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -124,8 +122,6 @@ int main(void)
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
EndShaderMode();
// Draw rectangle shadow using shader
rec = (Rectangle){ 50, 200, 110, 60 };
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);
EndShaderMode();
// Draw rectangle's border using shader
rec = (Rectangle){ 50, 330, 110, 60 };
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);
EndShaderMode();
// Draw one more rectangle with all three colors
rec = (Rectangle){ 240, 80, 500, 300 };
DrawRectangleLines((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);

正在加载...
取消
保存