diff options
| author | raysan5 <[email protected]> | 2021-10-17 19:10:09 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2021-10-17 19:10:09 +0200 |
| commit | c20df9aa47f3a9bdaf974d7e0f6c586a5852fca2 (patch) | |
| tree | b47a2db32069d92e66db034e76ec4c978dfa2c8c /examples/textures | |
| parent | d47d7c000146ed90a3270ba507e4769cf80c86af (diff) | |
| download | raylib-c20df9aa47f3a9bdaf974d7e0f6c586a5852fca2.tar.gz raylib-c20df9aa47f3a9bdaf974d7e0f6c586a5852fca2.zip | |
Reviewed examples
Diffstat (limited to 'examples/textures')
| -rw-r--r-- | examples/textures/textures_polygon.c (renamed from examples/textures/textures_poly.c) | 26 | ||||
| -rw-r--r-- | examples/textures/textures_polygon.png (renamed from examples/textures/textures_poly.png) | bin | 194233 -> 194233 bytes |
2 files changed, 15 insertions, 11 deletions
diff --git a/examples/textures/textures_poly.c b/examples/textures/textures_polygon.c index a2423a4b..9d26505e 100644 --- a/examples/textures/textures_poly.c +++ b/examples/textures/textures_polygon.c @@ -15,7 +15,7 @@ #include "raylib.h" #include "raymath.h" -#define MAX_POINTS 11 // 10 points and back to the start +#define MAX_POINTS 11 // 10 points and back to the start int main(void) { @@ -23,7 +23,10 @@ int main(void) //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [textures] example - textured polygon"); + // Define texture coordinates to map our texture to poly Vector2 texcoords[MAX_POINTS] = { (Vector2){ 0.75f, 0.0f }, (Vector2){ 0.25f, 0.0f }, @@ -38,22 +41,24 @@ int main(void) (Vector2){ 0.75f, 0.0f} // Close the poly }; + // Define the base poly vertices from the UV's + // NOTE: They can be specified in any other way Vector2 points[MAX_POINTS] = { 0 }; - - // Create the poly coords from the UV's - // you don't have to do this you can specify - // them however you want for (int i = 0; i < MAX_POINTS; i++) { points[i].x = (texcoords[i].x - 0.5f)*256.0f; points[i].y = (texcoords[i].y - 0.5f)*256.0f; } + + // Define the vertices drawing position + // NOTE: Initially same as points but updated every frame + Vector2 positions[MAX_POINTS] = { 0 }; + for (int i = 0; i < MAX_POINTS; i++) positions[i] = points[i]; - InitWindow(screenWidth, screenHeight, "raylib [textures] example - textured polygon"); - + // Load texture to be mapped to poly Texture texture = LoadTexture("resources/cat.png"); - float angle = 0.0f; + float angle = 0.0f; // Rotation angle (in degrees) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -63,10 +68,9 @@ int main(void) { // Update //---------------------------------------------------------------------------------- + // Update points rotation with an angle transform + // NOTE: Base points position are not modified angle++; - - Vector2 positions[MAX_POINTS] = { 0 }; - for (int i = 0; i < MAX_POINTS; i++) positions[i] = Vector2Rotate(points[i], angle*DEG2RAD); //---------------------------------------------------------------------------------- diff --git a/examples/textures/textures_poly.png b/examples/textures/textures_polygon.png Binary files differindex b977ada8..b977ada8 100644 --- a/examples/textures/textures_poly.png +++ b/examples/textures/textures_polygon.png |
