Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_ph_video.c @ 297:f6ffac90895c
Updated copyright information for 2002
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 06 Mar 2002 11:23:08 +0000 |
parents | 68a8a8237c09 |
children | 2de77f7b7a28 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
291
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
204
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <unistd.h> | |
31 #include <string.h> | |
32 #include <sys/ioctl.h> | |
33 | |
34 #include "SDL.h" | |
35 #include "SDL_error.h" | |
36 #include "SDL_timer.h" | |
37 #include "SDL_thread.h" | |
38 #include "SDL_video.h" | |
39 #include "SDL_mouse.h" | |
40 #include "SDL_endian.h" | |
41 #include "SDL_sysvideo.h" | |
42 #include "SDL_pixels_c.h" | |
43 #include "SDL_events_c.h" | |
44 #include "SDL_ph_video.h" | |
45 #include "SDL_ph_modes_c.h" | |
46 #include "SDL_ph_image_c.h" | |
47 #include "SDL_ph_events_c.h" | |
48 #include "SDL_ph_mouse_c.h" | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
49 #include "SDL_ph_wm_c.h" |
0 | 50 #include "SDL_phyuv_c.h" |
51 #include "blank_cursor.h" | |
52 | |
53 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat); | |
54 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, | |
55 int width, int height, int bpp, Uint32 flags); | |
56 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | |
57 static void ph_VideoQuit(_THIS); | |
58 static void ph_DeleteDevice(SDL_VideoDevice *device); | |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
59 |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
60 #ifdef HAVE_OPENGL |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
61 static void ph_GL_SwapBuffers(_THIS); |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
62 static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
63 #endif /* HAVE_OPENGL */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
64 |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
65 #ifdef HAVE_OPENGL |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
66 PdOpenGLContext_t* OGLContext=NULL; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
67 #endif /* HAVE_OPENGL */ |
0 | 68 |
69 static int ph_Available(void) | |
70 { | |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
71 return 1; |
0 | 72 } |
73 | |
74 static SDL_VideoDevice *ph_CreateDevice(int devindex) | |
75 { | |
76 SDL_VideoDevice *device; | |
77 | |
78 /* Initialize all variables that we clean on shutdown */ | |
79 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); | |
80 if ( device ) { | |
81 memset(device, 0, (sizeof *device)); | |
82 device->hidden = (struct SDL_PrivateVideoData *) | |
83 malloc((sizeof *device->hidden)); | |
84 device->gl_data = NULL; | |
85 } | |
86 if ( (device == NULL) || (device->hidden == NULL) ) { | |
87 SDL_OutOfMemory(); | |
88 ph_DeleteDevice(device); | |
89 return(0); | |
90 } | |
91 memset(device->hidden, 0, (sizeof *device->hidden)); | |
92 | |
93 /* Set the driver flags */ | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
94 device->handles_any_size = 1; /* JB not true for fullscreen */ |
0 | 95 |
96 /* Set the function pointers */ | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
97 device->CreateYUVOverlay = ph_CreateYUVOverlay; |
0 | 98 device->VideoInit = ph_VideoInit; |
99 device->ListModes = ph_ListModes; | |
100 device->SetVideoMode = ph_SetVideoMode; | |
101 device->ToggleFullScreen = ph_ToggleFullScreen; | |
102 device->UpdateMouse = NULL; | |
103 device->SetColors = ph_SetColors; | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
104 device->UpdateRects = NULL; /* ph_ResizeImage; */ |
0 | 105 device->VideoQuit = ph_VideoQuit; |
106 device->AllocHWSurface = ph_AllocHWSurface; | |
107 device->CheckHWBlit = NULL; | |
108 device->FillHWRect = NULL; | |
109 device->SetHWColorKey = NULL; | |
110 device->SetHWAlpha = NULL; | |
111 device->LockHWSurface = ph_LockHWSurface; | |
112 device->UnlockHWSurface = ph_UnlockHWSurface; | |
113 device->FlipHWSurface = ph_FlipHWSurface; | |
114 device->FreeHWSurface = ph_FreeHWSurface; | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
115 device->SetCaption = ph_SetCaption; |
0 | 116 device->SetIcon = NULL; |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
117 device->IconifyWindow = ph_IconifyWindow; |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
279
diff
changeset
|
118 device->GrabInput = ph_GrabInput; |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
119 device->GetWMInfo = ph_GetWMInfo; |
0 | 120 device->FreeWMCursor = ph_FreeWMCursor; |
121 device->CreateWMCursor = ph_CreateWMCursor; | |
122 device->ShowWMCursor = ph_ShowWMCursor; | |
123 device->WarpWMCursor = ph_WarpWMCursor; | |
124 device->CheckMouseMode = ph_CheckMouseMode; | |
125 device->InitOSKeymap = ph_InitOSKeymap; | |
126 device->PumpEvents = ph_PumpEvents; | |
127 | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
128 /* OpenGL support. */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
129 device->GL_LoadLibrary = NULL; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
130 device->GL_GetProcAddress = NULL; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
131 device->GL_MakeCurrent = NULL; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
132 #ifdef HAVE_OPENGL |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
133 device->GL_SwapBuffers = ph_GL_SwapBuffers; |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
134 device->GL_GetAttribute = ph_GL_GetAttribute; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
135 #else |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
136 device->GL_SwapBuffers = NULL; |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
137 device->GL_GetAttribute = NULL; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
138 #endif /* HAVE_OPENGL */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
139 |
0 | 140 device->free = ph_DeleteDevice; |
141 | |
142 return device; | |
143 } | |
144 | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
145 VideoBootStrap ph_bootstrap = { |
0 | 146 "photon", "QNX Photon video output", |
147 ph_Available, ph_CreateDevice | |
148 }; | |
149 | |
150 static void ph_DeleteDevice(SDL_VideoDevice *device) | |
151 { | |
152 | |
153 if ( device ) { | |
154 if ( device->hidden ) { | |
155 free(device->hidden); | |
156 device->hidden = NULL; | |
157 } | |
158 if ( device->gl_data ) { | |
159 free(device->gl_data); | |
160 device->gl_data = NULL; | |
161 } | |
162 free(device); | |
163 device = NULL; | |
164 } | |
165 } | |
166 | |
167 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat) | |
168 { | |
169 PtArg_t arg[1]; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
170 PhDim_t dim; |
0 | 171 PgColor_t ph_palette[_Pg_MAX_PALETTE]; |
172 int i; | |
173 unsigned long *tempptr; | |
174 int rtnval; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
175 // PgDisplaySettings_t mysettings; |
0 | 176 PgVideoModeInfo_t my_mode_info; |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
177 PgHWCaps_t my_hwcaps; |
0 | 178 |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
179 if( NULL == ( event = malloc( EVENT_SIZE ) ) ) |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
180 exit( EXIT_FAILURE ); |
0 | 181 |
182 /* Create a widget 'window' to capture events */ | |
183 dim.w=0; //JB test320; | |
184 dim.h=0; //JB test240; | |
185 //We need to return BytesPerPixel as it in used by CreateRGBsurface | |
186 | |
187 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0); | |
188 | |
189 /* | |
190 PtSetArg(&arg[1], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED); | |
191 PtSetArg(&arg[2], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | | |
192 Ph_WM_STATE_ISMAX | | |
193 Ph_WM_STATE_ISFOCUS); | |
194 | |
195 PtSetArg(&arg[3], Pt_ARG_WINDOW_RENDER_FLAGS,Pt_FALSE,~0); | |
196 PtSetArg(&arg[4], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, | |
197 Ph_WM_FFRONT | | |
198 Ph_WM_CLOSE | | |
199 Ph_WM_TOFRONT | | |
200 Ph_WM_CONSWITCH); | |
201 */ | |
202 | |
203 | |
204 window=PtAppInit(NULL, NULL, NULL, 1, arg); | |
205 | |
206 if(window == NULL) | |
207 { | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
208 printf("Photon application init failed, probably Photon is not running.\n"); |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
209 exit( EXIT_FAILURE ); |
0 | 210 } |
211 | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
212 //PgSetDrawBufferSize(16 *1024); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
213 PgSetRegion(PtWidgetRid(window)); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
214 PgSetClipping(0,NULL); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
215 PtRealizeWidget(window); |
0 | 216 |
217 | |
218 /* Get the available video modes */ | |
219 // if(ph_GetVideoModes(this) < 0) | |
220 // return -1; | |
221 | |
222 /* Create the blank cursor */ | |
223 SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask, | |
224 (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT, | |
225 (int)BLANK_CHOTX, (int)BLANK_CHOTY); | |
226 | |
227 if(SDL_BlankCursor == NULL) | |
228 printf("could not create blank cursor\n"); | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
229 |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
230 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0) |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
231 { |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
232 fprintf(stderr,"ph_VideoInit: GetGraphicsHWCaps failed!! \n"); |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
233 } |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
234 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0) |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
235 { |
0 | 236 fprintf(stderr,"ph_VideoInit: PgGetVideoModeInfo failed\n"); |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
237 } |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
238 |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
239 //We need to return BytesPerPixel as it in used by CreateRGBsurface |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
240 vformat->BitsPerPixel = my_mode_info.bits_per_pixel; |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
241 vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width; |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
242 |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
243 //return a palette if we are in 256 color mode |
0 | 244 if(vformat->BitsPerPixel == 8) |
245 { | |
246 vformat->palette = malloc(sizeof(SDL_Palette)); | |
247 memset(vformat->palette, 0, sizeof(SDL_Palette)); | |
248 vformat->palette->ncolors = 256; | |
249 vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color)); | |
250 | |
251 //fill the palette | |
252 rtnval = PgGetPalette(ph_palette); | |
253 if(rtnval < 0) | |
254 printf("ph_VideoInit: PgGetPalette failed\n"); | |
255 | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
256 tempptr = (unsigned long *)vformat->palette->colors; |
0 | 257 |
258 for(i=0;i<256; i++) | |
259 { | |
260 *tempptr = (((unsigned long)ph_palette[i]) << 8); | |
261 tempptr++; | |
262 | |
263 } | |
264 | |
265 } | |
266 | |
267 | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
268 currently_fullscreen = 0; |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
269 |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
270 this->info.wm_available = 1; |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
271 |
0 | 272 return 0; |
273 } | |
274 | |
275 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, | |
276 int width, int height, int bpp, Uint32 flags) | |
277 { | |
278 PgDisplaySettings_t settings; | |
279 int mode, actual_width, actual_height; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
280 PtArg_t arg[5]; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
281 PhDim_t dim; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
282 int rtnval; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
283 PgColor_t ph_palette[_Pg_MAX_PALETTE]; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
284 int i; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
285 unsigned long *tempptr; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
286 |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
287 #ifdef HAVE_OPENGL |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
288 uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS]; |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
289 int OGLargc; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
290 #endif /* HAVE_OPENGL */ |
0 | 291 |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
292 actual_width = width; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
293 actual_height = height; |
0 | 294 |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
295 dim.w=width; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
296 dim.h=height; |
0 | 297 |
298 /* Lock the event thread, in multi-threading environments */ | |
299 SDL_Lock_EventThread(); | |
300 | |
301 /* Initialize the window */ | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
302 if (flags & SDL_FULLSCREEN) /* Direct Context , assume SDL_HWSURFACE also set */ |
0 | 303 { |
304 /* Get the video mode and set it */ | |
305 if (flags & SDL_ANYFORMAT) | |
306 { | |
307 if ((mode = get_mode_any_format(width, height, bpp)) == 0) | |
308 { | |
309 fprintf(stderr,"error: get_mode_any_format failed\n"); | |
310 exit(1); | |
311 } | |
312 } | |
313 else | |
314 { | |
315 if ((mode = get_mode(width, height, bpp)) == 0) | |
316 { | |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
317 fprintf(stderr,"error: get_mode failed\n"); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
318 exit(1); |
0 | 319 } |
320 } | |
321 settings.mode = mode; | |
322 settings.refresh = 0; | |
323 settings.flags = 0; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
324 |
0 | 325 if (PgSetVideoMode( &settings ) < 0) |
326 { | |
327 fprintf(stderr,"error: PgSetVideoMode failed\n"); | |
328 } | |
329 | |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
330 /* Get the true height and width */ |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
331 |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
332 current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */ |
0 | 333 |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
334 /* Begin direct mode */ |
0 | 335 |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
336 ph_EnterFullScreen(this); |
0 | 337 |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
338 } /* end fullscreen flag */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
339 else |
0 | 340 { |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
341 if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */ |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
342 { |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
343 /* Hardware surface is Offsceen Context. ph_ResizeImage handles the switch */ |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
279
diff
changeset
|
344 current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
345 } |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
346 else /* must be SDL_SWSURFACE */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
347 { |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
279
diff
changeset
|
348 current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
349 } |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
350 |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
351 #ifdef HAVE_OPENGL |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
352 if (flags & SDL_OPENGL) /* for now support OpenGL in window mode only */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
353 { |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
354 OGLargc=0; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
355 if (this->gl_config.depth_size) |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
356 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
357 OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
358 OGLAttrib[OGLargc++]=this->gl_config.depth_size; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
359 } |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
360 if (this->gl_config.stencil_size) |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
361 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
362 OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
363 OGLAttrib[OGLargc++]=this->gl_config.stencil_size; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
364 } |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
365 OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
366 if (this->gl_config.double_buffer) |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
367 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
368 OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
369 } |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
370 else |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
371 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
372 OGLContext=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
373 } |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
374 if (OGLContext==NULL) |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
375 { |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
376 fprintf(stderr,"error: cannot create OpenGL context.\n"); |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
377 exit(1); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
378 } |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
379 PhDCSetCurrent(OGLContext); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
380 } |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
381 #else |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
382 if (flags & SDL_OPENGL) /* if no OpenGL support */ |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
383 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
384 fprintf(stderr, "error: no OpenGL support, try to recompile library.\n"); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
385 exit(1); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
386 } |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
387 |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
388 #endif /* HAVE_OPENGL */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
389 |
0 | 390 } |
391 | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
392 /* If we are setting video to use the palette make sure we have allocated memory for it */ |
0 | 393 if(bpp == 8) |
394 { | |
395 current->format->palette = malloc(sizeof(SDL_Palette)); | |
396 memset(current->format->palette, 0, sizeof(SDL_Palette)); | |
397 current->format->palette->ncolors = 256; | |
398 current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color)); | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
399 /* fill the palette */ |
0 | 400 rtnval = PgGetPalette(ph_palette); |
401 | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
402 tempptr = (unsigned long *)current->format->palette->colors; |
0 | 403 |
404 for(i=0;i<256; i++) | |
405 { | |
406 *tempptr = (((unsigned long)ph_palette[i]) << 8); | |
407 tempptr++; | |
408 | |
409 } | |
410 } | |
411 | |
412 | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
413 /* Current window dimensions */ |
0 | 414 PtGetResource( window, Pt_ARG_DIM, &dim, 0 ); |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
415 |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
416 /* If we need to resize the window */ |
0 | 417 if((dim.w != width)||(dim.h != height)) |
418 { | |
419 dim.w=width; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
420 dim.h=height; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
421 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
422 PtSetResources( window, 1, arg ); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
423 current->w = width; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
424 current->h = height; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
425 current->format->BitsPerPixel = bpp; |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
426 current->format->BytesPerPixel = (bpp+7)/8; |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
427 current->pitch = SDL_CalculatePitch(current); |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
428 /* Must call at least once it setup image planes */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
429 ph_ResizeImage(this, current, flags); |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
430 } |
0 | 431 |
432 SDL_Unlock_EventThread(); | |
433 | |
434 /* We're done! */ | |
435 return(current); | |
436 } | |
437 | |
438 static void ph_VideoQuit(_THIS) | |
439 { | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
279
diff
changeset
|
440 ph_DestroyImage(this, SDL_VideoSurface); |
0 | 441 |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
442 if (currently_fullscreen) |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
443 { |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
444 PdDirectStop( directContext ); |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
445 PdReleaseDirectContext( directContext ); |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
446 directContext=0; |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
447 currently_fullscreen = 0; |
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
448 } |
0 | 449 } |
450 | |
451 | |
452 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | |
453 { | |
454 PgColor_t *in, *out; | |
455 int i, j; | |
456 int alloct_all = 1; | |
457 | |
458 colors = this->screen->format->palette->colors; | |
459 | |
460 in = alloca( ncolors*sizeof(PgColor_t) ); | |
461 if ( in == NULL ) { | |
462 return 0; | |
463 } | |
464 memset(in,0,ncolors*sizeof(PgColor_t)); | |
465 | |
466 out = alloca( ncolors*sizeof(PgColor_t) ); | |
467 if ( out == NULL ) { | |
468 return 0; | |
469 } | |
470 | |
471 for (i=0,j=firstcolor;i<ncolors;i++,j++) | |
472 { | |
473 in[i] |= colors[j].r<<16 ; | |
474 in[i] |= colors[j].g<<8 ; | |
475 in[i] |= colors[j].b ; | |
476 } | |
477 | |
478 if ( (this->screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) | |
479 { | |
480 if( PgSetPalette( in, 0, 0, ncolors, Pg_PALSET_HARD, 0) < 0 ) | |
481 { | |
482 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_HARD) failed\n"); | |
483 return 0; | |
484 } | |
485 } | |
486 else | |
487 { | |
488 if ( PgColorMatch(ncolors, in, out) < 0 ) | |
489 { | |
490 fprintf(stderr,"error: PgColorMatch failed\n"); | |
491 return 0; | |
492 } | |
493 for (i=0;i<ncolors;i++) | |
494 { | |
495 if (memcmp(&in[i],&out[i],sizeof(PgColor_t))) | |
496 { | |
497 alloct_all = 0; | |
498 break; | |
499 } | |
500 } | |
501 if( PgSetPalette( out, 0, 0, ncolors, Pg_PALSET_SOFT, 0) < 0 ) | |
502 { | |
503 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_SOFT) failed\n"); | |
504 return 0; | |
505 } | |
506 } | |
507 return alloct_all; | |
508 } | |
509 | |
279
04351f59b051
Mike Gorchak added some QNX tweaks, including OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
510 #ifdef HAVE_OPENGL |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
511 void ph_GL_SwapBuffers(_THIS) |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
512 { |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
513 PgSetRegion(PtWidgetRid(window)); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
514 PdOpenGLContextSwapBuffers(OGLContext); |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
515 } |
0 | 516 |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
517 int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
518 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
519 switch (attrib) |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
520 { |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
521 case SDL_GL_DOUBLEBUFFER: |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
522 *value=this->gl_config.double_buffer; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
523 break; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
524 case SDL_GL_STENCIL_SIZE: |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
525 *value=this->gl_config.stencil_size; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
526 break; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
527 case SDL_GL_DEPTH_SIZE: |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
528 *value=this->gl_config.depth_size; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
529 break; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
530 default: |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
531 *value=0; |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
532 return(-1); |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
533 } |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
534 return 0; |
0 | 535 } |
291
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
536 |
68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
537 #endif /* HAVE_OPENGL */ |