|
@@ -247,7 +247,8 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
|
247
|
247
|
|
248
|
248
|
flags |= SDL_OPENGL;
|
249
|
249
|
|
250
|
|
- if (fullscreen)
|
|
250
|
+ mFullscreen = fullscreen;
|
|
251
|
+ if (mFullscreen)
|
251
|
252
|
{
|
252
|
253
|
flags |= SDL_FULLSCREEN;
|
253
|
254
|
SDL_ShowCursor(SDL_DISABLE);
|
|
@@ -278,6 +279,8 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
|
278
|
279
|
|
279
|
280
|
void SDLSystem::resize(unsigned int width, unsigned int height)
|
280
|
281
|
{
|
|
282
|
+ int flags;
|
|
283
|
+
|
281
|
284
|
GLfloat aspect;
|
282
|
285
|
|
283
|
286
|
|
|
@@ -302,7 +305,11 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
|
302
|
305
|
glLoadIdentity();
|
303
|
306
|
|
304
|
307
|
// Resize window
|
305
|
|
- mWindow = SDL_SetVideoMode(width, height, 16, SDL_OPENGL);
|
|
308
|
+ flags = SDL_OPENGL;
|
|
309
|
+ if (mFullscreen)
|
|
310
|
+ flags |= SDL_FULLSCREEN;
|
|
311
|
+
|
|
312
|
+ mWindow = SDL_SetVideoMode(width, height, 16, flags);
|
306
|
313
|
|
307
|
314
|
// Resize context
|
308
|
315
|
resizeGL(width, height);
|
|
@@ -491,7 +498,6 @@ void SDLSystem::runGame()
|
491
|
498
|
{
|
492
|
499
|
if (event.type == SDL_KEYDOWN)
|
493
|
500
|
{
|
494
|
|
- printf("Toggling console: %d!\n", mConsoleMode);
|
495
|
501
|
mConsoleMode = !mConsoleMode;
|
496
|
502
|
// Tmp hack
|
497
|
503
|
handleConsoleKeyPressEvent(mConsoleKey, 0);
|
|
@@ -502,7 +508,6 @@ void SDLSystem::runGame()
|
502
|
508
|
switch (event.type)
|
503
|
509
|
{
|
504
|
510
|
case SDL_KEYDOWN:
|
505
|
|
- printf("Console key press!\n");
|
506
|
511
|
handleConsoleKeyPressEvent(key, mod);
|
507
|
512
|
break;
|
508
|
513
|
default:
|
|
@@ -514,7 +519,6 @@ void SDLSystem::runGame()
|
514
|
519
|
//if (key < 255 && mKeyEvents[key] != 0)
|
515
|
520
|
key = mKeyEvents[key];
|
516
|
521
|
|
517
|
|
- printf("Bound key press!\n");
|
518
|
522
|
switch (event.type)
|
519
|
523
|
{
|
520
|
524
|
case SDL_KEYDOWN:
|
|
@@ -526,7 +530,6 @@ void SDLSystem::runGame()
|
526
|
530
|
}
|
527
|
531
|
else // 'Classic' key event handlers
|
528
|
532
|
{
|
529
|
|
- printf("Unbound key press!\n");
|
530
|
533
|
switch (event.type)
|
531
|
534
|
{
|
532
|
535
|
case SDL_KEYDOWN:
|
|
@@ -568,8 +571,45 @@ void SDLSystem::toggleFullscreen()
|
568
|
571
|
{
|
569
|
572
|
if (mWindow)
|
570
|
573
|
{
|
|
574
|
+ mFullscreen = !mFullscreen;
|
571
|
575
|
SDL_ShowCursor(SDL_DISABLE);
|
572
|
|
- SDL_WM_ToggleFullScreen(mWindow);
|
|
576
|
+
|
|
577
|
+ // SDL_WM_ToggleFullScreen does not work on all platforms
|
|
578
|
+ // eg. Mac OS X
|
|
579
|
+ // SDL_WM_ToggleFullScreen(mWindow);
|
|
580
|
+
|
|
581
|
+ // I added a mFullscreen flag to this class. Then I modified it's
|
|
582
|
+ // resize() method to use the SDL_FULLSCREEN flag in the
|
|
583
|
+ // SetVideoMode() call based on the mFullscreen flag.
|
|
584
|
+ // Then, I modified this method to find out an available
|
|
585
|
+ // resolution for the fullscreen mode.
|
|
586
|
+ // Now you can see something when switching to Fullscreen,
|
|
587
|
+ // but it's full of graphical glitches...? I don't know...
|
|
588
|
+ // -- xythobuz 2013-12-31
|
|
589
|
+ int width, height;
|
|
590
|
+ if (mFullscreen) {
|
|
591
|
+ m_old_width = m_width;
|
|
592
|
+ m_old_height = m_height;
|
|
593
|
+ SDL_Rect **dimensions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
|
|
594
|
+ if (dimensions == NULL) {
|
|
595
|
+ printf("Can't enter fullscreen!\n");
|
|
596
|
+ mFullscreen = !mFullscreen;
|
|
597
|
+ }
|
|
598
|
+ if (dimensions != (SDL_Rect **)-1) {
|
|
599
|
+ // TODO dont just use first available resolution...
|
|
600
|
+ width = dimensions[0]->w;
|
|
601
|
+ height = dimensions[0]->h;
|
|
602
|
+ } else {
|
|
603
|
+ // No restrictions, use current resolution
|
|
604
|
+ width = m_width;
|
|
605
|
+ height = m_height;
|
|
606
|
+ }
|
|
607
|
+ }
|
|
608
|
+ if (!mFullscreen) {
|
|
609
|
+ width = m_old_width;
|
|
610
|
+ height = m_old_height;
|
|
611
|
+ }
|
|
612
|
+ resize(width, height);
|
573
|
613
|
}
|
574
|
614
|
}
|
575
|
615
|
|