Merge branch 'raysan5:master' into rlsw
This commit is contained in:
commit
f447c97662
|
|
@ -14,6 +14,7 @@
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define MAX_BUILDINGS 100
|
#define MAX_BUILDINGS 100
|
||||||
|
|
||||||
|
|
@ -44,7 +45,11 @@ int main(void)
|
||||||
|
|
||||||
spacing += (int)buildings[i].width;
|
spacing += (int)buildings[i].width;
|
||||||
|
|
||||||
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
buildColors[i] = (Color){
|
||||||
|
(unsigned char)GetRandomValue(200, 240),
|
||||||
|
(unsigned char)GetRandomValue(200, 240),
|
||||||
|
(unsigned char)GetRandomValue(200, 250),
|
||||||
|
255};
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
Camera2D camera = { 0 };
|
||||||
|
|
@ -77,7 +82,8 @@ int main(void)
|
||||||
else if (camera.rotation < -40) camera.rotation = -40;
|
else if (camera.rotation < -40) camera.rotation = -40;
|
||||||
|
|
||||||
// Camera zoom controls
|
// Camera zoom controls
|
||||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
// Uses log scaling to provide consistent zoom speed
|
||||||
|
camera.zoom = expf(logf(camera.zoom) + ((float)GetMouseWheelMove()*0.1f));
|
||||||
|
|
||||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||||
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ int main ()
|
||||||
camera.target = mouseWorldPos;
|
camera.target = mouseWorldPos;
|
||||||
|
|
||||||
// Zoom increment
|
// Zoom increment
|
||||||
float scaleFactor = 1.0f + (0.25f*fabsf(wheel));
|
// Uses log scaling to provide consistent zoom speed
|
||||||
if (wheel < 0) scaleFactor = 1.0f/scaleFactor;
|
float scale = 0.2f*wheel;
|
||||||
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
|
camera.zoom = Clamp(expf(logf(camera.zoom)+scale), 0.125f, 64.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -96,10 +96,10 @@ int main ()
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
||||||
{
|
{
|
||||||
// Zoom increment
|
// Zoom increment
|
||||||
|
// Uses log scaling to provide consistent zoom speed
|
||||||
float deltaX = GetMouseDelta().x;
|
float deltaX = GetMouseDelta().x;
|
||||||
float scaleFactor = 1.0f + (0.01f*fabsf(deltaX));
|
float scale = 0.005f*deltaX;
|
||||||
if (deltaX < 0) scaleFactor = 1.0f/scaleFactor;
|
camera.zoom = Clamp(expf(logf(camera.zoom)+scale), 0.125f, 64.0f);
|
||||||
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,8 @@
|
||||||
|
|
||||||
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
|
|
||||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
#define RL_CULL_DISTANCE_NEAR 0.001 // Default projection matrix near cull distance
|
||||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
#define RL_CULL_DISTANCE_FAR 10000.0 // Default projection matrix far cull distance
|
||||||
|
|
||||||
// Default shader vertex attribute locations
|
// Default shader vertex attribute locations
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
|
||||||
|
|
|
||||||
7
src/external/jar_xm.h
vendored
7
src/external/jar_xm.h
vendored
|
|
@ -232,6 +232,13 @@ uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx);
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Undefine DEBUG to avoid external redefinition warnings/conflicts
|
||||||
|
// This is probably a common definition for
|
||||||
|
// many external build systems' debug configurations
|
||||||
|
#undef DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#if JAR_XM_DEBUG //JAR_XM_DEBUG defined as 0
|
#if JAR_XM_DEBUG //JAR_XM_DEBUG defined as 0
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define DEBUG(fmt, ...) do { \
|
#define DEBUG(fmt, ...) do { \
|
||||||
|
|
|
||||||
|
|
@ -859,7 +859,7 @@ static int InitGraphicsDevice(void)
|
||||||
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6)
|
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6)
|
||||||
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
|
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
|
||||||
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
|
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
|
||||||
EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!)
|
EGL_DEPTH_SIZE, 24, // Depth buffer size (Required to use Depth testing!)
|
||||||
//EGL_STENCIL_SIZE, 8, // Stencil buffer size
|
//EGL_STENCIL_SIZE, 8, // Stencil buffer size
|
||||||
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
|
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
|
||||||
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs)
|
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs)
|
||||||
|
|
|
||||||
|
|
@ -1741,7 +1741,7 @@ static void ErrorCallback(int error, const char *description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
||||||
// NOTE: Window resizing not allowed by default
|
// NOTE: Window resizing not enabled by default, use SetConfigFlags()
|
||||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
{
|
{
|
||||||
// Reset viewport and projection matrix for new size
|
// Reset viewport and projection matrix for new size
|
||||||
|
|
@ -1753,12 +1753,22 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
|
|
||||||
if (IsWindowFullscreen()) return;
|
if (IsWindowFullscreen()) return;
|
||||||
|
|
||||||
// Set current screen size
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
width = (int)(width/GetWindowScaleDPI().x);
|
||||||
|
height = (int)(height/GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set render size
|
||||||
|
CORE.Window.render.width = width;
|
||||||
|
CORE.Window.render.height = height;
|
||||||
|
|
||||||
|
// Set current screen size
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
||||||
// NOTE: Postprocessing texture is not scaled to new size
|
// WARNING: If using a render texture, it is not scaled to new size
|
||||||
}
|
}
|
||||||
static void WindowPosCallback(GLFWwindow* window, int x, int y)
|
static void WindowPosCallback(GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -76,14 +76,14 @@ void CloseWindow(void);
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define Rectangle rectangle_win32
|
#define Rectangle rectangle_win32
|
||||||
#define CloseWindow CloseWindow_win32
|
#define CloseWindow CloseWindow_win32
|
||||||
#define ShowCursor __imp_ShowCursor
|
#define ShowCursor __imp_ShowCursor
|
||||||
#define _APISETSTRING_
|
#define _APISETSTRING_
|
||||||
|
|
||||||
#undef MAX_PATH
|
#undef MAX_PATH
|
||||||
|
|
||||||
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
@ -103,8 +103,8 @@ void CloseWindow(void);
|
||||||
#undef CloseWindow
|
#undef CloseWindow
|
||||||
#undef Rectangle
|
#undef Rectangle
|
||||||
|
|
||||||
#undef MAX_PATH
|
#undef MAX_PATH
|
||||||
#define MAX_PATH 1025
|
#define MAX_PATH 1025
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
@ -896,23 +896,23 @@ const char *GetKeyName(int key)
|
||||||
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
||||||
|
|
||||||
int RGFW_gpConvTable[18] = {
|
int RGFW_gpConvTable[18] = {
|
||||||
[RGFW_gamepadY] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
[RGFW_gamepadY] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
||||||
[RGFW_gamepadB] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
[RGFW_gamepadB] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
||||||
[RGFW_gamepadA] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
[RGFW_gamepadA] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
||||||
[RGFW_gamepadX] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
[RGFW_gamepadX] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
||||||
[RGFW_gamepadL1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
[RGFW_gamepadL1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
||||||
[RGFW_gamepadR1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
[RGFW_gamepadR1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
||||||
[RGFW_gamepadL2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
[RGFW_gamepadL2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
||||||
[RGFW_gamepadR2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
[RGFW_gamepadR2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
||||||
[RGFW_gamepadSelect] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
[RGFW_gamepadSelect] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
||||||
[RGFW_gamepadHome] = GAMEPAD_BUTTON_MIDDLE,
|
[RGFW_gamepadHome] = GAMEPAD_BUTTON_MIDDLE,
|
||||||
[RGFW_gamepadStart] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
[RGFW_gamepadStart] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
||||||
[RGFW_gamepadUp] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
[RGFW_gamepadUp] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||||
[RGFW_gamepadRight] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
[RGFW_gamepadRight] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
||||||
[RGFW_gamepadDown] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
[RGFW_gamepadDown] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
||||||
[RGFW_gamepadLeft] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
[RGFW_gamepadLeft] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
||||||
[RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
[RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
||||||
[RGFW_gamepadR3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
[RGFW_gamepadR3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Register all input events
|
// Register all input events
|
||||||
|
|
@ -994,7 +994,7 @@ void PollInputEvents(void)
|
||||||
RGFW_event *event = &platform.window->event;
|
RGFW_event *event = &platform.window->event;
|
||||||
// All input events can be processed after polling
|
// All input events can be processed after polling
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case RGFW_mouseEnter: CORE.Input.Mouse.cursorOnScreen = true; break;
|
case RGFW_mouseEnter: CORE.Input.Mouse.cursorOnScreen = true; break;
|
||||||
case RGFW_mouseLeave: CORE.Input.Mouse.cursorOnScreen = false; break;
|
case RGFW_mouseLeave: CORE.Input.Mouse.cursorOnScreen = false; break;
|
||||||
|
|
@ -1033,8 +1033,19 @@ void PollInputEvents(void)
|
||||||
case RGFW_windowResized:
|
case RGFW_windowResized:
|
||||||
{
|
{
|
||||||
SetupViewport(platform.window->r.w, platform.window->r.h);
|
SetupViewport(platform.window->r.w, platform.window->r.h);
|
||||||
CORE.Window.screen.width = platform.window->r.w;
|
|
||||||
CORE.Window.screen.height = platform.window->r.h;
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = (int)(platform.window->r.w / GetWindowScaleDPI().x);
|
||||||
|
CORE.Window.screen.height = (int)(platform.window->r.h / GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = platform.window->r.w;
|
||||||
|
CORE.Window.screen.height = platform.window->r.h;
|
||||||
|
}
|
||||||
|
|
||||||
CORE.Window.currentFbo.width = platform.window->r.w;
|
CORE.Window.currentFbo.width = platform.window->r.w;
|
||||||
CORE.Window.currentFbo.height = platform.window->r.h;
|
CORE.Window.currentFbo.height = platform.window->r.h;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
|
@ -1168,7 +1179,7 @@ void PollInputEvents(void)
|
||||||
} break;
|
} break;
|
||||||
case RGFW_gamepadButtonPressed:
|
case RGFW_gamepadButtonPressed:
|
||||||
{
|
{
|
||||||
int button = RGFW_gpConvTable[event->button];
|
int button = RGFW_gpConvTable[event->button];
|
||||||
|
|
||||||
if (button >= 0)
|
if (button >= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1178,7 +1189,7 @@ void PollInputEvents(void)
|
||||||
} break;
|
} break;
|
||||||
case RGFW_gamepadButtonReleased:
|
case RGFW_gamepadButtonReleased:
|
||||||
{
|
{
|
||||||
int button = RGFW_gpConvTable[event->button];
|
int button = RGFW_gpConvTable[event->button];
|
||||||
|
|
||||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0;
|
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0;
|
||||||
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||||
|
|
@ -1186,34 +1197,34 @@ void PollInputEvents(void)
|
||||||
case RGFW_gamepadAxisMove:
|
case RGFW_gamepadAxisMove:
|
||||||
{
|
{
|
||||||
int axis = -1;
|
int axis = -1;
|
||||||
float value = 0;
|
float value = 0;
|
||||||
|
|
||||||
switch(event->whichAxis)
|
switch(event->whichAxis)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f;
|
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f;
|
||||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f;
|
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f;
|
||||||
} break;
|
} break;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f;
|
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f;
|
||||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f;
|
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f;
|
||||||
} break;
|
} break;
|
||||||
case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER;
|
case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER;
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER;
|
if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER;
|
||||||
|
|
||||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||||
int pressed = (value > 0.1f);
|
int pressed = (value > 0.1f);
|
||||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed;
|
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed;
|
||||||
|
|
||||||
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
||||||
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
@ -1311,14 +1322,14 @@ int InitPlatform(void)
|
||||||
CORE.Window.display.width = screenSize.w;
|
CORE.Window.display.width = screenSize.w;
|
||||||
CORE.Window.display.height = screenSize.h;
|
CORE.Window.display.height = screenSize.h;
|
||||||
#else
|
#else
|
||||||
CORE.Window.display.width = CORE.Window.screen.width;
|
CORE.Window.display.width = CORE.Window.screen.width;
|
||||||
CORE.Window.display.height = CORE.Window.screen.height;
|
CORE.Window.display.height = CORE.Window.screen.height;
|
||||||
#endif
|
#endif
|
||||||
// TODO: Is this needed by raylib now?
|
// TODO: Is this needed by raylib now?
|
||||||
// If so, rcore_desktop_sdl should be updated too
|
// If so, rcore_desktop_sdl should be updated too
|
||||||
//SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
|
//SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
|
||||||
|
|
||||||
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
|
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
|
||||||
RGFW_window_makeCurrent(platform.window);
|
RGFW_window_makeCurrent(platform.window);
|
||||||
|
|
||||||
// Check surface and context activation
|
// Check surface and context activation
|
||||||
|
|
@ -1399,5 +1410,5 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode)
|
||||||
{
|
{
|
||||||
if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0;
|
if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0;
|
||||||
|
|
||||||
return keyMappingRGFW[keycode];
|
return keyMappingRGFW[keycode];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1451,8 +1451,17 @@ void PollInputEvents(void)
|
||||||
const int width = event.window.data1;
|
const int width = event.window.data1;
|
||||||
const int height = event.window.data2;
|
const int height = event.window.data2;
|
||||||
SetupViewport(width, height);
|
SetupViewport(width, height);
|
||||||
CORE.Window.screen.width = width;
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
CORE.Window.screen.height = height;
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = (int)(width / GetWindowScaleDPI().x);
|
||||||
|
CORE.Window.screen.height = (int)(height / GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = width;
|
||||||
|
CORE.Window.screen.height = height;
|
||||||
|
}
|
||||||
CORE.Window.currentFbo.width = width;
|
CORE.Window.currentFbo.width = width;
|
||||||
CORE.Window.currentFbo.height = height;
|
CORE.Window.currentFbo.height = height;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
|
|
||||||
|
|
@ -735,20 +735,24 @@ int InitPlatform(void)
|
||||||
|
|
||||||
#if defined(DEFAULT_GRAPHIC_DEVICE_DRM)
|
#if defined(DEFAULT_GRAPHIC_DEVICE_DRM)
|
||||||
platform.fd = open(DEFAULT_GRAPHIC_DEVICE_DRM, O_RDWR);
|
platform.fd = open(DEFAULT_GRAPHIC_DEVICE_DRM, O_RDWR);
|
||||||
|
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: Default graphic device DRM opened successfully");
|
||||||
#else
|
#else
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: No graphic card set, trying platform-gpu-card");
|
TRACELOG(LOG_WARNING, "DISPLAY: No graphic card set, trying platform-gpu-card");
|
||||||
platform.fd = open("/dev/dri/by-path/platform-gpu-card", O_RDWR); // VideoCore VI (Raspberry Pi 4)
|
platform.fd = open("/dev/dri/by-path/platform-gpu-card", O_RDWR); // VideoCore VI (Raspberry Pi 4)
|
||||||
|
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: platform-gpu-card opened successfully");
|
||||||
|
|
||||||
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Failed to open platform-gpu-card, trying card1");
|
TRACELOG(LOG_WARNING, "DISPLAY: Failed to open platform-gpu-card, trying card1");
|
||||||
platform.fd = open("/dev/dri/card1", O_RDWR); // Other Embedded
|
platform.fd = open("/dev/dri/card1", O_RDWR); // Other Embedded
|
||||||
|
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: card1 opened successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Failed to open graphic card1, trying card0");
|
TRACELOG(LOG_WARNING, "DISPLAY: Failed to open graphic card1, trying card0");
|
||||||
platform.fd = open("/dev/dri/card0", O_RDWR); // VideoCore IV (Raspberry Pi 1-3)
|
platform.fd = open("/dev/dri/card0", O_RDWR); // VideoCore IV (Raspberry Pi 1-3)
|
||||||
|
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: card0 opened successfully");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -906,7 +910,7 @@ int InitPlatform(void)
|
||||||
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
|
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
|
||||||
EGL_ALPHA_SIZE, 8, // ALPHA bit depth (required for transparent framebuffer)
|
EGL_ALPHA_SIZE, 8, // ALPHA bit depth (required for transparent framebuffer)
|
||||||
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
|
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
|
||||||
EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!)
|
EGL_DEPTH_SIZE, 24, // Depth buffer size (Required to use Depth testing!)
|
||||||
//EGL_STENCIL_SIZE, 8, // Stencil buffer size
|
//EGL_STENCIL_SIZE, 8, // Stencil buffer size
|
||||||
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
|
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
|
||||||
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs)
|
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs)
|
||||||
|
|
@ -1399,7 +1403,7 @@ static void ConfigureEvdevDevice(char *device)
|
||||||
int fd = open(device, O_RDONLY | O_NONBLOCK);
|
int fd = open(device, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "DRM: Failed to open input device: %s", device);
|
TRACELOG(LOG_WARNING, "SYSTEM: Failed to open input device: %s", device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
22
src/rcore.c
22
src/rcore.c
|
|
@ -1119,7 +1119,7 @@ void BeginTextureMode(RenderTexture2D target)
|
||||||
//rlScalef(0.0f, -1.0f, 0.0f); // Flip Y-drawing (?)
|
//rlScalef(0.0f, -1.0f, 0.0f); // Flip Y-drawing (?)
|
||||||
|
|
||||||
// Setup current width/height for proper aspect ratio
|
// Setup current width/height for proper aspect ratio
|
||||||
// calculation when using BeginMode3D()
|
// calculation when using BeginTextureMode()
|
||||||
CORE.Window.currentFbo.width = target.texture.width;
|
CORE.Window.currentFbo.width = target.texture.width;
|
||||||
CORE.Window.currentFbo.height = target.texture.height;
|
CORE.Window.currentFbo.height = target.texture.height;
|
||||||
CORE.Window.usingFbo = true;
|
CORE.Window.usingFbo = true;
|
||||||
|
|
@ -3688,12 +3688,16 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
|
||||||
(strcmp(dp->d_name, "..") != 0))
|
(strcmp(dp->d_name, "..") != 0))
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
sprintf(path, "%s\\%s", basePath, dp->d_name);
|
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
|
||||||
#else
|
#else
|
||||||
sprintf(path, "%s/%s", basePath, dp->d_name);
|
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s/%s", basePath, dp->d_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (filter != NULL)
|
if ((pathLength < 0) || (pathLength >= MAX_FILEPATH_LENGTH))
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_WARNING, "FILEIO: Path longer than %d characters (%s...)", MAX_FILEPATH_LENGTH, basePath);
|
||||||
|
}
|
||||||
|
else if (filter != NULL)
|
||||||
{
|
{
|
||||||
if (IsPathFile(path))
|
if (IsPathFile(path))
|
||||||
{
|
{
|
||||||
|
|
@ -3742,12 +3746,16 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi
|
||||||
{
|
{
|
||||||
// Construct new path from our base path
|
// Construct new path from our base path
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
sprintf(path, "%s\\%s", basePath, dp->d_name);
|
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
|
||||||
#else
|
#else
|
||||||
sprintf(path, "%s/%s", basePath, dp->d_name);
|
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s/%s", basePath, dp->d_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (IsPathFile(path))
|
if ((pathLength < 0) || (pathLength >= MAX_FILEPATH_LENGTH))
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_WARNING, "FILEIO: Path longer than %d characters (%s...)", MAX_FILEPATH_LENGTH, basePath);
|
||||||
|
}
|
||||||
|
else if (IsPathFile(path))
|
||||||
{
|
{
|
||||||
if (filter != NULL)
|
if (filter != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
16
src/rlgl.h
16
src/rlgl.h
|
|
@ -56,8 +56,8 @@
|
||||||
*
|
*
|
||||||
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||||
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
* #define RL_CULL_DISTANCE_NEAR 0.001 // Default projection matrix near cull distance
|
||||||
* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
* #define RL_CULL_DISTANCE_FAR 10000.0 // Default projection matrix far cull distance
|
||||||
*
|
*
|
||||||
* When loading a shader, the following vertex attributes and uniform
|
* When loading a shader, the following vertex attributes and uniform
|
||||||
* location names are tried to be set automatically:
|
* location names are tried to be set automatically:
|
||||||
|
|
@ -234,10 +234,10 @@
|
||||||
|
|
||||||
// Projection matrix culling
|
// Projection matrix culling
|
||||||
#ifndef RL_CULL_DISTANCE_NEAR
|
#ifndef RL_CULL_DISTANCE_NEAR
|
||||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance
|
#define RL_CULL_DISTANCE_NEAR 0.001 // Default near cull distance
|
||||||
#endif
|
#endif
|
||||||
#ifndef RL_CULL_DISTANCE_FAR
|
#ifndef RL_CULL_DISTANCE_FAR
|
||||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance
|
#define RL_CULL_DISTANCE_FAR 10000.0 // Default far cull distance
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Texture parameters (equivalent to OpenGL defines)
|
// Texture parameters (equivalent to OpenGL defines)
|
||||||
|
|
@ -1459,9 +1459,6 @@ void rlBegin(int mode)
|
||||||
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
|
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
|
||||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
|
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
|
||||||
{
|
{
|
||||||
// Get current binded texture to preserve it between draw modes change (QUADS <--> TRIANGLES)
|
|
||||||
int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
|
|
||||||
|
|
||||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
|
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
|
||||||
{
|
{
|
||||||
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
|
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
|
||||||
|
|
@ -1484,16 +1481,13 @@ void rlBegin(int mode)
|
||||||
|
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture; // Preserve active texture
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish vertex providing
|
// Finish vertex providing
|
||||||
void rlEnd(void)
|
void rlEnd(void)
|
||||||
{
|
{
|
||||||
// Reset texture to default
|
|
||||||
rlSetTexture(RLGL.State.defaultTextureId);
|
|
||||||
|
|
||||||
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
|
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
|
||||||
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
|
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
|
||||||
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
|
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,7 @@ void DrawCircleV(Vector2 center, float radius, Color color)
|
||||||
// Draw a piece of a circle
|
// Draw a piece of a circle
|
||||||
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
|
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
|
||||||
{
|
{
|
||||||
|
if (startAngle == endAngle) return;
|
||||||
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero
|
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero
|
||||||
|
|
||||||
// Function expects (endAngle > startAngle)
|
// Function expects (endAngle > startAngle)
|
||||||
|
|
@ -376,6 +377,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
|
||||||
// Draw a piece of a circle outlines
|
// Draw a piece of a circle outlines
|
||||||
void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
|
void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
|
||||||
{
|
{
|
||||||
|
if (startAngle == endAngle) return;
|
||||||
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero issue
|
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero issue
|
||||||
|
|
||||||
// Function expects (endAngle > startAngle)
|
// Function expects (endAngle > startAngle)
|
||||||
|
|
@ -2237,7 +2239,7 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
|
||||||
// NOTE: Based on http://jeffreythompson.org/collision-detection/poly-point.php
|
// NOTE: Based on http://jeffreythompson.org/collision-detection/poly-point.php
|
||||||
bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCount)
|
bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCount)
|
||||||
{
|
{
|
||||||
bool inside = false;
|
bool collision = false;
|
||||||
|
|
||||||
if (pointCount > 2)
|
if (pointCount > 2)
|
||||||
{
|
{
|
||||||
|
|
@ -2246,12 +2248,12 @@ bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCoun
|
||||||
if ((points[i].y > point.y) != (points[j].y > point.y) &&
|
if ((points[i].y > point.y) != (points[j].y > point.y) &&
|
||||||
(point.x < (points[j].x - points[i].x)*(point.y - points[i].y)/(points[j].y - points[i].y) + points[i].x))
|
(point.x < (points[j].x - points[i].x)*(point.y - points[i].y)/(points[j].y - points[i].y) + points[i].x))
|
||||||
{
|
{
|
||||||
inside = !inside;
|
collision = !collision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return inside;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check collision between two rectangles
|
// Check collision between two rectangles
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user