Select Git revision
WindowManager.cpp
Forked from
einsteinathome / graphicsframework
Source project has a limited visibility.
WindowManager.cpp 8.39 KiB
#include "WindowManager.h"
WindowManager::WindowManager()
{
}
WindowManager::~WindowManager()
{
}
bool WindowManager::initialize()
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
cerr << "Window system could not be initalized: " << SDL_GetError() << endl;
return false;
}
atexit(SDL_Quit);
// retrieve current video settings
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
if (videoInfo->current_w != 0) {
m_CurrentWidth = m_DesktopWidth = videoInfo->current_w;
}
if (videoInfo->current_h != 0) {
m_CurrentHeight = m_DesktopHeight = videoInfo->current_h;
}
if (videoInfo->vfmt->BitsPerPixel != 0) {
m_DesktopBitsPerPixel = videoInfo->vfmt->BitsPerPixel;
}
/*
* SDL_SWSURFACE - Das Surface wird im Hauptspeicher abgelegt (default)
* SDL_HWSURFACE - Das Surface wird im Grafikspeicher abgelegt
* SDL_ASYNCBLIT - Surface benutzt asynchrone Blits, wenn möglich
* SDL_ANYFORMAT - Erlaubt jedes Pixel-Format (nur beim display-surface)
* SDL_HWPALETTE - Surface nutzt exclusive Farbpalette
* SDL_DOUBLEBUF - Surface ist "double buffered" (nur display-surface)
* SDL_FULLSCREEN - Surface im Full-Screen-Mode initialisieren (nur display-surface)
* SDL_OPENGL - Surface nutzt OpenGL (nur display-surface)
* SDL_RESIZABLE - Surfacefenster ist veränderbar (nur display-Surface)
* SDL_HWACCEL- Surface blit nutzt Hardwarebeschleunigung
* SDL_SRCCOLORKEY - Surface nutzt colorkey blitting
* SDL_RLEACCEL - Colorkey blitting ist durch RLE beschleunigt
* SDL_SRCALPHA - Surface blit nutzt alpha blending
* SDL_PREALLOC - Surface nutzt vorher allokierten Speicher
*/
m_VideoModeFlags = SDL_OPENGL | SDL_RESIZABLE;
Uint32 bitPerPixel = SDL_VideoModeOK(
m_DesktopWidth,
m_DesktopHeight,
m_DesktopBitsPerPixel,
m_VideoModeFlags);
if ( !bitPerPixel) {
cerr << "Video mode not supported: " << SDL_GetError() << endl;
return false;
}
// specify minimum requirements
// (query with SDL_GL_SetAttribute() after SDL_SetVideoMode() if needed)
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
//SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);