changed Color struct to 4 floats
GetRandomValue returns floats added GetRandomInt added Color4ub rgba 0-255 edited examples to work colour palette values could bare a double check!
This commit is contained in:
parent
ea70c47a1a
commit
b4d8f0b5d1
|
|
@ -44,10 +44,10 @@ int main(void)
|
||||||
{
|
{
|
||||||
circles[i].alpha = 0.0f;
|
circles[i].alpha = 0.0f;
|
||||||
circles[i].radius = GetRandomValue(10, 40);
|
circles[i].radius = GetRandomValue(10, 40);
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
circles[i].position.x = GetRandomInt(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
circles[i].position.y = GetRandomInt(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
circles[i].speed = (float)GetRandomInt(1, 100)/2000.0f;
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[(int)GetRandomInt(0, 13)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/mini1111.xm");
|
Music music = LoadMusicStream("resources/mini1111.xm");
|
||||||
|
|
@ -97,11 +97,11 @@ int main(void)
|
||||||
if (circles[i].alpha <= 0.0f)
|
if (circles[i].alpha <= 0.0f)
|
||||||
{
|
{
|
||||||
circles[i].alpha = 0.0f;
|
circles[i].alpha = 0.0f;
|
||||||
circles[i].radius = GetRandomValue(10, 40);
|
circles[i].radius = GetRandomInt(10, 40);
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
circles[i].position.x = GetRandomInt(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
circles[i].position.y = GetRandomInt(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[(int)GetRandomInt(0, 13)];
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
circles[i].speed = (float)GetRandomInt(1, 100)/2000.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ int main(void)
|
||||||
if (!inhibitOgg) PlaySoundMulti(fxOgg);
|
if (!inhibitOgg) PlaySoundMulti(fxOgg);
|
||||||
|
|
||||||
frame = 0;
|
frame = 0;
|
||||||
maxFrame = GetRandomValue(6,12);
|
maxFrame = GetRandomInt(6,12);
|
||||||
}
|
}
|
||||||
|
|
||||||
soundsCounter = GetSoundsPlaying();
|
soundsCounter = GetSoundsPlaying();
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,14 @@ int main(void)
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BUILDINGS; i++)
|
for (int i = 0; i < MAX_BUILDINGS; i++)
|
||||||
{
|
{
|
||||||
buildings[i].width = GetRandomValue(50, 200);
|
buildings[i].width = GetRandomInt(50, 200);
|
||||||
buildings[i].height = GetRandomValue(100, 800);
|
buildings[i].height = GetRandomInt(100, 800);
|
||||||
buildings[i].y = screenHeight - 130 - buildings[i].height;
|
buildings[i].y = screenHeight - 130 - buildings[i].height;
|
||||||
buildings[i].x = -6000 + spacing;
|
buildings[i].x = -6000 + spacing;
|
||||||
|
|
||||||
spacing += buildings[i].width;
|
spacing += buildings[i].width;
|
||||||
|
|
||||||
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
buildColors[i] = (Color){ GetRandomValue(.8, .95), GetRandomValue(.8, .95), GetRandomValue(.8, .95), 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
Camera2D camera = { 0 };
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ int main(void)
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||||
{
|
{
|
||||||
heights[i] = (float)GetRandomValue(1, 12);
|
heights[i] = (float)GetRandomInt(1, 12);
|
||||||
positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) };
|
positions[i] = (Vector3){ GetRandomInt(-15, 15), heights[i]/2, GetRandomInt(-15, 15) };
|
||||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
colors[i] = (Color){ GetRandomValue(.1, 1), GetRandomValue(.1, .3), .1, 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ int main(void)
|
||||||
|
|
||||||
int framesCounter = 0; // Variable used to count frames
|
int framesCounter = 0; // Variable used to count frames
|
||||||
|
|
||||||
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
int randValue = GetRandomInt(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -37,7 +37,7 @@ int main(void)
|
||||||
// Every two seconds (120 frames) a new random value is generated
|
// Every two seconds (120 frames) a new random value is generated
|
||||||
if (((framesCounter/120)%2) == 1)
|
if (((framesCounter/120)%2) == 1)
|
||||||
{
|
{
|
||||||
randValue = GetRandomValue(-8, 5);
|
randValue = GetRandomInt(-8, 5);
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_R))
|
if (IsKeyPressed(KEY_R))
|
||||||
{
|
{
|
||||||
score = GetRandomValue(1000, 2000);
|
score = GetRandomInt(1000, 2000);
|
||||||
hiscore = GetRandomValue(2000, 4000);
|
hiscore = GetRandomInt(2000, 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_ENTER))
|
if (IsKeyPressed(KEY_ENTER))
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ int main(void)
|
||||||
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
||||||
|
|
||||||
Color colors[10] = { 0 };
|
Color colors[10] = { 0 };
|
||||||
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(.5, .95), GetRandomValue(.2, .6), GetRandomValue(.05, .4), 1 };
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -50,7 +50,7 @@ int main(void)
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
// Recalculate random colors for the bars
|
// Recalculate random colors for the bars
|
||||||
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(.5, .95), GetRandomValue(.2, .6), GetRandomValue(.05, .4), 1 };
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main(void)
|
||||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
// Get map image data to be used for collision detection
|
// Get map image data to be used for collision detection
|
||||||
Color *mapPixels = GetImageData(imMap);
|
Color4ub *mapPixels = GetImageData(imMap);
|
||||||
UnloadImage(imMap); // Unload image from RAM
|
UnloadImage(imMap); // Unload image from RAM
|
||||||
|
|
||||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,14 @@ int main(void)
|
||||||
MeshTangents(&model.meshes[0]);
|
MeshTangents(&model.meshes[0]);
|
||||||
|
|
||||||
UnloadMaterial(model.materials[0]); // get rid of default material
|
UnloadMaterial(model.materials[0]); // get rid of default material
|
||||||
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
model.materials[0] = LoadMaterialPBR((Color){ 1, 1, 1, 1 }, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Create lights
|
// Create lights
|
||||||
// NOTE: Lights are added to an internal lights pool automatically
|
// NOTE: Lights are added to an internal lights pool automatically
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader);
|
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 1, 0, 0, 1 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader);
|
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 1, 0, 1 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader);
|
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 1, 1 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader);
|
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 1, 0, 1, 1 }, model.materials[0].shader);
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
|
|
@ -223,7 +223,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||||
|
|
||||||
// Set up material properties color
|
// Set up material properties color
|
||||||
mat.maps[MAP_ALBEDO].color = albedo;
|
mat.maps[MAP_ALBEDO].color = albedo;
|
||||||
mat.maps[MAP_NORMAL].color = (Color){ 128, 128, 255, 255 };
|
mat.maps[MAP_NORMAL].color = (Color){ 0.5, 0.5, 1, 1 };
|
||||||
mat.maps[MAP_METALNESS].value = metalness;
|
mat.maps[MAP_METALNESS].value = metalness;
|
||||||
mat.maps[MAP_ROUGHNESS].value = roughness;
|
mat.maps[MAP_ROUGHNESS].value = roughness;
|
||||||
mat.maps[MAP_OCCLUSION].value = 1.0f;
|
mat.maps[MAP_OCCLUSION].value = 1.0f;
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ void DrawSphereBasic(Color color)
|
||||||
int slices = 16;
|
int slices = 16;
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < (rings + 2); i++)
|
for (int i = 0; i < (rings + 2); i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ void DrawSphereBasic(Color color)
|
||||||
int slices = 16;
|
int slices = 16;
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < (rings + 2); i++)
|
for (int i = 0; i < (rings + 2); i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ void UpdateLightValues(Shader shader, Light light)
|
||||||
SetShaderValue(shader, light.targetLoc, target, UNIFORM_VEC3);
|
SetShaderValue(shader, light.targetLoc, target, UNIFORM_VEC3);
|
||||||
|
|
||||||
// Send to shader light color values
|
// Send to shader light color values
|
||||||
float diff[4] = { (float)light.color.r/(float)255, (float)light.color.g/(float)255, (float)light.color.b/(float)255, (float)light.color.a/(float)255 };
|
float diff[4] = { light.color.r, light.color.g, light.color.b, light.color.a };
|
||||||
SetShaderValue(shader, light.colorLoc, diff, UNIFORM_VEC4);
|
SetShaderValue(shader, light.colorLoc, diff, UNIFORM_VEC4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,9 @@
|
||||||
|
|
||||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||||
|
|
||||||
#define RED (Color){ 230, 41, 55, 255 } // Red
|
#define RED (Color){ 0.89844, 0.16667, 0.21484, 1.0 } // Red
|
||||||
#define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
|
#define DARKGRAY (Color){ 0.3125 , 0.3125 , 0.3125 , 1.0 } // Dark Gray
|
||||||
#define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
|
#define RAYWHITE (Color){ 0.96078, 0.96078, 0.96078, 1.0 } // My own White (raylib logo)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Declaration
|
// Module specific Functions Declaration
|
||||||
|
|
@ -128,7 +128,7 @@ int main(void)
|
||||||
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
||||||
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
||||||
|
|
||||||
rlClearColor(245, 245, 245, 255); // Define clear color
|
rlClearColor(.95, .95, .95, 1); // Define clear color
|
||||||
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
||||||
|
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
|
|
@ -232,7 +232,7 @@ static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, i
|
||||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2i(position.x, position.y);
|
rlVertex2i(position.x, position.y);
|
||||||
rlVertex2i(position.x, position.y + size.y);
|
rlVertex2i(position.x, position.y + size.y);
|
||||||
|
|
@ -292,7 +292,7 @@ static void DrawCube(Vector3 position, float width, float height, float length,
|
||||||
//rlRotatef(45, 0, 1, 0);
|
//rlRotatef(45, 0, 1, 0);
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
// Front Face -----------------------------------------------------
|
// Front Face -----------------------------------------------------
|
||||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||||
|
|
@ -364,7 +364,7 @@ static void DrawCubeWires(Vector3 position, float width, float height, float len
|
||||||
//rlRotatef(45, 0, 1, 0);
|
//rlRotatef(45, 0, 1, 0);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
// Front Face -----------------------------------------------------
|
// Front Face -----------------------------------------------------
|
||||||
// Bottom Line
|
// Bottom Line
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Physics body creation inputs
|
// Physics body creation inputs
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomInt(20, 80), GetRandomInt(3, 8), 10);
|
||||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomInt(10, 45), 10);
|
||||||
|
|
||||||
// Destroy falling physics bodies
|
// Destroy falling physics bodies
|
||||||
int bodiesCount = GetPhysicsBodiesCount();
|
int bodiesCount = GetPhysicsBodiesCount();
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ int main(void)
|
||||||
SetPhysicsGravity(0, 0);
|
SetPhysicsGravity(0, 0);
|
||||||
|
|
||||||
// Create random polygon physics body to shatter
|
// Create random polygon physics body to shatter
|
||||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomInt(80, 200), GetRandomInt(3, 8), 10);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -57,7 +57,7 @@ int main(void)
|
||||||
if (needsReset)
|
if (needsReset)
|
||||||
{
|
{
|
||||||
// Create random polygon physics body to shatter
|
// Create random polygon physics body to shatter
|
||||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomInt(80, 200), GetRandomInt(3, 8), 10);
|
||||||
needsReset = false;
|
needsReset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,7 @@ void UpdateLightValues(Shader shader, Light light)
|
||||||
SetShaderValue(shader, light.targetLoc, target, UNIFORM_VEC3);
|
SetShaderValue(shader, light.targetLoc, target, UNIFORM_VEC3);
|
||||||
|
|
||||||
// Send to shader light color values
|
// Send to shader light color values
|
||||||
float color[4] = { (float)light.color.r/(float)255, (float)light.color.g/(float)255,
|
float color[4] = { light.color.r, light.color.g, light.color.b, light.color.a };
|
||||||
(float)light.color.b/(float)255, (float)light.color.a/(float)255 };
|
|
||||||
SetShaderValue(shader, light.colorLoc, color, UNIFORM_VEC4);
|
SetShaderValue(shader, light.colorLoc, color, UNIFORM_VEC4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText(TextFormat("Use KEY_UP/KEY_DOWN to change fog density [%.2f]", fogDensity), 10, 10, 20, RAYWHITE);
|
DrawText(TextFormat("Use KEY_UP/KEY_DOWN to change fog density [%.2f]", fogDensity), 10, 10, 20, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Draw horizontal screen-wide rectangles with increasing "palette index"
|
// Draw horizontal screen-wide rectangles with increasing "palette index"
|
||||||
// The used palette index is encoded in the RGB components of the pixel
|
// The used palette index is encoded in the RGB components of the pixel
|
||||||
DrawRectangle(0, lineHeight*i, GetScreenWidth(), lineHeight, (Color){ i, i, i, 255 });
|
DrawRectangle(0, lineHeight*i, GetScreenWidth(), lineHeight, (Color){ (float)i/255, 0, 0, 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
|
||||||
|
|
@ -303,18 +303,18 @@ int main(int argc, char **argv)
|
||||||
static void RandomizeEmoji(void)
|
static void RandomizeEmoji(void)
|
||||||
{
|
{
|
||||||
hovered = selected = -1;
|
hovered = selected = -1;
|
||||||
int start = GetRandomValue(45, 360);
|
int start = GetRandomInt(45, 360);
|
||||||
|
|
||||||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
for (int i = 0; i < SIZEOF(emoji); ++i)
|
||||||
{
|
{
|
||||||
// 0-179 emoji codepoints (from emoji char array) each 4bytes + null char
|
// 0-179 emoji codepoints (from emoji char array) each 4bytes + null char
|
||||||
emoji[i].index = GetRandomValue(0, 179)*5;
|
emoji[i].index = GetRandomInt(0, 179)*5;
|
||||||
|
|
||||||
// Generate a random color for this emoji
|
// Generate a random color for this emoji
|
||||||
Vector3 hsv = {(start*(i + 1))%360, 0.6f, 0.85f};
|
Vector3 hsv = {(start*(i + 1))%360, 0.6f, 0.85f};
|
||||||
emoji[i].color = Fade(ColorFromHSV(hsv), 0.8f);
|
emoji[i].color = Fade(ColorFromHSV(hsv), 0.8f);
|
||||||
|
|
||||||
// Set a random message for this emoji
|
// Set a random message for this emoji
|
||||||
emoji[i].message = GetRandomValue(0, SIZEOF(messages) - 1);
|
emoji[i].message = GetRandomInt(0, SIZEOF(messages) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,11 @@ int main(void)
|
||||||
if (bunniesCount < MAX_BUNNIES)
|
if (bunniesCount < MAX_BUNNIES)
|
||||||
{
|
{
|
||||||
bunnies[bunniesCount].position = GetMousePosition();
|
bunnies[bunniesCount].position = GetMousePosition();
|
||||||
bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f;
|
bunnies[bunniesCount].speed.x = (float)GetRandomInt(-250, 250)/60.0f;
|
||||||
bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f;
|
bunnies[bunniesCount].speed.y = (float)GetRandomInt(-250, 250)/60.0f;
|
||||||
bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240),
|
bunnies[bunniesCount].color = (Color){ GetRandomValue(0.5, .9),
|
||||||
GetRandomValue(80, 240),
|
GetRandomValue(.8, .9),
|
||||||
GetRandomValue(100, 240), 255 };
|
GetRandomValue(.5, .9), 1 };
|
||||||
bunniesCount++;
|
bunniesCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ int main(void)
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
|
Color4ub *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
|
||||||
UpdateTexture(texture, pixels); // Update texture with new image data
|
UpdateTexture(texture, pixels); // Update texture with new image data
|
||||||
free(pixels); // Unload pixels data from RAM
|
free(pixels); // Unload pixels data from RAM
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ int main(void)
|
||||||
for (int i = 0; i < MAX_PARTICLES; i++)
|
for (int i = 0; i < MAX_PARTICLES; i++)
|
||||||
{
|
{
|
||||||
mouseTail[i].position = (Vector2){ 0, 0 };
|
mouseTail[i].position = (Vector2){ 0, 0 };
|
||||||
mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
|
mouseTail[i].color = (Color){ GetRandomValue(0, 1), GetRandomValue(0, 1), GetRandomValue(0, 1), 1 };
|
||||||
mouseTail[i].alpha = 1.0f;
|
mouseTail[i].alpha = 1.0f;
|
||||||
mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f;
|
mouseTail[i].size = (float)GetRandomInt(1, 30)/20.0f;
|
||||||
mouseTail[i].rotation = (float)GetRandomValue(0, 360);
|
mouseTail[i].rotation = (float)GetRandomInt(0, 360);
|
||||||
mouseTail[i].active = false;
|
mouseTail[i].active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,14 @@ int main(void)
|
||||||
int height = 480;
|
int height = 480;
|
||||||
|
|
||||||
// Dynamic memory allocation to store pixels data (Color type)
|
// Dynamic memory allocation to store pixels data (Color type)
|
||||||
Color *pixels = (Color *)malloc(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)malloc(width*height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = ORANGE;
|
if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = (Color4ub){ 255, 0.62891*255, 0.0, 255 }; // orange
|
||||||
else pixels[y*width + x] = GOLD;
|
else pixels[y*width + x] = (Color4ub){ 255, 0.79297*255, 0.0, 255 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
60
src/core.c
60
src/core.c
|
|
@ -1600,18 +1600,24 @@ double GetTime(void)
|
||||||
// Returns hexadecimal value for a Color
|
// Returns hexadecimal value for a Color
|
||||||
int ColorToInt(Color color)
|
int ColorToInt(Color color)
|
||||||
{
|
{
|
||||||
return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
|
Color4ub c;
|
||||||
|
c.r = color.r * 255;
|
||||||
|
c.g = color.g * 255;
|
||||||
|
c.b = color.b * 255;
|
||||||
|
c.a = color.a * 255;
|
||||||
|
|
||||||
|
return (((int)c.r << 24) | ((int)c.g << 16) | ((int)c.b << 8) | (int)c.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns color normalized as float [0..1]
|
// Returns color normalized as float [0..1]
|
||||||
Vector4 ColorNormalize(Color color)
|
Color Color4ubNormalize(Color4ub color)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Color result;
|
||||||
|
|
||||||
result.x = (float)color.r/255.0f;
|
result.r = (float)color.r/255.0f;
|
||||||
result.y = (float)color.g/255.0f;
|
result.g = (float)color.g/255.0f;
|
||||||
result.z = (float)color.b/255.0f;
|
result.b = (float)color.b/255.0f;
|
||||||
result.w = (float)color.a/255.0f;
|
result.a = (float)color.a/255.0f;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -1620,7 +1626,7 @@ Vector4 ColorNormalize(Color color)
|
||||||
// NOTE: Hue is returned as degrees [0..360]
|
// NOTE: Hue is returned as degrees [0..360]
|
||||||
Vector3 ColorToHSV(Color color)
|
Vector3 ColorToHSV(Color color)
|
||||||
{
|
{
|
||||||
Vector3 rgb = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
|
Vector3 rgb = { color.r, color.g, color.b };
|
||||||
Vector3 hsv = { 0.0f, 0.0f, 0.0f };
|
Vector3 hsv = { 0.0f, 0.0f, 0.0f };
|
||||||
float min, max, delta;
|
float min, max, delta;
|
||||||
|
|
||||||
|
|
@ -1673,7 +1679,7 @@ Vector3 ColorToHSV(Color color)
|
||||||
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
|
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
|
||||||
Color ColorFromHSV(Vector3 hsv)
|
Color ColorFromHSV(Vector3 hsv)
|
||||||
{
|
{
|
||||||
Color color = { 0, 0, 0, 255 };
|
Color color = { 0, 0, 0, 1 };
|
||||||
float h = hsv.x, s = hsv.y, v = hsv.z;
|
float h = hsv.x, s = hsv.y, v = hsv.z;
|
||||||
|
|
||||||
// Red channel
|
// Red channel
|
||||||
|
|
@ -1682,7 +1688,7 @@ Color ColorFromHSV(Vector3 hsv)
|
||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.r = (v - v*s*k)*255;
|
color.r = v - v*s*k;
|
||||||
|
|
||||||
// Green channel
|
// Green channel
|
||||||
k = fmod((3.0f + h/60.0f), 6);
|
k = fmod((3.0f + h/60.0f), 6);
|
||||||
|
|
@ -1690,7 +1696,7 @@ Color ColorFromHSV(Vector3 hsv)
|
||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.g = (v - v*s*k)*255;
|
color.g = v - v*s*k;
|
||||||
|
|
||||||
// Blue channel
|
// Blue channel
|
||||||
k = fmod((1.0f + h/60.0f), 6);
|
k = fmod((1.0f + h/60.0f), 6);
|
||||||
|
|
@ -1698,7 +1704,7 @@ Color ColorFromHSV(Vector3 hsv)
|
||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.b = (v - v*s*k)*255;
|
color.b = v - v*s*k;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
@ -1708,16 +1714,16 @@ Color GetColor(int hexValue)
|
||||||
{
|
{
|
||||||
Color color;
|
Color color;
|
||||||
|
|
||||||
color.r = (unsigned char)(hexValue >> 24) & 0xFF;
|
color.r = ((hexValue >> 24) & 0xFF) / 255;
|
||||||
color.g = (unsigned char)(hexValue >> 16) & 0xFF;
|
color.g = ((hexValue >> 16) & 0xFF) / 255;
|
||||||
color.b = (unsigned char)(hexValue >> 8) & 0xFF;
|
color.b = ((hexValue >> 8) & 0xFF) / 255;
|
||||||
color.a = (unsigned char)hexValue & 0xFF;
|
color.a = (hexValue & 0xFF) / 255;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a random value between min and max (both included)
|
// Returns a random integer between min and max (both included)
|
||||||
int GetRandomValue(int min, int max)
|
int GetRandomInt(int min, int max)
|
||||||
{
|
{
|
||||||
if (min > max)
|
if (min > max)
|
||||||
{
|
{
|
||||||
|
|
@ -1729,13 +1735,29 @@ int GetRandomValue(int min, int max)
|
||||||
return (rand()%(abs(max - min) + 1) + min);
|
return (rand()%(abs(max - min) + 1) + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a random float between min and max (both included)
|
||||||
|
// as this is often used to make random colours it was
|
||||||
|
// changed to produce floats, GetRandomInt is the
|
||||||
|
// original version.
|
||||||
|
float GetRandomValue(float min, float max)
|
||||||
|
{
|
||||||
|
if (min > max)
|
||||||
|
{
|
||||||
|
int tmp = max;
|
||||||
|
max = min;
|
||||||
|
min = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float)rand()/(float)(RAND_MAX/(max-min))+min;
|
||||||
|
}
|
||||||
|
|
||||||
// Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
// Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||||
Color Fade(Color color, float alpha)
|
Color Fade(Color color, float alpha)
|
||||||
{
|
{
|
||||||
if (alpha < 0.0f) alpha = 0.0f;
|
if (alpha < 0.0f) alpha = 0.0f;
|
||||||
else if (alpha > 1.0f) alpha = 1.0f;
|
else if (alpha > 1.0f) alpha = 1.0f;
|
||||||
|
|
||||||
return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)};
|
return (Color){color.r, color.g, color.b, alpha};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup window configuration flags (view FLAGS)
|
// Setup window configuration flags (view FLAGS)
|
||||||
|
|
|
||||||
99
src/models.c
99
src/models.c
|
|
@ -104,7 +104,7 @@ static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
|
||||||
void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
|
void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex3f(startPos.x, startPos.y, startPos.z);
|
rlVertex3f(startPos.x, startPos.y, startPos.z);
|
||||||
rlVertex3f(endPos.x, endPos.y, endPos.z);
|
rlVertex3f(endPos.x, endPos.y, endPos.z);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -122,7 +122,7 @@ void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rota
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
for (int i = 0; i < 360; i += 10)
|
for (int i = 0; i < 360; i += 10)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex3f(sinf(DEG2RAD*i)*radius, cosf(DEG2RAD*i)*radius, 0.0f);
|
rlVertex3f(sinf(DEG2RAD*i)*radius, cosf(DEG2RAD*i)*radius, 0.0f);
|
||||||
rlVertex3f(sinf(DEG2RAD*(i + 10))*radius, cosf(DEG2RAD*(i + 10))*radius, 0.0f);
|
rlVertex3f(sinf(DEG2RAD*(i + 10))*radius, cosf(DEG2RAD*(i + 10))*radius, 0.0f);
|
||||||
|
|
@ -148,7 +148,7 @@ void DrawCube(Vector3 position, float width, float height, float length, Color c
|
||||||
//rlScalef(1.0f, 1.0f, 1.0f); // NOTE: Vertices are directly scaled on definition
|
//rlScalef(1.0f, 1.0f, 1.0f); // NOTE: Vertices are directly scaled on definition
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
// Front face
|
// Front face
|
||||||
rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left
|
rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left
|
||||||
|
|
@ -226,7 +226,7 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
// Front Face -----------------------------------------------------
|
// Front Face -----------------------------------------------------
|
||||||
// Bottom Line
|
// Bottom Line
|
||||||
|
|
@ -308,7 +308,7 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
|
||||||
//rlScalef(2.0f, 2.0f, 2.0f);
|
//rlScalef(2.0f, 2.0f, 2.0f);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
// Front Face
|
// Front Face
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
|
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
|
||||||
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
|
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
|
||||||
|
|
@ -369,7 +369,7 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
|
||||||
rlScalef(radius, radius, radius);
|
rlScalef(radius, radius, radius);
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < (rings + 2); i++)
|
for (int i = 0; i < (rings + 2); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -412,7 +412,7 @@ void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Col
|
||||||
rlScalef(radius, radius, radius);
|
rlScalef(radius, radius, radius);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < (rings + 2); i++)
|
for (int i = 0; i < (rings + 2); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -457,7 +457,7 @@ void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float h
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
if (radiusTop > 0)
|
if (radiusTop > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -516,7 +516,7 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < 360; i += 360/sides)
|
for (int i = 0; i < 360; i += 360/sides)
|
||||||
{
|
{
|
||||||
|
|
@ -547,7 +547,7 @@ void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
||||||
rlScalef(size.x, 1.0f, size.y);
|
rlScalef(size.x, 1.0f, size.y);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlNormal3f(0.0f, 1.0f, 0.0f);
|
rlNormal3f(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
rlVertex3f(-0.5f, 0.0f, -0.5f);
|
rlVertex3f(-0.5f, 0.0f, -0.5f);
|
||||||
|
|
@ -564,8 +564,8 @@ void DrawRay(Ray ray, Color color)
|
||||||
float scale = 10000;
|
float scale = 10000;
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex3f(ray.position.x, ray.position.y, ray.position.z);
|
rlVertex3f(ray.position.x, ray.position.y, ray.position.z);
|
||||||
rlVertex3f(ray.position.x + ray.direction.x*scale, ray.position.y + ray.direction.y*scale, ray.position.z + ray.direction.z*scale);
|
rlVertex3f(ray.position.x + ray.direction.x*scale, ray.position.y + ray.direction.y*scale, ray.position.z + ray.direction.z*scale);
|
||||||
|
|
@ -1775,7 +1775,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
|
||||||
int mapX = heightmap.width;
|
int mapX = heightmap.width;
|
||||||
int mapZ = heightmap.height;
|
int mapZ = heightmap.height;
|
||||||
|
|
||||||
Color *pixels = GetImageData(heightmap);
|
Color4ub *pixels = GetImageData(heightmap);
|
||||||
|
|
||||||
// NOTE: One vertex per pixel
|
// NOTE: One vertex per pixel
|
||||||
mesh.triangleCount = (mapX-1)*(mapZ-1)*2; // One quad every four pixels
|
mesh.triangleCount = (mapX-1)*(mapZ-1)*2; // One quad every four pixels
|
||||||
|
|
@ -1881,7 +1881,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
||||||
Mesh mesh = { 0 };
|
Mesh mesh = { 0 };
|
||||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||||
|
|
||||||
Color *cubicmapPixels = GetImageData(cubicmap);
|
Color4ub *cubicmapPixels = GetImageData(cubicmap);
|
||||||
|
|
||||||
int mapWidth = cubicmap.width;
|
int mapWidth = cubicmap.width;
|
||||||
int mapHeight = cubicmap.height;
|
int mapHeight = cubicmap.height;
|
||||||
|
|
@ -2385,18 +2385,15 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
|
||||||
|
|
||||||
for (int i = 0; i < model.meshCount; i++)
|
for (int i = 0; i < model.meshCount; i++)
|
||||||
{
|
{
|
||||||
// TODO: Review color + tint premultiplication mechanism
|
Color s = model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color;
|
||||||
Color color = model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color;
|
Color c = s;
|
||||||
|
c.r *= tint.r; // mix material colour with tint
|
||||||
Color colorTint = WHITE;
|
c.g *= tint.g;
|
||||||
colorTint.r = ((color.r/255)*(tint.r/255))*255;
|
c.b *= tint.b;
|
||||||
colorTint.g = ((color.g/255)*(tint.g/255))*255;
|
c.a *= tint.a;
|
||||||
colorTint.b = ((color.b/255)*(tint.b/255))*255;
|
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = c;
|
||||||
colorTint.a = ((color.a/255)*(tint.a/255))*255;
|
|
||||||
|
|
||||||
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = colorTint;
|
|
||||||
rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
|
rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
|
||||||
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = color;
|
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = s; // restore material colour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2464,7 +2461,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
|
||||||
rlEnableTexture(texture.id);
|
rlEnableTexture(texture.id);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
rlColor4f(tint.r, tint.g, tint.b, tint.a);
|
||||||
|
|
||||||
// Bottom-left corner for texture and quad
|
// Bottom-left corner for texture and quad
|
||||||
rlTexCoord2f((float)sourceRec.x/texture.width, (float)sourceRec.y/texture.height);
|
rlTexCoord2f((float)sourceRec.x/texture.width, (float)sourceRec.y/texture.height);
|
||||||
|
|
@ -2915,18 +2912,18 @@ static Model LoadOBJ(const char *fileName)
|
||||||
model.materials[m].maps[MAP_DIFFUSE].texture = GetTextureDefault(); // Get default texture, in case no texture is defined
|
model.materials[m].maps[MAP_DIFFUSE].texture = GetTextureDefault(); // Get default texture, in case no texture is defined
|
||||||
|
|
||||||
if (materials[m].diffuse_texname != NULL) model.materials[m].maps[MAP_DIFFUSE].texture = LoadTexture(materials[m].diffuse_texname); //char *diffuse_texname; // map_Kd
|
if (materials[m].diffuse_texname != NULL) model.materials[m].maps[MAP_DIFFUSE].texture = LoadTexture(materials[m].diffuse_texname); //char *diffuse_texname; // map_Kd
|
||||||
model.materials[m].maps[MAP_DIFFUSE].color = (Color){ (float)(materials[m].diffuse[0]*255.0f), (float)(materials[m].diffuse[1]*255.0f), (float)(materials[m].diffuse[2]*255.0f), 255 }; //float diffuse[3];
|
model.materials[m].maps[MAP_DIFFUSE].color = (Color){ (float)(materials[m].diffuse[0]), (float)(materials[m].diffuse[1]), (float)(materials[m].diffuse[2]), 1 }; //float diffuse[3];
|
||||||
model.materials[m].maps[MAP_DIFFUSE].value = 0.0f;
|
model.materials[m].maps[MAP_DIFFUSE].value = 0.0f;
|
||||||
|
|
||||||
if (materials[m].specular_texname != NULL) model.materials[m].maps[MAP_SPECULAR].texture = LoadTexture(materials[m].specular_texname); //char *specular_texname; // map_Ks
|
if (materials[m].specular_texname != NULL) model.materials[m].maps[MAP_SPECULAR].texture = LoadTexture(materials[m].specular_texname); //char *specular_texname; // map_Ks
|
||||||
model.materials[m].maps[MAP_SPECULAR].color = (Color){ (float)(materials[m].specular[0]*255.0f), (float)(materials[m].specular[1]*255.0f), (float)(materials[m].specular[2]*255.0f), 255 }; //float specular[3];
|
model.materials[m].maps[MAP_SPECULAR].color = (Color){ (float)(materials[m].specular[0]), (float)(materials[m].specular[1]), (float)(materials[m].specular[2]), 1 }; //float specular[3];
|
||||||
model.materials[m].maps[MAP_SPECULAR].value = 0.0f;
|
model.materials[m].maps[MAP_SPECULAR].value = 0.0f;
|
||||||
|
|
||||||
if (materials[m].bump_texname != NULL) model.materials[m].maps[MAP_NORMAL].texture = LoadTexture(materials[m].bump_texname); //char *bump_texname; // map_bump, bump
|
if (materials[m].bump_texname != NULL) model.materials[m].maps[MAP_NORMAL].texture = LoadTexture(materials[m].bump_texname); //char *bump_texname; // map_bump, bump
|
||||||
model.materials[m].maps[MAP_NORMAL].color = WHITE;
|
model.materials[m].maps[MAP_NORMAL].color = WHITE;
|
||||||
model.materials[m].maps[MAP_NORMAL].value = materials[m].shininess;
|
model.materials[m].maps[MAP_NORMAL].value = materials[m].shininess;
|
||||||
|
|
||||||
model.materials[m].maps[MAP_EMISSION].color = (Color){ (float)(materials[m].emission[0]*255.0f), (float)(materials[m].emission[1]*255.0f), (float)(materials[m].emission[2]*255.0f), 255 }; //float emission[3];
|
model.materials[m].maps[MAP_EMISSION].color = (Color){ (float)(materials[m].emission[0]), (float)(materials[m].emission[1]), (float)(materials[m].emission[2]), 1 }; //float emission[3];
|
||||||
|
|
||||||
if (materials[m].displacement_texname != NULL) model.materials[m].maps[MAP_HEIGHT].texture = LoadTexture(materials[m].displacement_texname); //char *displacement_texname; // disp
|
if (materials[m].displacement_texname != NULL) model.materials[m].maps[MAP_HEIGHT].texture = LoadTexture(materials[m].displacement_texname); //char *displacement_texname; // disp
|
||||||
}
|
}
|
||||||
|
|
@ -3394,12 +3391,25 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Image rimage = LoadImage(TextFormat("%s/%s", texPath, image->uri));
|
char *textureName = image->uri;
|
||||||
|
char *texturePath;
|
||||||
|
// path can be null!
|
||||||
|
if (texPath==0) {
|
||||||
|
texturePath = RL_MALLOC(strlen(textureName));
|
||||||
|
strcpy(texturePath, textureName);
|
||||||
|
} else {
|
||||||
|
texturePath = RL_MALLOC(strlen(texPath) + strlen(textureName) + 2);
|
||||||
|
strcpy(texturePath, texPath);
|
||||||
|
strcat(texturePath, "/");
|
||||||
|
strcat(texturePath, textureName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Image rimage = LoadImage(texturePath);
|
||||||
// TODO: Tint shouldn't be applied here!
|
// TODO: Tint shouldn't be applied here!
|
||||||
ImageColorTint(&rimage, tint);
|
ImageColorTint(&rimage, tint);
|
||||||
texture = LoadTextureFromImage(rimage);
|
texture = LoadTextureFromImage(rimage);
|
||||||
UnloadImage(rimage);
|
UnloadImage(rimage);
|
||||||
|
RL_FREE(texturePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (image->buffer_view)
|
else if (image->buffer_view)
|
||||||
|
|
@ -3424,10 +3434,17 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
|
||||||
ImageColorTint(&rimage, tint);
|
ImageColorTint(&rimage, tint);
|
||||||
texture = LoadTextureFromImage(rimage);
|
texture = LoadTextureFromImage(rimage);
|
||||||
UnloadImage(rimage);
|
UnloadImage(rimage);
|
||||||
|
free(raw);
|
||||||
|
free(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Image rimage = LoadImageEx(&tint, 1, 1);
|
Color4ub c;
|
||||||
|
c.r = tint.r * 255;
|
||||||
|
c.g = tint.g * 255;
|
||||||
|
c.b = tint.b * 255;
|
||||||
|
c.a = tint.a * 255;
|
||||||
|
Image rimage = LoadImageEx(&c, 1, 1);
|
||||||
texture = LoadTextureFromImage(rimage);
|
texture = LoadTextureFromImage(rimage);
|
||||||
UnloadImage(rimage);
|
UnloadImage(rimage);
|
||||||
}
|
}
|
||||||
|
|
@ -3519,7 +3536,7 @@ static Model LoadGLTF(const char *fileName)
|
||||||
for (int i = 0; i < model.materialCount - 1; i++)
|
for (int i = 0; i < model.materialCount - 1; i++)
|
||||||
{
|
{
|
||||||
model.materials[i] = LoadMaterialDefault();
|
model.materials[i] = LoadMaterialDefault();
|
||||||
Color tint = (Color){ 255, 255, 255, 255 };
|
Color tint = (Color){ 1, 1, 1, 1 };
|
||||||
const char *texPath = GetDirectoryPath(fileName);
|
const char *texPath = GetDirectoryPath(fileName);
|
||||||
|
|
||||||
//Ensure material follows raylib support for PBR (metallic/roughness flow)
|
//Ensure material follows raylib support for PBR (metallic/roughness flow)
|
||||||
|
|
@ -3528,16 +3545,20 @@ static Model LoadGLTF(const char *fileName)
|
||||||
float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor;
|
float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor;
|
||||||
float metallic = data->materials[i].pbr_metallic_roughness.metallic_factor;
|
float metallic = data->materials[i].pbr_metallic_roughness.metallic_factor;
|
||||||
|
|
||||||
// NOTE: Material name not used for the moment
|
if (model.materials[i].name && data->materials[i].name) {
|
||||||
//if (model.materials[i].name && data->materials[i].name) strcpy(model.materials[i].name, data->materials[i].name);
|
strcpy(model.materials[i].name, data->materials[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: REview: shouldn't these be *255 ???
|
tint.r = data->materials[i].pbr_metallic_roughness.base_color_factor[0];
|
||||||
tint.r = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[0]*255);
|
tint.g = data->materials[i].pbr_metallic_roughness.base_color_factor[1];
|
||||||
tint.g = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[1]*255);
|
tint.b = data->materials[i].pbr_metallic_roughness.base_color_factor[2];
|
||||||
tint.b = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[2]*255);
|
tint.a = data->materials[i].pbr_metallic_roughness.base_color_factor[3];
|
||||||
tint.a = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[3]*255);
|
|
||||||
|
|
||||||
|
// for now putting the metallic roughness base colour
|
||||||
|
// as the diffuse colour, so at least none textured
|
||||||
|
// materials look okay
|
||||||
model.materials[i].maps[MAP_ROUGHNESS].color = tint;
|
model.materials[i].maps[MAP_ROUGHNESS].color = tint;
|
||||||
|
model.materials[i].maps[MAP_DIFFUSE].color = tint;
|
||||||
|
|
||||||
if (data->materials[i].pbr_metallic_roughness.base_color_texture.texture)
|
if (data->materials[i].pbr_metallic_roughness.base_color_texture.texture)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
75
src/raylib.h
75
src/raylib.h
|
|
@ -115,35 +115,35 @@
|
||||||
#define CLITERAL(type) (type)
|
#define CLITERAL(type) (type)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Some Basic Colors
|
// Some Basic Colors (NOTE may bare checking with old 0-255 values in case I miss typed)
|
||||||
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
||||||
#define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray
|
#define LIGHTGRAY CLITERAL(Color){ 0.78125, 0.78125, 0.78125, 1.0 } // Light Gray
|
||||||
#define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray
|
#define GRAY CLITERAL(Color){ 0.50780, 0.50780, 0.50780, 1.0 } // Gray
|
||||||
#define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray
|
#define DARKGRAY CLITERAL(Color){ 0.3125 , 0.3125 , 0.3125 , 1.0 } // Dark Gray
|
||||||
#define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow
|
#define YELLOW CLITERAL(Color){ 0.98828, 0.97265, 0.0 , 1.0 } // Yellow
|
||||||
#define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold
|
#define GOLD CLITERAL(Color){ 1.0 , 0.79297, 0.0 , 1.0 } // Gold
|
||||||
#define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange
|
#define ORANGE CLITERAL(Color){ 1.0 , 0.62891, 0.0 , 1.0 } // Orange
|
||||||
#define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink
|
#define PINK CLITERAL(Color){ 1.0 , 0.42578, 0.75781, 1.0 } // Pink
|
||||||
#define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red
|
#define RED CLITERAL(Color){ 0.89844, 0.16667, 0.21484, 1.0 } // Red
|
||||||
#define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon
|
#define MAROON CLITERAL(Color){ 0.74218, 0.12891, 0.21484, 1.0 } // Maroon
|
||||||
#define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green
|
#define GREEN CLITERAL(Color){ 0 , 0.89412, 0.1875 , 1.0 } // Green
|
||||||
#define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime
|
#define LIME CLITERAL(Color){ 0 , 0.61719, 0.18359, 1.0 } // Lime
|
||||||
#define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green
|
#define DARKGREEN CLITERAL(Color){ 0 , 0.45703, 0.17188, 1.0 } // Dark Green
|
||||||
#define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue
|
#define SKYBLUE CLITERAL(Color){ 0.39844, 0.74609, 1.0 , 1.0 } // Sky Blue
|
||||||
#define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue
|
#define BLUE CLITERAL(Color){ 0 , 0.47266, 0.94141, 1.0 } // Blue
|
||||||
#define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue
|
#define DARKBLUE CLITERAL(Color){ 0 , 0.32031, 0.67188, 1.0 } // Dark Blue
|
||||||
#define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple
|
#define PURPLE CLITERAL(Color){ 0.78125, 0.47656, 1.0 , 1.0 } // Purple
|
||||||
#define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet
|
#define VIOLET CLITERAL(Color){ 0.52734, 0.23438, 0.74219, 1.0 } // Violet
|
||||||
#define DARKPURPLE CLITERAL(Color){ 112, 31, 126, 255 } // Dark Purple
|
#define DARKPURPLE CLITERAL(Color){ 0.4375 , 0.12109, 0.49219, 1.0 } // Dark Purple
|
||||||
#define BEIGE CLITERAL(Color){ 211, 176, 131, 255 } // Beige
|
#define BEIGE CLITERAL(Color){ 0.82422, 0.6875 , 0.51172, 1.0 } // Beige
|
||||||
#define BROWN CLITERAL(Color){ 127, 106, 79, 255 } // Brown
|
#define BROWN CLITERAL(Color){ 0.5 , 0.41406, 0.30859, 1.0 } // Brown
|
||||||
#define DARKBROWN CLITERAL(Color){ 76, 63, 47, 255 } // Dark Brown
|
#define DARKBROWN CLITERAL(Color){ 0.29687, 0.24609, 0.18359, 1.0 } // Dark Brown
|
||||||
|
|
||||||
#define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White
|
#define WHITE CLITERAL(Color){ 1.0 , 1.0 , 1.0 , 1.0 } // White
|
||||||
#define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black
|
#define BLACK CLITERAL(Color){ 0 , 0 , 0 , 1.0 } // Black
|
||||||
#define BLANK CLITERAL(Color){ 0 , 0 , 0 , 0 } // Blank (Transparent)
|
#define BLANK CLITERAL(Color){ 0 , 0 , 0 , 0 } // Blank (Transparent)
|
||||||
#define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta
|
#define MAGENTA CLITERAL(Color){ 1.0 , 0 , 1.0 , 1.0 } // Magenta
|
||||||
#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo)
|
#define RAYWHITE CLITERAL(Color){ 0.96078, 0.96078, 0.96078, 1.0 } // My own White (raylib logo)
|
||||||
|
|
||||||
// Temporal hack to avoid breaking old codebases using
|
// Temporal hack to avoid breaking old codebases using
|
||||||
// deprecated raylib implementation of these functions
|
// deprecated raylib implementation of these functions
|
||||||
|
|
@ -193,12 +193,20 @@ typedef struct Matrix {
|
||||||
float m3, m7, m11, m15;
|
float m3, m7, m11, m15;
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
// Color type, RGBA (32bit)
|
// colour type used for example in raw images
|
||||||
typedef struct Color {
|
typedef struct Color4ub {
|
||||||
unsigned char r;
|
unsigned char r;
|
||||||
unsigned char g;
|
unsigned char g;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
unsigned char a;
|
unsigned char a;
|
||||||
|
} Color4ub;
|
||||||
|
|
||||||
|
// Color type, RGBA (normalised floats)
|
||||||
|
typedef struct Color {
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
float a;
|
||||||
} Color;
|
} Color;
|
||||||
|
|
||||||
// Rectangle type
|
// Rectangle type
|
||||||
|
|
@ -336,6 +344,7 @@ typedef struct MaterialMap {
|
||||||
|
|
||||||
// Material type (generic)
|
// Material type (generic)
|
||||||
typedef struct Material {
|
typedef struct Material {
|
||||||
|
char* name; // Material name
|
||||||
Shader shader; // Material shader
|
Shader shader; // Material shader
|
||||||
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
||||||
float *params; // Material generic parameters (if required)
|
float *params; // Material generic parameters (if required)
|
||||||
|
|
@ -923,7 +932,7 @@ RLAPI double GetTime(void); // Returns ela
|
||||||
|
|
||||||
// Color-related functions
|
// Color-related functions
|
||||||
RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color
|
RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color
|
||||||
RLAPI Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1]
|
RLAPI Color Color4ubNormalize(Color4ub color); // Returns color normalized as float [0..1]
|
||||||
RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color
|
RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color
|
||||||
RLAPI Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values
|
RLAPI Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values
|
||||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||||
|
|
@ -936,8 +945,8 @@ RLAPI void SetTraceLogExit(int logType); // Set the exi
|
||||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging
|
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging
|
||||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
|
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
|
||||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
RLAPI float GetRandomValue(float min, float max); // Returns a random float between min and max (both included)
|
||||||
|
RLAPI int GetRandomInt(int min, int max); // Returns a random int between min and max (both included)
|
||||||
// Files management functions
|
// Files management functions
|
||||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||||
|
|
@ -1085,7 +1094,7 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
||||||
|
|
||||||
// Image/Texture2D data loading/unloading/saving functions
|
// Image/Texture2D data loading/unloading/saving functions
|
||||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
RLAPI Image LoadImageEx(Color4ub *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||||
RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
|
RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
|
||||||
RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file
|
RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file
|
||||||
|
|
@ -1097,7 +1106,7 @@ RLAPI RenderTexture2D LoadRenderTexture(int width, int height);
|
||||||
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
||||||
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
||||||
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
|
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
|
||||||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
RLAPI Color4ub *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||||
RLAPI Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized)
|
RLAPI Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized)
|
||||||
RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle
|
RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle
|
||||||
RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture)
|
RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture)
|
||||||
|
|
|
||||||
60
src/rlgl.h
60
src/rlgl.h
|
|
@ -177,13 +177,22 @@ typedef unsigned char byte;
|
||||||
typedef enum { false, true } bool;
|
typedef enum { false, true } bool;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Color type, RGBA (32bit)
|
// colour type used for example in raw images
|
||||||
typedef struct Color {
|
typedef struct Color4ub {
|
||||||
unsigned char r;
|
unsigned char r;
|
||||||
unsigned char g;
|
unsigned char g;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
unsigned char a;
|
unsigned char a;
|
||||||
} Color;
|
} colour4ub;
|
||||||
|
|
||||||
|
// Color type, RGBA (normalized floats)
|
||||||
|
typedef struct Colour {
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
float a;
|
||||||
|
} Colour;
|
||||||
|
|
||||||
|
|
||||||
// Texture2D type
|
// Texture2D type
|
||||||
// NOTE: Data stored in GPU memory
|
// NOTE: Data stored in GPU memory
|
||||||
|
|
@ -467,7 +476,7 @@ RLAPI void rlDeleteRenderTextures(RenderTexture2D target); // Delete render t
|
||||||
RLAPI void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
|
RLAPI void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
|
||||||
RLAPI void rlDeleteVertexArrays(unsigned int id); // Unload vertex data (VAO) from GPU memory
|
RLAPI void rlDeleteVertexArrays(unsigned int id); // Unload vertex data (VAO) from GPU memory
|
||||||
RLAPI void rlDeleteBuffers(unsigned int id); // Unload vertex data (VBO) from GPU memory
|
RLAPI void rlDeleteBuffers(unsigned int id); // Unload vertex data (VBO) from GPU memory
|
||||||
RLAPI void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
|
RLAPI void rlClearColor(float r, float g, float b, float a); // Clear color buffer with color
|
||||||
RLAPI void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
|
RLAPI void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
|
||||||
RLAPI void rlUpdateBuffer(int bufferId, void *data, int dataSize); // Update GPU buffer with new data
|
RLAPI void rlUpdateBuffer(int bufferId, void *data, int dataSize); // Update GPU buffer with new data
|
||||||
RLAPI unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic); // Load a new attributes buffer
|
RLAPI unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic); // Load a new attributes buffer
|
||||||
|
|
@ -875,7 +884,7 @@ static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView);
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
|
static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
|
||||||
static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight);
|
static Color4ub *GenNextMipmap(Color4ub *srcData, int srcWidth, int srcHeight);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -1441,15 +1450,9 @@ void rlDeleteBuffers(unsigned int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear color buffer with color
|
// Clear color buffer with color
|
||||||
void rlClearColor(byte r, byte g, byte b, byte a)
|
void rlClearColor(float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
// Color values clamp to 0.0f(0) and 1.0f(255)
|
glClearColor(r, g, b, a);
|
||||||
float cr = (float)r/255;
|
|
||||||
float cg = (float)g/255;
|
|
||||||
float cb = (float)b/255;
|
|
||||||
float ca = (float)a/255;
|
|
||||||
|
|
||||||
glClearColor(cr, cg, cb, ca);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear used screen buffers (color and depth)
|
// Clear used screen buffers (color and depth)
|
||||||
|
|
@ -2591,7 +2594,10 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlMultMatrixf(MatrixToFloat(transform));
|
rlMultMatrixf(MatrixToFloat(transform));
|
||||||
rlColor4ub(material.maps[MAP_DIFFUSE].color.r, material.maps[MAP_DIFFUSE].color.g, material.maps[MAP_DIFFUSE].color.b, material.maps[MAP_DIFFUSE].color.a);
|
rlColor4f(material.maps[MAP_DIFFUSE].color.r,
|
||||||
|
material.maps[MAP_DIFFUSE].color.g,
|
||||||
|
material.maps[MAP_DIFFUSE].color.b,
|
||||||
|
material.maps[MAP_DIFFUSE].color.a);
|
||||||
|
|
||||||
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, mesh.indices);
|
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, mesh.indices);
|
||||||
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
||||||
|
|
@ -2617,17 +2623,17 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
|
|
||||||
// Upload to shader material.colDiffuse
|
// Upload to shader material.colDiffuse
|
||||||
if (material.shader.locs[LOC_COLOR_DIFFUSE] != -1)
|
if (material.shader.locs[LOC_COLOR_DIFFUSE] != -1)
|
||||||
glUniform4f(material.shader.locs[LOC_COLOR_DIFFUSE], (float)material.maps[MAP_DIFFUSE].color.r/255.0f,
|
glUniform4f(material.shader.locs[LOC_COLOR_DIFFUSE], (float)material.maps[MAP_DIFFUSE].color.r,
|
||||||
(float)material.maps[MAP_DIFFUSE].color.g/255.0f,
|
(float)material.maps[MAP_DIFFUSE].color.g,
|
||||||
(float)material.maps[MAP_DIFFUSE].color.b/255.0f,
|
(float)material.maps[MAP_DIFFUSE].color.b,
|
||||||
(float)material.maps[MAP_DIFFUSE].color.a/255.0f);
|
(float)material.maps[MAP_DIFFUSE].color.a);
|
||||||
|
|
||||||
// Upload to shader material.colSpecular (if available)
|
// Upload to shader material.colSpecular (if available)
|
||||||
if (material.shader.locs[LOC_COLOR_SPECULAR] != -1)
|
if (material.shader.locs[LOC_COLOR_SPECULAR] != -1)
|
||||||
glUniform4f(material.shader.locs[LOC_COLOR_SPECULAR], (float)material.maps[MAP_SPECULAR].color.r/255.0f,
|
glUniform4f(material.shader.locs[LOC_COLOR_SPECULAR], (float)material.maps[MAP_SPECULAR].color.r,
|
||||||
(float)material.maps[MAP_SPECULAR].color.g/255.0f,
|
(float)material.maps[MAP_SPECULAR].color.g,
|
||||||
(float)material.maps[MAP_SPECULAR].color.b/255.0f,
|
(float)material.maps[MAP_SPECULAR].color.b,
|
||||||
(float)material.maps[MAP_SPECULAR].color.a/255.0f);
|
(float)material.maps[MAP_SPECULAR].color.a);
|
||||||
|
|
||||||
if (material.shader.locs[LOC_MATRIX_VIEW] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_VIEW], modelview);
|
if (material.shader.locs[LOC_MATRIX_VIEW] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_VIEW], modelview);
|
||||||
if (material.shader.locs[LOC_MATRIX_PROJECTION] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_PROJECTION], projection);
|
if (material.shader.locs[LOC_MATRIX_PROJECTION] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_PROJECTION], projection);
|
||||||
|
|
@ -4467,8 +4473,8 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
|
||||||
|
|
||||||
// Generate mipmaps
|
// Generate mipmaps
|
||||||
// NOTE: Every mipmap data is stored after data
|
// NOTE: Every mipmap data is stored after data
|
||||||
Color *image = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *image = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
Color *mipmap = NULL;
|
Color4ub *mipmap = NULL;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
|
|
@ -4516,15 +4522,15 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manual mipmap generation (basic scaling algorithm)
|
// Manual mipmap generation (basic scaling algorithm)
|
||||||
static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight)
|
static Color4ub *GenNextMipmap(Color4ub *srcData, int srcWidth, int srcHeight)
|
||||||
{
|
{
|
||||||
int x2, y2;
|
int x2, y2;
|
||||||
Color prow, pcol;
|
Color4ub prow, pcol;
|
||||||
|
|
||||||
int width = srcWidth/2;
|
int width = srcWidth/2;
|
||||||
int height = srcHeight/2;
|
int height = srcHeight/2;
|
||||||
|
|
||||||
Color *mipmap = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *mipmap = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
|
||||||
// Scaling algorithm works perfectly (box-filter)
|
// Scaling algorithm works perfectly (box-filter)
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
|
|
|
||||||
118
src/shapes.c
118
src/shapes.c
|
|
@ -75,7 +75,7 @@ static Texture2D GetShapesTexture(void); // Get textu
|
||||||
void DrawPixel(int posX, int posY, Color color)
|
void DrawPixel(int posX, int posY, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2i(posX, posY);
|
rlVertex2i(posX, posY);
|
||||||
rlVertex2i(posX + 1, posY + 1);
|
rlVertex2i(posX + 1, posY + 1);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -85,7 +85,7 @@ void DrawPixel(int posX, int posY, Color color)
|
||||||
void DrawPixelV(Vector2 position, Color color)
|
void DrawPixelV(Vector2 position, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(position.x, position.y);
|
rlVertex2f(position.x, position.y);
|
||||||
rlVertex2f(position.x + 1.0f, position.y + 1.0f);
|
rlVertex2f(position.x + 1.0f, position.y + 1.0f);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -95,7 +95,7 @@ void DrawPixelV(Vector2 position, Color color)
|
||||||
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color)
|
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2i(startPosX, startPosY);
|
rlVertex2i(startPosX, startPosY);
|
||||||
rlVertex2i(endPosX, endPosY);
|
rlVertex2i(endPosX, endPosY);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -105,7 +105,7 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
|
||||||
void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
|
void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(startPos.x, startPos.y);
|
rlVertex2f(startPos.x, startPos.y);
|
||||||
rlVertex2f(endPos.x, endPos.y);
|
rlVertex2f(endPos.x, endPos.y);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -135,7 +135,7 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
|
||||||
rlTranslatef(0, (thick > 1.0f)? -thick/2.0f : -1.0f, 0.0f);
|
rlTranslatef(0, (thick > 1.0f)? -thick/2.0f : -1.0f, 0.0f);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
|
|
@ -184,7 +184,7 @@ void DrawLineStrip(Vector2 *points, int pointsCount, Color color)
|
||||||
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 0; i < pointsCount - 1; i++)
|
for (int i = 0; i < pointsCount - 1; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -239,7 +239,7 @@ void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle
|
||||||
// NOTE: Every QUAD actually represents two segments
|
// NOTE: Every QUAD actually represents two segments
|
||||||
for (int i = 0; i < segments/2; i++)
|
for (int i = 0; i < segments/2; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
|
|
@ -259,7 +259,7 @@ void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle
|
||||||
// NOTE: In case number of segments is odd, we add one last piece to the cake
|
// NOTE: In case number of segments is odd, we add one last piece to the cake
|
||||||
if (segments%2)
|
if (segments%2)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
|
|
@ -282,7 +282,7 @@ void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
||||||
|
|
@ -334,14 +334,14 @@ void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int end
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
if (showCapLines)
|
if (showCapLines)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
|
||||||
|
|
@ -351,7 +351,7 @@ void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int end
|
||||||
|
|
||||||
if (showCapLines)
|
if (showCapLines)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
||||||
}
|
}
|
||||||
|
|
@ -367,11 +367,11 @@ void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Co
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < 360; i += 10)
|
for (int i = 0; i < 360; i += 10)
|
||||||
{
|
{
|
||||||
rlColor4ub(color1.r, color1.g, color1.b, color1.a);
|
rlColor4f(color1.r, color1.g, color1.b, color1.a);
|
||||||
rlVertex2f(centerX, centerY);
|
rlVertex2f(centerX, centerY);
|
||||||
rlColor4ub(color2.r, color2.g, color2.b, color2.a);
|
rlColor4f(color2.r, color2.g, color2.b, color2.a);
|
||||||
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius);
|
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius);
|
||||||
rlColor4ub(color2.r, color2.g, color2.b, color2.a);
|
rlColor4f(color2.r, color2.g, color2.b, color2.a);
|
||||||
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius);
|
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius);
|
||||||
}
|
}
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -390,7 +390,7 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
|
||||||
if (rlCheckBufferLimit(2*36)) rlglDraw();
|
if (rlCheckBufferLimit(2*36)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
// NOTE: Circle outline is drawn pixel by pixel every degree (0 to 360)
|
// NOTE: Circle outline is drawn pixel by pixel every degree (0 to 360)
|
||||||
for (int i = 0; i < 360; i += 10)
|
for (int i = 0; i < 360; i += 10)
|
||||||
|
|
@ -456,7 +456,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAng
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
|
|
@ -481,7 +481,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAng
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
|
|
@ -552,14 +552,14 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int sta
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
if (showCapLines)
|
if (showCapLines)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
|
||||||
|
|
@ -572,7 +572,7 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int sta
|
||||||
|
|
||||||
if (showCapLines)
|
if (showCapLines)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
}
|
}
|
||||||
|
|
@ -610,7 +610,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(0.0f, 0.0f);
|
rlVertex2f(0.0f, 0.0f);
|
||||||
|
|
@ -654,19 +654,19 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3,
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
// NOTE: Default raylib font character 95 is a white square
|
// NOTE: Default raylib font character 95 is a white square
|
||||||
rlColor4ub(col1.r, col1.g, col1.b, col1.a);
|
rlColor4f(col1.r, col1.g, col1.b, col1.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(rec.x, rec.y);
|
rlVertex2f(rec.x, rec.y);
|
||||||
|
|
||||||
rlColor4ub(col2.r, col2.g, col2.b, col2.a);
|
rlColor4f(col2.r, col2.g, col2.b, col2.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
rlVertex2f(rec.x, rec.y + rec.height);
|
rlVertex2f(rec.x, rec.y + rec.height);
|
||||||
|
|
||||||
rlColor4ub(col3.r, col3.g, col3.b, col3.a);
|
rlColor4f(col3.r, col3.g, col3.b, col3.a);
|
||||||
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
||||||
|
|
||||||
rlColor4ub(col4.r, col4.g, col4.b, col4.a);
|
rlColor4f(col4.r, col4.g, col4.b, col4.a);
|
||||||
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(rec.x + rec.width, rec.y);
|
rlVertex2f(rec.x + rec.width, rec.y);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
@ -686,7 +686,7 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
|
||||||
DrawRectangle(posX, posY + 1, 1, height - 2, color);
|
DrawRectangle(posX, posY + 1, 1, height - 2, color);
|
||||||
#else
|
#else
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2i(posX + 1, posY + 1);
|
rlVertex2i(posX + 1, posY + 1);
|
||||||
rlVertex2i(posX + width, posY + 1);
|
rlVertex2i(posX + width, posY + 1);
|
||||||
|
|
||||||
|
|
@ -789,7 +789,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
// NOTE: Every QUAD actually represents two segments
|
// NOTE: Every QUAD actually represents two segments
|
||||||
for (int i = 0; i < segments/2; i++)
|
for (int i = 0; i < segments/2; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -803,7 +803,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
// NOTE: In case number of segments is odd, we add one last piece to the cake
|
// NOTE: In case number of segments is odd, we add one last piece to the cake
|
||||||
if (segments%2)
|
if (segments%2)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -816,7 +816,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
}
|
}
|
||||||
|
|
||||||
// [2] Upper Rectangle
|
// [2] Upper Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[0].x, point[0].y);
|
rlVertex2f(point[0].x, point[0].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -827,7 +827,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[1].x, point[1].y);
|
rlVertex2f(point[1].x, point[1].y);
|
||||||
|
|
||||||
// [4] Right Rectangle
|
// [4] Right Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[2].x, point[2].y);
|
rlVertex2f(point[2].x, point[2].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -838,7 +838,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
||||||
// [6] Bottom Rectangle
|
// [6] Bottom Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -849,7 +849,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[10].x, point[10].y);
|
rlVertex2f(point[10].x, point[10].y);
|
||||||
|
|
||||||
// [8] Left Rectangle
|
// [8] Left Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[7].x, point[7].y);
|
rlVertex2f(point[7].x, point[7].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -860,7 +860,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[8].x, point[8].y);
|
rlVertex2f(point[8].x, point[8].y);
|
||||||
|
|
||||||
// [9] Middle Rectangle
|
// [9] Middle Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[8].x, point[8].y);
|
rlVertex2f(point[8].x, point[8].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -883,7 +883,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
const Vector2 center = centers[k];
|
const Vector2 center = centers[k];
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x, center.y);
|
rlVertex2f(center.x, center.y);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
|
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
|
||||||
|
|
@ -892,7 +892,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
}
|
}
|
||||||
|
|
||||||
// [2] Upper Rectangle
|
// [2] Upper Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[0].x, point[0].y);
|
rlVertex2f(point[0].x, point[0].y);
|
||||||
rlVertex2f(point[8].x, point[8].y);
|
rlVertex2f(point[8].x, point[8].y);
|
||||||
rlVertex2f(point[9].x, point[9].y);
|
rlVertex2f(point[9].x, point[9].y);
|
||||||
|
|
@ -901,7 +901,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[9].x, point[9].y);
|
rlVertex2f(point[9].x, point[9].y);
|
||||||
|
|
||||||
// [4] Right Rectangle
|
// [4] Right Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[9].x, point[9].y);
|
rlVertex2f(point[9].x, point[9].y);
|
||||||
rlVertex2f(point[10].x, point[10].y);
|
rlVertex2f(point[10].x, point[10].y);
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
@ -910,7 +910,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
||||||
// [6] Bottom Rectangle
|
// [6] Bottom Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
rlVertex2f(point[5].x, point[5].y);
|
rlVertex2f(point[5].x, point[5].y);
|
||||||
rlVertex2f(point[4].x, point[4].y);
|
rlVertex2f(point[4].x, point[4].y);
|
||||||
|
|
@ -919,7 +919,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[4].x, point[4].y);
|
rlVertex2f(point[4].x, point[4].y);
|
||||||
|
|
||||||
// [8] Left Rectangle
|
// [8] Left Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[7].x, point[7].y);
|
rlVertex2f(point[7].x, point[7].y);
|
||||||
rlVertex2f(point[6].x, point[6].y);
|
rlVertex2f(point[6].x, point[6].y);
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
|
|
@ -928,7 +928,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
|
|
||||||
// [9] Middle Rectangle
|
// [9] Middle Rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[8].x, point[8].y);
|
rlVertex2f(point[8].x, point[8].y);
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
rlVertex2f(point[10].x, point[10].y);
|
rlVertex2f(point[10].x, point[10].y);
|
||||||
|
|
@ -1021,7 +1021,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
const Vector2 center = centers[k];
|
const Vector2 center = centers[k];
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -1036,7 +1036,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upper rectangle
|
// Upper rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[0].x, point[0].y);
|
rlVertex2f(point[0].x, point[0].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -1047,7 +1047,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[1].x, point[1].y);
|
rlVertex2f(point[1].x, point[1].y);
|
||||||
|
|
||||||
// Right rectangle
|
// Right rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[2].x, point[2].y);
|
rlVertex2f(point[2].x, point[2].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -1058,7 +1058,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
||||||
// Lower rectangle
|
// Lower rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[13].x, point[13].y);
|
rlVertex2f(point[13].x, point[13].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -1069,7 +1069,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[12].x, point[12].y);
|
rlVertex2f(point[12].x, point[12].y);
|
||||||
|
|
||||||
// Left rectangle
|
// Left rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(point[15].x, point[15].y);
|
rlVertex2f(point[15].x, point[15].y);
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
|
||||||
|
|
@ -1094,7 +1094,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
|
|
@ -1109,7 +1109,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upper rectangle
|
// Upper rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[0].x, point[0].y);
|
rlVertex2f(point[0].x, point[0].y);
|
||||||
rlVertex2f(point[8].x, point[8].y);
|
rlVertex2f(point[8].x, point[8].y);
|
||||||
rlVertex2f(point[9].x, point[9].y);
|
rlVertex2f(point[9].x, point[9].y);
|
||||||
|
|
@ -1118,7 +1118,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[9].x, point[9].y);
|
rlVertex2f(point[9].x, point[9].y);
|
||||||
|
|
||||||
// Right rectangle
|
// Right rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[10].x, point[10].y);
|
rlVertex2f(point[10].x, point[10].y);
|
||||||
rlVertex2f(point[11].x, point[11].y);
|
rlVertex2f(point[11].x, point[11].y);
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
@ -1127,7 +1127,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[3].x, point[3].y);
|
rlVertex2f(point[3].x, point[3].y);
|
||||||
|
|
||||||
// Lower rectangle
|
// Lower rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[13].x, point[13].y);
|
rlVertex2f(point[13].x, point[13].y);
|
||||||
rlVertex2f(point[5].x, point[5].y);
|
rlVertex2f(point[5].x, point[5].y);
|
||||||
rlVertex2f(point[4].x, point[4].y);
|
rlVertex2f(point[4].x, point[4].y);
|
||||||
|
|
@ -1136,7 +1136,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
rlVertex2f(point[4].x, point[4].y);
|
rlVertex2f(point[4].x, point[4].y);
|
||||||
|
|
||||||
// Left rectangle
|
// Left rectangle
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[7].x, point[7].y);
|
rlVertex2f(point[7].x, point[7].y);
|
||||||
rlVertex2f(point[6].x, point[6].y);
|
rlVertex2f(point[6].x, point[6].y);
|
||||||
rlVertex2f(point[14].x, point[14].y);
|
rlVertex2f(point[14].x, point[14].y);
|
||||||
|
|
@ -1161,7 +1161,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
|
||||||
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
|
rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
|
||||||
angle += stepLength;
|
angle += stepLength;
|
||||||
|
|
@ -1170,7 +1170,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int
|
||||||
// And now the remaining 4 lines
|
// And now the remaining 4 lines
|
||||||
for(int i = 0; i < 8; i += 2)
|
for(int i = 0; i < 8; i += 2)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(point[i].x, point[i].y);
|
rlVertex2f(point[i].x, point[i].y);
|
||||||
rlVertex2f(point[i + 1].x, point[i + 1].y);
|
rlVertex2f(point[i + 1].x, point[i + 1].y);
|
||||||
}
|
}
|
||||||
|
|
@ -1188,7 +1188,7 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||||
rlEnableTexture(GetShapesTexture().id);
|
rlEnableTexture(GetShapesTexture().id);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(v1.x, v1.y);
|
rlVertex2f(v1.x, v1.y);
|
||||||
|
|
@ -1206,7 +1206,7 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||||
rlDisableTexture();
|
rlDisableTexture();
|
||||||
#else
|
#else
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(v1.x, v1.y);
|
rlVertex2f(v1.x, v1.y);
|
||||||
rlVertex2f(v2.x, v2.y);
|
rlVertex2f(v2.x, v2.y);
|
||||||
rlVertex2f(v3.x, v3.y);
|
rlVertex2f(v3.x, v3.y);
|
||||||
|
|
@ -1221,7 +1221,7 @@ void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||||
if (rlCheckBufferLimit(6)) rlglDraw();
|
if (rlCheckBufferLimit(6)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
rlVertex2f(v1.x, v1.y);
|
rlVertex2f(v1.x, v1.y);
|
||||||
rlVertex2f(v2.x, v2.y);
|
rlVertex2f(v2.x, v2.y);
|
||||||
|
|
||||||
|
|
@ -1243,7 +1243,7 @@ void DrawTriangleFan(Vector2 *points, int pointsCount, Color color)
|
||||||
|
|
||||||
rlEnableTexture(GetShapesTexture().id);
|
rlEnableTexture(GetShapesTexture().id);
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 1; i < pointsCount - 1; i++)
|
for (int i = 1; i < pointsCount - 1; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1273,7 +1273,7 @@ void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color)
|
||||||
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
for (int i = 2; i < pointsCount; i++)
|
for (int i = 2; i < pointsCount; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1312,7 +1312,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
for (int i = 0; i < sides; i++)
|
for (int i = 0; i < sides; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
|
||||||
rlVertex2f(0, 0);
|
rlVertex2f(0, 0);
|
||||||
|
|
@ -1333,7 +1333,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < sides; i++)
|
for (int i = 0; i < sides; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
rlVertex2f(0, 0);
|
rlVertex2f(0, 0);
|
||||||
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius);
|
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius);
|
||||||
|
|
|
||||||
12
src/text.c
12
src/text.c
|
|
@ -176,9 +176,9 @@ extern void LoadFontDefault(void)
|
||||||
int imWidth = 128;
|
int imWidth = 128;
|
||||||
int imHeight = 128;
|
int imHeight = 128;
|
||||||
|
|
||||||
Color *imagePixels = (Color *)RL_MALLOC(imWidth*imHeight*sizeof(Color));
|
Color4ub *imagePixels = (Color4ub *)RL_MALLOC(imWidth*imHeight*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int i = 0; i < imWidth*imHeight; i++) imagePixels[i] = BLANK; // Initialize array
|
for (int i = 0; i < imWidth*imHeight; i++) imagePixels[i] = (Color4ub){0,0,0,0}; // Initialize array
|
||||||
|
|
||||||
int counter = 0; // Font data elements counter
|
int counter = 0; // Font data elements counter
|
||||||
|
|
||||||
|
|
@ -187,7 +187,7 @@ extern void LoadFontDefault(void)
|
||||||
{
|
{
|
||||||
for (int j = 31; j >= 0; j--)
|
for (int j = 31; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (BIT_CHECK(defaultFontData[counter], j)) imagePixels[i+j] = WHITE;
|
if (BIT_CHECK(defaultFontData[counter], j)) imagePixels[i+j] = (Color4ub){255,255,255,255};
|
||||||
}
|
}
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
|
|
@ -345,7 +345,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou
|
||||||
// Load an Image font file (XNA style)
|
// Load an Image font file (XNA style)
|
||||||
Font LoadFontFromImage(Image image, Color key, int firstChar)
|
Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
{
|
{
|
||||||
#define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a))
|
#define COLOR_EQUAL(col1, col2) ((col1.r == col2.r*255)&&(col1.g == col2.g*255)&&(col1.b == col2.b*255)&&(col1.a == col2.a*255))
|
||||||
|
|
||||||
int charSpacing = 0;
|
int charSpacing = 0;
|
||||||
int lineSpacing = 0;
|
int lineSpacing = 0;
|
||||||
|
|
@ -361,7 +361,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
int tempCharValues[MAX_FONTCHARS];
|
int tempCharValues[MAX_FONTCHARS];
|
||||||
Rectangle tempCharRecs[MAX_FONTCHARS];
|
Rectangle tempCharRecs[MAX_FONTCHARS];
|
||||||
|
|
||||||
Color *pixels = GetImageData(image);
|
Color4ub *pixels = GetImageData(image);
|
||||||
|
|
||||||
// Parse image data to get charSpacing and lineSpacing
|
// Parse image data to get charSpacing and lineSpacing
|
||||||
for (y = 0; y < image.height; y++)
|
for (y = 0; y < image.height; y++)
|
||||||
|
|
@ -420,7 +420,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
|
|
||||||
// NOTE: We need to remove key color borders from image to avoid weird
|
// NOTE: We need to remove key color borders from image to avoid weird
|
||||||
// artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR
|
// artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR
|
||||||
for (int i = 0; i < image.height*image.width; i++) if (COLOR_EQUAL(pixels[i], key)) pixels[i] = BLANK;
|
for (int i = 0; i < image.height*image.width; i++) if (COLOR_EQUAL(pixels[i], key)) pixels[i] = (Color4ub){0,0,0,0};
|
||||||
|
|
||||||
// Create a new image with the processed color data (key color replaced by BLANK)
|
// Create a new image with the processed color data (key color replaced by BLANK)
|
||||||
Image fontClear = LoadImageEx(pixels, image.width, image.height);
|
Image fontClear = LoadImageEx(pixels, image.width, image.height);
|
||||||
|
|
|
||||||
255
src/textures.c
255
src/textures.c
|
|
@ -299,7 +299,7 @@ Image LoadImage(const char *fileName)
|
||||||
|
|
||||||
// Load image from Color array data (RGBA - 32bit)
|
// Load image from Color array data (RGBA - 32bit)
|
||||||
// NOTE: Creates a copy of pixels data array
|
// NOTE: Creates a copy of pixels data array
|
||||||
Image LoadImageEx(Color *pixels, int width, int height)
|
Image LoadImageEx(Color4ub *pixels, int width, int height)
|
||||||
{
|
{
|
||||||
Image image;
|
Image image;
|
||||||
image.data = NULL;
|
image.data = NULL;
|
||||||
|
|
@ -455,9 +455,9 @@ void UnloadRenderTexture(RenderTexture2D target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get pixel data from image in the form of Color struct array
|
// Get pixel data from image in the form of Color struct array
|
||||||
Color *GetImageData(Image image)
|
Color4ub *GetImageData(Image image)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(image.width*image.height*sizeof(Color4ub));
|
||||||
|
|
||||||
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
|
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
|
||||||
else
|
else
|
||||||
|
|
@ -683,7 +683,7 @@ Vector4 *GetImageDataNormalized(Image image)
|
||||||
// Get image alpha border rectangle
|
// Get image alpha border rectangle
|
||||||
Rectangle GetImageAlphaBorder(Image image, float threshold)
|
Rectangle GetImageAlphaBorder(Image image, float threshold)
|
||||||
{
|
{
|
||||||
Color *pixels = GetImageData(image);
|
Color4ub *pixels = GetImageData(image);
|
||||||
|
|
||||||
int xMin = 65536; // Define a big enough number
|
int xMin = 65536; // Define a big enough number
|
||||||
int xMax = 0;
|
int xMax = 0;
|
||||||
|
|
@ -936,12 +936,17 @@ Image ImageFromImage(Image image, Rectangle rec)
|
||||||
|
|
||||||
// Convert image to POT (power-of-two)
|
// Convert image to POT (power-of-two)
|
||||||
// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
|
// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
|
||||||
void ImageToPOT(Image *image, Color fillColor)
|
void ImageToPOT(Image *image, Color fill)
|
||||||
{
|
{
|
||||||
|
Color4ub fillColor;
|
||||||
|
fillColor.r = fill.r * 255;
|
||||||
|
fillColor.g = fill.g * 255;
|
||||||
|
fillColor.b = fill.b * 255;
|
||||||
|
fillColor.a = fill.a * 255;
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image); // Get pixels data
|
Color4ub *pixels = GetImageData(*image); // Get pixels data
|
||||||
|
|
||||||
// Calculate next power-of-two values
|
// Calculate next power-of-two values
|
||||||
// NOTE: Just add the required amount of pixels at the right and bottom sides of image...
|
// NOTE: Just add the required amount of pixels at the right and bottom sides of image...
|
||||||
|
|
@ -951,10 +956,10 @@ void ImageToPOT(Image *image, Color fillColor)
|
||||||
// Check if POT texture generation is required (if texture is not already POT)
|
// Check if POT texture generation is required (if texture is not already POT)
|
||||||
if ((potWidth != image->width) || (potHeight != image->height))
|
if ((potWidth != image->width) || (potHeight != image->height))
|
||||||
{
|
{
|
||||||
Color *pixelsPOT = NULL;
|
Color4ub *pixelsPOT = NULL;
|
||||||
|
|
||||||
// Generate POT array from NPOT data
|
// Generate POT array from NPOT data
|
||||||
pixelsPOT = (Color *)RL_MALLOC(potWidth*potHeight*sizeof(Color));
|
pixelsPOT = (Color4ub *)RL_MALLOC(potWidth*potHeight*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int j = 0; j < potHeight; j++)
|
for (int j = 0; j < potHeight; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1214,12 +1219,17 @@ void ImageAlphaMask(Image *image, Image alphaMask)
|
||||||
// NOTE: Threshold defines the alpha limit, 0.0f to 1.0f
|
// NOTE: Threshold defines the alpha limit, 0.0f to 1.0f
|
||||||
void ImageAlphaClear(Image *image, Color color, float threshold)
|
void ImageAlphaClear(Image *image, Color color, float threshold)
|
||||||
{
|
{
|
||||||
|
Color4ub actual;
|
||||||
|
actual.r = color.r * 255;
|
||||||
|
actual.g = color.g * 255;
|
||||||
|
actual.b = color.b * 255;
|
||||||
|
actual.a = color.a * 255;
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int i = 0; i < image->width*image->height; i++) if (pixels[i].a <= (unsigned char)(threshold*255.0f)) pixels[i] = color;
|
for (int i = 0; i < image->width*image->height; i++) if (pixels[i].a <= (unsigned char)(threshold*255.0f)) pixels[i] = actual;
|
||||||
|
|
||||||
UnloadImage(*image);
|
UnloadImage(*image);
|
||||||
|
|
||||||
|
|
@ -1236,7 +1246,7 @@ void ImageAlphaPremultiply(Image *image)
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
float alpha = 0.0f;
|
float alpha = 0.0f;
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int i = 0; i < image->width*image->height; i++)
|
for (int i = 0; i < image->width*image->height; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1353,8 +1363,8 @@ void ImageCrop(Image *image, Rectangle crop)
|
||||||
if ((crop.x < image->width) && (crop.y < image->height))
|
if ((crop.x < image->width) && (crop.y < image->height))
|
||||||
{
|
{
|
||||||
// Start the cropping process
|
// Start the cropping process
|
||||||
Color *pixels = GetImageData(*image); // Get data as Color pixels array
|
Color4ub *pixels = GetImageData(*image); // Get data as Color pixels array
|
||||||
Color *cropPixels = (Color *)RL_MALLOC((int)crop.width*(int)crop.height*sizeof(Color));
|
Color4ub *cropPixels = (Color4ub *)RL_MALLOC((int)crop.width*(int)crop.height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int j = (int)crop.y; j < (int)(crop.y + crop.height); j++)
|
for (int j = (int)crop.y; j < (int)(crop.y + crop.height); j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1386,7 +1396,7 @@ void ImageAlphaCrop(Image *image, float threshold)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
int xMin = 65536; // Define a big enough number
|
int xMin = 65536; // Define a big enough number
|
||||||
int xMax = 0;
|
int xMax = 0;
|
||||||
|
|
@ -1425,8 +1435,8 @@ void ImageResize(Image *image, int newWidth, int newHeight)
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
// Get data as Color pixels array to work with it
|
// Get data as Color pixels array to work with it
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
|
Color4ub *output = (Color4ub *)RL_MALLOC(newWidth*newHeight*sizeof(Color4ub));
|
||||||
|
|
||||||
// NOTE: Color data is casted to (unsigned char *), there shouldn't been any problem...
|
// NOTE: Color data is casted to (unsigned char *), there shouldn't been any problem...
|
||||||
stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4);
|
stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4);
|
||||||
|
|
@ -1448,8 +1458,8 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
|
Color4ub *output = (Color4ub *)RL_MALLOC(newWidth*newHeight*sizeof(Color4ub));
|
||||||
|
|
||||||
// EDIT: added +1 to account for an early rounding problem
|
// EDIT: added +1 to account for an early rounding problem
|
||||||
int xRatio = (int)((image->width << 16)/newWidth) + 1;
|
int xRatio = (int)((image->width << 16)/newWidth) + 1;
|
||||||
|
|
@ -1654,7 +1664,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
RL_FREE(image->data); // free old image data
|
RL_FREE(image->data); // free old image data
|
||||||
|
|
||||||
|
|
@ -1676,8 +1686,8 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
|
||||||
// NOTE: We will store the dithered data as unsigned short (16bpp)
|
// NOTE: We will store the dithered data as unsigned short (16bpp)
|
||||||
image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short));
|
image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short));
|
||||||
|
|
||||||
Color oldPixel = WHITE;
|
Color4ub oldPixel = (Color4ub){255,255,255,255};
|
||||||
Color newPixel = WHITE;
|
Color4ub newPixel = (Color4ub){255,255,255,255};
|
||||||
|
|
||||||
int rError, gError, bError;
|
int rError, gError, bError;
|
||||||
unsigned short rPixel, gPixel, bPixel, aPixel; // Used for 16bit pixel composition
|
unsigned short rPixel, gPixel, bPixel, aPixel; // Used for 16bit pixel composition
|
||||||
|
|
@ -1752,11 +1762,12 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount)
|
||||||
{
|
{
|
||||||
#define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a))
|
#define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a))
|
||||||
|
|
||||||
Color *pixels = GetImageData(image);
|
Color4ub *pixels = GetImageData(image);
|
||||||
Color *palette = (Color *)RL_MALLOC(maxPaletteSize*sizeof(Color));
|
Color4ub *palette = (Color4ub *)RL_MALLOC(maxPaletteSize*sizeof(Color4ub));
|
||||||
|
Color *fPalette = (Color *)RL_MALLOC(maxPaletteSize*sizeof(Color));
|
||||||
|
|
||||||
int palCount = 0;
|
int palCount = 0;
|
||||||
for (int i = 0; i < maxPaletteSize; i++) palette[i] = BLANK; // Set all colors to BLANK
|
for (int i = 0; i < maxPaletteSize; i++) palette[i] = (Color4ub){0,0,0,0}; // Set all colors to BLANK
|
||||||
|
|
||||||
for (int i = 0; i < image.width*image.height; i++)
|
for (int i = 0; i < image.width*image.height; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1793,8 +1804,15 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount)
|
||||||
RL_FREE(pixels);
|
RL_FREE(pixels);
|
||||||
|
|
||||||
*extractCount = palCount;
|
*extractCount = palCount;
|
||||||
|
for (int i=0; i<palCount; i++) {
|
||||||
|
fPalette[i].r = palette[i].r / 255;
|
||||||
|
fPalette[i].r = palette[i].g / 255;
|
||||||
|
fPalette[i].r = palette[i].b / 255;
|
||||||
|
fPalette[i].r = palette[i].a / 255;
|
||||||
|
}
|
||||||
|
RL_FREE(palette);
|
||||||
|
|
||||||
return palette;
|
return fPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw an image (source) within an image (destination)
|
// Draw an image (source) within an image (destination)
|
||||||
|
|
@ -1862,13 +1880,13 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get image data as Color pixels array to work with it
|
// Get image data as Color pixels array to work with it
|
||||||
Color *dstPixels = GetImageData(*dst);
|
Color4ub *dstPixels = GetImageData(*dst);
|
||||||
Color *srcPixels = GetImageData(srcCopy);
|
Color4ub *srcPixels = GetImageData(srcCopy);
|
||||||
|
|
||||||
UnloadImage(srcCopy); // Source copy not required any more
|
UnloadImage(srcCopy); // Source copy not required any more
|
||||||
|
|
||||||
Vector4 fsrc, fdst, fout; // Normalized pixel data (ready for operation)
|
Color fsrc, fdst, fout; // Normalized pixel data (ready for operation)
|
||||||
Vector4 ftint = ColorNormalize(tint); // Normalized color tint
|
Color ftint = (Color){tint.r, tint.g, tint.b, tint.a};
|
||||||
|
|
||||||
// Blit pixels, copy source image into destination
|
// Blit pixels, copy source image into destination
|
||||||
// TODO: Maybe out-of-bounds blitting could be considered here instead of so much cropping
|
// TODO: Maybe out-of-bounds blitting could be considered here instead of so much cropping
|
||||||
|
|
@ -1878,31 +1896,31 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
||||||
{
|
{
|
||||||
// Alpha blending (https://en.wikipedia.org/wiki/Alpha_compositing)
|
// Alpha blending (https://en.wikipedia.org/wiki/Alpha_compositing)
|
||||||
|
|
||||||
fdst = ColorNormalize(dstPixels[j*(int)dst->width + i]);
|
fdst = Color4ubNormalize(dstPixels[j*(int)dst->width + i]);
|
||||||
fsrc = ColorNormalize(srcPixels[(j - (int)dstRec.y)*(int)dstRec.width + (i - (int)dstRec.x)]);
|
fsrc = Color4ubNormalize(srcPixels[(j - (int)dstRec.y)*(int)dstRec.width + (i - (int)dstRec.x)]);
|
||||||
|
|
||||||
// Apply color tint to source image
|
// Apply color tint to source image
|
||||||
fsrc.x *= ftint.x; fsrc.y *= ftint.y; fsrc.z *= ftint.z; fsrc.w *= ftint.w;
|
fsrc.r *= ftint.r; fsrc.g *= ftint.g; fsrc.b *= ftint.b; fsrc.a *= ftint.a;
|
||||||
|
|
||||||
fout.w = fsrc.w + fdst.w*(1.0f - fsrc.w);
|
fout.a = fsrc.a + fdst.a*(1.0f - fsrc.a);
|
||||||
|
|
||||||
if (fout.w <= 0.0f)
|
if (fout.a <= 0.0f)
|
||||||
{
|
{
|
||||||
fout.x = 0.0f;
|
fout.r = 0.0f;
|
||||||
fout.y = 0.0f;
|
fout.g = 0.0f;
|
||||||
fout.z = 0.0f;
|
fout.b = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fout.x = (fsrc.x*fsrc.w + fdst.x*fdst.w*(1 - fsrc.w))/fout.w;
|
fout.r = (fsrc.r*fsrc.a + fdst.r*fdst.a*(1 - fsrc.a))/fout.a;
|
||||||
fout.y = (fsrc.y*fsrc.w + fdst.y*fdst.w*(1 - fsrc.w))/fout.w;
|
fout.g = (fsrc.g*fsrc.a + fdst.g*fdst.a*(1 - fsrc.a))/fout.a;
|
||||||
fout.z = (fsrc.z*fsrc.w + fdst.z*fdst.w*(1 - fsrc.w))/fout.w;
|
fout.b = (fsrc.b*fsrc.a + fdst.b*fdst.a*(1 - fsrc.a))/fout.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
dstPixels[j*(int)dst->width + i] = (Color){ (unsigned char)(fout.x*255.0f),
|
dstPixels[j*(int)dst->width + i] = (Color4ub){ (unsigned char)(fout.r*255.0f),
|
||||||
(unsigned char)(fout.y*255.0f),
|
(unsigned char)(fout.g*255.0f),
|
||||||
(unsigned char)(fout.z*255.0f),
|
(unsigned char)(fout.b*255.0f),
|
||||||
(unsigned char)(fout.w*255.0f) };
|
(unsigned char)(fout.a*255.0f) };
|
||||||
|
|
||||||
// TODO: Support other blending options
|
// TODO: Support other blending options
|
||||||
}
|
}
|
||||||
|
|
@ -2031,8 +2049,8 @@ void ImageFlipVertical(Image *image)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *srcPixels = GetImageData(*image);
|
Color4ub *srcPixels = GetImageData(*image);
|
||||||
Color *dstPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color));
|
Color4ub *dstPixels = (Color4ub *)RL_MALLOC(image->width*image->height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2058,8 +2076,8 @@ void ImageFlipHorizontal(Image *image)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *srcPixels = GetImageData(*image);
|
Color4ub *srcPixels = GetImageData(*image);
|
||||||
Color *dstPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color));
|
Color4ub *dstPixels = (Color4ub *)RL_MALLOC(image->width*image->height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2085,8 +2103,8 @@ void ImageRotateCW(Image *image)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *srcPixels = GetImageData(*image);
|
Color4ub *srcPixels = GetImageData(*image);
|
||||||
Color *rotPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color));
|
Color4ub *rotPixels = (Color4ub *)RL_MALLOC(image->width*image->height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2114,8 +2132,8 @@ void ImageRotateCCW(Image *image)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *srcPixels = GetImageData(*image);
|
Color4ub *srcPixels = GetImageData(*image);
|
||||||
Color *rotPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color));
|
Color4ub *rotPixels = (Color4ub *)RL_MALLOC(image->width*image->height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2143,12 +2161,12 @@ void ImageColorTint(Image *image, Color color)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
float cR = (float)color.r/255;
|
float cR = (float)color.r;
|
||||||
float cG = (float)color.g/255;
|
float cG = (float)color.g;
|
||||||
float cB = (float)color.b/255;
|
float cB = (float)color.b;
|
||||||
float cA = (float)color.a/255;
|
float cA = (float)color.a;
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2181,7 +2199,7 @@ void ImageColorInvert(Image *image)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2220,7 +2238,7 @@ void ImageColorContrast(Image *image, float contrast)
|
||||||
contrast = (100.0f + contrast)/100.0f;
|
contrast = (100.0f + contrast)/100.0f;
|
||||||
contrast *= contrast;
|
contrast *= contrast;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2274,7 +2292,7 @@ void ImageColorBrightness(Image *image, int brightness)
|
||||||
if (brightness < -255) brightness = -255;
|
if (brightness < -255) brightness = -255;
|
||||||
if (brightness > 255) brightness = 255;
|
if (brightness > 255) brightness = 255;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2313,21 +2331,21 @@ void ImageColorReplace(Image *image, Color color, Color replace)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
Color *pixels = GetImageData(*image);
|
Color4ub *pixels = GetImageData(*image);
|
||||||
|
|
||||||
for (int y = 0; y < image->height; y++)
|
for (int y = 0; y < image->height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < image->width; x++)
|
for (int x = 0; x < image->width; x++)
|
||||||
{
|
{
|
||||||
if ((pixels[y*image->width + x].r == color.r) &&
|
if ((pixels[y*image->width + x].r == color.r * 255) &&
|
||||||
(pixels[y*image->width + x].g == color.g) &&
|
(pixels[y*image->width + x].g == color.g * 255) &&
|
||||||
(pixels[y*image->width + x].b == color.b) &&
|
(pixels[y*image->width + x].b == color.b * 255) &&
|
||||||
(pixels[y*image->width + x].a == color.a))
|
(pixels[y*image->width + x].a == color.a * 255))
|
||||||
{
|
{
|
||||||
pixels[y*image->width + x].r = replace.r;
|
pixels[y*image->width + x].r = replace.r * 255;
|
||||||
pixels[y*image->width + x].g = replace.g;
|
pixels[y*image->width + x].g = replace.g * 255;
|
||||||
pixels[y*image->width + x].b = replace.b;
|
pixels[y*image->width + x].b = replace.b * 255;
|
||||||
pixels[y*image->width + x].a = replace.a;
|
pixels[y*image->width + x].a = replace.a * 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2344,9 +2362,14 @@ void ImageColorReplace(Image *image, Color color, Color replace)
|
||||||
// Generate image: plain color
|
// Generate image: plain color
|
||||||
Image GenImageColor(int width, int height, Color color)
|
Image GenImageColor(int width, int height, Color color)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_CALLOC(width*height, sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_CALLOC(width*height, sizeof(Color4ub));
|
||||||
|
Color4ub rcol;
|
||||||
|
rcol.r = color.r * 255;
|
||||||
|
rcol.g = color.g * 255;
|
||||||
|
rcol.b = color.b * 255;
|
||||||
|
rcol.a = color.a * 255;
|
||||||
|
|
||||||
for (int i = 0; i < width*height; i++) pixels[i] = color;
|
for (int i = 0; i < width*height; i++) pixels[i] = rcol;
|
||||||
|
|
||||||
Image image = LoadImageEx(pixels, width, height);
|
Image image = LoadImageEx(pixels, width, height);
|
||||||
|
|
||||||
|
|
@ -2359,17 +2382,26 @@ Image GenImageColor(int width, int height, Color color)
|
||||||
// Generate image: vertical gradient
|
// Generate image: vertical gradient
|
||||||
Image GenImageGradientV(int width, int height, Color top, Color bottom)
|
Image GenImageGradientV(int width, int height, Color top, Color bottom)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
Color4ub topr, bottomr;
|
||||||
|
topr.r = top.r * 255;
|
||||||
|
topr.g = top.g * 255;
|
||||||
|
topr.b = top.b * 255;
|
||||||
|
topr.a = top.a * 255;
|
||||||
|
bottomr.r = bottom.r * 255;
|
||||||
|
bottomr.g = bottom.r * 255;
|
||||||
|
bottomr.b = bottom.r * 255;
|
||||||
|
bottomr.a = bottom.r * 255;
|
||||||
|
|
||||||
for (int j = 0; j < height; j++)
|
for (int j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
float factor = (float)j/(float)height;
|
float factor = (float)j/(float)height;
|
||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
pixels[j*width + i].r = (int)((float)bottom.r*factor + (float)top.r*(1.f - factor));
|
pixels[j*width + i].r = (int)((float)bottomr.r*factor + (float)topr.r*(1.f - factor));
|
||||||
pixels[j*width + i].g = (int)((float)bottom.g*factor + (float)top.g*(1.f - factor));
|
pixels[j*width + i].g = (int)((float)bottomr.g*factor + (float)topr.g*(1.f - factor));
|
||||||
pixels[j*width + i].b = (int)((float)bottom.b*factor + (float)top.b*(1.f - factor));
|
pixels[j*width + i].b = (int)((float)bottomr.b*factor + (float)topr.b*(1.f - factor));
|
||||||
pixels[j*width + i].a = (int)((float)bottom.a*factor + (float)top.a*(1.f - factor));
|
pixels[j*width + i].a = (int)((float)bottomr.a*factor + (float)topr.a*(1.f - factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2382,17 +2414,26 @@ Image GenImageGradientV(int width, int height, Color top, Color bottom)
|
||||||
// Generate image: horizontal gradient
|
// Generate image: horizontal gradient
|
||||||
Image GenImageGradientH(int width, int height, Color left, Color right)
|
Image GenImageGradientH(int width, int height, Color left, Color right)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
Color4ub leftr, rightr;
|
||||||
|
leftr.r = left.r * 255;
|
||||||
|
leftr.g = left.g * 255;
|
||||||
|
leftr.b = left.b * 255;
|
||||||
|
leftr.a = left.a * 255;
|
||||||
|
rightr.r = right.r * 255;
|
||||||
|
rightr.g = right.g * 255;
|
||||||
|
rightr.b = right.b * 255;
|
||||||
|
rightr.a = right.a * 255;
|
||||||
|
|
||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
float factor = (float)i/(float)width;
|
float factor = (float)i/(float)width;
|
||||||
for (int j = 0; j < height; j++)
|
for (int j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
pixels[j*width + i].r = (int)((float)right.r*factor + (float)left.r*(1.f - factor));
|
pixels[j*width + i].r = (int)((float)rightr.r*factor + (float)leftr.r*(1.f - factor));
|
||||||
pixels[j*width + i].g = (int)((float)right.g*factor + (float)left.g*(1.f - factor));
|
pixels[j*width + i].g = (int)((float)rightr.g*factor + (float)leftr.g*(1.f - factor));
|
||||||
pixels[j*width + i].b = (int)((float)right.b*factor + (float)left.b*(1.f - factor));
|
pixels[j*width + i].b = (int)((float)rightr.b*factor + (float)leftr.b*(1.f - factor));
|
||||||
pixels[j*width + i].a = (int)((float)right.a*factor + (float)left.a*(1.f - factor));
|
pixels[j*width + i].a = (int)((float)rightr.a*factor + (float)leftr.a*(1.f - factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2405,8 +2446,17 @@ Image GenImageGradientH(int width, int height, Color left, Color right)
|
||||||
// Generate image: radial gradient
|
// Generate image: radial gradient
|
||||||
Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
|
Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
float radius = (width < height)? (float)width/2.0f : (float)height/2.0f;
|
float radius = (width < height)? (float)width/2.0f : (float)height/2.0f;
|
||||||
|
Color4ub innerr, outerr;
|
||||||
|
innerr.r = inner.r * 255;
|
||||||
|
innerr.g = inner.g * 255;
|
||||||
|
innerr.b = inner.b * 255;
|
||||||
|
innerr.a = inner.a * 255;
|
||||||
|
outerr.r = outer.r * 255;
|
||||||
|
outerr.g = outer.g * 255;
|
||||||
|
outerr.b = outer.b * 255;
|
||||||
|
outerr.a = outer.a * 255;
|
||||||
|
|
||||||
float centerX = (float)width/2.0f;
|
float centerX = (float)width/2.0f;
|
||||||
float centerY = (float)height/2.0f;
|
float centerY = (float)height/2.0f;
|
||||||
|
|
@ -2421,10 +2471,10 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
|
||||||
factor = (float)fmax(factor, 0.f);
|
factor = (float)fmax(factor, 0.f);
|
||||||
factor = (float)fmin(factor, 1.f); // dist can be bigger than radius so we have to check
|
factor = (float)fmin(factor, 1.f); // dist can be bigger than radius so we have to check
|
||||||
|
|
||||||
pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));
|
pixels[y*width + x].r = (int)((float)outerr.r*factor + (float)innerr.r*(1.0f - factor));
|
||||||
pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor));
|
pixels[y*width + x].g = (int)((float)outerr.g*factor + (float)innerr.g*(1.0f - factor));
|
||||||
pixels[y*width + x].b = (int)((float)outer.b*factor + (float)inner.b*(1.0f - factor));
|
pixels[y*width + x].b = (int)((float)outerr.b*factor + (float)innerr.b*(1.0f - factor));
|
||||||
pixels[y*width + x].a = (int)((float)outer.a*factor + (float)inner.a*(1.0f - factor));
|
pixels[y*width + x].a = (int)((float)outerr.a*factor + (float)innerr.a*(1.0f - factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2437,14 +2487,23 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
|
||||||
// Generate image: checked
|
// Generate image: checked
|
||||||
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
|
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
Color4ub col1r, col2r;
|
||||||
|
col1r.r = col1.r * 255;
|
||||||
|
col1r.g = col1.g * 255;
|
||||||
|
col1r.b = col1.b * 255;
|
||||||
|
col1r.a = col1.a * 255;
|
||||||
|
col2r.r = col2.r * 255;
|
||||||
|
col2r.g = col2.g * 255;
|
||||||
|
col2r.b = col2.b * 255;
|
||||||
|
col2r.a = col2.a * 255;
|
||||||
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
if ((x/checksX + y/checksY)%2 == 0) pixels[y*width + x] = col1;
|
if ((x/checksX + y/checksY)%2 == 0) pixels[y*width + x] = col1r;
|
||||||
else pixels[y*width + x] = col2;
|
else pixels[y*width + x] = col2r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2457,12 +2516,12 @@ Image GenImageChecked(int width, int height, int checksX, int checksY, Color col
|
||||||
// Generate image: white noise
|
// Generate image: white noise
|
||||||
Image GenImageWhiteNoise(int width, int height, float factor)
|
Image GenImageWhiteNoise(int width, int height, float factor)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int i = 0; i < width*height; i++)
|
for (int i = 0; i < width*height; i++)
|
||||||
{
|
{
|
||||||
if (GetRandomValue(0, 99) < (int)(factor*100.0f)) pixels[i] = WHITE;
|
if (GetRandomValue(0, 99) < (int)(factor*100.0f)) pixels[i] = (Color4ub){255,255,255,255};
|
||||||
else pixels[i] = BLACK;
|
else pixels[i] = (Color4ub){0,0,0,255};;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image image = LoadImageEx(pixels, width, height);
|
Image image = LoadImageEx(pixels, width, height);
|
||||||
|
|
@ -2474,7 +2533,7 @@ Image GenImageWhiteNoise(int width, int height, float factor)
|
||||||
// Generate image: perlin noise
|
// Generate image: perlin noise
|
||||||
Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale)
|
Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -2492,7 +2551,7 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
|
||||||
float p = (stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6) + 1.0f)/2.0f;
|
float p = (stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6) + 1.0f)/2.0f;
|
||||||
|
|
||||||
int intensity = (int)(p*255.0f);
|
int intensity = (int)(p*255.0f);
|
||||||
pixels[y*width + x] = (Color){intensity, intensity, intensity, 255};
|
pixels[y*width + x] = (Color4ub){intensity, intensity, intensity, 255};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2505,7 +2564,7 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
|
||||||
// Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
// Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||||
Image GenImageCellular(int width, int height, int tileSize)
|
Image GenImageCellular(int width, int height, int tileSize)
|
||||||
{
|
{
|
||||||
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
Color4ub *pixels = (Color4ub *)RL_MALLOC(width*height*sizeof(Color4ub));
|
||||||
|
|
||||||
int seedsPerRow = width/tileSize;
|
int seedsPerRow = width/tileSize;
|
||||||
int seedsPerCol = height/tileSize;
|
int seedsPerCol = height/tileSize;
|
||||||
|
|
@ -2550,7 +2609,7 @@ Image GenImageCellular(int width, int height, int tileSize)
|
||||||
int intensity = (int)(minDistance*256.0f/tileSize);
|
int intensity = (int)(minDistance*256.0f/tileSize);
|
||||||
if (intensity > 255) intensity = 255;
|
if (intensity > 255) intensity = 255;
|
||||||
|
|
||||||
pixels[y*width + x] = (Color){ intensity, intensity, intensity, 255 };
|
pixels[y*width + x] = (Color4ub){ intensity, intensity, intensity, 255 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2731,7 +2790,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
|
||||||
rlTranslatef(-origin.x, -origin.y, 0.0f);
|
rlTranslatef(-origin.x, -origin.y, 0.0f);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
rlColor4ub(tint.r * 255, tint.g * 255, tint.b * 255, tint.a * 255);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
||||||
|
|
||||||
// Bottom-left corner for texture and quad
|
// Bottom-left corner for texture and quad
|
||||||
|
|
@ -2826,7 +2885,7 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destR
|
||||||
rlTranslatef(-origin.x, -origin.y, 0.0f);
|
rlTranslatef(-origin.x, -origin.y, 0.0f);
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
rlColor4f(tint.r, tint.g, tint.b, tint.a);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
||||||
|
|
||||||
if (nPatchInfo.type == NPT_9PATCH)
|
if (nPatchInfo.type == NPT_9PATCH)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user