aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-02-04 17:10:12 +0100
committerRay <raysan5@gmail.com>2019-02-04 17:10:12 +0100
commitc200642887a8a5a4fd38168aee224dc9fc9906ab (patch)
tree21c058a688a9da43198f3e68a09eab9bda19a778 /src
parentfef7bbb495f1d971f1075a3e098cebb8df1c04c4 (diff)
downloadraylib-c200642887a8a5a4fd38168aee224dc9fc9906ab.tar.gz
raylib-c200642887a8a5a4fd38168aee224dc9fc9906ab.zip
Review issue with aspect ratio...
...while using a RenderTexture combined with 3d mode
Diffstat (limited to 'src')
-rw-r--r--src/core.c14
-rw-r--r--src/libraylib.abin0 -> 1293606 bytes
2 files changed, 13 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index e66eabf4..331867b1 100644
--- a/src/core.c
+++ b/src/core.c
@@ -278,6 +278,7 @@ static const char *windowTitle = NULL; // Window text title...
static unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...)
static int screenWidth, screenHeight; // Screen width and height (used render area)
static int renderWidth, renderHeight; // Framebuffer width and height (render area, including black bars if required)
+static int currentWidth, currentHeight; // Current render width and height, it could change on BeginTextureMode()
static int renderOffsetX = 0; // Offset X from render area (must be divided by 2)
static int renderOffsetY = 0; // Offset Y from render area (must be divided by 2)
static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP)
@@ -518,6 +519,8 @@ void InitWindow(int width, int height, const char *title)
#if defined(PLATFORM_ANDROID)
screenWidth = width;
screenHeight = height;
+ currentWidth = width;
+ currentHeight = height;
// Input data is android app pointer
internalDataPath = androidApp->activity->internalDataPath;
@@ -1142,7 +1145,7 @@ void BeginMode3D(Camera3D camera)
rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection
rlLoadIdentity(); // Reset current matrix (PROJECTION)
- float aspect = (float)screenWidth/(float)screenHeight;
+ float aspect = (float)currentWidth/(float)currentHeight;
if (camera.type == CAMERA_PERSPECTIVE)
{
@@ -1208,6 +1211,11 @@ void BeginTextureMode(RenderTexture2D target)
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
//rlScalef(0.0f, -1.0f, 0.0f); // Flip Y-drawing (?)
+
+ // Setup current width/height for proper aspect ratio
+ // calculation when using BeginMode3D()
+ currentWidth = target.texture.width;
+ currentHeight = target.texture.height;
}
// Ends drawing to render texture
@@ -2262,6 +2270,8 @@ static bool InitGraphicsDevice(int width, int height)
{
screenWidth = width; // User desired width
screenHeight = height; // User desired height
+ currentWidth = width;
+ currentHeight = height;
// NOTE: Framebuffer (render area - renderWidth, renderHeight) could include black bars...
// ...in top-down or left-right to match display aspect ratio (no weird scalings)
@@ -3378,6 +3388,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
screenHeight = height;
renderWidth = width;
renderHeight = height;
+ currentWidth = width;
+ currentHeight = height;
// NOTE: Postprocessing texture is not scaled to new size
}
diff --git a/src/libraylib.a b/src/libraylib.a
new file mode 100644
index 00000000..223fbf0d
--- /dev/null
+++ b/src/libraylib.a
Binary files differ