mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-25 05:38:27 -04:00
Compare commits
14 Commits
f00317bead
...
patch-1
| Author | SHA1 | Date | |
|---|---|---|---|
| 46b9579f0c | |||
| 8eb613e50a | |||
| 89b4fbd298 | |||
| 93e64f2210 | |||
| a9a0c046f1 | |||
| d224912bd5 | |||
| 39706cccbe | |||
| 4640c84920 | |||
| af98e3126e | |||
| e063385c47 | |||
| 7a247ff40f | |||
| 5de8c3521f | |||
| b631fb3d05 | |||
| fb4649a3fe |
@ -99,7 +99,7 @@ vec3 ComputePBR()
|
||||
vec3 N = normalize(fragNormal);
|
||||
if (useTexNormal == 1)
|
||||
{
|
||||
N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.y, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = normalize(N*2.0 - 1.0);
|
||||
N = normalize(N*TBN);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ vec3 ComputePBR()
|
||||
vec3 N = normalize(fragNormal);
|
||||
if (useTexNormal == 1)
|
||||
{
|
||||
N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.y, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = normalize(N*2.0 - 1.0);
|
||||
N = normalize(N*TBN);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ vec3 ComputePBR()
|
||||
vec3 N = normalize(fragNormal);
|
||||
if (useTexNormal == 1)
|
||||
{
|
||||
N = texture(normalMap, vec2(fragTexCoord.x*tiling.x + offset.y, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = texture(normalMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
||||
N = normalize(N*2.0 - 1.0);
|
||||
N = normalize(N*TBN);
|
||||
}
|
||||
|
||||
@ -9,10 +9,10 @@ IDE | Platform(s) | Source | Example(s)
|
||||
[CMake](https://cmake.org/) | Windows, Linux, macOS, Web | ✔️ | ✔️
|
||||
[CodeBlocks](http://www.codeblocks.org/) | Windows, Linux, macOS | ❌ | ✔️
|
||||
[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 | ✔️ | ✔️
|
||||
[VS2019](https://www.visualstudio.com) | Windows | ✔️ | ✔️
|
||||
[VSCode](https://code.visualstudio.com/) | Windows, macOS | ❌ | ✔️
|
||||
[VS2022](https://www.visualstudio.com) | Windows | ✔️ | ✔️
|
||||
[VSCode](https://code.visualstudio.com/) | Windows, Linux, macOS | ❌ | ✔️
|
||||
[Zig](https://ziglang.org) | Windows, Linux, macOS, Web | ✔️ | ✔️
|
||||
scripts | Windows, Linux, macOS | ✔️ | ✔️
|
||||
|
||||
|
||||
8
src/external/rlsw.h
vendored
8
src/external/rlsw.h
vendored
@ -3909,7 +3909,6 @@ static void sw_immediate_set_color(const float color[4])
|
||||
RLSW.primitive.color[2] = color[2];
|
||||
RLSW.primitive.color[3] = color[3];
|
||||
|
||||
RLSW.primitive.hasColorAlpha |= (color[3] < 1.0f);
|
||||
}
|
||||
|
||||
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 < 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
|
||||
if (RLSW.primitive.vertexCount == SW_PRIMITIVE_VERTEX_COUNT[RLSW.drawMode])
|
||||
{
|
||||
@ -4307,8 +4309,8 @@ void swScissor(int x, int y, int width, int height)
|
||||
|
||||
RLSW.scClipMin[0] = (2.0f*(float)RLSW.scMin[0]/(float)RLSW.vpSize[0]) - 1.0f;
|
||||
RLSW.scClipMax[0] = (2.0f*(float)RLSW.scMax[0]/(float)RLSW.vpSize[0]) - 1.0f;
|
||||
RLSW.scClipMax[1] = 1.0f - (2.0f*(float)RLSW.scMin[1]/(float)RLSW.vpSize[1]);
|
||||
RLSW.scClipMin[1] = 1.0f - (2.0f*(float)RLSW.scMax[1]/(float)RLSW.vpSize[1]);
|
||||
RLSW.scClipMin[1] = (2.0f*(float)RLSW.scMin[1]/(float)RLSW.vpSize[1]) - 1.0f;
|
||||
RLSW.scClipMax[1] = (2.0f*(float)RLSW.scMax[1]/(float)RLSW.vpSize[1]) - 1.0f;
|
||||
}
|
||||
|
||||
void swClearColor(float r, float g, float b, float a)
|
||||
|
||||
@ -726,7 +726,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -1237,7 +1237,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
// NOTE: emscripten not implemented
|
||||
glfwSetCursorPos(platform.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);
|
||||
@ -1326,7 +1325,7 @@ void PollInputEvents(void)
|
||||
// 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];
|
||||
|
||||
// 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
|
||||
GLFWgamepadstate state = { 0 };
|
||||
int result = glfwGetGamepadState(i, &state); // This remaps all gamepads so they have their buttons mapped like an xbox controller
|
||||
|
||||
@ -1526,7 +1526,6 @@ void SetMousePosition(int x, int y)
|
||||
{
|
||||
RGFW_window_moveMouse(platform.window, x, y);
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -1255,12 +1255,14 @@ Image GetClipboardImage(void)
|
||||
|
||||
for (int i = 0; i < SDL_arraysize(imageFormats); i++)
|
||||
{
|
||||
// NOTE: This pointer should be free with SDL_free() at some point
|
||||
fileData = SDL_GetClipboardData(imageFormats[i], &dataSize);
|
||||
|
||||
if (fileData)
|
||||
{
|
||||
image = LoadImageFromMemory(imageExtensions[i], fileData, (int)dataSize);
|
||||
|
||||
SDL_free(fileData);
|
||||
|
||||
if (IsImageValid(image))
|
||||
{
|
||||
TRACELOG(LOG_INFO, "Clipboard: Got image from clipboard successfully: %s", imageExtensions[i]);
|
||||
@ -1409,7 +1411,6 @@ void SetMousePosition(int x, int y)
|
||||
SDL_WarpMouseInWindow(platform.window, x, y);
|
||||
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -1299,8 +1299,8 @@ void SetMousePosition(int x, int y)
|
||||
if (!CORE.Input.Mouse.cursorLocked)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
TRACELOG(LOG_WARNING, "SetMousePosition not implemented");
|
||||
|
||||
TRACELOG(LOG_WARNING, "SetMousePosition not implemented at platform level");
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "INPUT: MOUSE: Cursor not enabled");
|
||||
}
|
||||
|
||||
@ -1042,7 +1042,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -420,7 +420,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -395,7 +395,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
|
||||
@ -1047,7 +1047,6 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
if (CORE.Input.Mouse.cursorLocked) CORE.Input.Mouse.lockedPosition = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
|
||||
@ -1507,8 +1507,16 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
|
||||
{
|
||||
switch (eventType)
|
||||
{
|
||||
case EMSCRIPTEN_EVENT_MOUSEENTER: CORE.Input.Mouse.cursorOnScreen = true; break;
|
||||
case EMSCRIPTEN_EVENT_MOUSELEAVE: CORE.Input.Mouse.cursorOnScreen = false; break;
|
||||
case EMSCRIPTEN_EVENT_MOUSEENTER: {
|
||||
// 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:
|
||||
{
|
||||
// NOTE: Emscripten and raylib buttons indices are not aligned
|
||||
|
||||
@ -5237,7 +5237,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||
{
|
||||
int blockWidth = (width + 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;
|
||||
|
||||
} break;
|
||||
@ -5248,7 +5248,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||
{
|
||||
int blockWidth = (width + 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;
|
||||
|
||||
} break;
|
||||
@ -5256,7 +5256,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||
{
|
||||
int blockWidth = (width + 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;
|
||||
|
||||
} break;
|
||||
@ -5267,7 +5267,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||
if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
|
||||
(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;
|
||||
}
|
||||
|
||||
|
||||
@ -888,14 +888,13 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
|
||||
// Draw rectangle with rounded edges
|
||||
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);
|
||||
}
|
||||
|
||||
// Draw rectangle with rounded edges outline with line thickness
|
||||
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
|
||||
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 };
|
||||
|
||||
if (thick > 1)
|
||||
{
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
@ -1107,35 +1104,6 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
|
||||
rlVertex2f(point[14].x, point[14].y);
|
||||
rlEnd();
|
||||
#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
|
||||
|
||||
@ -1699,7 +1699,7 @@ const char *TextSubtext(const char *text, int position, int length)
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
if ((text != NULL) && (position > 0) && (length > 0))
|
||||
if ((text != NULL) && (position >= 0) && (length > 0))
|
||||
{
|
||||
int textLength = TextLength(text);
|
||||
|
||||
@ -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 = 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
|
||||
}
|
||||
|
||||
@ -1231,9 +1231,9 @@ Image ImageFromImage(Image image, Rectangle rec)
|
||||
Image result = { 0 };
|
||||
|
||||
// Basic rectangle validation: size smaller than image size
|
||||
if ((rec.x > 0) && (rec.y > 0) && (rec.width > 0) && (rec.height > 0) &&
|
||||
(((int)rec.x + (int)rec.width) < image.width) &&
|
||||
(((int)rec.y + (int)rec.height) < image.height))
|
||||
if ((rec.x >= 0) && (rec.y >= 0) && (rec.width > 0) && (rec.height > 0) &&
|
||||
(((int)rec.x + (int)rec.width) <= image.width) &&
|
||||
(((int)rec.y + (int)rec.height) <= image.height))
|
||||
{
|
||||
int bytesPerPixel = GetPixelDataSize(1, 1, image.format);
|
||||
|
||||
@ -2693,8 +2693,9 @@ void ImageRotate(Image *image, int degrees)
|
||||
int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius));
|
||||
int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius));
|
||||
|
||||
int bytesPerPixel = GetPixelDataSize(width, height, image->format);
|
||||
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(bytesPerPixel, 1);
|
||||
int dataSize = GetPixelDataSize(width, height, image->format);
|
||||
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
|
||||
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(dataSize, 1);
|
||||
|
||||
if (rotatedData != NULL)
|
||||
{
|
||||
@ -5514,7 +5515,7 @@ int GetPixelDataSize(int width, int height, int format)
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user