commit
bcdde6c65a
21
src/core.c
21
src/core.c
@ -153,8 +153,9 @@
|
|||||||
//#define GLFW_DLL // Using GLFW DLL on Windows -> No, we use static version!
|
//#define GLFW_DLL // Using GLFW DLL on Windows -> No, we use static version!
|
||||||
|
|
||||||
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
|
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
|
||||||
__stdcall unsigned int timeBeginPeriod(unsigned int uPeriod);
|
// NOTE: Those functions require linking with winmm library
|
||||||
__stdcall unsigned int timeEndPeriod(unsigned int uPeriod);
|
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||||
|
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -351,7 +352,7 @@ extern void UnloadDefaultFont(void); // [Module: text] Unloads default fo
|
|||||||
static void InitGraphicsDevice(int width, int height); // Initialize graphics device
|
static void InitGraphicsDevice(int width, int height); // Initialize graphics device
|
||||||
static void SetupFramebufferSize(int displayWidth, int displayHeight);
|
static void SetupFramebufferSize(int displayWidth, int displayHeight);
|
||||||
static void InitTimer(void); // Initialize timer
|
static void InitTimer(void); // Initialize timer
|
||||||
static double GetTime(void); // Returns time since InitTimer() was run
|
double GetTime(void); // Returns time since InitTimer() was run
|
||||||
static void Wait(float ms); // Wait for some milliseconds (stop program execution)
|
static void Wait(float ms); // Wait for some milliseconds (stop program execution)
|
||||||
static bool GetKeyStatus(int key); // Returns if a key has been pressed
|
static bool GetKeyStatus(int key); // Returns if a key has been pressed
|
||||||
static bool GetMouseButtonStatus(int button); // Returns if a mouse button has been pressed
|
static bool GetMouseButtonStatus(int button); // Returns if a mouse button has been pressed
|
||||||
@ -412,7 +413,7 @@ static void *GamepadThread(void *arg); // Mouse reading thread
|
|||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
// Initialize window and OpenGL context
|
// Initialize window and OpenGL context
|
||||||
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||||
void InitWindow(int width, int height, void *data)
|
void InitRLWindow(int width, int height, void *data)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
||||||
|
|
||||||
@ -476,7 +477,7 @@ void InitWindow(int width, int height, void *data)
|
|||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
// Initialize window and OpenGL context (and Android activity)
|
// Initialize window and OpenGL context (and Android activity)
|
||||||
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||||
void InitWindow(int width, int height, void *data)
|
void InitRLWindow(int width, int height, void *data)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
||||||
|
|
||||||
@ -537,7 +538,7 @@ void InitWindow(int width, int height, void *data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Close window and unload OpenGL context
|
// Close window and unload OpenGL context
|
||||||
void CloseWindow(void)
|
void CloseRLWindow(void)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_GIF_RECORDING)
|
#if defined(SUPPORT_GIF_RECORDING)
|
||||||
if (gifRecording)
|
if (gifRecording)
|
||||||
@ -714,7 +715,7 @@ int GetScreenHeight(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
void ShowCursor()
|
void ShowRLCursor()
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@ -727,7 +728,7 @@ void ShowCursor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hides mouse cursor
|
// Hides mouse cursor
|
||||||
void HideCursor()
|
void HideRLCursor()
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@ -1134,7 +1135,7 @@ void SetConfigFlags(char flags)
|
|||||||
// Takes a screenshot of current screen (saved a .png)
|
// Takes a screenshot of current screen (saved a .png)
|
||||||
void TakeScreenshot(const char *fileName)
|
void TakeScreenshot(const char *fileName)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
#if (defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)) && defined(SUPPORT_SAVE_PNG)
|
||||||
unsigned char *imgData = rlReadScreenPixels(renderWidth, renderHeight);
|
unsigned char *imgData = rlReadScreenPixels(renderWidth, renderHeight);
|
||||||
SavePNG(fileName, imgData, renderWidth, renderHeight, 4); // Save image as PNG
|
SavePNG(fileName, imgData, renderWidth, renderHeight, 4); // Save image as PNG
|
||||||
free(imgData);
|
free(imgData);
|
||||||
@ -2119,7 +2120,7 @@ static void InitTimer(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get current time measure (in seconds) since InitTimer()
|
// Get current time measure (in seconds) since InitTimer()
|
||||||
static double GetTime(void)
|
double GetTime(void)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||||
return glfwGetTime();
|
return glfwGetTime();
|
||||||
|
25
src/external/glad.h
vendored
25
src/external/glad.h
vendored
@ -3446,6 +3446,19 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum
|
|||||||
GLAPI PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
|
GLAPI PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
|
||||||
#define glBlendFuncSeparateEXT glad_glBlendFuncSeparateEXT
|
#define glBlendFuncSeparateEXT glad_glBlendFuncSeparateEXT
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GL_EXT_debug_marker
|
||||||
|
#define GL_EXT_debug_marker 1
|
||||||
|
GLAPI int GLAD_GL_EXT_debug_marker;
|
||||||
|
typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar *marker);
|
||||||
|
GLAPI PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
|
||||||
|
#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
|
||||||
|
typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar *marker);
|
||||||
|
GLAPI PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
|
||||||
|
#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
|
||||||
|
typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC)(void);
|
||||||
|
GLAPI PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
|
||||||
|
#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
|
||||||
|
#endif
|
||||||
#ifndef GL_EXT_framebuffer_blit
|
#ifndef GL_EXT_framebuffer_blit
|
||||||
#define GL_EXT_framebuffer_blit 1
|
#define GL_EXT_framebuffer_blit 1
|
||||||
GLAPI int GLAD_GL_EXT_framebuffer_blit;
|
GLAPI int GLAD_GL_EXT_framebuffer_blit;
|
||||||
@ -4209,6 +4222,7 @@ int GLAD_GL_ARB_vertex_shader;
|
|||||||
int GLAD_GL_ARB_vertex_attrib_binding;
|
int GLAD_GL_ARB_vertex_attrib_binding;
|
||||||
int GLAD_GL_ARB_vertex_program;
|
int GLAD_GL_ARB_vertex_program;
|
||||||
int GLAD_GL_EXT_texture_compression_s3tc;
|
int GLAD_GL_EXT_texture_compression_s3tc;
|
||||||
|
int GLAD_GL_EXT_debug_marker;
|
||||||
int GLAD_GL_EXT_texture_swizzle;
|
int GLAD_GL_EXT_texture_swizzle;
|
||||||
int GLAD_GL_ARB_texture_multisample;
|
int GLAD_GL_ARB_texture_multisample;
|
||||||
int GLAD_GL_ARB_texture_rg;
|
int GLAD_GL_ARB_texture_rg;
|
||||||
@ -4391,6 +4405,9 @@ PFNGLGETVARIANTARRAYOBJECTIVATIPROC glad_glGetVariantArrayObjectivATI;
|
|||||||
PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
|
PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
|
||||||
PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
|
PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
|
||||||
PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
|
PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
|
||||||
|
PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
|
||||||
|
PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
|
||||||
|
PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
|
||||||
PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
|
PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
|
||||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
|
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
|
||||||
PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
|
PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
|
||||||
@ -5190,6 +5207,12 @@ static void load_GL_EXT_blend_func_separate(GLADloadproc load) {
|
|||||||
if(!GLAD_GL_EXT_blend_func_separate) return;
|
if(!GLAD_GL_EXT_blend_func_separate) return;
|
||||||
glad_glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)load("glBlendFuncSeparateEXT");
|
glad_glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)load("glBlendFuncSeparateEXT");
|
||||||
}
|
}
|
||||||
|
static void load_GL_EXT_debug_marker(GLADloadproc load) {
|
||||||
|
if(!GLAD_GL_EXT_debug_marker) return;
|
||||||
|
glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC)load("glInsertEventMarkerEXT");
|
||||||
|
glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC)load("glPushGroupMarkerEXT");
|
||||||
|
glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC)load("glPopGroupMarkerEXT");
|
||||||
|
}
|
||||||
static void load_GL_EXT_framebuffer_blit(GLADloadproc load) {
|
static void load_GL_EXT_framebuffer_blit(GLADloadproc load) {
|
||||||
if(!GLAD_GL_EXT_framebuffer_blit) return;
|
if(!GLAD_GL_EXT_framebuffer_blit) return;
|
||||||
glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)load("glBlitFramebufferEXT");
|
glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)load("glBlitFramebufferEXT");
|
||||||
@ -5316,6 +5339,7 @@ static int find_extensionsGL(void) {
|
|||||||
GLAD_GL_EXT_blend_color = has_ext("GL_EXT_blend_color");
|
GLAD_GL_EXT_blend_color = has_ext("GL_EXT_blend_color");
|
||||||
GLAD_GL_EXT_blend_equation_separate = has_ext("GL_EXT_blend_equation_separate");
|
GLAD_GL_EXT_blend_equation_separate = has_ext("GL_EXT_blend_equation_separate");
|
||||||
GLAD_GL_EXT_blend_func_separate = has_ext("GL_EXT_blend_func_separate");
|
GLAD_GL_EXT_blend_func_separate = has_ext("GL_EXT_blend_func_separate");
|
||||||
|
GLAD_GL_EXT_debug_marker = has_ext("GL_EXT_debug_marker");
|
||||||
GLAD_GL_EXT_framebuffer_blit = has_ext("GL_EXT_framebuffer_blit");
|
GLAD_GL_EXT_framebuffer_blit = has_ext("GL_EXT_framebuffer_blit");
|
||||||
GLAD_GL_EXT_framebuffer_multisample = has_ext("GL_EXT_framebuffer_multisample");
|
GLAD_GL_EXT_framebuffer_multisample = has_ext("GL_EXT_framebuffer_multisample");
|
||||||
GLAD_GL_EXT_framebuffer_multisample_blit_scaled = has_ext("GL_EXT_framebuffer_multisample_blit_scaled");
|
GLAD_GL_EXT_framebuffer_multisample_blit_scaled = has_ext("GL_EXT_framebuffer_multisample_blit_scaled");
|
||||||
@ -5430,6 +5454,7 @@ int gladLoadGLLoader(GLADloadproc load) {
|
|||||||
load_GL_EXT_blend_color(load);
|
load_GL_EXT_blend_color(load);
|
||||||
load_GL_EXT_blend_equation_separate(load);
|
load_GL_EXT_blend_equation_separate(load);
|
||||||
load_GL_EXT_blend_func_separate(load);
|
load_GL_EXT_blend_func_separate(load);
|
||||||
|
load_GL_EXT_debug_marker(load);
|
||||||
load_GL_EXT_framebuffer_blit(load);
|
load_GL_EXT_framebuffer_blit(load);
|
||||||
load_GL_EXT_framebuffer_multisample(load);
|
load_GL_EXT_framebuffer_multisample(load);
|
||||||
load_GL_EXT_framebuffer_object(load);
|
load_GL_EXT_framebuffer_object(load);
|
||||||
|
12
src/raylib.h
12
src/raylib.h
@ -682,8 +682,8 @@ extern "C" { // Prevents name mangling of functions
|
|||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Window-related functions
|
// Window-related functions
|
||||||
RLAPI void InitWindow(int width, int height, void *data); // Initialize window and OpenGL context
|
RLAPI void InitRLWindow(int width, int height, void *data); // Initialize window and OpenGL context
|
||||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
RLAPI void CloseRLWindow(void); // Close window and unload OpenGL context
|
||||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||||
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
||||||
@ -696,8 +696,8 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||||||
RLAPI int GetScreenHeight(void); // Get current screen height
|
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||||
|
|
||||||
// Cursor-related functions
|
// Cursor-related functions
|
||||||
RLAPI void ShowCursor(void); // Shows cursor
|
RLAPI void ShowRLCursor(void); // Shows cursor
|
||||||
RLAPI void HideCursor(void); // Hides cursor
|
RLAPI void HideRLCursor(void); // Hides cursor
|
||||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||||
RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)
|
RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)
|
||||||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||||
@ -723,6 +723,9 @@ RLAPI void SetTargetFPS(int fps); // Set target
|
|||||||
RLAPI int GetFPS(void); // Returns current FPS
|
RLAPI int GetFPS(void); // Returns current FPS
|
||||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||||
|
|
||||||
|
RLAPI double GetTime(void); // Return time in seconds
|
||||||
|
|
||||||
|
|
||||||
// Color-related functions
|
// Color-related functions
|
||||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||||
@ -1046,6 +1049,7 @@ RLAPI void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int
|
|||||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||||
|
RLAPI Matrix GetMatrixModelview();
|
||||||
|
|
||||||
// Texture maps generation (PBR)
|
// Texture maps generation (PBR)
|
||||||
// NOTE: Required shaders should be provided
|
// NOTE: Required shaders should be provided
|
||||||
|
@ -227,21 +227,29 @@ RMDEF float Clamp(float value, float min, float max)
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Vector with components value 0.0f
|
// Vector with components value 0.0f
|
||||||
RMDEF Vector2 Vector2Zero(void) { return (Vector2){ 0.0f, 0.0f }; }
|
RMDEF Vector2 Vector2Zero(void) {
|
||||||
|
Vector2 tmp = {0.0f, 0.0f};
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Vector with components value 1.0f
|
// Vector with components value 1.0f
|
||||||
RMDEF Vector2 Vector2One(void) { return (Vector2){ 1.0f, 1.0f }; }
|
RMDEF Vector2 Vector2One(void) {
|
||||||
|
Vector2 tmp = {1.0f, 1.0f};
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Add two vectors (v1 + v2)
|
// Add two vectors (v1 + v2)
|
||||||
RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
||||||
{
|
{
|
||||||
return (Vector2){ v1.x + v2.x, v1.y + v2.y };
|
Vector2 tmp = { v1.x + v2.x, v1.y + v2.y };
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subtract two vectors (v1 - v2)
|
// Subtract two vectors (v1 - v2)
|
||||||
RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
||||||
{
|
{
|
||||||
return (Vector2){ v1.x - v2.x, v1.y - v2.y };
|
Vector2 tmp = { v1.x - v2.x, v1.y - v2.y };
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate vector length
|
// Calculate vector length
|
||||||
@ -289,7 +297,8 @@ RMDEF void Vector2Negate(Vector2 *v)
|
|||||||
// Divide vector by a float value
|
// Divide vector by a float value
|
||||||
RMDEF void Vector2Divide(Vector2 *v, float div)
|
RMDEF void Vector2Divide(Vector2 *v, float div)
|
||||||
{
|
{
|
||||||
*v = (Vector2){v->x/div, v->y/div};
|
Vector2 tmp = {v->x/div, v->y/div};
|
||||||
|
*v = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize provided vector
|
// Normalize provided vector
|
||||||
@ -303,21 +312,29 @@ RMDEF void Vector2Normalize(Vector2 *v)
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Vector with components value 0.0f
|
// Vector with components value 0.0f
|
||||||
RMDEF Vector3 Vector3Zero(void) { return (Vector3){ 0.0f, 0.0f, 0.0f }; }
|
RMDEF Vector3 Vector3Zero(void) {
|
||||||
|
Vector3 tmp = { 0.0f, 0.0f, 0.0f };
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Vector with components value 1.0f
|
// Vector with components value 1.0f
|
||||||
RMDEF Vector3 Vector3One(void) { return (Vector3){ 1.0f, 1.0f, 1.0f }; }
|
RMDEF Vector3 Vector3One(void) {
|
||||||
|
Vector3 tmp = { 1.0f, 1.0f, 1.0f };
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Add two vectors
|
// Add two vectors
|
||||||
RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
return (Vector3){ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
|
Vector3 tmp = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substract two vectors
|
// Substract two vectors
|
||||||
RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
return (Vector3){ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
|
Vector3 tmp = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply vector by scalar
|
// Multiply vector by scalar
|
||||||
@ -365,12 +382,14 @@ RMDEF Vector3 Vector3Perpendicular(Vector3 v)
|
|||||||
if (fabsf(v.y) < min)
|
if (fabsf(v.y) < min)
|
||||||
{
|
{
|
||||||
min = fabsf(v.y);
|
min = fabsf(v.y);
|
||||||
cardinalAxis = (Vector3){0.0f, 1.0f, 0.0f};
|
Vector3 tmp = {0.0f, 1.0f, 0.0f};
|
||||||
|
cardinalAxis = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabsf(v.z) < min)
|
if (fabsf(v.z) < min)
|
||||||
{
|
{
|
||||||
cardinalAxis = (Vector3){0.0f, 0.0f, 1.0f};
|
Vector3 tmp = {0.0f, 0.0f, 1.0f};
|
||||||
|
cardinalAxis = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Vector3CrossProduct(v, cardinalAxis);
|
result = Vector3CrossProduct(v, cardinalAxis);
|
||||||
@ -740,8 +759,6 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
|
|||||||
{
|
{
|
||||||
Matrix result;
|
Matrix result;
|
||||||
|
|
||||||
Matrix mat = MatrixIdentity();
|
|
||||||
|
|
||||||
float x = axis.x, y = axis.y, z = axis.z;
|
float x = axis.x, y = axis.y, z = axis.z;
|
||||||
|
|
||||||
float length = sqrtf(x*x + y*y + z*z);
|
float length = sqrtf(x*x + y*y + z*z);
|
||||||
@ -758,33 +775,25 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
|
|||||||
float cosres = cosf(angle);
|
float cosres = cosf(angle);
|
||||||
float t = 1.0f - cosres;
|
float t = 1.0f - cosres;
|
||||||
|
|
||||||
// Cache some matrix values (speed optimization)
|
result.m0 = x*x*t + cosres;
|
||||||
float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;
|
result.m1 = y*x*t + z*sinres;
|
||||||
float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;
|
result.m2 = z*x*t - y*sinres;
|
||||||
float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;
|
result.m3 = 0.0f;
|
||||||
|
|
||||||
// Construct the elements of the rotation matrix
|
result.m4 = x*y*t - z*sinres;
|
||||||
float b00 = x*x*t + cosres, b01 = y*x*t + z*sinres, b02 = z*x*t - y*sinres;
|
result.m5 = y*y*t + cosres;
|
||||||
float b10 = x*y*t - z*sinres, b11 = y*y*t + cosres, b12 = z*y*t + x*sinres;
|
result.m6 = z*y*t + x*sinres;
|
||||||
float b20 = x*z*t + y*sinres, b21 = y*z*t - x*sinres, b22 = z*z*t + cosres;
|
result.m7 = 0.0f;
|
||||||
|
|
||||||
// Perform rotation-specific matrix multiplication
|
result.m8 = x*z*t + y*sinres;
|
||||||
result.m0 = a00*b00 + a10*b01 + a20*b02;
|
result.m9 = y*z*t - x*sinres;
|
||||||
result.m1 = a01*b00 + a11*b01 + a21*b02;
|
result.m10 = z*z*t + cosres;
|
||||||
result.m2 = a02*b00 + a12*b01 + a22*b02;
|
result.m11 = 0.0f;
|
||||||
result.m3 = a03*b00 + a13*b01 + a23*b02;
|
|
||||||
result.m4 = a00*b10 + a10*b11 + a20*b12;
|
result.m12 = 0.0f;
|
||||||
result.m5 = a01*b10 + a11*b11 + a21*b12;
|
result.m13 = 0.0f;
|
||||||
result.m6 = a02*b10 + a12*b11 + a22*b12;
|
result.m14 = 0.0f;
|
||||||
result.m7 = a03*b10 + a13*b11 + a23*b12;
|
result.m15 = 1.0f;
|
||||||
result.m8 = a00*b20 + a10*b21 + a20*b22;
|
|
||||||
result.m9 = a01*b20 + a11*b21 + a21*b22;
|
|
||||||
result.m10 = a02*b20 + a12*b21 + a22*b22;
|
|
||||||
result.m11 = a03*b20 + a13*b21 + a23*b22;
|
|
||||||
result.m12 = mat.m12;
|
|
||||||
result.m13 = mat.m13;
|
|
||||||
result.m14 = mat.m14;
|
|
||||||
result.m15 = mat.m15;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1011,7 +1020,8 @@ RMDEF float *MatrixToFloat(Matrix mat)
|
|||||||
// Returns identity quaternion
|
// Returns identity quaternion
|
||||||
RMDEF Quaternion QuaternionIdentity(void)
|
RMDEF Quaternion QuaternionIdentity(void)
|
||||||
{
|
{
|
||||||
return (Quaternion){ 0.0f, 0.0f, 0.0f, 1.0f };
|
Quaternion q = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Computes the length of a quaternion
|
// Computes the length of a quaternion
|
||||||
|
21
src/rlgl.c
21
src/rlgl.c
@ -307,6 +307,8 @@ static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays;
|
|||||||
//static PFNGLISVERTEXARRAYOESPROC glIsVertexArray; // NOTE: Fails in WebGL, omitted
|
//static PFNGLISVERTEXARRAYOESPROC glIsVertexArray; // NOTE: Fails in WebGL, omitted
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool debugMarkerSupported = false;
|
||||||
|
|
||||||
// Compressed textures support flags
|
// Compressed textures support flags
|
||||||
static bool texCompDXTSupported = false; // DDS texture compression support
|
static bool texCompDXTSupported = false; // DDS texture compression support
|
||||||
static bool texNPOTSupported = false; // NPOT textures full support
|
static bool texNPOTSupported = false; // NPOT textures full support
|
||||||
@ -412,7 +414,7 @@ void rlPushMatrix(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stack[stackCounter] = *currentMatrix;
|
stack[stackCounter] = *currentMatrix;
|
||||||
rlLoadIdentity();
|
// rlLoadIdentity();
|
||||||
stackCounter++;
|
stackCounter++;
|
||||||
|
|
||||||
if (currentMatrixMode == RL_MODELVIEW) useTempBuffer = true;
|
if (currentMatrixMode == RL_MODELVIEW) useTempBuffer = true;
|
||||||
@ -1135,6 +1137,10 @@ void rlglInit(int width, int height)
|
|||||||
glGetFloatv(0x84FF, &maxAnisotropicLevel); // GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
glGetFloatv(0x84FF, &maxAnisotropicLevel); // GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) {
|
||||||
|
debugMarkerSupported = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Clamp mirror wrap mode supported
|
// Clamp mirror wrap mode supported
|
||||||
if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texClampMirrorSupported = true;
|
if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texClampMirrorSupported = true;
|
||||||
}
|
}
|
||||||
@ -1160,6 +1166,8 @@ void rlglInit(int width, int height)
|
|||||||
if (texAnisotropicFilterSupported) TraceLog(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", maxAnisotropicLevel);
|
if (texAnisotropicFilterSupported) TraceLog(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", maxAnisotropicLevel);
|
||||||
if (texClampMirrorSupported) TraceLog(LOG_INFO, "[EXTENSION] Clamp mirror wrap texture mode supported");
|
if (texClampMirrorSupported) TraceLog(LOG_INFO, "[EXTENSION] Clamp mirror wrap texture mode supported");
|
||||||
|
|
||||||
|
if (debugMarkerSupported) TraceLog(LOG_INFO, "[EXTENSION] Debug Marker supported");
|
||||||
|
|
||||||
// Initialize buffers, default shaders and default textures
|
// Initialize buffers, default shaders and default textures
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
@ -2539,6 +2547,12 @@ void SetMatrixModelview(Matrix view)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix GetMatrixModelview() {
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
return modelview;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Generate cubemap texture from HDR texture
|
// Generate cubemap texture from HDR texture
|
||||||
// TODO: OpenGL ES 2.0 does not support GL_RGB16F texture format, neither GL_DEPTH_COMPONENT24
|
// TODO: OpenGL ES 2.0 does not support GL_RGB16F texture format, neither GL_DEPTH_COMPONENT24
|
||||||
Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
|
Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
|
||||||
@ -4212,3 +4226,8 @@ void TraceLog(int msgType, const char *text, ...)
|
|||||||
if (msgType == LOG_ERROR) exit(1);
|
if (msgType == LOG_ERROR) exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void rlSetMarker(const char *text) {
|
||||||
|
if(debugMarkerSupported)
|
||||||
|
glInsertEventMarkerEXT(0, text); //0 terminated string
|
||||||
|
}
|
||||||
|
@ -440,6 +440,9 @@ void rlUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update ve
|
|||||||
void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
||||||
void rlUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
|
void rlUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
|
||||||
|
|
||||||
|
// Debug Marker for Analysis
|
||||||
|
void rlSetMarker(const char *text);
|
||||||
|
|
||||||
// NOTE: There is a set of shader related functions that are available to end user,
|
// NOTE: There is a set of shader related functions that are available to end user,
|
||||||
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
||||||
|
|
||||||
@ -456,11 +459,13 @@ Texture2D GetTextureDefault(void); // Get default texture
|
|||||||
|
|
||||||
// Shader configuration functions
|
// Shader configuration functions
|
||||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||||
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
void SetShaderValue(Shader shader, int uniformLoc, const float *value, int size); // Set shader uniform value (float)
|
||||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int size); // Set shader uniform value (int)
|
||||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||||
void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||||
void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||||
|
Matrix GetMatrixModelview();
|
||||||
|
|
||||||
|
|
||||||
// Texture maps generation (PBR)
|
// Texture maps generation (PBR)
|
||||||
// NOTE: Required shaders should be provided
|
// NOTE: Required shaders should be provided
|
||||||
|
@ -290,11 +290,12 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
|||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
if (IsFileExtension(fileName, ".ttf")) spriteFont = LoadSpriteFontEx(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL);
|
if (IsFileExtension(fileName, ".ttf")) spriteFont = LoadSpriteFontEx(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL);
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||||
else if (IsFileExtension(fileName, ".fnt")) spriteFont = LoadBMFont(fileName);
|
if (IsFileExtension(fileName, ".fnt")) spriteFont = LoadBMFont(fileName);
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Image image = LoadImage(fileName);
|
Image image = LoadImage(fileName);
|
||||||
if (image.data != NULL) spriteFont = LoadImageFont(image, MAGENTA, DEFAULT_FIRST_CHAR);
|
if (image.data != NULL) spriteFont = LoadImageFont(image, MAGENTA, DEFAULT_FIRST_CHAR);
|
||||||
|
@ -554,7 +554,7 @@ void UpdateTexture(Texture2D texture, const void *pixels)
|
|||||||
// Save image to a PNG file
|
// Save image to a PNG file
|
||||||
void SaveImageAs(const char* fileName, Image image)
|
void SaveImageAs(const char* fileName, Image image)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
#if (defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)) && defined(SUPPORT_SAVE_PNG)
|
||||||
unsigned char* imgData = (unsigned char*)GetImageData(image); // this works since Color is just a container for the RGBA values
|
unsigned char* imgData = (unsigned char*)GetImageData(image); // this works since Color is just a container for the RGBA values
|
||||||
SavePNG(fileName, imgData, image.width, image.height, 4);
|
SavePNG(fileName, imgData, image.width, image.height, 4);
|
||||||
free(imgData);
|
free(imgData);
|
||||||
|
Loading…
Reference in New Issue
Block a user