Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
c5f419fbf7
4 changed files with 107317 additions and 44962 deletions
|
|
@ -5,13 +5,13 @@
|
|||
* This example has been created using raylib 1.8 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2O17 Wilhem Barbier (@nounoursheureux)
|
||||
* Copyright (c) 2O17-2021 Wilhem Barbier (@nounoursheureux) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define NUM_TEXTURES 7 // Currently we have 7 generation algorithms
|
||||
#define NUM_TEXTURES 6 // Currently we have 7 generation algorithms
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
@ -27,7 +27,6 @@ int main(void)
|
|||
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
|
||||
Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE);
|
||||
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
|
||||
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
|
||||
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
|
||||
|
||||
Texture2D textures[NUM_TEXTURES] = { 0 };
|
||||
|
|
@ -37,8 +36,7 @@ int main(void)
|
|||
textures[2] = LoadTextureFromImage(radialGradient);
|
||||
textures[3] = LoadTextureFromImage(checked);
|
||||
textures[4] = LoadTextureFromImage(whiteNoise);
|
||||
textures[5] = LoadTextureFromImage(perlinNoise);
|
||||
textures[6] = LoadTextureFromImage(cellular);
|
||||
textures[5] = LoadTextureFromImage(cellular);
|
||||
|
||||
// Unload image data (CPU RAM)
|
||||
UnloadImage(verticalGradient);
|
||||
|
|
@ -46,7 +44,6 @@ int main(void)
|
|||
UnloadImage(radialGradient);
|
||||
UnloadImage(checked);
|
||||
UnloadImage(whiteNoise);
|
||||
UnloadImage(perlinNoise);
|
||||
UnloadImage(cellular);
|
||||
|
||||
int currentTexture = 0;
|
||||
|
|
@ -84,8 +81,7 @@ int main(void)
|
|||
case 2: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break;
|
||||
case 3: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break;
|
||||
case 4: DrawText("WHITE NOISE", 640, 10, 20, RED); break;
|
||||
case 5: DrawText("PERLIN NOISE", 630, 10, 20, RAYWHITE); break;
|
||||
case 6: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
|
||||
case 5: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
|
|||
100
examples/textures/textures_polygon.c
Normal file
100
examples/textures/textures_polygon.c
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shapes] example - Draw Textured Polygon
|
||||
*
|
||||
* This example has been created using raylib 3.7 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Chris Camacho (@codifies - bedroomcoders.co.uk) and
|
||||
* reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2021 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#define MAX_POINTS 11 // 10 points and back to the start
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
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 },
|
||||
(Vector2){ 0.0f, 0.5f },
|
||||
(Vector2){ 0.0f, 0.75f },
|
||||
(Vector2){ 0.25f, 1.0f},
|
||||
(Vector2){ 0.375f, 0.875f},
|
||||
(Vector2){ 0.625f, 0.875f},
|
||||
(Vector2){ 0.75f, 1.0f},
|
||||
(Vector2){ 1.0f, 0.75f},
|
||||
(Vector2){ 1.0f, 0.5f},
|
||||
(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 };
|
||||
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];
|
||||
|
||||
// Load texture to be mapped to poly
|
||||
Texture texture = LoadTexture("resources/cat.png");
|
||||
|
||||
float angle = 0.0f; // Rotation angle (in degrees)
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update points rotation with an angle transform
|
||||
// NOTE: Base points position are not modified
|
||||
angle++;
|
||||
for (int i = 0; i < MAX_POINTS; i++) positions[i] = Vector2Rotate(points[i], angle*DEG2RAD);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("textured polygon", 20, 20, 20, DARKGRAY);
|
||||
|
||||
DrawTexturePoly(texture, (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 },
|
||||
positions, texcoords, MAX_POINTS, WHITE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/textures/textures_polygon.png
Normal file
BIN
examples/textures/textures_polygon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
|
|
@ -32,8 +32,8 @@ int main(void)
|
|||
Texture2D explosion = LoadTexture("resources/explosion.png");
|
||||
|
||||
// Init variables for animation
|
||||
float frameWidth = explosion.width/NUM_FRAMES_PER_LINE; // Sprite one frame rectangle width
|
||||
float frameHeight = explosion.height/NUM_LINES; // Sprite one frame rectangle height
|
||||
float frameWidth = (float)(explosion.width/NUM_FRAMES_PER_LINE); // Sprite one frame rectangle width
|
||||
float frameHeight = (float)(explosion.height/NUM_LINES); // Sprite one frame rectangle height
|
||||
int currentFrame = 0;
|
||||
int currentLine = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue