don't stretch viewport when resizing
This commit is contained in:
+7
-7
@@ -5,8 +5,8 @@
|
||||
static SDL_Window *s_sdlWindow;
|
||||
static SDL_GLContext s_sdlGlContext;
|
||||
static SDL_GameController *s_controller;
|
||||
static int s_windowWidth;
|
||||
static int s_windowHeight;
|
||||
int WINDOW_WIDTH;
|
||||
int WINDOW_HEIGHT;
|
||||
|
||||
void context_init( const char *title, int width, int height, int major, int minor )
|
||||
{
|
||||
@@ -18,8 +18,8 @@ void context_init( const char *title, int width, int height, int major, int mino
|
||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, minor );
|
||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, profile );
|
||||
|
||||
s_windowWidth = width;
|
||||
s_windowHeight = height;
|
||||
WINDOW_WIDTH = width;
|
||||
WINDOW_HEIGHT = height;
|
||||
|
||||
s_sdlWindow = SDL_CreateWindow(
|
||||
title,
|
||||
@@ -87,9 +87,9 @@ bool context_flip_frame_poll_events( void )
|
||||
case SDL_WINDOWEVENT:
|
||||
if( event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED )
|
||||
{
|
||||
s_windowWidth = event.window.data1;
|
||||
s_windowHeight = event.window.data2;
|
||||
glViewport( 0, 0, s_windowWidth, s_windowHeight );
|
||||
WINDOW_WIDTH = event.window.data1;
|
||||
WINDOW_HEIGHT = event.window.data2;
|
||||
glViewport( 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "../renderer.h"
|
||||
#include "../context.h"
|
||||
#include "../level.h"
|
||||
#include <GL/glu.h>
|
||||
|
||||
static void load_collision_mesh( CollisionMesh *mesh )
|
||||
{
|
||||
|
||||
+3
-5
@@ -21,9 +21,6 @@ extern "C" {
|
||||
|
||||
#include "audio.h"
|
||||
|
||||
int WINDOW_WIDTH = 1280;
|
||||
int WINDOW_HEIGHT = 800;
|
||||
|
||||
uint8_t *utils_read_file_alloc( const char *path, size_t *fileLength )
|
||||
{
|
||||
FILE *f = fopen( path, "rb" );
|
||||
@@ -88,6 +85,7 @@ int main( void )
|
||||
struct Renderer *renderer;
|
||||
|
||||
int major, minor, selection = 0;
|
||||
int w = 1280, h = 800;
|
||||
printf("Select OpenGL version\n1. OpenGL 3.3 Core\n2. OpenGL 2.0\n> ");
|
||||
scanf("%d", &selection);
|
||||
if (selection == 2)
|
||||
@@ -108,12 +106,12 @@ int main( void )
|
||||
if (selection == 2)
|
||||
{
|
||||
printf("Launching in 800x600\n");
|
||||
WINDOW_WIDTH = 800; WINDOW_HEIGHT = 600;
|
||||
w = 800; h = 600;
|
||||
}
|
||||
else
|
||||
printf("Launching in 1280x600\n");
|
||||
|
||||
context_init( "libsm64", WINDOW_WIDTH, WINDOW_HEIGHT, major, minor );
|
||||
context_init( "libsm64", w, h, major, minor );
|
||||
renderer->init( &renderState, texture );
|
||||
|
||||
struct SM64MarioInputs marioInputs;
|
||||
|
||||
Reference in New Issue
Block a user