comparison src/video/SDL_video.c @ 1658:e49147870aac SDL-1.3

glSDL support
author Sam Lantinga <slouken@libsdl.org>
date Mon, 01 May 2006 06:58:33 +0000
parents 96c2f89cc7e1
children 8b9d79e7eacf
comparison
equal deleted inserted replaced
1657:5b0805ceb50f 1658:e49147870aac
120 #if SDL_VIDEO_DRIVER_AALIB 120 #if SDL_VIDEO_DRIVER_AALIB
121 &AALIB_bootstrap, 121 &AALIB_bootstrap,
122 #endif 122 #endif
123 #if SDL_VIDEO_DRIVER_DUMMY 123 #if SDL_VIDEO_DRIVER_DUMMY
124 &DUMMY_bootstrap, 124 &DUMMY_bootstrap,
125 #endif
126 #if SDL_VIDEO_DRIVER_GLSDL
127 &glSDL_bootstrap,
125 #endif 128 #endif
126 NULL 129 NULL
127 }; 130 };
128 131
129 SDL_VideoDevice *current_video = NULL; 132 SDL_VideoDevice *current_video = NULL;
573 int video_h; 576 int video_h;
574 int video_bpp; 577 int video_bpp;
575 int is_opengl; 578 int is_opengl;
576 SDL_GrabMode saved_grab; 579 SDL_GrabMode saved_grab;
577 580
578 /* Handle obsolete flags */
579 if ( (flags & SDL_OPENGLBLIT_OBSOLETE) == SDL_OPENGLBLIT_OBSOLETE ) {
580 SDL_SetError("SDL_OPENGLBLIT is no longer supported");
581 return(NULL);
582 }
583
584 /* Start up the video driver, if necessary.. 581 /* Start up the video driver, if necessary..
585 WARNING: This is the only function protected this way! 582 WARNING: This is the only function protected this way!
586 */ 583 */
587 if ( ! current_video ) { 584 if ( ! current_video ) {
588 if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) { 585 if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) {
611 if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { 608 if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) {
612 return(NULL); 609 return(NULL);
613 } 610 }
614 611
615 /* Check the requested flags */ 612 /* Check the requested flags */
616 /* There's no palette in > 8 bits-per-pixel mode */ 613 if ( flags & SDL_INTERNALOPENGL ) {
614 SDL_SetError("SDL_INTERNALOPENGL is for internal use only");
615 return(NULL);
616 }
617 if ( video_bpp > 8 ) { 617 if ( video_bpp > 8 ) {
618 /* There's no palette in > 8 bits-per-pixel mode */
618 flags &= ~SDL_HWPALETTE; 619 flags &= ~SDL_HWPALETTE;
619 } 620 }
620 #if 0 621 #if 0
621 if ( (flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) { 622 if ( (flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
622 /* There's no windowed double-buffering */ 623 /* There's no windowed double-buffering */
630 631
631 is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL ); 632 is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL );
632 if ( is_opengl ) { 633 if ( is_opengl ) {
633 /* These flags are for 2D video modes only */ 634 /* These flags are for 2D video modes only */
634 flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF); 635 flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
636 /* This flag tells the backends to treat the surface accordingly */
637 flags |= SDL_INTERNALOPENGL;
635 } 638 }
636 639
637 /* Reset the keyboard here so event callbacks can run */ 640 /* Reset the keyboard here so event callbacks can run */
638 SDL_ResetKeyboard(); 641 SDL_ResetKeyboard();
639 SDL_ResetMouse(); 642 SDL_ResetMouse();
672 #ifndef __OS2__ 675 #ifndef __OS2__
673 SDL_PrivateResize(mode->w, mode->h); 676 SDL_PrivateResize(mode->w, mode->h);
674 #endif 677 #endif
675 678
676 /* Sam - If we asked for OpenGL mode, and didn't get it, fail */ 679 /* Sam - If we asked for OpenGL mode, and didn't get it, fail */
677 if ( is_opengl && !(mode->flags & SDL_OPENGL) ) { 680 if ( is_opengl && !(mode->flags & SDL_INTERNALOPENGL) ) {
678 mode = NULL; 681 mode = NULL;
679 SDL_SetError("OpenGL not available"); 682 SDL_SetError("OpenGL not available");
680 } 683 }
681 } 684 }
682 /* 685 /*
750 SDL_WM_GrabInput(saved_grab); 753 SDL_WM_GrabInput(saved_grab);
751 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */ 754 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
752 755
753 #if SDL_VIDEO_OPENGL 756 #if SDL_VIDEO_OPENGL
754 /* Load GL symbols (before MakeCurrent, where we need glGetString). */ 757 /* Load GL symbols (before MakeCurrent, where we need glGetString). */
755 if ( flags & SDL_OPENGL ) { 758 if ( flags & SDL_INTERNALOPENGL ) {
756 759
757 #if defined(__QNXNTO__) && (_NTO_VERSION < 630) 760 #if defined(__QNXNTO__) && (_NTO_VERSION < 630)
758 #define __SDL_NOGETPROCADDR__ 761 #define __SDL_NOGETPROCADDR__
759 #elif defined(__MINT__) 762 #elif defined(__MINT__)
760 #define __SDL_NOGETPROCADDR__ 763 #define __SDL_NOGETPROCADDR__
777 #undef SDL_PROC 780 #undef SDL_PROC
778 } 781 }
779 #endif /* SDL_VIDEO_OPENGL */ 782 #endif /* SDL_VIDEO_OPENGL */
780 783
781 /* If we're running OpenGL, make the context current */ 784 /* If we're running OpenGL, make the context current */
782 if ( (video->screen->flags & SDL_OPENGL) && 785 if ( (video->screen->flags & SDL_INTERNALOPENGL) &&
783 video->GL_MakeCurrent ) { 786 video->GL_MakeCurrent ) {
784 if ( video->GL_MakeCurrent(this) < 0 ) { 787 if ( video->GL_MakeCurrent(this) < 0 ) {
785 return(NULL); 788 return(NULL);
786 } 789 }
787 } 790 }
1429 void SDL_GL_SwapBuffers(void) 1432 void SDL_GL_SwapBuffers(void)
1430 { 1433 {
1431 SDL_VideoDevice *video = current_video; 1434 SDL_VideoDevice *video = current_video;
1432 SDL_VideoDevice *this = current_video; 1435 SDL_VideoDevice *this = current_video;
1433 1436
1434 if ( video->screen->flags & SDL_OPENGL ) { 1437 if ( video->screen->flags & SDL_INTERNALOPENGL ) {
1435 video->GL_SwapBuffers(this); 1438 video->GL_SwapBuffers(this);
1436 } else { 1439 } else {
1437 SDL_SetError("OpenGL video mode has not been set"); 1440 SDL_SetError("OpenGL video mode has not been set");
1438 } 1441 }
1439 } 1442 }