Merge branch 'raysan5:master' into master
This commit is contained in:
commit
19c273b440
|
|
@ -9,7 +9,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| raylib | **5.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
|
| raylib | **5.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
|
||||||
| raylib-beef | **5.0** | [Beef](https://www.beeflang.org/) | MIT | https://github.com/Starpelly/raylib-beef |
|
| raylib-beef | **5.0** | [Beef](https://www.beeflang.org/) | MIT | https://github.com/Starpelly/raylib-beef |
|
||||||
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
|
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
|
||||||
| Raylib-cs | 4.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
|
| Raylib-cs | 5.0 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
|
||||||
| Raylib-CsLo | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
| Raylib-CsLo | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
||||||
| cl-raylib | 4.0 | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
| cl-raylib | 4.0 | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
||||||
| claylib/wrap | 4.5 | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
| claylib/wrap | 4.5 | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
||||||
cubemap.id = rlLoadTextureCubemap(0, size, format);
|
cubemap.id = rlLoadTextureCubemap(0, size, format);
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
unsigned int fbo = rlLoadFramebuffer();
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ int main(void)
|
||||||
|
|
||||||
// Initialize the G-buffer
|
// Initialize the G-buffer
|
||||||
GBuffer gBuffer = { 0 };
|
GBuffer gBuffer = { 0 };
|
||||||
gBuffer.framebuffer = rlLoadFramebuffer(screenWidth, screenHeight);
|
gBuffer.framebuffer = rlLoadFramebuffer();
|
||||||
|
|
||||||
if (!gBuffer.framebuffer)
|
if (!gBuffer.framebuffer)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
|
||||||
{
|
{
|
||||||
RenderTexture2D target = { 0 };
|
RenderTexture2D target = { 0 };
|
||||||
|
|
||||||
target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
|
target.id = rlLoadFramebuffer(); // Load an empty framebuffer
|
||||||
|
|
||||||
if (target.id > 0)
|
if (target.id > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ RenderTexture2D LoadShadowmapRenderTexture(int width, int height)
|
||||||
{
|
{
|
||||||
RenderTexture2D target = { 0 };
|
RenderTexture2D target = { 0 };
|
||||||
|
|
||||||
target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
|
target.id = rlLoadFramebuffer(); // Load an empty framebuffer
|
||||||
target.texture.width = width;
|
target.texture.width = width;
|
||||||
target.texture.height = height;
|
target.texture.height = height;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
|
||||||
{
|
{
|
||||||
RenderTexture2D target = { 0 };
|
RenderTexture2D target = { 0 };
|
||||||
|
|
||||||
target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
|
target.id = rlLoadFramebuffer(); // Load an empty framebuffer
|
||||||
|
|
||||||
if (target.id > 0)
|
if (target.id > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3887,24 +3887,25 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "GetCameraMatrix",
|
"name": "GetViewRay",
|
||||||
"description": "Get camera transform matrix (view matrix)",
|
"description": "Get a ray trace from mouse position in a viewport",
|
||||||
"returnType": "Matrix",
|
"returnType": "Ray",
|
||||||
"params": [
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Vector2",
|
||||||
|
"name": "mousePosition"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "Camera",
|
"type": "Camera",
|
||||||
"name": "camera"
|
"name": "camera"
|
||||||
}
|
},
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetCameraMatrix2D",
|
|
||||||
"description": "Get camera 2d transform matrix",
|
|
||||||
"returnType": "Matrix",
|
|
||||||
"params": [
|
|
||||||
{
|
{
|
||||||
"type": "Camera2D",
|
"type": "float",
|
||||||
"name": "camera"
|
"name": "width"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "float",
|
||||||
|
"name": "height"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -3923,21 +3924,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "GetScreenToWorld2D",
|
|
||||||
"description": "Get the world space position for a 2d camera screen space position",
|
|
||||||
"returnType": "Vector2",
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"type": "Vector2",
|
|
||||||
"name": "position"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Camera2D",
|
|
||||||
"name": "camera"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "GetWorldToScreenEx",
|
"name": "GetWorldToScreenEx",
|
||||||
"description": "Get size position for a 3d world space position",
|
"description": "Get size position for a 3d world space position",
|
||||||
|
|
@ -3976,6 +3962,43 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "GetScreenToWorld2D",
|
||||||
|
"description": "Get the world space position for a 2d camera screen space position",
|
||||||
|
"returnType": "Vector2",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Vector2",
|
||||||
|
"name": "position"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Camera2D",
|
||||||
|
"name": "camera"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetCameraMatrix",
|
||||||
|
"description": "Get camera transform matrix (view matrix)",
|
||||||
|
"returnType": "Matrix",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Camera",
|
||||||
|
"name": "camera"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetCameraMatrix2D",
|
||||||
|
"description": "Get camera 2d transform matrix",
|
||||||
|
"returnType": "Matrix",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Camera2D",
|
||||||
|
"name": "camera"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SetTargetFPS",
|
"name": "SetTargetFPS",
|
||||||
"description": "Set target FPS (maximum)",
|
"description": "Set target FPS (maximum)",
|
||||||
|
|
|
||||||
|
|
@ -3644,19 +3644,14 @@ return {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "GetCameraMatrix",
|
name = "GetViewRay",
|
||||||
description = "Get camera transform matrix (view matrix)",
|
description = "Get a ray trace from mouse position in a viewport",
|
||||||
returnType = "Matrix",
|
returnType = "Ray",
|
||||||
params = {
|
params = {
|
||||||
{type = "Camera", name = "camera"}
|
{type = "Vector2", name = "mousePosition"},
|
||||||
}
|
{type = "Camera", name = "camera"},
|
||||||
},
|
{type = "float", name = "width"},
|
||||||
{
|
{type = "float", name = "height"}
|
||||||
name = "GetCameraMatrix2D",
|
|
||||||
description = "Get camera 2d transform matrix",
|
|
||||||
returnType = "Matrix",
|
|
||||||
params = {
|
|
||||||
{type = "Camera2D", name = "camera"}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -3668,15 +3663,6 @@ return {
|
||||||
{type = "Camera", name = "camera"}
|
{type = "Camera", name = "camera"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name = "GetScreenToWorld2D",
|
|
||||||
description = "Get the world space position for a 2d camera screen space position",
|
|
||||||
returnType = "Vector2",
|
|
||||||
params = {
|
|
||||||
{type = "Vector2", name = "position"},
|
|
||||||
{type = "Camera2D", name = "camera"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name = "GetWorldToScreenEx",
|
name = "GetWorldToScreenEx",
|
||||||
description = "Get size position for a 3d world space position",
|
description = "Get size position for a 3d world space position",
|
||||||
|
|
@ -3697,6 +3683,31 @@ return {
|
||||||
{type = "Camera2D", name = "camera"}
|
{type = "Camera2D", name = "camera"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name = "GetScreenToWorld2D",
|
||||||
|
description = "Get the world space position for a 2d camera screen space position",
|
||||||
|
returnType = "Vector2",
|
||||||
|
params = {
|
||||||
|
{type = "Vector2", name = "position"},
|
||||||
|
{type = "Camera2D", name = "camera"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "GetCameraMatrix",
|
||||||
|
description = "Get camera transform matrix (view matrix)",
|
||||||
|
returnType = "Matrix",
|
||||||
|
params = {
|
||||||
|
{type = "Camera", name = "camera"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "GetCameraMatrix2D",
|
||||||
|
description = "Get camera 2d transform matrix",
|
||||||
|
returnType = "Matrix",
|
||||||
|
params = {
|
||||||
|
{type = "Camera2D", name = "camera"}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name = "SetTargetFPS",
|
name = "SetTargetFPS",
|
||||||
description = "Set target FPS (maximum)",
|
description = "Set target FPS (maximum)",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -669,7 +669,7 @@
|
||||||
<Param type="unsigned int" name="frames" desc="" />
|
<Param type="unsigned int" name="frames" desc="" />
|
||||||
</Callback>
|
</Callback>
|
||||||
</Callbacks>
|
</Callbacks>
|
||||||
<Functions count="558">
|
<Functions count="559">
|
||||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||||
<Param type="int" name="width" desc="" />
|
<Param type="int" name="width" desc="" />
|
||||||
<Param type="int" name="height" desc="" />
|
<Param type="int" name="height" desc="" />
|
||||||
|
|
@ -906,20 +906,16 @@
|
||||||
<Param type="Vector2" name="mousePosition" desc="" />
|
<Param type="Vector2" name="mousePosition" desc="" />
|
||||||
<Param type="Camera" name="camera" desc="" />
|
<Param type="Camera" name="camera" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="GetCameraMatrix" retType="Matrix" paramCount="1" desc="Get camera transform matrix (view matrix)">
|
<Function name="GetViewRay" retType="Ray" paramCount="4" desc="Get a ray trace from mouse position in a viewport">
|
||||||
|
<Param type="Vector2" name="mousePosition" desc="" />
|
||||||
<Param type="Camera" name="camera" desc="" />
|
<Param type="Camera" name="camera" desc="" />
|
||||||
</Function>
|
<Param type="float" name="width" desc="" />
|
||||||
<Function name="GetCameraMatrix2D" retType="Matrix" paramCount="1" desc="Get camera 2d transform matrix">
|
<Param type="float" name="height" desc="" />
|
||||||
<Param type="Camera2D" name="camera" desc="" />
|
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="GetWorldToScreen" retType="Vector2" paramCount="2" desc="Get the screen space position for a 3d world space position">
|
<Function name="GetWorldToScreen" retType="Vector2" paramCount="2" desc="Get the screen space position for a 3d world space position">
|
||||||
<Param type="Vector3" name="position" desc="" />
|
<Param type="Vector3" name="position" desc="" />
|
||||||
<Param type="Camera" name="camera" desc="" />
|
<Param type="Camera" name="camera" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="GetScreenToWorld2D" retType="Vector2" paramCount="2" desc="Get the world space position for a 2d camera screen space position">
|
|
||||||
<Param type="Vector2" name="position" desc="" />
|
|
||||||
<Param type="Camera2D" name="camera" desc="" />
|
|
||||||
</Function>
|
|
||||||
<Function name="GetWorldToScreenEx" retType="Vector2" paramCount="4" desc="Get size position for a 3d world space position">
|
<Function name="GetWorldToScreenEx" retType="Vector2" paramCount="4" desc="Get size position for a 3d world space position">
|
||||||
<Param type="Vector3" name="position" desc="" />
|
<Param type="Vector3" name="position" desc="" />
|
||||||
<Param type="Camera" name="camera" desc="" />
|
<Param type="Camera" name="camera" desc="" />
|
||||||
|
|
@ -930,6 +926,16 @@
|
||||||
<Param type="Vector2" name="position" desc="" />
|
<Param type="Vector2" name="position" desc="" />
|
||||||
<Param type="Camera2D" name="camera" desc="" />
|
<Param type="Camera2D" name="camera" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
|
<Function name="GetScreenToWorld2D" retType="Vector2" paramCount="2" desc="Get the world space position for a 2d camera screen space position">
|
||||||
|
<Param type="Vector2" name="position" desc="" />
|
||||||
|
<Param type="Camera2D" name="camera" desc="" />
|
||||||
|
</Function>
|
||||||
|
<Function name="GetCameraMatrix" retType="Matrix" paramCount="1" desc="Get camera transform matrix (view matrix)">
|
||||||
|
<Param type="Camera" name="camera" desc="" />
|
||||||
|
</Function>
|
||||||
|
<Function name="GetCameraMatrix2D" retType="Matrix" paramCount="1" desc="Get camera 2d transform matrix">
|
||||||
|
<Param type="Camera2D" name="camera" desc="" />
|
||||||
|
</Function>
|
||||||
<Function name="SetTargetFPS" retType="void" paramCount="1" desc="Set target FPS (maximum)">
|
<Function name="SetTargetFPS" retType="void" paramCount="1" desc="Set target FPS (maximum)">
|
||||||
<Param type="int" name="fps" desc="" />
|
<Param type="int" name="fps" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@
|
||||||
// Selected desired font fileformats to be supported for loading
|
// Selected desired font fileformats to be supported for loading
|
||||||
#define SUPPORT_FILEFORMAT_FNT 1
|
#define SUPPORT_FILEFORMAT_FNT 1
|
||||||
#define SUPPORT_FILEFORMAT_TTF 1
|
#define SUPPORT_FILEFORMAT_TTF 1
|
||||||
|
#define SUPPORT_FILEFORMAT_BDF 1
|
||||||
|
|
||||||
// Support text management functions
|
// Support text management functions
|
||||||
// If not defined, still some functions are supported: TextLength(), TextFormat()
|
// If not defined, still some functions are supported: TextLength(), TextFormat()
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ typedef struct {
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_GLContext glContext;
|
SDL_GLContext glContext;
|
||||||
|
|
||||||
SDL_Joystick *gamepad;
|
SDL_Joystick *gamepad[MAX_GAMEPADS];
|
||||||
SDL_Cursor *cursor;
|
SDL_Cursor *cursor;
|
||||||
bool cursorRelative;
|
bool cursorRelative;
|
||||||
} PlatformData;
|
} PlatformData;
|
||||||
|
|
@ -978,8 +978,18 @@ void PollInputEvents(void)
|
||||||
else CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
else CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||||
|
|
||||||
// Reset last gamepad button/axis registered state
|
// Reset last gamepad button/axis registered state
|
||||||
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;
|
for (int i = 0; (i < SDL_NumJoysticks()) && (i < MAX_GAMEPADS); i++)
|
||||||
for (int i = 0; i < MAX_GAMEPADS; i++) CORE.Input.Gamepad.axisCount[i] = 0;
|
{
|
||||||
|
// Check if gamepad is available
|
||||||
|
if (CORE.Input.Gamepad.ready[i])
|
||||||
|
{
|
||||||
|
// Register previous gamepad button states
|
||||||
|
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++)
|
||||||
|
{
|
||||||
|
CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Register previous touch states
|
// Register previous touch states
|
||||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
|
||||||
|
|
@ -1215,20 +1225,134 @@ void PollInputEvents(void)
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// Check gamepad events
|
// Check gamepad events
|
||||||
|
case SDL_JOYDEVICEADDED:
|
||||||
|
{
|
||||||
|
int jid = event.jdevice.which;
|
||||||
|
if (!CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS)) {
|
||||||
|
platform.gamepad[jid] = SDL_JoystickOpen(jid);
|
||||||
|
|
||||||
|
if (platform.gamepad[jid])
|
||||||
|
{
|
||||||
|
CORE.Input.Gamepad.ready[jid] = true;
|
||||||
|
CORE.Input.Gamepad.axisCount[jid] = SDL_JoystickNumAxes(platform.gamepad[jid]);
|
||||||
|
CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||||
|
CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||||
|
strncpy(CORE.Input.Gamepad.name[jid], SDL_JoystickName(platform.gamepad[jid]), 63);
|
||||||
|
CORE.Input.Gamepad.name[jid][63] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SDL_JOYDEVICEREMOVED:
|
||||||
|
{
|
||||||
|
int jid = event.jdevice.which;
|
||||||
|
if (jid == SDL_JoystickInstanceID(platform.gamepad[jid])) {
|
||||||
|
SDL_JoystickClose(platform.gamepad[jid]);
|
||||||
|
platform.gamepad[jid] = SDL_JoystickOpen(0);
|
||||||
|
CORE.Input.Gamepad.ready[jid] = false;
|
||||||
|
memset(CORE.Input.Gamepad.name[jid], 0, 64);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SDL_JOYBUTTONDOWN:
|
||||||
|
{
|
||||||
|
int button = -1;
|
||||||
|
|
||||||
|
switch (event.jbutton.button)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_BUTTON_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_BACK: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_GUIDE: button = GAMEPAD_BUTTON_MIDDLE; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_LEFTSTICK: button = GAMEPAD_BUTTON_LEFT_THUMB; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_RIGHTSTICK: button = GAMEPAD_BUTTON_RIGHT_THUMB; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button >= 0)
|
||||||
|
{
|
||||||
|
CORE.Input.Gamepad.currentButtonState[event.jbutton.which][button] = 1;
|
||||||
|
CORE.Input.Gamepad.lastButtonPressed = button;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SDL_JOYBUTTONUP:
|
||||||
|
{
|
||||||
|
int button = -1;
|
||||||
|
|
||||||
|
switch (event.jbutton.button)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_BUTTON_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_BACK: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_GUIDE: button = GAMEPAD_BUTTON_MIDDLE; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_LEFTSTICK: button = GAMEPAD_BUTTON_LEFT_THUMB; break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_RIGHTSTICK: button = GAMEPAD_BUTTON_RIGHT_THUMB; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button >= 0)
|
||||||
|
{
|
||||||
|
CORE.Input.Gamepad.currentButtonState[event.jbutton.which][button] = 0;
|
||||||
|
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
{
|
{
|
||||||
// Motion on gamepad 0
|
int axis = -1;
|
||||||
if (event.jaxis.which == 0)
|
|
||||||
|
switch (event.jaxis.axis)
|
||||||
{
|
{
|
||||||
// X axis motion
|
case SDL_CONTROLLER_AXIS_LEFTX: axis = GAMEPAD_AXIS_LEFT_X; break;
|
||||||
if (event.jaxis.axis == 0)
|
case SDL_CONTROLLER_AXIS_LEFTY: axis = GAMEPAD_AXIS_LEFT_Y; break;
|
||||||
|
case SDL_CONTROLLER_AXIS_RIGHTX: axis = GAMEPAD_AXIS_RIGHT_X; break;
|
||||||
|
case SDL_CONTROLLER_AXIS_RIGHTY: axis = GAMEPAD_AXIS_RIGHT_Y; break;
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERLEFT: axis = GAMEPAD_AXIS_LEFT_TRIGGER; break;
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: axis = GAMEPAD_AXIS_RIGHT_TRIGGER; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (axis >= 0)
|
||||||
|
{
|
||||||
|
// SDL axis value range is -32768 to 32767, we normalize it to RayLib's -1.0 to 1.0f range
|
||||||
|
float value = event.jaxis.value / (float) 32767;
|
||||||
|
CORE.Input.Gamepad.axisState[event.jaxis.which][axis] = value;
|
||||||
|
|
||||||
|
// Register button state for triggers in addition to their axes
|
||||||
|
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
|
||||||
{
|
{
|
||||||
//...
|
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER) ? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||||
}
|
int pressed = (value > 0.1f);
|
||||||
// Y axis motion
|
CORE.Input.Gamepad.currentButtonState[event.jaxis.which][button] = pressed;
|
||||||
else if (event.jaxis.axis == 1)
|
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
||||||
{
|
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||||
//...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -1405,10 +1529,20 @@ int InitPlatform(void)
|
||||||
|
|
||||||
// Initialize input events system
|
// Initialize input events system
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
if (SDL_NumJoysticks() >= 1)
|
// Initialize gamepads
|
||||||
|
for (int i = 0; (i < SDL_NumJoysticks()) && (i < MAX_GAMEPADS); i++)
|
||||||
{
|
{
|
||||||
platform.gamepad = SDL_JoystickOpen(0);
|
platform.gamepad[i] = SDL_JoystickOpen(i);
|
||||||
//if (platform.gamepadgamepad == NULL) TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
|
if (platform.gamepad[i])
|
||||||
|
{
|
||||||
|
CORE.Input.Gamepad.ready[i] = true;
|
||||||
|
CORE.Input.Gamepad.axisCount[i] = SDL_JoystickNumAxes(platform.gamepad[i]);
|
||||||
|
CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||||
|
CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||||
|
strncpy(CORE.Input.Gamepad.name[i], SDL_JoystickName(platform.gamepad[i]), 63);
|
||||||
|
CORE.Input.Gamepad.name[i][63] = '\0';
|
||||||
|
}
|
||||||
|
else TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable mouse events being interpreted as touch events
|
// Disable mouse events being interpreted as touch events
|
||||||
|
|
|
||||||
13
src/raylib.h
13
src/raylib.h
|
|
@ -1049,13 +1049,14 @@ RLAPI void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
|
||||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||||
|
|
||||||
// Screen-space-related functions
|
// Screen-space-related functions
|
||||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position
|
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position
|
||||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
|
RLAPI Ray GetViewRay(Vector2 mousePosition, Camera camera, float width, float height); // Get a ray trace from mouse position in a viewport
|
||||||
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
|
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position
|
||||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position
|
|
||||||
RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
|
|
||||||
RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position
|
RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position
|
||||||
RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position
|
RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position
|
||||||
|
RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
|
||||||
|
RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
|
||||||
|
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
|
||||||
|
|
||||||
// Timing-related functions
|
// Timing-related functions
|
||||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||||
|
|
|
||||||
48
src/rcore.c
48
src/rcore.c
|
|
@ -1404,14 +1404,20 @@ void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Get a ray trace from mouse position
|
// Get a ray trace from mouse position
|
||||||
Ray GetMouseRay(Vector2 mouse, Camera camera)
|
Ray GetMouseRay(Vector2 mousePosition, Camera camera)
|
||||||
|
{
|
||||||
|
return GetViewRay(mousePosition, camera, GetScreenWidth(), GetScreenHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a ray trace from the mouse position within a specific section of the screen
|
||||||
|
Ray GetViewRay(Vector2 mousePosition, Camera camera, float width, float height)
|
||||||
{
|
{
|
||||||
Ray ray = { 0 };
|
Ray ray = { 0 };
|
||||||
|
|
||||||
// Calculate normalized device coordinates
|
// Calculate normalized device coordinates
|
||||||
// NOTE: y value is negative
|
// NOTE: y value is negative
|
||||||
float x = (2.0f*mouse.x)/(float)GetScreenWidth() - 1.0f;
|
float x = (2.0f*mousePosition.x)/width - 1.0f;
|
||||||
float y = 1.0f - (2.0f*mouse.y)/(float)GetScreenHeight();
|
float y = 1.0f - (2.0f*mousePosition.y)/height;
|
||||||
float z = 1.0f;
|
float z = 1.0f;
|
||||||
|
|
||||||
// Store values in a vector
|
// Store values in a vector
|
||||||
|
|
@ -1425,11 +1431,11 @@ Ray GetMouseRay(Vector2 mouse, Camera camera)
|
||||||
if (camera.projection == CAMERA_PERSPECTIVE)
|
if (camera.projection == CAMERA_PERSPECTIVE)
|
||||||
{
|
{
|
||||||
// Calculate projection matrix from perspective
|
// Calculate projection matrix from perspective
|
||||||
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)width/(double)height), RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
||||||
}
|
}
|
||||||
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
||||||
{
|
{
|
||||||
double aspect = (double)CORE.Window.screen.width/(double)CORE.Window.screen.height;
|
double aspect = (double)width/(double)height;
|
||||||
double top = camera.fovy/2.0;
|
double top = camera.fovy/2.0;
|
||||||
double right = top*aspect;
|
double right = top*aspect;
|
||||||
|
|
||||||
|
|
@ -1840,7 +1846,7 @@ bool FileExists(const char *fileName)
|
||||||
// NOTE: Extensions checking is not case-sensitive
|
// NOTE: Extensions checking is not case-sensitive
|
||||||
bool IsFileExtension(const char *fileName, const char *ext)
|
bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
{
|
{
|
||||||
#define MAX_FILE_EXTENSION_SIZE 16
|
#define MAX_FILE_EXTENSION_LENGTH 16
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
const char *fileExt = GetFileExtension(fileName);
|
const char *fileExt = GetFileExtension(fileName);
|
||||||
|
|
@ -1851,8 +1857,8 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
int extCount = 0;
|
int extCount = 0;
|
||||||
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
|
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
|
||||||
|
|
||||||
char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 };
|
char fileExtLower[MAX_FILE_EXTENSION_LENGTH + 1] = { 0 };
|
||||||
strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
|
strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_LENGTH); // WARNING: Module required: rtext
|
||||||
|
|
||||||
for (int i = 0; i < extCount; i++)
|
for (int i = 0; i < extCount; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1946,22 +1952,24 @@ const char *GetFileName(const char *filePath)
|
||||||
// Get filename string without extension (uses static string)
|
// Get filename string without extension (uses static string)
|
||||||
const char *GetFileNameWithoutExt(const char *filePath)
|
const char *GetFileNameWithoutExt(const char *filePath)
|
||||||
{
|
{
|
||||||
#define MAX_FILENAMEWITHOUTEXT_LENGTH 256
|
#define MAX_FILENAME_LENGTH 256
|
||||||
|
|
||||||
static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH] = { 0 };
|
static char fileName[MAX_FILENAME_LENGTH] = { 0 };
|
||||||
memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH);
|
memset(fileName, 0, MAX_FILENAME_LENGTH);
|
||||||
|
|
||||||
if (filePath != NULL) strcpy(fileName, GetFileName(filePath)); // Get filename with extension
|
if (filePath != NULL)
|
||||||
|
|
||||||
int size = (int)strlen(fileName); // Get size in bytes
|
|
||||||
|
|
||||||
for (int i = 0; (i < size) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
|
|
||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
strcpy(fileName, GetFileName(filePath)); // Get filename.ext without path
|
||||||
|
int size = (int)strlen(fileName); // Get size in bytes
|
||||||
|
|
||||||
|
for (int i = size; i > 0; i--) // Reverse search '.'
|
||||||
{
|
{
|
||||||
// NOTE: We break on first '.' found
|
if (fileName[i] == '.')
|
||||||
fileName[i] = '\0';
|
{
|
||||||
break;
|
// NOTE: We break on first '.' found
|
||||||
|
fileName[i] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ RLAPI void *rlReadTexturePixels(unsigned int id, int width, int height, int form
|
||||||
RLAPI unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
|
RLAPI unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
|
||||||
|
|
||||||
// Framebuffer management (fbo)
|
// Framebuffer management (fbo)
|
||||||
RLAPI unsigned int rlLoadFramebuffer(int width, int height); // Load an empty framebuffer
|
RLAPI unsigned int rlLoadFramebuffer(void); // Load an empty framebuffer
|
||||||
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
|
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
|
||||||
RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
|
RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
|
||||||
RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
||||||
|
|
@ -3456,7 +3456,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
||||||
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
|
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
|
||||||
// We are using Option 1, just need to care for texture format on retrieval
|
// We are using Option 1, just need to care for texture format on retrieval
|
||||||
// NOTE: This behaviour could be conditioned by graphic driver...
|
// NOTE: This behaviour could be conditioned by graphic driver...
|
||||||
unsigned int fboId = rlLoadFramebuffer(width, height);
|
unsigned int fboId = rlLoadFramebuffer();
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
|
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
@ -3510,7 +3510,7 @@ unsigned char *rlReadScreenPixels(int width, int height)
|
||||||
//-----------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------
|
||||||
// Load a framebuffer to be used for rendering
|
// Load a framebuffer to be used for rendering
|
||||||
// NOTE: No textures attached
|
// NOTE: No textures attached
|
||||||
unsigned int rlLoadFramebuffer(int width, int height)
|
unsigned int rlLoadFramebuffer(void)
|
||||||
{
|
{
|
||||||
unsigned int fboId = 0;
|
unsigned int fboId = 0;
|
||||||
|
|
||||||
|
|
|
||||||
381
src/rtext.c
381
src/rtext.c
|
|
@ -12,6 +12,7 @@
|
||||||
*
|
*
|
||||||
* #define SUPPORT_FILEFORMAT_FNT
|
* #define SUPPORT_FILEFORMAT_FNT
|
||||||
* #define SUPPORT_FILEFORMAT_TTF
|
* #define SUPPORT_FILEFORMAT_TTF
|
||||||
|
* #define SUPPORT_FILEFORMAT_BDF
|
||||||
* Selected desired fileformats to be supported for loading. Some of those formats are
|
* Selected desired fileformats to be supported for loading. Some of those formats are
|
||||||
* supported by default, to remove support, just comment unrequired #define in this module
|
* supported by default, to remove support, just comment unrequired #define in this module
|
||||||
*
|
*
|
||||||
|
|
@ -70,14 +71,27 @@
|
||||||
#include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()]
|
#include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()]
|
||||||
#include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
|
#include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
#if defined(__GNUC__) // GCC and Clang
|
#if defined(__GNUC__) // GCC and Clang
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STB_RECT_PACK_IMPLEMENTATION
|
#define STB_RECT_PACK_IMPLEMENTATION
|
||||||
#include "external/stb_rect_pack.h" // Required for: ttf font rectangles packaging
|
#include "external/stb_rect_pack.h" // Required for: ttf/bdf font rectangles packaging
|
||||||
|
|
||||||
|
#include <math.h> // Required for: ttf/bdf font rectangles packaging
|
||||||
|
|
||||||
|
#if defined(__GNUC__) // GCC and Clang
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
|
#if defined(__GNUC__) // GCC and Clang
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STBTT_STATIC
|
#define STBTT_STATIC
|
||||||
#define STB_TRUETYPE_IMPLEMENTATION
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
|
|
@ -127,6 +141,9 @@ static Font defaultFont = { 0 };
|
||||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||||
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
|
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
|
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize);
|
||||||
|
#endif
|
||||||
static int textLineSpacing = 15; // Text vertical line spacing in pixels
|
static int textLineSpacing = 15; // Text vertical line spacing in pixels
|
||||||
|
|
||||||
#if defined(SUPPORT_DEFAULT_FONT)
|
#if defined(SUPPORT_DEFAULT_FONT)
|
||||||
|
|
@ -334,6 +351,10 @@ Font LoadFont(const char *fileName)
|
||||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||||
if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName);
|
if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
|
if (IsFileExtension(fileName, ".bdf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Image image = LoadImage(fileName);
|
Image image = LoadImage(fileName);
|
||||||
|
|
@ -355,7 +376,7 @@ Font LoadFont(const char *fileName)
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Font from TTF font file with generation parameters
|
// Load Font from TTF or BDF font file with generation parameters
|
||||||
// NOTE: You can pass an array with desired characters, those characters should be available in the font
|
// NOTE: You can pass an array with desired characters, those characters should be available in the font
|
||||||
// if array is NULL, default char set is selected 32..126
|
// if array is NULL, default char set is selected 32..126
|
||||||
Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount)
|
Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount)
|
||||||
|
|
@ -511,35 +532,49 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||||
char fileExtLower[16] = { 0 };
|
char fileExtLower[16] = { 0 };
|
||||||
strcpy(fileExtLower, TextToLower(fileType));
|
strcpy(fileExtLower, TextToLower(fileType));
|
||||||
|
|
||||||
|
font.baseSize = fontSize;
|
||||||
|
font.glyphCount = (codepointCount > 0)? codepointCount : 95;
|
||||||
|
font.glyphPadding = 0;
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
if (TextIsEqual(fileExtLower, ".ttf") ||
|
if (TextIsEqual(fileExtLower, ".ttf") ||
|
||||||
TextIsEqual(fileExtLower, ".otf"))
|
TextIsEqual(fileExtLower, ".otf"))
|
||||||
{
|
{
|
||||||
font.baseSize = fontSize;
|
|
||||||
font.glyphCount = (codepointCount > 0)? codepointCount : 95;
|
|
||||||
font.glyphPadding = 0;
|
|
||||||
font.glyphs = LoadFontData(fileData, dataSize, font.baseSize, codepoints, font.glyphCount, FONT_DEFAULT);
|
font.glyphs = LoadFontData(fileData, dataSize, font.baseSize, codepoints, font.glyphCount, FONT_DEFAULT);
|
||||||
|
|
||||||
if (font.glyphs != NULL)
|
|
||||||
{
|
|
||||||
font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING;
|
|
||||||
|
|
||||||
Image atlas = GenImageFontAtlas(font.glyphs, &font.recs, font.glyphCount, font.baseSize, font.glyphPadding, 0);
|
|
||||||
font.texture = LoadTextureFromImage(atlas);
|
|
||||||
|
|
||||||
// Update glyphs[i].image to use alpha, required to be used on ImageDrawText()
|
|
||||||
for (int i = 0; i < font.glyphCount; i++)
|
|
||||||
{
|
|
||||||
UnloadImage(font.glyphs[i].image);
|
|
||||||
font.glyphs[i].image = ImageFromImage(atlas, font.recs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
UnloadImage(atlas);
|
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", font.baseSize, font.glyphCount);
|
|
||||||
}
|
|
||||||
else font = GetFontDefault();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
|
if (TextIsEqual(fileExtLower, ".bdf"))
|
||||||
|
{
|
||||||
|
font.glyphs = LoadFontDataBDF(fileData, dataSize, codepoints, font.glyphCount, &font.baseSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
font.glyphs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
|
if (font.glyphs != NULL)
|
||||||
|
{
|
||||||
|
font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING;
|
||||||
|
|
||||||
|
Image atlas = GenImageFontAtlas(font.glyphs, &font.recs, font.glyphCount, font.baseSize, font.glyphPadding, 0);
|
||||||
|
font.texture = LoadTextureFromImage(atlas);
|
||||||
|
|
||||||
|
// Update glyphs[i].image to use alpha, required to be used on ImageDrawText()
|
||||||
|
for (int i = 0; i < font.glyphCount; i++)
|
||||||
|
{
|
||||||
|
UnloadImage(font.glyphs[i].image);
|
||||||
|
font.glyphs[i].image = ImageFromImage(atlas, font.recs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
UnloadImage(atlas);
|
||||||
|
|
||||||
|
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", font.baseSize, font.glyphCount);
|
||||||
|
}
|
||||||
|
else font = GetFontDefault();
|
||||||
#else
|
#else
|
||||||
font = GetFontDefault();
|
font = GetFontDefault();
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -699,7 +734,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
|
||||||
|
|
||||||
// Generate image font atlas using chars info
|
// Generate image font atlas using chars info
|
||||||
// NOTE: Packing method: 0-Default, 1-Skyline
|
// NOTE: Packing method: 0-Default, 1-Skyline
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod)
|
Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod)
|
||||||
{
|
{
|
||||||
Image atlas = { 0 };
|
Image atlas = { 0 };
|
||||||
|
|
@ -1422,6 +1457,9 @@ int TextToInteger(const char *text)
|
||||||
return value*sign;
|
return value*sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get float value from text
|
||||||
|
// NOTE: This function replaces atof() [stdlib.h]
|
||||||
|
// WARNING: Only '.' character is understood as decimal point
|
||||||
float TextToFloat(const char *text)
|
float TextToFloat(const char *text)
|
||||||
{
|
{
|
||||||
float value = 0.0f;
|
float value = 0.0f;
|
||||||
|
|
@ -1429,18 +1467,24 @@ float TextToFloat(const char *text)
|
||||||
|
|
||||||
if ((text[0] == '+') || (text[0] == '-'))
|
if ((text[0] == '+') || (text[0] == '-'))
|
||||||
{
|
{
|
||||||
if (text[0] == '-') sign = -1;
|
if (text[0] == '-') sign = -1.0f;
|
||||||
text++;
|
text++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10.0f + (float)(text[i] - '0');
|
for (; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10.0f + (float)(text[i] - '0');
|
||||||
if (text[i++] != '.') return value*sign;
|
|
||||||
float divisor = 10.0f;
|
if (text[i++] != '.') value *= sign;
|
||||||
for (; ((text[i] >= '0') && (text[i] <= '9')); ++i)
|
else
|
||||||
{
|
{
|
||||||
value += ((float)(text[i] - '0'))/divisor;
|
float divisor = 10.0f;
|
||||||
divisor = divisor*10.0f;
|
for (; ((text[i] >= '0') && (text[i] <= '9')); i++)
|
||||||
|
{
|
||||||
|
value += ((float)(text[i] - '0'))/divisor;
|
||||||
|
divisor = divisor*10.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2036,18 +2080,21 @@ int GetCodepointPrevious(const char *text, int *codepointSize)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Definition
|
// Module specific Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
#if defined(SUPPORT_FILEFORMAT_FNT) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
// Read a line from memory
|
// Read a line from memory
|
||||||
// REQUIRES: memcpy()
|
// REQUIRES: memcpy()
|
||||||
// NOTE: Returns the number of bytes read
|
// NOTE: Returns the number of bytes read
|
||||||
static int GetLine(const char *origin, char *buffer, int maxLength)
|
static int GetLine(const char *origin, char *buffer, int maxLength)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (; count < maxLength; count++) if (origin[count] == '\n') break;
|
for (; count < maxLength - 1; count++) if (origin[count] == '\n') break;
|
||||||
memcpy(buffer, origin, count);
|
memcpy(buffer, origin, count);
|
||||||
|
buffer[count] = '\0';
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||||
// Load a BMFont file (AngelCode font file)
|
// Load a BMFont file (AngelCode font file)
|
||||||
// REQUIRES: strstr(), sscanf(), strrchr(), memcpy()
|
// REQUIRES: strstr(), sscanf(), strrchr(), memcpy()
|
||||||
static Font LoadBMFont(const char *fileName)
|
static Font LoadBMFont(const char *fileName)
|
||||||
|
|
@ -2213,4 +2260,266 @@ static Font LoadBMFont(const char *fileName)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||||
|
|
||||||
|
// Convert hexadecimal to decimal (single digit)
|
||||||
|
static char HexToInt(char hex) {
|
||||||
|
if (hex >= '0' && hex <= '9')
|
||||||
|
{
|
||||||
|
return hex - '0';
|
||||||
|
}
|
||||||
|
else if (hex >= 'a' && hex <= 'f')
|
||||||
|
{
|
||||||
|
return hex - 'a' + 10;
|
||||||
|
}
|
||||||
|
else if (hex >= 'A' && hex <= 'F')
|
||||||
|
{
|
||||||
|
return hex - 'A' + 10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load font data for further use
|
||||||
|
// NOTE: Requires BDF font memory data
|
||||||
|
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize)
|
||||||
|
{
|
||||||
|
#define MAX_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
char buffer[MAX_BUFFER_SIZE] = { 0 };
|
||||||
|
|
||||||
|
GlyphInfo *glyphs = NULL;
|
||||||
|
bool genFontChars = false;
|
||||||
|
|
||||||
|
int totalReadBytes = 0; // Data bytes read (total)
|
||||||
|
int readBytes = 0; // Data bytes read (line)
|
||||||
|
int readVars = 0; // Variables filled by sscanf()
|
||||||
|
|
||||||
|
const char *fileText = (const char*)fileData;
|
||||||
|
const char *fileTextPtr = fileText;
|
||||||
|
|
||||||
|
bool fontMalformed = false; // Is the font malformed
|
||||||
|
bool fontStarted = false; // Has font started (STARTFONT)
|
||||||
|
int fontBBw = 0; // Font base character bounding box width
|
||||||
|
int fontBBh = 0; // Font base character bounding box height
|
||||||
|
int fontBBxoff0 = 0; // Font base character bounding box X0 offset
|
||||||
|
int fontBByoff0 = 0; // Font base character bounding box Y0 offset
|
||||||
|
int fontAscent = 0; // Font ascent
|
||||||
|
|
||||||
|
bool charStarted = false; // Has character started (STARTCHAR)
|
||||||
|
bool charBitmapStarted = false; // Has bitmap data started (BITMAP)
|
||||||
|
int charBitmapNextRow = 0; // Y position for the next row of bitmap data
|
||||||
|
int charEncoding = -1; // The unicode value of the character (-1 if not set)
|
||||||
|
int charBBw = 0; // Character bounding box width
|
||||||
|
int charBBh = 0; // Character bounding box height
|
||||||
|
int charBBxoff0 = 0; // Character bounding box X0 offset
|
||||||
|
int charBByoff0 = 0; // Character bounding box Y0 offset
|
||||||
|
int charDWidthX = 0; // Character advance X
|
||||||
|
int charDWidthY = 0; // Character advance Y (unused)
|
||||||
|
GlyphInfo *charGlyphInfo = NULL; // Pointer to output glyph info (NULL if not set)
|
||||||
|
|
||||||
|
if (fileData == NULL) return glyphs;
|
||||||
|
|
||||||
|
// In case no chars count provided, default to 95
|
||||||
|
codepointCount = (codepointCount > 0)? codepointCount : 95;
|
||||||
|
|
||||||
|
// Fill fontChars in case not provided externally
|
||||||
|
// NOTE: By default we fill glyphCount consecutively, starting at 32 (Space)
|
||||||
|
if (codepoints == NULL)
|
||||||
|
{
|
||||||
|
codepoints = (int *)RL_MALLOC(codepointCount*sizeof(int));
|
||||||
|
for (int i = 0; i < codepointCount; i++) codepoints[i] = i + 32;
|
||||||
|
genFontChars = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
glyphs = (GlyphInfo *)RL_CALLOC(codepointCount, sizeof(GlyphInfo));
|
||||||
|
|
||||||
|
while (totalReadBytes <= dataSize)
|
||||||
|
{
|
||||||
|
readBytes = GetLine(fileTextPtr, buffer, MAX_BUFFER_SIZE);
|
||||||
|
totalReadBytes += (readBytes + 1);
|
||||||
|
fileTextPtr += (readBytes + 1);
|
||||||
|
|
||||||
|
// Line: COMMENT
|
||||||
|
if (strstr(buffer, "COMMENT") != NULL) continue; // Ignore line
|
||||||
|
|
||||||
|
if (charStarted)
|
||||||
|
{
|
||||||
|
// Line: ENDCHAR
|
||||||
|
if (strstr(buffer, "ENDCHAR") != NULL)
|
||||||
|
{
|
||||||
|
charStarted = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charBitmapStarted)
|
||||||
|
{
|
||||||
|
if (charGlyphInfo != NULL)
|
||||||
|
{
|
||||||
|
int pixelY = charBitmapNextRow++;
|
||||||
|
|
||||||
|
if (pixelY >= charGlyphInfo->image.height) break;
|
||||||
|
|
||||||
|
for (int x = 0; x < readBytes; x++)
|
||||||
|
{
|
||||||
|
char byte = HexToInt(buffer[x]);
|
||||||
|
|
||||||
|
for (int bitX = 0; bitX < 4; bitX++)
|
||||||
|
{
|
||||||
|
int pixelX = ((x * 4) + bitX);
|
||||||
|
|
||||||
|
if (pixelX >= charGlyphInfo->image.width) break;
|
||||||
|
|
||||||
|
if ((byte & (8 >> bitX)) > 0) ((unsigned char*)charGlyphInfo->image.data)[(pixelY * charGlyphInfo->image.width) + pixelX] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line: ENCODING
|
||||||
|
if (strstr(buffer, "ENCODING") != NULL)
|
||||||
|
{
|
||||||
|
readVars = sscanf(buffer, "ENCODING %i", &charEncoding);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line: BBX
|
||||||
|
if (strstr(buffer, "BBX") != NULL)
|
||||||
|
{
|
||||||
|
readVars = sscanf(buffer, "BBX %i %i %i %i", &charBBw, &charBBh, &charBBxoff0, &charBByoff0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line: DWIDTH
|
||||||
|
if (strstr(buffer, "DWIDTH") != NULL)
|
||||||
|
{
|
||||||
|
readVars = sscanf(buffer, "DWIDTH %i %i", &charDWidthX, &charDWidthY);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line: BITMAP
|
||||||
|
if (strstr(buffer, "BITMAP") != NULL)
|
||||||
|
{
|
||||||
|
// Search for glyph index in codepoints
|
||||||
|
charGlyphInfo = NULL;
|
||||||
|
|
||||||
|
for (int codepointIndex = 0; codepointIndex < codepointCount; codepointIndex++)
|
||||||
|
{
|
||||||
|
if (codepoints[codepointIndex] == charEncoding)
|
||||||
|
{
|
||||||
|
charGlyphInfo = &glyphs[codepointIndex];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init glyph info
|
||||||
|
if (charGlyphInfo != NULL)
|
||||||
|
{
|
||||||
|
charGlyphInfo->value = charEncoding;
|
||||||
|
charGlyphInfo->offsetX = charBBxoff0 + fontBByoff0;
|
||||||
|
charGlyphInfo->offsetY = fontBBh - (charBBh + charBByoff0 + fontBByoff0 + fontAscent);
|
||||||
|
charGlyphInfo->advanceX = charDWidthX;
|
||||||
|
|
||||||
|
charGlyphInfo->image.data = RL_CALLOC(charBBw * charBBh, 1);
|
||||||
|
charGlyphInfo->image.width = charBBw;
|
||||||
|
charGlyphInfo->image.height = charBBh;
|
||||||
|
charGlyphInfo->image.mipmaps = 1;
|
||||||
|
charGlyphInfo->image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
|
||||||
|
}
|
||||||
|
|
||||||
|
charBitmapStarted = true;
|
||||||
|
charBitmapNextRow = 0;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fontStarted)
|
||||||
|
{
|
||||||
|
// Line: ENDFONT
|
||||||
|
if (strstr(buffer, "ENDFONT") != NULL)
|
||||||
|
{
|
||||||
|
fontStarted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line: SIZE
|
||||||
|
if (strstr(buffer, "SIZE") != NULL)
|
||||||
|
{
|
||||||
|
if (outFontSize != NULL) readVars = sscanf(buffer, "SIZE %i", outFontSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PIXEL_SIZE
|
||||||
|
if (strstr(buffer, "PIXEL_SIZE") != NULL)
|
||||||
|
{
|
||||||
|
if (outFontSize != NULL) readVars = sscanf(buffer, "PIXEL_SIZE %i", outFontSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FONTBOUNDINGBOX
|
||||||
|
if (strstr(buffer, "FONTBOUNDINGBOX") != NULL)
|
||||||
|
{
|
||||||
|
readVars = sscanf(buffer, "FONTBOUNDINGBOX %i %i %i %i", &fontBBw, &fontBBh, &fontBBxoff0, &fontBByoff0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FONT_ASCENT
|
||||||
|
if (strstr(buffer, "FONT_ASCENT") != NULL)
|
||||||
|
{
|
||||||
|
readVars = sscanf(buffer, "FONT_ASCENT %i", &fontAscent);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// STARTCHAR
|
||||||
|
if (strstr(buffer, "STARTCHAR") != NULL)
|
||||||
|
{
|
||||||
|
charStarted = true;
|
||||||
|
charEncoding = -1;
|
||||||
|
charGlyphInfo = NULL;
|
||||||
|
charBBw = 0;
|
||||||
|
charBBh = 0;
|
||||||
|
charBBxoff0 = 0;
|
||||||
|
charBByoff0 = 0;
|
||||||
|
charDWidthX = 0;
|
||||||
|
charDWidthY = 0;
|
||||||
|
charGlyphInfo = NULL;
|
||||||
|
charBitmapStarted = false;
|
||||||
|
charBitmapNextRow = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// STARTFONT
|
||||||
|
if (strstr(buffer, "STARTFONT") != NULL)
|
||||||
|
{
|
||||||
|
if (fontStarted)
|
||||||
|
{
|
||||||
|
fontMalformed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fontStarted = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (genFontChars) RL_FREE(codepoints);
|
||||||
|
|
||||||
|
if (fontMalformed)
|
||||||
|
{
|
||||||
|
RL_FREE(glyphs);
|
||||||
|
glyphs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return glyphs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SUPPORT_MODULE_RTEXT
|
#endif // SUPPORT_MODULE_RTEXT
|
||||||
|
|
|
||||||
|
|
@ -3893,7 +3893,7 @@ RenderTexture2D LoadRenderTexture(int width, int height)
|
||||||
{
|
{
|
||||||
RenderTexture2D target = { 0 };
|
RenderTexture2D target = { 0 };
|
||||||
|
|
||||||
target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
|
target.id = rlLoadFramebuffer(); // Load an empty framebuffer
|
||||||
|
|
||||||
if (target.id > 0)
|
if (target.id > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user