Fixed togglefullscreen() in opengl

This commit is contained in:
Rob Pearce 2016-07-24 18:43:31 +12:00
parent db9e2779f6
commit 85370a2dba
3 changed files with 27 additions and 18 deletions

37
rc.c
View File

@ -11013,6 +11013,7 @@ void togglepause(void) {
}
void togglefullscreen(void) {
int vidargs;
// close window
//SDL_Quit();
@ -11023,10 +11024,17 @@ void togglefullscreen(void) {
fullscreen = B_TRUE;
}
vidargs = SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0);
#ifdef OPENGL
realscreen=SDL_SetVideoMode(realscreen->w,realscreen->h,realscreen->format->BitsPerPixel,SDL_SWSURFACE|SDL_OPENGL|(fullscreen?SDL_FULLSCREEN:0));
vidargs |= SDL_OPENGL;
#endif
#ifdef OPENGL
preinitgl();
realscreen=SDL_SetVideoMode(realscreen->w,realscreen->h,realscreen->format->BitsPerPixel,vidargs);
initgl();
#else
screen=SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,SDL_SWSURFACE|(screen->flags&SDL_FULLSCREEN?0:SDL_FULLSCREEN));
screen=SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,vidargs);
#endif
// set title bar if required
@ -11041,11 +11049,24 @@ void togglefullscreen(void) {
SDL_setFramerate(&manager, WANTFPS);
}
flip(B_CLEAR);
/*
gengl(screen);
blittoscreen();
*/
}
#ifdef OPENGL
void preinitgl(void) {
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
}
void initgl(void) {
glClearColor( 0, 0, 0, 0 );
glDisable(GL_DEPTH_TEST);
@ -11076,27 +11097,19 @@ void initsdl(void) {
}
#ifdef OPENGL
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
preinitgl();
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
//SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
//screen = SDL_SetVideoMode(SCREENW,SCREENH,16,SDL_SWSURFACE|SDL_OPENGLBLIT|vidargs);
realscreen = SDL_SetVideoMode(SCREENW,SCREENH,wantbpp,SDL_SWSURFACE|SDL_OPENGL|vidargs);
screen = SDL_CreateRGBSurface(SDL_SWSURFACE, realscreen->w, realscreen->h, wantbpp, rm, gm, bm ,am);
SDL_SetAlpha(screen, SDL_SRCALPHA, 0);
#else
//screen = SDL_SetVideoMode(SCREENW,SCREENH,16,SDL_SWSURFACE|SDL_DOUBLEBUF|vidargs);
// Try for 16 bit mode, but SDL_ANYFORMAT means that 32 bit is acceptable.
screen = SDL_SetVideoMode(SCREENW,SCREENH,wantbpp,SDL_SWSURFACE|SDL_ANYFORMAT|vidargs);
#endif
// set drawpixel function based on what depth we ended up with
if (realscreen->format->BitsPerPixel == 32) {
drawpixel = drawpixel32;

1
rc.h
View File

@ -76,6 +76,7 @@ int getmonjumpspeed(sprite_t *s);
int getjumpdelay(int mid);
void togglepause(void);
void togglefullscreen(void);
void preinitgl(void);
void initgl(void);
void initsdl(void);
void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier);

7
todo
View File

@ -1,9 +1,4 @@
- On spike school, allow 40 more seconds before hurryup.
- Convert to openGL so it will run properly in non-fullsecreen mode.
*initial conversion
cloud isn't being cleared properly during level transition
- fullscreen mode not working with open
- get it working not super slow while in non-fullscreen mode.