OpenGL error output in debug window + highdpi mode test
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int SCREEN_WIDTH = 800;
|
||||
const int SCREEN_HEIGHT = 600;
|
||||
static SDL_Window* gWindow = NULL;
|
||||
static SDL_GLContext glcontext;
|
||||
static bool gameQuit = false;
|
||||
@@ -46,6 +44,10 @@ void Game::exit() {
|
||||
gameQuit = true;
|
||||
}
|
||||
|
||||
namespace Game {
|
||||
float DDPI, HDPI,VDPI;
|
||||
}
|
||||
|
||||
bool initSDL() {
|
||||
//Init SDL
|
||||
if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
|
||||
@@ -53,16 +55,20 @@ bool initSDL() {
|
||||
return false;
|
||||
}
|
||||
//Init Window
|
||||
gWindow = SDL_CreateWindow( "SDL TEST", SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
|
||||
uint32_t WindowFlags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL;
|
||||
gWindow = SDL_CreateWindow( "SDL TEST", SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, Game::SCREEN_WIDTH, Game::SCREEN_HEIGHT, WindowFlags);
|
||||
if( gWindow == NULL) {
|
||||
cout << "Window could not be created! SDL_Error: " << SDL_GetError() << endl;
|
||||
return false;
|
||||
}
|
||||
//Read in Display DPI
|
||||
SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(gWindow),&Game::DDPI,&Game::HDPI,&Game::VDPI);
|
||||
cout << "DPI: DDPI: " << Game::DDPI << " HDPI: " << Game::HDPI << " VPDI: " << Game::VDPI << endl;
|
||||
//Mask deprectated functions
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
#ifndef NDEBUG
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||
#endif
|
||||
//Init OpenGL Renderer
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
glcontext = SDL_GL_CreateContext(gWindow);
|
||||
@@ -78,7 +84,7 @@ bool initSDL() {
|
||||
return false;
|
||||
}
|
||||
//Init debug callback function
|
||||
#ifndef NDEBUG
|
||||
#ifndef NDEBUG
|
||||
if (GLEW_ARB_debug_output) {
|
||||
Utility::printInfo(Utility::GLEW, "Supporting ARB debug output!");
|
||||
}
|
||||
@@ -104,7 +110,7 @@ bool initSDL() {
|
||||
} else {
|
||||
Utility::printWarning(Utility::OpenGL, "glDebugMessageCallback not available");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user