context_init args for GL ver and init SDL audio

This commit is contained in:
headshot2017
2022-12-27 21:35:28 -04:00
parent 6e8aa3dd91
commit c305f282de
2 changed files with 12 additions and 10 deletions
+7 -8
View File
@@ -8,16 +8,15 @@ static SDL_GameController *s_controller;
static int s_windowWidth; static int s_windowWidth;
static int s_windowHeight; static int s_windowHeight;
void context_init( const char *title, int width, int height ) void context_init( const char *title, int width, int height, int major, int minor )
{ {
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0 ) goto err; if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO ) < 0 ) goto err;
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); int profile = (major < 3) ? SDL_GL_CONTEXT_PROFILE_COMPATIBILITY : SDL_GL_CONTEXT_PROFILE_CORE;
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, major );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, minor );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, profile );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetSwapInterval( 1 ); SDL_GL_SetSwapInterval( 1 );
s_windowWidth = width; s_windowWidth = width;
+5 -2
View File
@@ -8,13 +8,16 @@
#elif _WIN32 #elif _WIN32
# define HAVE_M_PI # define HAVE_M_PI
# include <GL/glew.h> # include <GL/glew.h>
# include <SDL.h> # include <SDL2/SDL.h>
#else #else
# include <GL/glew.h> # include <GL/glew.h>
# include <SDL2/SDL.h> # include <SDL2/SDL.h>
#endif #endif
extern void context_init( const char *title, int width, int height ); extern int WINDOW_WIDTH;
extern int WINDOW_HEIGHT;
extern void context_init( const char *title, int width, int height, int major, int minor );
extern bool context_flip_frame_poll_events( void ); extern bool context_flip_frame_poll_events( void );
extern SDL_GameController *context_get_controller( void ); extern SDL_GameController *context_get_controller( void );
extern void context_terminate( void ); extern void context_terminate( void );