Replace more float logic with integer-only
I hate floats >:(
This commit is contained in:
parent
c7a3e9c308
commit
1582af91cf
3 changed files with 7 additions and 7 deletions
|
@ -738,12 +738,12 @@ void RenderBackend_DrawScreen(void)
|
|||
GLsizei width;
|
||||
GLsizei height;
|
||||
|
||||
if ((float)actual_screen_width / (float)actual_screen_height > (float)framebuffer.width / (float)framebuffer.height)
|
||||
if (actual_screen_width * framebuffer.height > framebuffer.width * actual_screen_height) // Fancy way to do `if (actual_screen_width / actual_screen_height > framebuffer.width / framebuffer.height)` without floats
|
||||
{
|
||||
y = 0;
|
||||
height = actual_screen_height;
|
||||
|
||||
width = framebuffer.width * ((float)actual_screen_height / (float)framebuffer.height);
|
||||
width = (framebuffer.width * actual_screen_height) / framebuffer.height;
|
||||
x = (actual_screen_width - width) / 2;
|
||||
}
|
||||
else
|
||||
|
@ -751,7 +751,7 @@ void RenderBackend_DrawScreen(void)
|
|||
x = 0;
|
||||
width = actual_screen_width;
|
||||
|
||||
height = framebuffer.height * ((float)actual_screen_width / (float)framebuffer.width);
|
||||
height = (framebuffer.height * actual_screen_width) / framebuffer.width;
|
||||
y = (actual_screen_height - height) / 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int
|
|||
GLsizei viewport_width;
|
||||
GLsizei viewport_height;
|
||||
|
||||
if ((float)width / (float)height > (float)framebuffer_width / (float)framebuffer_height)
|
||||
if (width * framebuffer_height > framebuffer_width * height) // Fancy way to do `if (width / height > framebuffer_width / framebuffer_height)` without floats
|
||||
{
|
||||
viewport_y = 0;
|
||||
viewport_height = height;
|
||||
|
|
|
@ -50,12 +50,12 @@ static Viewport drc_viewport;
|
|||
|
||||
static void CalculateViewport(unsigned int actual_screen_width, unsigned int actual_screen_height, Viewport *viewport)
|
||||
{
|
||||
if ((float)actual_screen_width / (float)actual_screen_height > (float)fake_framebuffer_width / (float)fake_framebuffer_height)
|
||||
if (actual_screen_width * fake_framebuffer_height > fake_framebuffer_width * actual_screen_height) // Fancy way to do `if (actual_screen_width / actual_screen_height > fake_framebuffer_width / fake_framebuffer_height)` without floats
|
||||
{
|
||||
viewport->y = 0.0f;
|
||||
viewport->height = actual_screen_height;
|
||||
|
||||
viewport->width = fake_framebuffer_width * ((float)actual_screen_height / (float)fake_framebuffer_height);
|
||||
viewport->width = (fake_framebuffer_width * actual_screen_height) / fake_framebuffer_height;
|
||||
viewport->x = (actual_screen_width - viewport->width) / 2;
|
||||
}
|
||||
else
|
||||
|
@ -63,7 +63,7 @@ static void CalculateViewport(unsigned int actual_screen_width, unsigned int act
|
|||
viewport->x = 0.0f;
|
||||
viewport->width = actual_screen_width;
|
||||
|
||||
viewport->height = fake_framebuffer_height * ((float)actual_screen_width / (float)fake_framebuffer_width);
|
||||
viewport->height = (fake_framebuffer_height * actual_screen_width) / fake_framebuffer_width;
|
||||
viewport->y = (actual_screen_height - viewport->height) / 2;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue