7 Commits

8 changed files with 164 additions and 185 deletions

View File

@ -9,10 +9,10 @@ IDE | Platform(s) | Source | Example(s)
[CMake](https://cmake.org/) | Windows, Linux, macOS, Web | ✔️ | ✔️ [CMake](https://cmake.org/) | Windows, Linux, macOS, Web | ✔️ | ✔️
[CodeBlocks](http://www.codeblocks.org/) | Windows, Linux, macOS | ❌ | ✔️ [CodeBlocks](http://www.codeblocks.org/) | Windows, Linux, macOS | ❌ | ✔️
[Geany](https://www.geany.org/) | Windows, Linux | ✔️ | ✔️ [Geany](https://www.geany.org/) | Windows, Linux | ✔️ | ✔️
[Notepad++](https://notepad-plus-plus.org/) | Windows | ✔️ | ✔️ [Notepad++](https://notepad-plus-plus.org/) | Windows Web | ✔️ | ✔️
[SublimeText](https://www.sublimetext.com/) | Windows, Linux, macOS | ✔️ | ✔️ [SublimeText](https://www.sublimetext.com/) | Windows, Linux, macOS | ✔️ | ✔️
[VS2019](https://www.visualstudio.com) | Windows | ✔️ | ✔️ [VS2022](https://www.visualstudio.com) | Windows | ✔️ | ✔️
[VSCode](https://code.visualstudio.com/) | Windows, macOS | ❌ | ✔️ [VSCode](https://code.visualstudio.com/) | Windows, Linux, macOS | ❌ | ✔️
[Zig](https://ziglang.org) | Windows, Linux, macOS, Web | ✔️ | ✔️ [Zig](https://ziglang.org) | Windows, Linux, macOS, Web | ✔️ | ✔️
scripts | Windows, Linux, macOS | ✔️ | ✔️ scripts | Windows, Linux, macOS | ✔️ | ✔️

4
src/external/rlsw.h vendored
View File

@ -3909,7 +3909,6 @@ static void sw_immediate_set_color(const float color[4])
RLSW.primitive.color[2] = color[2]; RLSW.primitive.color[2] = color[2];
RLSW.primitive.color[3] = color[3]; RLSW.primitive.color[3] = color[3];
RLSW.primitive.hasColorAlpha |= (color[3] < 1.0f);
} }
static void sw_immediate_set_texcoord(const float texcoord[2]) static void sw_immediate_set_texcoord(const float texcoord[2])
@ -3948,6 +3947,9 @@ static void sw_immediate_push_vertex(const float position[4])
for (int i = 0; i < 4; i++) vertex->color[i] = RLSW.primitive.color[i]; for (int i = 0; i < 4; i++) vertex->color[i] = RLSW.primitive.color[i];
for (int i = 0; i < 2; i++) vertex->texcoord[i] = RLSW.primitive.texcoord[i]; for (int i = 0; i < 2; i++) vertex->texcoord[i] = RLSW.primitive.texcoord[i];
// Track whether any vertex in this primitive has alpha < 1.0
RLSW.primitive.hasColorAlpha |= (vertex->color[3] < 1.0f);
// Immediate rendering of the primitive if the required number is reached // Immediate rendering of the primitive if the required number is reached
if (RLSW.primitive.vertexCount == SW_PRIMITIVE_VERTEX_COUNT[RLSW.drawMode]) if (RLSW.primitive.vertexCount == SW_PRIMITIVE_VERTEX_COUNT[RLSW.drawMode])
{ {

View File

@ -1325,7 +1325,7 @@ void PollInputEvents(void)
// Register previous gamepad states // Register previous gamepad states
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k]; for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k];
// Get current gamepad state // Get current gamepad state using internal GLFW mapping, instead of the immediate joystick API
// NOTE: There is no callback available, getting it manually // NOTE: There is no callback available, getting it manually
GLFWgamepadstate state = { 0 }; GLFWgamepadstate state = { 0 };
int result = glfwGetGamepadState(i, &state); // This remaps all gamepads so they have their buttons mapped like an xbox controller int result = glfwGetGamepadState(i, &state); // This remaps all gamepads so they have their buttons mapped like an xbox controller

View File

@ -1507,8 +1507,16 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
{ {
switch (eventType) switch (eventType)
{ {
case EMSCRIPTEN_EVENT_MOUSEENTER: CORE.Input.Mouse.cursorOnScreen = true; break; case EMSCRIPTEN_EVENT_MOUSEENTER: {
case EMSCRIPTEN_EVENT_MOUSELEAVE: CORE.Input.Mouse.cursorOnScreen = false; break; // NOTE: Mouse position updated by EmscriptenMouseMoveCallback(),
// EmscriptenPointerlockCallback(), and EmscriptenTouchCallback()
CORE.Input.Mouse.cursorOnScreen = true;
} break;
case EMSCRIPTEN_EVENT_MOUSELEAVE:
{
CORE.Input.Mouse.cursorOnScreen = false;
CORE.Input.Mouse.currentPosition = (Vector2){ 0 };
} break;
case EMSCRIPTEN_EVENT_MOUSEDOWN: case EMSCRIPTEN_EVENT_MOUSEDOWN:
{ {
// NOTE: Emscripten and raylib buttons indices are not aligned // NOTE: Emscripten and raylib buttons indices are not aligned

View File

@ -5237,7 +5237,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
{ {
int blockWidth = (width + 3)/4; int blockWidth = (width + 3)/4;
int blockHeight = (height + 3)/4; int blockHeight = (height + 3)/4;
unsigned long long dataSizeBytes = blockWidth*blockHeight*8; unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*8;
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes; if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
} break; } break;
@ -5248,7 +5248,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
{ {
int blockWidth = (width + 3)/4; int blockWidth = (width + 3)/4;
int blockHeight = (height + 3)/4; int blockHeight = (height + 3)/4;
unsigned long long dataSizeBytes = blockWidth*blockHeight*16; unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*16;
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes; if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
} break; } break;
@ -5256,7 +5256,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
{ {
int blockWidth = (width + 3)/4; int blockWidth = (width + 3)/4;
int blockHeight = (height + 3)/4; int blockHeight = (height + 3)/4;
unsigned long long dataSizeBytes = blockWidth*blockHeight*4; unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*4;
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes; if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
} break; } break;
@ -5267,7 +5267,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) && if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
(format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) (format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
{ {
unsigned long long dataSizeBytes = (width*height*bpp) >> 3; // Get size in bytes (dividing by 8) unsigned long long dataSizeBytes = ((unsigned long long)width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes; if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
} }

View File

@ -888,14 +888,13 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
// Draw rectangle with rounded edges // Draw rectangle with rounded edges
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, Color color) void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, Color color)
{ {
// NOTE: For line thicknes <=1.0f using RL_LINES, otherwise using RL_QUADS/RL_TRIANGLES
DrawRectangleRoundedLinesEx(rec, roundness, segments, 1.0f, color); DrawRectangleRoundedLinesEx(rec, roundness, segments, 1.0f, color);
} }
// Draw rectangle with rounded edges outline with line thickness // Draw rectangle with rounded edges outline with line thickness
void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, float thick, Color color) void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, float thick, Color color)
{ {
if (thick < 0) thick = 0; if (thick <= 0) return;
// Not a rounded rectangle // Not a rounded rectangle
if (roundness <= 0.0f) if (roundness <= 0.0f)
@ -966,8 +965,6 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };
if (thick > 1)
{
#if SUPPORT_QUADS_DRAW_MODE #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1107,35 +1104,6 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
rlVertex2f(point[14].x, point[14].y); rlVertex2f(point[14].x, point[14].y);
rlEnd(); rlEnd();
#endif #endif
}
else
{
// Use LINES to draw the outline
rlBegin(RL_LINES);
// Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{
float angle = angles[k];
const Vector2 center = centers[k];
for (int i = 0; i < segments; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
angle += stepLength;
}
}
// And now the remaining 4 lines
for (int i = 0; i < 8; i += 2)
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(point[i].x, point[i].y);
rlVertex2f(point[i + 1].x, point[i + 1].y);
}
rlEnd();
}
} }
// Draw a polygon of n sides // Draw a polygon of n sides

View File

@ -2014,7 +2014,7 @@ char *TextInsertAlloc(const char *text, const char *insert, int position)
for (int i = 0; i < position; i++) result[i] = text[i]; for (int i = 0; i < position; i++) result[i] = text[i];
for (int i = position; i < (insertLen + position); i++) result[i] = insert[i - position]; for (int i = position; i < (insertLen + position); i++) result[i] = insert[i - position];
for (int i = (insertLen + position); i < (textLen + insertLen + position); i++) result[i] = text[i - insertLen]; for (int i = (insertLen + position); i < (textLen + insertLen); i++) result[i] = text[i - insertLen];
result[textLen + insertLen] = '\0'; // Add EOL result[textLen + insertLen] = '\0'; // Add EOL
} }

View File

@ -2693,8 +2693,9 @@ void ImageRotate(Image *image, int degrees)
int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius)); int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius));
int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius)); int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius));
int bytesPerPixel = GetPixelDataSize(width, height, image->format); int dataSize = GetPixelDataSize(width, height, image->format);
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(bytesPerPixel, 1); int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(dataSize, 1);
if (rotatedData != NULL) if (rotatedData != NULL)
{ {
@ -5514,7 +5515,7 @@ int GetPixelDataSize(int width, int height, int format)
default: break; default: break;
} }
unsigned long long dataSizeBytes = (width*height*bpp) >> 3; // Get size in bytes (dividing by 8) unsigned long long dataSizeBytes = ((unsigned long long)width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
if (dataSizeBytes < INT_MAX) if (dataSizeBytes < INT_MAX)
{ {