|
@@ -24,6 +24,8 @@ App::App( int /*argc*/, char* /*argv*/[] )
|
|
|
/*windowW = 1440;
|
|
/*windowW = 1440;
|
|
|
windowH = 900;*/
|
|
windowH = 900;*/
|
|
|
|
|
|
|
|
|
|
+ fullScreenFlag = false;
|
|
|
|
|
+
|
|
|
terminalColoringEnabled = true;
|
|
terminalColoringEnabled = true;
|
|
|
|
|
|
|
|
timerTick = 1000/40; // in ms. 1000/Hz
|
|
timerTick = 1000/40; // in ms. 1000/Hz
|
|
@@ -37,31 +39,40 @@ App::App( int /*argc*/, char* /*argv*/[] )
|
|
|
void App::initWindow()
|
|
void App::initWindow()
|
|
|
{
|
|
{
|
|
|
INFO( "SDL window initializing..." );
|
|
INFO( "SDL window initializing..." );
|
|
|
|
|
+
|
|
|
if( SDL_Init(SDL_INIT_VIDEO) < 0 )
|
|
if( SDL_Init(SDL_INIT_VIDEO) < 0 )
|
|
|
FATAL( "Failed to init SDL_VIDEO" );
|
|
FATAL( "Failed to init SDL_VIDEO" );
|
|
|
|
|
|
|
|
// print driver name
|
|
// print driver name
|
|
|
- char charBuff [256];
|
|
|
|
|
- if( SDL_VideoDriverName(charBuff, sizeof(charBuff)) != NULL )
|
|
|
|
|
|
|
+ const char* driverName = SDL_GetCurrentVideoDriver();
|
|
|
|
|
+ if( driverName != NULL )
|
|
|
{
|
|
{
|
|
|
- INFO( "Video driver name: " << charBuff );
|
|
|
|
|
|
|
+ INFO( "Video driver name: " << driverName );
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
ERROR( "Failed to obtain the video driver name" );
|
|
ERROR( "Failed to obtain the video driver name" );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Chose GL ver
|
|
|
|
|
|
|
+ // set GL attribs
|
|
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
|
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
|
|
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
|
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
|
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 8 ); // WARNING: Set this low only in deferred shading
|
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
|
|
|
|
|
+
|
|
|
|
|
+ // OpenWindow
|
|
|
|
|
+ windowId = SDL_CreateWindow( "AnKi Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowW, windowH, SDL_WINDOW_OPENGL |
|
|
|
|
|
+ SDL_WINDOW_SHOWN );
|
|
|
|
|
+
|
|
|
|
|
+ if( !windowId )
|
|
|
|
|
+ FATAL( "Cannot create main window" );
|
|
|
|
|
+
|
|
|
|
|
+ glContext = SDL_GL_CreateContext( windowId );
|
|
|
|
|
|
|
|
- // get desktop size
|
|
|
|
|
- const SDL_VideoInfo* info = SDL_GetVideoInfo();
|
|
|
|
|
- desktopW = info->current_w;
|
|
|
|
|
- desktopH = info->current_h;
|
|
|
|
|
|
|
|
|
|
// the icon
|
|
// the icon
|
|
|
- iconImage = SDL_LoadBMP("gfx/icon.bmp");
|
|
|
|
|
|
|
+ /*iconImage = SDL_LoadBMP("gfx/icon.bmp");
|
|
|
if( iconImage == NULL )
|
|
if( iconImage == NULL )
|
|
|
{
|
|
{
|
|
|
ERROR( "Cannot load window icon" );
|
|
ERROR( "Cannot load window icon" );
|
|
@@ -71,18 +82,7 @@ void App::initWindow()
|
|
|
Uint32 colorkey = SDL_MapRGB( iconImage->format, 255, 0, 255 );
|
|
Uint32 colorkey = SDL_MapRGB( iconImage->format, 255, 0, 255 );
|
|
|
SDL_SetColorKey( iconImage, SDL_SRCCOLORKEY, colorkey );
|
|
SDL_SetColorKey( iconImage, SDL_SRCCOLORKEY, colorkey );
|
|
|
SDL_WM_SetIcon( iconImage, NULL );
|
|
SDL_WM_SetIcon( iconImage, NULL );
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // set GL attribs
|
|
|
|
|
- SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 8 ); // WARNING: Set this only in deferred shading
|
|
|
|
|
- SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
|
|
|
|
- SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
|
|
|
|
|
-
|
|
|
|
|
- // set the surface
|
|
|
|
|
- mainSurf = SDL_SetVideoMode( windowW, windowH, 24, SDL_HWSURFACE | SDL_OPENGL );
|
|
|
|
|
-
|
|
|
|
|
- SDL_WM_SetCaption( "AnKi Engine", NULL );
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
|
|
INFO( "SDL window initialization ends" );
|
|
INFO( "SDL window initialization ends" );
|
|
|
}
|
|
}
|
|
@@ -93,7 +93,9 @@ void App::initWindow()
|
|
|
//=====================================================================================================================================
|
|
//=====================================================================================================================================
|
|
|
void App::togleFullScreen()
|
|
void App::togleFullScreen()
|
|
|
{
|
|
{
|
|
|
- SDL_WM_ToggleFullScreen( mainSurf );
|
|
|
|
|
|
|
+ //SDL_WM_ToggleFullScreen( mainSurf );
|
|
|
|
|
+ SDL_SetWindowFullscreen( windowId, fullScreenFlag );
|
|
|
|
|
+ fullScreenFlag = !fullScreenFlag;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -102,8 +104,8 @@ void App::togleFullScreen()
|
|
|
//=====================================================================================================================================
|
|
//=====================================================================================================================================
|
|
|
void App::swapBuffers()
|
|
void App::swapBuffers()
|
|
|
{
|
|
{
|
|
|
- SDL_GL_SwapBuffers();
|
|
|
|
|
- //SDL_GL_SwapWindow(mainwindow);
|
|
|
|
|
|
|
+ //SDL_GL_SwapBuffers();
|
|
|
|
|
+ SDL_GL_SwapWindow( windowId );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -112,7 +114,8 @@ void App::swapBuffers()
|
|
|
//=====================================================================================================================================
|
|
//=====================================================================================================================================
|
|
|
void App::quitApp( int code )
|
|
void App::quitApp( int code )
|
|
|
{
|
|
{
|
|
|
- SDL_FreeSurface( mainSurf );
|
|
|
|
|
|
|
+ SDL_GL_DeleteContext( glContext );
|
|
|
|
|
+ SDL_DestroyWindow( windowId );
|
|
|
SDL_Quit();
|
|
SDL_Quit();
|
|
|
exit(code);
|
|
exit(code);
|
|
|
}
|
|
}
|
|
@@ -164,6 +167,28 @@ void App::printAppInfo()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+//=====================================================================================================================================
|
|
|
|
|
+// getDesktopWidth =
|
|
|
|
|
+//=====================================================================================================================================
|
|
|
|
|
+uint App::getDesktopWidth() const
|
|
|
|
|
+{
|
|
|
|
|
+ SDL_DisplayMode mode;
|
|
|
|
|
+ SDL_GetDesktopDisplayMode( &mode );
|
|
|
|
|
+ return mode.w;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//=====================================================================================================================================
|
|
|
|
|
+// getDesktopHeight =
|
|
|
|
|
+//=====================================================================================================================================
|
|
|
|
|
+uint App::getDesktopHeight() const
|
|
|
|
|
+{
|
|
|
|
|
+ SDL_DisplayMode mode;
|
|
|
|
|
+ SDL_GetDesktopDisplayMode( &mode );
|
|
|
|
|
+ return mode.h;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//=====================================================================================================================================
|
|
//=====================================================================================================================================
|
|
|
// getTicks =
|
|
// getTicks =
|
|
|
//=====================================================================================================================================
|
|
//=====================================================================================================================================
|