mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 06:13:10 +00:00
Compare commits
4 Commits
7e3d6cbfa8
...
a7ce14ee95
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7ce14ee95 | ||
|
|
47a8b554bc | ||
|
|
fc8049a039 | ||
|
|
bd36610f91 |
@ -533,6 +533,20 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|ARM64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\platforms\rcore_memory.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release.DLL|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|ARM64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\platforms\rcore_template.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@ -49,6 +49,9 @@
|
||||
<ClCompile Include="..\..\..\src\platforms\rcore_desktop_win32.c">
|
||||
<Filter>Source Files\Platform Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\platforms\rcore_memory.c">
|
||||
<Filter>Source Files\Platform Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\external\cgltf.h">
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
#define SUPPORT_CLIPBOARD_IMAGE 1
|
||||
|
||||
// NOTE: Clipboard image loading requires support for some image file formats
|
||||
// TODO: Those defines should probably be removed from here, I prefer to let the user manage them
|
||||
// TODO: Those defines should probably be removed from here, letting the user manage them
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#ifndef SUPPORT_MODULE_RTEXTURES
|
||||
#define SUPPORT_MODULE_RTEXTURES 1
|
||||
|
||||
14
src/external/rlsw.h
vendored
14
src/external/rlsw.h
vendored
@ -3668,9 +3668,9 @@ void swCopyFramebuffer(int x, int y, int w, int h, SWformat format, SWtype type,
|
||||
x = sw_clampi(x, 0, w);
|
||||
y = sw_clampi(y, 0, h);
|
||||
|
||||
if (x >= w || y >= h) return;
|
||||
if ((x >= w) || (y >= h)) return;
|
||||
|
||||
if (x == 0 && y == 0 && w == RLSW.framebuffer.width && h == RLSW.framebuffer.height)
|
||||
if ((x == 0) && (y == 0) && (w == RLSW.framebuffer.width) && (h == RLSW.framebuffer.height))
|
||||
{
|
||||
#if SW_COLOR_BUFFER_BITS == 32
|
||||
if (pFormat == SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
@ -3695,7 +3695,7 @@ void swCopyFramebuffer(int x, int y, int w, int h, SWformat format, SWtype type,
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8: sw_framebuffer_copy_to_R8G8B8(x, y, w, h, (uint8_t *)pixels); break;
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: sw_framebuffer_copy_to_R5G5B5A1(x, y, w, h, (uint16_t *)pixels); break;
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: sw_framebuffer_copy_to_R4G4B4A4(x, y, w, h, (uint16_t *)pixels); break;
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: sw_framebuffer_copy_to_R8G8B8A8(x, y, w, h, (uint8_t *)pixels); break;
|
||||
//case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: sw_framebuffer_copy_to_R8G8B8A8(x, y, w, h, (uint8_t *)pixels); break;
|
||||
// Below: not implemented
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R32:
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R32G32B32:
|
||||
@ -3703,9 +3703,7 @@ void swCopyFramebuffer(int x, int y, int w, int h, SWformat format, SWtype type,
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R16:
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R16G16B16:
|
||||
case SW_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
|
||||
default:
|
||||
RLSW.errCode = SW_INVALID_ENUM;
|
||||
break;
|
||||
default: RLSW.errCode = SW_INVALID_ENUM; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4330,7 +4328,7 @@ void swVertex2f(float x, float y)
|
||||
void swVertex2fv(const float *v)
|
||||
{
|
||||
const float v4[4] = { v[0], v[1], 0.0f, 1.0f };
|
||||
sw_immediate_push_vertex(v, RLSW.current.color, RLSW.current.texcoord);
|
||||
sw_immediate_push_vertex(v4, RLSW.current.color, RLSW.current.texcoord);
|
||||
}
|
||||
|
||||
void swVertex3i(int x, int y, int z)
|
||||
@ -4348,7 +4346,7 @@ void swVertex3f(float x, float y, float z)
|
||||
void swVertex3fv(const float *v)
|
||||
{
|
||||
const float v4[4] = { v[0], v[1], v[2], 1.0f };
|
||||
sw_immediate_push_vertex(v, RLSW.current.color, RLSW.current.texcoord);
|
||||
sw_immediate_push_vertex(v4, RLSW.current.color, RLSW.current.texcoord);
|
||||
}
|
||||
|
||||
void swVertex4i(int x, int y, int z, int w)
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
|
||||
|
||||
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
|
||||
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
|
||||
// Set appropriate expose macros based on available backends
|
||||
#if defined(_GLFW_X11)
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
@ -94,11 +94,10 @@
|
||||
|
||||
#include "GLFW/glfw3native.h" // Include native header only once, regardless of how many backends are defined
|
||||
// Required for: glfwGetX11Window() and glfwGetWaylandWindow()
|
||||
|
||||
#if defined(_GLFW_X11) // Clean up X11-specific hacks
|
||||
#undef Font // Revert hack and allow normal raylib Font usage
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include <unistd.h> // Required for: usleep()
|
||||
|
||||
@ -262,9 +262,9 @@ static bool DecoratedFromStyle(DWORD style)
|
||||
// Get window style from required flags
|
||||
static DWORD MakeWindowStyle(unsigned flags)
|
||||
{
|
||||
// We don't need this since we don't have any child windows, but I guess
|
||||
// it improves efficiency, plus, windows adds this flag automatically anyway
|
||||
// so it keeps our flags in sync with the OS
|
||||
// Flag is not needed because there are no child windows,
|
||||
// but supposedly it improves efficiency, plus, windows adds this
|
||||
// flag automatically anyway so it keeps flags in sync with the OS
|
||||
DWORD style = WS_CLIPSIBLINGS;
|
||||
|
||||
style |= (flags & FLAG_WINDOW_HIDDEN)? 0 : WS_VISIBLE;
|
||||
@ -1230,7 +1230,7 @@ void SwapScreenBuffer(void)
|
||||
// Get elapsed time measure in seconds
|
||||
double GetTime(void)
|
||||
{
|
||||
LARGE_INTEGER now;
|
||||
LARGE_INTEGER now = 0;
|
||||
QueryPerformanceCounter(&now);
|
||||
return (double)(now.QuadPart - CORE.Time.base)/(double)platform.timerFrequency.QuadPart;
|
||||
}
|
||||
@ -1987,7 +1987,7 @@ static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[key] = state;
|
||||
|
||||
if ((key == KEY_ESCAPE) && (state == 1)) CORE.Window.shouldClose = 1;
|
||||
if ((key == KEY_ESCAPE) && (state == 1)) CORE.Window.shouldClose = true;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "INPUT: Unknown (or currently unhandled) virtual keycode %d (0x%x)", wparam, wparam);
|
||||
|
||||
|
||||
595
src/platforms/rcore_memory.c
Normal file
595
src/platforms/rcore_memory.c
Normal file
@ -0,0 +1,595 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_memory - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: MEMORY (No OS)
|
||||
* - Memory framebuffer output (no os)
|
||||
*
|
||||
* LIMITATIONS:
|
||||
* - Software renderer (rlsw)
|
||||
* - No input system
|
||||
*
|
||||
* POSSIBLE IMPROVEMENTS:
|
||||
* - Improvement 01
|
||||
* - Improvement 02
|
||||
*
|
||||
* ADDITIONAL NOTES:
|
||||
* - TRACELOG() function is located in raylib [utils] module
|
||||
*
|
||||
* CONFIGURATION:
|
||||
* #define RCORE_PLATFORM_CUSTOM_FLAG
|
||||
* Custom flag for rcore on target platform -not used-
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* - rlsw: Software renderer
|
||||
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2025 Ramon Santamaria (@raysan5) and contributors
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h> // Required for: kbhit()
|
||||
#else
|
||||
// Provide kbhit() function in non-Windows platforms
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
// Platform-specific required data for timming (Win32)
|
||||
#if defined(_WIN32)
|
||||
typedef struct _LARGE_INTEGER { int64_t QuadPart; } LARGE_INTEGER;
|
||||
__declspec(dllimport) int __stdcall QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
|
||||
__declspec(dllimport) int __stdcall QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
unsigned int *pixels; // Pointer to pixel data buffer (RGBA8888 format)
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER timerFrequency;
|
||||
#endif
|
||||
} PlatformData;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
extern CoreData CORE; // Global CORE state context
|
||||
|
||||
static PlatformData platform = { 0 }; // Platform specific data
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
int InitPlatform(void); // Initialize platform (graphics, inputs and more)
|
||||
bool InitGraphicsDevice(void); // Initialize graphics device
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
// NOTE: Functions declaration is provided by raylib.h
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
#if !defined(_WIN32)
|
||||
static int kbhit(void); // Check if a key has been pressed
|
||||
static char getch(void) { return getchar(); } // Get pressed character
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Window and Graphics Device
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Check if application should close
|
||||
bool WindowShouldClose(void)
|
||||
{
|
||||
if (CORE.Window.ready) return CORE.Window.shouldClose;
|
||||
else return true;
|
||||
}
|
||||
|
||||
// Toggle fullscreen mode
|
||||
void ToggleFullscreen(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "ToggleFullscreen() not available on target platform");
|
||||
}
|
||||
|
||||
// Toggle borderless windowed mode
|
||||
void ToggleBorderlessWindowed(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "ToggleBorderlessWindowed() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window state: maximized, if resizable
|
||||
void MaximizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MaximizeWindow() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window state: minimized
|
||||
void MinimizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform");
|
||||
}
|
||||
|
||||
// Restore window from being minimized/maximized
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowState() not available on target platform");
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "ClearWindowState() not available on target platform");
|
||||
}
|
||||
|
||||
// Set icon for window
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowIcon() not available on target platform");
|
||||
}
|
||||
|
||||
// Set icon for window
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowIcons() not available on target platform");
|
||||
}
|
||||
|
||||
// Set title for window
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowPosition() not available on target platform");
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowMonitor() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.screenMin.width = width;
|
||||
CORE.Window.screenMin.height = height;
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.screenMax.width = width;
|
||||
CORE.Window.screenMax.height = height;
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowSize() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowOpacity() not available on target platform");
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetWindowFocused() not available on target platform");
|
||||
}
|
||||
|
||||
// Get native window handle
|
||||
void *GetWindowHandle(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetWindowHandle() not implemented on target platform");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get number of monitors
|
||||
int GetMonitorCount(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorCount() not implemented on target platform");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get current monitor where window is placed
|
||||
int GetCurrentMonitor(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get selected monitor position
|
||||
Vector2 GetMonitorPosition(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorPosition() not implemented on target platform");
|
||||
return (Vector2){ 0, 0 };
|
||||
}
|
||||
|
||||
// Get selected monitor width (currently used by monitor)
|
||||
int GetMonitorWidth(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get selected monitor height (currently used by monitor)
|
||||
int GetMonitorHeight(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get selected monitor physical width in millimetres
|
||||
int GetMonitorPhysicalWidth(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get selected monitor physical height in millimetres
|
||||
int GetMonitorPhysicalHeight(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get selected monitor refresh rate
|
||||
int GetMonitorRefreshRate(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorRefreshRate() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
||||
const char *GetMonitorName(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform");
|
||||
return "";
|
||||
}
|
||||
|
||||
// Get window position XY on monitor
|
||||
Vector2 GetWindowPosition(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetWindowPosition() not implemented on target platform");
|
||||
return (Vector2){ 0, 0 };
|
||||
}
|
||||
|
||||
// Get window scale DPI factor for current monitor
|
||||
Vector2 GetWindowScaleDPI(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform");
|
||||
return (Vector2){ 1.0f, 1.0f };
|
||||
}
|
||||
|
||||
// Set clipboard text content
|
||||
void SetClipboardText(const char *text)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform");
|
||||
}
|
||||
|
||||
// Get clipboard text content
|
||||
// NOTE: returned string is allocated and freed by GLFW
|
||||
const char *GetClipboardText(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetClipboardText() not implemented on target platform");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
CORE.Input.Mouse.cursorHidden = false;
|
||||
}
|
||||
|
||||
// Hides mouse cursor
|
||||
void HideCursor(void)
|
||||
{
|
||||
CORE.Input.Mouse.cursorHidden = true;
|
||||
}
|
||||
|
||||
// Enables cursor (unlock cursor)
|
||||
void EnableCursor(void)
|
||||
{
|
||||
// Set cursor position in the middle
|
||||
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
|
||||
|
||||
CORE.Input.Mouse.cursorHidden = false;
|
||||
}
|
||||
|
||||
// Disables cursor (lock cursor)
|
||||
void DisableCursor(void)
|
||||
{
|
||||
// Set cursor position in the middle
|
||||
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
|
||||
|
||||
CORE.Input.Mouse.cursorHidden = true;
|
||||
}
|
||||
|
||||
// Swap back buffer with front buffer (screen drawing)
|
||||
void SwapScreenBuffer(void)
|
||||
{
|
||||
// Update framebuffer
|
||||
rlCopyFramebuffer(0, 0, CORE.Window.render.width, CORE.Window.render.height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, platform.pixels);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Misc
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Get elapsed time measure in seconds since InitTimer()
|
||||
double GetTime(void)
|
||||
{
|
||||
double time = 0.0;
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER now = { 0 };
|
||||
QueryPerformanceCounter(&now);
|
||||
return (double)(now.QuadPart - CORE.Time.base)/(double)platform.timerFrequency.QuadPart;
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
|
||||
double time = 0.0;
|
||||
struct timespec ts = { 0 };
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
||||
#endif
|
||||
return time;
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given.
|
||||
// A user could craft a malicious string performing another action.
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself.
|
||||
// Ref: https://github.com/raysan5/raylib/issues/686
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code on target platform
|
||||
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
|
||||
else
|
||||
{
|
||||
char *cmd = (char *)RL_CALLOC(strlen(url) + 32, sizeof(char));
|
||||
sprintf(cmd, "explorer \"%s\"", url);
|
||||
int result = system(cmd);
|
||||
if (result == -1) TRACELOG(LOG_WARNING, "OpenURL() child process could not be created");
|
||||
RL_FREE(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Inputs
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Set internal gamepad mappings
|
||||
int SetGamepadMappings(const char *mappings)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetGamepadMappings() not implemented on target platform");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetGamepadVibration() not implemented on target platform");
|
||||
}
|
||||
|
||||
// Set mouse position XY
|
||||
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
|
||||
void SetMouseCursor(int cursor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform");
|
||||
}
|
||||
|
||||
// Get physical key name.
|
||||
const char *GetKeyName(int key)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform");
|
||||
return "";
|
||||
}
|
||||
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
#endif
|
||||
|
||||
// Reset keys/chars pressed registered
|
||||
CORE.Input.Keyboard.keyPressedQueueCount = 0;
|
||||
CORE.Input.Keyboard.charPressedQueueCount = 0;
|
||||
|
||||
// Reset key repeats
|
||||
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
|
||||
|
||||
// Reset last gamepad button/axis registered state
|
||||
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
|
||||
//CORE.Input.Gamepad.axisCount = 0;
|
||||
|
||||
// Register previous touch states
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
|
||||
|
||||
// Reset touch positions
|
||||
// TODO: It resets on target platform the mouse position and not filled again until a move-event,
|
||||
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
|
||||
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 };
|
||||
|
||||
// Register previous keys states
|
||||
// NOTE: Android supports up to 260 keys
|
||||
for (int i = 0; i < 260; i++)
|
||||
{
|
||||
CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
|
||||
CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
|
||||
}
|
||||
|
||||
// TODO: Poll input events for current platform
|
||||
|
||||
// Check for key pressed to exit
|
||||
if (kbhit())
|
||||
{
|
||||
int key = getch();
|
||||
if (key == 27) CORE.Window.shouldClose = true; // KEY_SCAPE
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Initialize platform: graphics, inputs and more
|
||||
int InitPlatform(void)
|
||||
{
|
||||
// Memory framebuffer can only work with software renderer
|
||||
if (rlGetVersion() != RL_OPENGL_11_SOFTWARE)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Memory platform requires software renderer (GRAPHICS_API_OPENGL_11_SOFTWARE)");
|
||||
TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphics device");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load memory framebuffer with desired screen size
|
||||
platform.pixels = (unsigned int *)RL_CALLOC(CORE.Window.screen.width*CORE.Window.screen.height, sizeof(int));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// If everything work as expected, we can continue
|
||||
CORE.Window.render.width = CORE.Window.screen.width;
|
||||
CORE.Window.render.height = CORE.Window.screen.height;
|
||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||
|
||||
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
|
||||
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
||||
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
|
||||
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
|
||||
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
|
||||
|
||||
CORE.Window.ready = true;
|
||||
|
||||
// TODO: Load OpenGL extensions
|
||||
// NOTE: GL procedures address loader is required to load extensions
|
||||
//----------------------------------------------------------------------------
|
||||
// ...
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// TODO: Initialize input events system
|
||||
// It could imply keyboard, mouse, gamepad, touch...
|
||||
// Depending on the platform libraries/SDK it could use a callback mechanism
|
||||
// For system events and inputs evens polling on a per-frame basis, use PollInputEvents()
|
||||
//----------------------------------------------------------------------------
|
||||
// ...
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Initialize timing system
|
||||
//----------------------------------------------------------------------------
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER time = { 0 };
|
||||
QueryPerformanceCounter(&time);
|
||||
QueryPerformanceFrequency(&platform.timerFrequency);
|
||||
CORE.Time.base = time.QuadPart;
|
||||
#endif
|
||||
InitTimer();
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
TRACELOG(LOG_INFO, "PLATFORM: MEMORY: Initialized successfully");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Close platform
|
||||
void ClosePlatform(void)
|
||||
{
|
||||
RL_FREE(platform.pixels);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#if !defined(_WIN32)
|
||||
// Check if a key has been pressed
|
||||
static int kbhit(void)
|
||||
{
|
||||
struct termios oldt = { 0 };
|
||||
struct termios newt = { 0 };
|
||||
int ch = 0;
|
||||
int oldf = 0;
|
||||
|
||||
tcgetattr(STDIN_FILENO, &oldt);
|
||||
newt = oldt;
|
||||
newt.c_lflag &= ~(ICANON | ECHO);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
||||
|
||||
ch = getchar();
|
||||
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
||||
|
||||
if (ch != EOF)
|
||||
{
|
||||
ungetc(ch, stdin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// EOF
|
||||
@ -99,13 +99,13 @@
|
||||
#define __declspec(x) __attribute__((x))
|
||||
#endif
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
|
||||
#elif defined(USE_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
|
||||
#endif
|
||||
#else
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib)
|
||||
#define RLAPI __attribute__((visibility("default"))) // Building as a Unix shared library (.so/.dylib)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -157,7 +157,7 @@
|
||||
#error "C++11 or later is required. Add -std=c++11"
|
||||
#endif
|
||||
|
||||
// NOTE: We set some defines with some data types declared by raylib
|
||||
// NOTE: Set some defines with some data types declared by raylib
|
||||
// Other modules (raymath, rlgl) also require some of those types, so,
|
||||
// to be able to use those other modules as standalone (not depending on raylib)
|
||||
// this defines are very useful for internal check and avoid type (re)definitions
|
||||
|
||||
58
src/rcore.c
58
src/rcore.c
@ -28,6 +28,8 @@
|
||||
* - Android (ARM, ARM64)
|
||||
* > PLATFORM_DESKTOP_WIN32 (Native Win32):
|
||||
* - Windows (Win32, Win64)
|
||||
* > PLATFORM_MEMORY
|
||||
* - Memory framebuffer output, using software renderer, no OS required
|
||||
* CONFIGURATION:
|
||||
* #define SUPPORT_DEFAULT_FONT (default)
|
||||
* Default font is loaded on window initialization to be available for the user to render simple text
|
||||
@ -92,12 +94,12 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_XOPEN_SOURCE < 500)
|
||||
#undef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext.
|
||||
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without GNU extensions
|
||||
#endif
|
||||
|
||||
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_POSIX_C_SOURCE < 199309L)
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
||||
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without GNU extensions
|
||||
#endif
|
||||
|
||||
#include "raylib.h" // Declares module functions
|
||||
@ -115,6 +117,9 @@
|
||||
#include <time.h> // Required for: time() [Used in InitTimer()]
|
||||
#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
|
||||
|
||||
#if defined(PLATFORM_MEMORY)
|
||||
#define SW_GL_FRAMEBUFFER_COPY_BGRA false
|
||||
#endif
|
||||
#define RLGL_IMPLEMENTATION
|
||||
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
|
||||
|
||||
@ -155,18 +160,18 @@
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
struct HINSTANCE__;
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(struct HINSTANCE__ *hModule, char *lpFilename, unsigned long nSize);
|
||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(struct HINSTANCE__ *hModule, wchar_t *lpFilename, unsigned long nSize);
|
||||
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
|
||||
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
struct HINSTANCE__;
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(struct HINSTANCE__ *hModule, char *lpFilename, unsigned long nSize);
|
||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(struct HINSTANCE__ *hModule, wchar_t *lpFilename, unsigned long nSize);
|
||||
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
|
||||
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#elif defined(__linux__)
|
||||
#include <unistd.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
@ -314,7 +319,8 @@ typedef struct CoreData {
|
||||
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
|
||||
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
|
||||
|
||||
// NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
|
||||
// NOTE: Since key press logic involves comparing previous vs currrent key state,
|
||||
// key repeats needs to be handled specially
|
||||
char keyRepeatInFrame[MAX_KEYBOARD_KEYS]; // Registers key repeats for current frame
|
||||
|
||||
int keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue
|
||||
@ -547,6 +553,8 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
|
||||
#include "platforms/rcore_drm.c"
|
||||
#elif defined(PLATFORM_ANDROID)
|
||||
#include "platforms/rcore_android.c"
|
||||
#elif defined(PLATFORM_MEMORY)
|
||||
#include "platforms/rcore_memory.c"
|
||||
#else
|
||||
// TODO: Include your custom platform backend!
|
||||
// i.e software rendering backend or console backend!
|
||||
@ -621,6 +629,8 @@ void InitWindow(int width, int height, const char *title)
|
||||
TRACELOG(LOG_INFO, "Platform backend: NATIVE DRM");
|
||||
#elif defined(PLATFORM_ANDROID)
|
||||
TRACELOG(LOG_INFO, "Platform backend: ANDROID");
|
||||
#elif defined(PLATFORM_MEMORY)
|
||||
TRACELOG(LOG_INFO, "Platform backend: MEMORY (No OS)");
|
||||
#else
|
||||
// TODO: Include your custom platform backend!
|
||||
// i.e software rendering backend or console backend!
|
||||
@ -2233,13 +2243,15 @@ const char *GetApplicationDirectory(void)
|
||||
|
||||
#if defined(_WIN32)
|
||||
int len = 0;
|
||||
#if defined(UNICODE)
|
||||
|
||||
#if defined(UNICODE)
|
||||
unsigned short widePath[MAX_PATH];
|
||||
len = GetModuleFileNameW(NULL, (wchar_t *)widePath, MAX_PATH);
|
||||
len = WideCharToMultiByte(0, 0, (wchar_t *)widePath, len, appDir, MAX_PATH, NULL, NULL);
|
||||
#else
|
||||
#else
|
||||
len = GetModuleFileNameA(NULL, appDir, MAX_PATH);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
for (int i = len; i >= 0; --i)
|
||||
@ -2258,6 +2270,7 @@ const char *GetApplicationDirectory(void)
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
unsigned int size = sizeof(appDir);
|
||||
ssize_t len = readlink("/proc/self/exe", appDir, size);
|
||||
|
||||
@ -2277,7 +2290,9 @@ const char *GetApplicationDirectory(void)
|
||||
appDir[0] = '.';
|
||||
appDir[1] = '/';
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
uint32_t size = sizeof(appDir);
|
||||
|
||||
if (_NSGetExecutablePath(appDir, &size) == 0)
|
||||
@ -2297,8 +2312,11 @@ const char *GetApplicationDirectory(void)
|
||||
appDir[0] = '.';
|
||||
appDir[1] = '/';
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
size_t size = sizeof(appDir);
|
||||
|
||||
size_t size = sizeof(appD
|
||||
ir);
|
||||
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||
|
||||
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
|
||||
@ -2318,7 +2336,6 @@ const char *GetApplicationDirectory(void)
|
||||
appDir[0] = '.';
|
||||
appDir[1] = '/';
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return appDir;
|
||||
@ -3887,6 +3904,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
|
||||
if ((strcmp(dp->d_name, ".") != 0) &&
|
||||
(strcmp(dp->d_name, "..") != 0))
|
||||
{
|
||||
// Construct new path from our base path
|
||||
#if defined(_WIN32)
|
||||
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
|
||||
#else
|
||||
|
||||
@ -776,10 +776,9 @@ RLAPI unsigned int rlLoadFramebuffer(void); // Loa
|
||||
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 void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
// WARNING: Copy and resize framebuffer functionality only defined for software backend
|
||||
RLAPI void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels); // Copy framebuffer pixel data to internal buffer
|
||||
RLAPI void rlResizeFramebuffer(int width, int height); // Resize internal framebuffer
|
||||
#endif
|
||||
|
||||
// Shaders management
|
||||
RLAPI unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings
|
||||
@ -3750,21 +3749,23 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
||||
return pixels;
|
||||
}
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
// Copy framebuffer pixel data to internal buffer
|
||||
void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
unsigned int glInternalFormat, glFormat, glType;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); // Get OpenGL texture format
|
||||
swCopyFramebuffer(x, y, width, height, glFormat, glType, pixels);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Resize internal framebuffer
|
||||
void rlResizeFramebuffer(int width, int height)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
swResizeFramebuffer(width, height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Read screen pixel data (color buffer)
|
||||
unsigned char *rlReadScreenPixels(int width, int height)
|
||||
|
||||
@ -5018,7 +5018,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou
|
||||
animations[a].boneCount = iqmHeader->num_poses;
|
||||
animations[a].bones = (BoneInfo *)RL_MALLOC(iqmHeader->num_poses*sizeof(BoneInfo));
|
||||
animations[a].framePoses = (Transform **)RL_MALLOC(anim[a].num_frames*sizeof(Transform *));
|
||||
memcpy(animations[a].name, fileDataPtr + iqmHeader->ofs_text + anim[a].name, 32); // I don't like this 32 here
|
||||
memcpy(animations[a].name, fileDataPtr + iqmHeader->ofs_text + anim[a].name, 32);
|
||||
TRACELOG(LOG_INFO, "IQM Anim %s", animations[a].name);
|
||||
//animations[a].framerate = anim.framerate; // TODO: Use animation framerate data?
|
||||
|
||||
|
||||
@ -1099,7 +1099,7 @@ Image GenImageCellular(int width, int height, int tileSize)
|
||||
}
|
||||
}
|
||||
|
||||
// I made this up, but it seems to give good results at all tile sizes
|
||||
// This approach seems to give good results at all tile sizes
|
||||
int intensity = (int)(minDistance*256.0f/tileSize);
|
||||
if (intensity > 255) intensity = 255;
|
||||
|
||||
@ -4600,7 +4600,7 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
|
||||
// NOTE: Vertex position can be transformed using matrices
|
||||
// but the process is way more costly than just calculating
|
||||
// the vertex positions manually, like done above
|
||||
// I leave here the old implementation for educational purposes,
|
||||
// Old implementation is left here for educational purposes,
|
||||
// just in case someone wants to do some performance test
|
||||
/*
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
@ -451,7 +451,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
|
||||
{
|
||||
if (mode[0] == 'w')
|
||||
{
|
||||
// fopen() is mapped to android_fopen() that only grants read access to
|
||||
// NOTE: fopen() is mapped to android_fopen() that only grants read access to
|
||||
// assets directory through AAssetManager but we want to also be able to
|
||||
// write data when required using the standard stdio FILE access functions
|
||||
// Ref: https://stackoverflow.com/questions/11294487/android-writing-saving-files-from-native-code-only
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
"name": "RLAPI",
|
||||
"type": "UNKNOWN",
|
||||
"value": "__declspec(dllexport)",
|
||||
"description": "We are building the library as a Win32 shared library (.dll)"
|
||||
"description": "Building the library as a Win32 shared library (.dll)"
|
||||
},
|
||||
{
|
||||
"name": "PI",
|
||||
|
||||
@ -40,7 +40,7 @@ return {
|
||||
name = "RLAPI",
|
||||
type = "UNKNOWN",
|
||||
value = "__declspec(dllexport)",
|
||||
description = "We are building the library as a Win32 shared library (.dll)"
|
||||
description = "Building the library as a Win32 shared library (.dll)"
|
||||
},
|
||||
{
|
||||
name = "PI",
|
||||
|
||||
@ -35,7 +35,7 @@ Define 007: RLAPI
|
||||
Name: RLAPI
|
||||
Type: UNKNOWN
|
||||
Value: __declspec(dllexport)
|
||||
Description: We are building the library as a Win32 shared library (.dll)
|
||||
Description: Building the library as a Win32 shared library (.dll)
|
||||
Define 008: PI
|
||||
Name: PI
|
||||
Type: FLOAT
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<Define name="RAYLIB_VERSION_PATCH" type="INT" value="0" desc="" />
|
||||
<Define name="RAYLIB_VERSION" type="STRING" value="5.6-dev" desc="" />
|
||||
<Define name="__declspec(x)" type="MACRO" value="__attribute__((x))" desc="" />
|
||||
<Define name="RLAPI" type="UNKNOWN" value="__declspec(dllexport)" desc="We are building the library as a Win32 shared library (.dll)" />
|
||||
<Define name="RLAPI" type="UNKNOWN" value="__declspec(dllexport)" desc="Building the library as a Win32 shared library (.dll)" />
|
||||
<Define name="PI" type="FLOAT" value="3.14159265358979323846" desc="" />
|
||||
<Define name="DEG2RAD" type="FLOAT_MATH" value="(PI/180.0f)" desc="" />
|
||||
<Define name="RAD2DEG" type="FLOAT_MATH" value="(180.0f/PI)" desc="" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user