Skip to content
Snippets Groups Projects
Select Git revision
  • 519b367108bf918b38333ccbb06c98c4e6871f7e
  • master default
  • mingw_gcc44
  • release_ABP1_012
  • release_ABP1_008
  • release_ABP1_006
  • release_ABP1_007
  • release_ABP1_005
  • release_ABP1_004
  • release_ABP1_003
  • pre_release_0.15
  • release_ABP1_001
  • release_ABP1_002
  • pre_release_0.13
  • pre_release_0.14
  • pre_release_0.11
  • pre_release_0.12
  • pre_release_0.10
  • pre_release_0.09
  • pre_release_0.08
20 results

WindowManager.cpp

Blame
  • 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);