comparison src/video/SDL_video.c @ 1361:19418e4422cb

New configure-based build system. Still work in progress, but much improved
author Sam Lantinga <slouken@libsdl.org>
date Thu, 16 Feb 2006 10:11:48 +0000
parents c71e05b4dc2e
children c0a74f199ecf
comparison
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
22 22
23 /* The high-level video driver subsystem */ 23 /* The high-level video driver subsystem */
24 24
25 #include "SDL.h" 25 #include "SDL.h"
26 #include "SDL_sysvideo.h" 26 #include "SDL_sysvideo.h"
27 #include "SDL_sysevents.h"
28 #include "SDL_blit.h" 27 #include "SDL_blit.h"
29 #include "SDL_pixels_c.h" 28 #include "SDL_pixels_c.h"
30 #include "SDL_events_c.h"
31 #include "SDL_cursor_c.h" 29 #include "SDL_cursor_c.h"
30 #include "../events/SDL_sysevents.h"
31 #include "../events/SDL_events_c.h"
32 32
33 /* Available video drivers */ 33 /* Available video drivers */
34 static VideoBootStrap *bootstrap[] = { 34 static VideoBootStrap *bootstrap[] = {
35 #ifdef ENABLE_QUARTZ 35 #if SDL_VIDEO_DRIVER_QUARTZ
36 &QZ_bootstrap, 36 &QZ_bootstrap,
37 #endif 37 #endif
38 #ifdef ENABLE_X11 38 #if SDL_VIDEO_DRIVER_X11
39 &X11_bootstrap, 39 &X11_bootstrap,
40 #endif 40 #endif
41 #ifdef ENABLE_DGA 41 #if SDL_VIDEO_DRIVER_DGA
42 &DGA_bootstrap, 42 &DGA_bootstrap,
43 #endif 43 #endif
44 #ifdef ENABLE_NANOX 44 #if SDL_VIDEO_DRIVER_NANOX
45 &NX_bootstrap, 45 &NX_bootstrap,
46 #endif 46 #endif
47 #ifdef ENABLE_IPOD 47 #if SDL_VIDEO_DRIVER_IPOD
48 &iPod_bootstrap, 48 &iPod_bootstrap,
49 #endif 49 #endif
50 #ifdef ENABLE_QTOPIA 50 #if SDL_VIDEO_DRIVER_QTOPIA
51 &Qtopia_bootstrap, 51 &Qtopia_bootstrap,
52 #endif 52 #endif
53 #ifdef ENABLE_WSCONS 53 #if SDL_VIDEO_DRIVER_WSCONS
54 &WSCONS_bootstrap, 54 &WSCONS_bootstrap,
55 #endif 55 #endif
56 #ifdef ENABLE_FBCON 56 #if SDL_VIDEO_DRIVER_FBCON
57 &FBCON_bootstrap, 57 &FBCON_bootstrap,
58 #endif 58 #endif
59 #ifdef ENABLE_DIRECTFB 59 #if SDL_VIDEO_DRIVER_DIRECTFB
60 &DirectFB_bootstrap, 60 &DirectFB_bootstrap,
61 #endif 61 #endif
62 #ifdef ENABLE_PS2GS 62 #if SDL_VIDEO_DRIVER_PS2GS
63 &PS2GS_bootstrap, 63 &PS2GS_bootstrap,
64 #endif 64 #endif
65 #ifdef ENABLE_GGI 65 #if SDL_VIDEO_DRIVER_GGI
66 &GGI_bootstrap, 66 &GGI_bootstrap,
67 #endif 67 #endif
68 #ifdef ENABLE_VGL 68 #if SDL_VIDEO_DRIVER_VGL
69 &VGL_bootstrap, 69 &VGL_bootstrap,
70 #endif 70 #endif
71 #ifdef ENABLE_SVGALIB 71 #if SDL_VIDEO_DRIVER_SVGALIB
72 &SVGALIB_bootstrap, 72 &SVGALIB_bootstrap,
73 #endif 73 #endif
74 #ifdef ENABLE_AALIB 74 #if SDL_VIDEO_DRIVER_GAPI
75 &GAPI_bootstrap,
76 #endif
77 #if SDL_VIDEO_DRIVER_WINDIB
78 &WINDIB_bootstrap,
79 #endif
80 #if SDL_VIDEO_DRIVER_DDRAW
81 &DIRECTX_bootstrap,
82 #endif
83 #if SDL_VIDEO_DRIVER_BWINDOW
84 &BWINDOW_bootstrap,
85 #endif
86 #if SDL_VIDEO_DRIVER_TOOLBOX
87 &TOOLBOX_bootstrap,
88 #endif
89 #if SDL_VIDEO_DRIVER_DRAWSPROCKET
90 &DSp_bootstrap,
91 #endif
92 #if SDL_VIDEO_DRIVER_CYBERGRAPHICS
93 &CGX_bootstrap,
94 #endif
95 #if SDL_VIDEO_DRIVER_PHOTON
96 &ph_bootstrap,
97 #endif
98 #if SDL_VIDEO_DRIVER_EPOC
99 &EPOC_bootstrap,
100 #endif
101 #if SDL_VIDEO_DRIVER_XBIOS
102 &XBIOS_bootstrap,
103 #endif
104 #if SDL_VIDEO_DRIVER_GEM
105 &GEM_bootstrap,
106 #endif
107 #if SDL_VIDEO_DRIVER_PICOGUI
108 &PG_bootstrap,
109 #endif
110 #if SDL_VIDEO_DRIVER_DC
111 &DC_bootstrap,
112 #endif
113 #if SDL_VIDEO_DRIVER_RISCOS
114 &RISCOS_bootstrap,
115 #endif
116 #if SDL_VIDEO_DRIVER_OS2FS
117 &OS2FSLib_bootstrap,
118 #endif
119 #if SDL_VIDEO_DRIVER_AALIB
75 &AALIB_bootstrap, 120 &AALIB_bootstrap,
76 #endif 121 #endif
77 #ifdef ENABLE_GAPI 122 #if SDL_VIDEO_DRIVER_DUMMY
78 &GAPI_bootstrap,
79 #endif
80 #ifdef ENABLE_WINDIB
81 &WINDIB_bootstrap,
82 #endif
83 #ifdef ENABLE_DIRECTX
84 &DIRECTX_bootstrap,
85 #endif
86 #ifdef ENABLE_BWINDOW
87 &BWINDOW_bootstrap,
88 #endif
89 #ifdef ENABLE_TOOLBOX
90 &TOOLBOX_bootstrap,
91 #endif
92 #ifdef ENABLE_DRAWSPROCKET
93 &DSp_bootstrap,
94 #endif
95 #ifdef ENABLE_CYBERGRAPHICS
96 &CGX_bootstrap,
97 #endif
98 #ifdef ENABLE_PHOTON
99 &ph_bootstrap,
100 #endif
101 #ifdef ENABLE_EPOC
102 &EPOC_bootstrap,
103 #endif
104 #ifdef ENABLE_XBIOS
105 &XBIOS_bootstrap,
106 #endif
107 #ifdef ENABLE_GEM
108 &GEM_bootstrap,
109 #endif
110 #ifdef ENABLE_PICOGUI
111 &PG_bootstrap,
112 #endif
113 #ifdef ENABLE_DC
114 &DC_bootstrap,
115 #endif
116 #ifdef ENABLE_RISCOS
117 &RISCOS_bootstrap,
118 #endif
119 #ifdef __OS2__
120 &OS2FSLib_bootstrap,
121 #endif
122 #ifdef ENABLE_DUMMYVIDEO
123 &DUMMY_bootstrap, 123 &DUMMY_bootstrap,
124 #endif 124 #endif
125 NULL 125 NULL
126 }; 126 };
127 127
131 int SDL_VideoInit(const char *driver_name, Uint32 flags); 131 int SDL_VideoInit(const char *driver_name, Uint32 flags);
132 void SDL_VideoQuit(void); 132 void SDL_VideoQuit(void);
133 void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects); 133 void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
134 134
135 static SDL_GrabMode SDL_WM_GrabInputOff(void); 135 static SDL_GrabMode SDL_WM_GrabInputOff(void);
136 #ifdef HAVE_OPENGL 136 #if SDL_VIDEO_OPENGL
137 static int lock_count = 0; 137 static int lock_count = 0;
138 #endif 138 #endif
139 139
140 140
141 /* 141 /*
741 video->UpdateMouse(this); 741 video->UpdateMouse(this);
742 } 742 }
743 SDL_WM_GrabInput(saved_grab); 743 SDL_WM_GrabInput(saved_grab);
744 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */ 744 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
745 745
746 #ifdef HAVE_OPENGL 746 #if SDL_VIDEO_OPENGL
747 /* Load GL symbols (before MakeCurrent, where we need glGetString). */ 747 /* Load GL symbols (before MakeCurrent, where we need glGetString). */
748 if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) { 748 if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
749 749
750 #if defined(__QNXNTO__) && (_NTO_VERSION < 630) 750 #if defined(__QNXNTO__) && (_NTO_VERSION < 630)
751 #define __SDL_NOGETPROCADDR__ 751 #define __SDL_NOGETPROCADDR__
767 #endif /* __SDL_NOGETPROCADDR__ */ 767 #endif /* __SDL_NOGETPROCADDR__ */
768 768
769 #include "SDL_glfuncs.h" 769 #include "SDL_glfuncs.h"
770 #undef SDL_PROC 770 #undef SDL_PROC
771 } 771 }
772 #endif /* HAVE_OPENGL */ 772 #endif /* SDL_VIDEO_OPENGL */
773 773
774 /* If we're running OpenGL, make the context current */ 774 /* If we're running OpenGL, make the context current */
775 if ( (video->screen->flags & SDL_OPENGL) && 775 if ( (video->screen->flags & SDL_OPENGL) &&
776 video->GL_MakeCurrent ) { 776 video->GL_MakeCurrent ) {
777 if ( video->GL_MakeCurrent(this) < 0 ) { 777 if ( video->GL_MakeCurrent(this) < 0 ) {
780 } 780 }
781 781
782 /* Set up a fake SDL surface for OpenGL "blitting" */ 782 /* Set up a fake SDL surface for OpenGL "blitting" */
783 if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) { 783 if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
784 /* Load GL functions for performing the texture updates */ 784 /* Load GL functions for performing the texture updates */
785 #ifdef HAVE_OPENGL 785 #if SDL_VIDEO_OPENGL
786 786
787 /* Create a software surface for blitting */ 787 /* Create a software surface for blitting */
788 #ifdef GL_VERSION_1_2 788 #ifdef GL_VERSION_1_2
789 /* If the implementation either supports the packed pixels 789 /* If the implementation either supports the packed pixels
790 extension, or implements the core OpenGL 1.2 API, it will 790 extension, or implements the core OpenGL 1.2 API, it will
855 #endif 855 #endif
856 NULL); 856 NULL);
857 857
858 video->UpdateRects = SDL_GL_UpdateRectsLock; 858 video->UpdateRects = SDL_GL_UpdateRectsLock;
859 #else 859 #else
860 SDL_SetError("Somebody forgot to #define HAVE_OPENGL"); 860 SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL");
861 return(NULL); 861 return(NULL);
862 #endif 862 #endif
863 } 863 }
864 864
865 /* Create a shadow surface if necessary */ 865 /* Create a shadow surface if necessary */
1511 } 1511 }
1512 1512
1513 /* Update rects without state setting and changing (the caller is responsible for it) */ 1513 /* Update rects without state setting and changing (the caller is responsible for it) */
1514 void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) 1514 void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
1515 { 1515 {
1516 #ifdef HAVE_OPENGL 1516 #if SDL_VIDEO_OPENGL
1517 SDL_VideoDevice *this = current_video; 1517 SDL_VideoDevice *this = current_video;
1518 SDL_Rect update, tmp; 1518 SDL_Rect update, tmp;
1519 int x, y, i; 1519 int x, y, i;
1520 1520
1521 for ( i = 0; i < numrects; i++ ) 1521 for ( i = 0; i < numrects; i++ )
1585 } 1585 }
1586 1586
1587 /* Lock == save current state */ 1587 /* Lock == save current state */
1588 void SDL_GL_Lock() 1588 void SDL_GL_Lock()
1589 { 1589 {
1590 #ifdef HAVE_OPENGL 1590 #if SDL_VIDEO_OPENGL
1591 lock_count--; 1591 lock_count--;
1592 if (lock_count==-1) 1592 if (lock_count==-1)
1593 { 1593 {
1594 SDL_VideoDevice *this = current_video; 1594 SDL_VideoDevice *this = current_video;
1595 1595
1633 } 1633 }
1634 1634
1635 /* Unlock == restore saved state */ 1635 /* Unlock == restore saved state */
1636 void SDL_GL_Unlock() 1636 void SDL_GL_Unlock()
1637 { 1637 {
1638 #ifdef HAVE_OPENGL 1638 #if SDL_VIDEO_OPENGL
1639 lock_count++; 1639 lock_count++;
1640 if (lock_count==0) 1640 if (lock_count==0)
1641 { 1641 {
1642 SDL_VideoDevice *this = current_video; 1642 SDL_VideoDevice *this = current_video;
1643 1643