Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_image.c @ 291:68a8a8237c09
Date: Thu, 21 Feb 2002 09:18:24 +0200
From: "Mike Gorchak" <mike@malva.ua>
Subject: Re: Patches for QNX RtP again.
SDL_ph_image.c - Added OpenGL update functions - fixed some application
crashes.
Some dead code removed, reformatting some functions.
SDL_ph_image_c.h - Added OpenGL update function prototype.
SDL_ph_video.c - Added GL_GetAttribute and GL_SetAttribute functions
with next supported flags: SDL_GL_DOUBLEBUFFER,
SDL_GL_STENCIL_SIZE, SDL_GL_DEPTH_SIZE
GetWMInfo function (stub) has been implemented by me,
but not listed in device structure - fixed.
SDL_ph_wm.c - fixed warning 'no return in non-void function'.
README.QNX - Updating readme. Some spellcheck. ;-)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 02 Mar 2002 16:50:35 +0000 |
parents | 3d8b6b9f1e18 |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
290:9a02597bc1b0 | 291:68a8a8237c09 |
---|---|
31 | 31 |
32 #include "SDL_error.h" | 32 #include "SDL_error.h" |
33 #include "SDL_endian.h" | 33 #include "SDL_endian.h" |
34 #include "SDL_ph_image_c.h" | 34 #include "SDL_ph_image_c.h" |
35 | 35 |
36 //printf("%s:%s:%d\n", __FILE__, __PRETTY_FUNCTION__, __LINE__ ); | |
37 | |
38 /* Various screen update functions available */ | |
39 //static void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | |
40 //static void ph_DummyUpdate(_THIS, int numrects, SDL_Rect *rects); | |
41 | |
42 int ph_SetupImage(_THIS, SDL_Surface *screen) | 36 int ph_SetupImage(_THIS, SDL_Surface *screen) |
43 { | 37 { |
44 int type = 0; | 38 int type = 0; |
45 | 39 |
46 /* Determine image type */ | 40 /* Determine image type */ |
47 switch(screen->format->BitsPerPixel) | 41 switch(screen->format->BitsPerPixel) |
48 { | 42 { |
49 case 8:{ | 43 case 8:{ |
50 type = Pg_IMAGE_PALETTE_BYTE; | 44 type = Pg_IMAGE_PALETTE_BYTE; |
51 } | 45 } |
52 break; | 46 break; |
53 case 15:{ | 47 case 15:{ |
54 type = Pg_IMAGE_DIRECT_555; | 48 type = Pg_IMAGE_DIRECT_555; |
55 } | 49 } |
56 break; | 50 break; |
57 case 16:{ | 51 case 16:{ |
58 type = Pg_IMAGE_DIRECT_565; | 52 type = Pg_IMAGE_DIRECT_565; |
59 } | 53 } |
60 break; | 54 break; |
61 | 55 case 24:{ |
62 case 24:{ | 56 type = Pg_IMAGE_DIRECT_888; |
63 type = Pg_IMAGE_DIRECT_888; | 57 } |
64 } | 58 break; |
65 break; | 59 case 32:{ |
66 | 60 type = Pg_IMAGE_DIRECT_8888; |
67 case 32:{ | 61 } |
68 type = Pg_IMAGE_DIRECT_8888; | 62 break; |
69 } | 63 default:{ |
70 break; | 64 /* should never get here */ |
71 default:{ | 65 fprintf(stderr,"error: unsupported bbp = %d\n", |
72 /* should never get here */ | 66 screen->format->BitsPerPixel); |
73 fprintf(stderr,"error: unsupported bbp = %d\n", | 67 return -1; |
74 screen->format->BitsPerPixel); | 68 } |
75 return -1; | 69 break; |
76 } | 70 } |
77 break; | 71 |
78 } | 72 /* using shared memory for speed (set last param to 1) */ |
79 | 73 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) |
80 //using shared memory for speed (set last param to 1) | 74 { |
81 if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) == NULL) | 75 fprintf(stderr,"error: PhCreateImage failed.\n"); |
82 { | 76 return -1; |
83 fprintf(stderr,"error: PhCreateImage failed.\n"); | 77 } |
84 return -1; | 78 |
85 } | 79 screen->pixels = SDL_Image->image; |
86 | 80 |
87 screen->pixels = SDL_Image->image; | 81 this->UpdateRects = ph_NormalUpdate; |
88 | 82 |
89 this->UpdateRects = ph_NormalUpdate; | 83 return 0; |
90 | |
91 return 0; | |
92 } | 84 } |
93 | 85 |
94 int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context | 86 int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context |
95 { | 87 { |
96 int type = 0; | 88 int type = 0; |
170 this->UpdateRects = ph_OCUpdate; | 162 this->UpdateRects = ph_OCUpdate; |
171 | 163 |
172 return 0; | 164 return 0; |
173 } | 165 } |
174 | 166 |
167 int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen) | |
168 { | |
169 this->UpdateRects = ph_OpenGLUpdate; | |
170 | |
171 return 0; | |
172 } | |
175 | 173 |
176 void ph_DestroyImage(_THIS, SDL_Surface *screen) | 174 void ph_DestroyImage(_THIS, SDL_Surface *screen) |
177 { | 175 { |
178 #if 0 | 176 if (OCImage.offscreen_context != NULL) |
179 if(SDL_Image == NULL) | 177 { |
180 return; | 178 PhDCRelease(OCImage.offscreen_context); |
181 #endif | 179 OCImage.offscreen_context = NULL; |
182 | 180 free(OCImage.FrameData0); |
183 if (OCImage.offscreen_context != NULL) | 181 OCImage.FrameData0 = NULL; |
184 { | 182 free(OCImage.FrameData1); |
185 PhDCRelease(OCImage.offscreen_context); | 183 OCImage.FrameData1 = NULL; |
186 OCImage.offscreen_context = NULL; | 184 } |
187 free(OCImage.FrameData0); | 185 |
188 OCImage.FrameData0 = NULL; | 186 if (SDL_Image) |
189 free(OCImage.FrameData1); | 187 { |
190 OCImage.FrameData1 = NULL; | 188 PgShmemDestroy(SDL_Image->image); |
191 } | 189 free(SDL_Image); |
192 | 190 SDL_Image = NULL; |
193 if (SDL_Image) | 191 } |
194 { | 192 |
195 // SDL_Image->flags=Ph_RELEASE_IMAGE; | 193 if (screen) |
196 // PhReleaseImage(SDL_Image); | 194 { |
197 if (SDL_Image->image) | 195 screen->pixels = NULL; |
198 PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment | 196 } |
199 // lines above if not (and comment this line ;-) | |
200 free(SDL_Image); | |
201 SDL_Image = NULL; | |
202 } | |
203 | |
204 if ( screen ) | |
205 { | |
206 screen->pixels = NULL; | |
207 } | |
208 } | 197 } |
209 | 198 |
210 int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) | 199 int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) |
211 { | 200 { |
212 ph_DestroyImage(this, screen); | 201 ph_DestroyImage(this, screen); |
213 | 202 |
214 if( flags & SDL_HWSURFACE) | 203 if( flags & SDL_HWSURFACE) |
215 { | 204 { |
216 OCImage.flags = flags; //needed for SDL_DOUBLEBUF check | 205 OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */ |
217 return ph_SetupOCImage(this,screen); | 206 return ph_SetupOCImage(this, screen); |
218 } | 207 } |
219 else if(flags & SDL_OPENGL) /* No image when using GL */ | 208 else if(flags & SDL_OPENGL) |
220 { | 209 { |
221 return 0; | 210 return ph_SetupOpenGLImage(this, screen); |
222 } | 211 } |
223 else | 212 else |
224 { | 213 { |
225 return ph_SetupImage(this, screen); | 214 return ph_SetupImage(this, screen); |
226 } | 215 } |
257 } | 246 } |
258 | 247 |
259 static PhPoint_t ph_pos; | 248 static PhPoint_t ph_pos; |
260 static PhRect_t ph_rect; | 249 static PhRect_t ph_rect; |
261 static int i; | 250 static int i; |
251 | |
252 void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects) | |
253 { | |
254 this->GL_SwapBuffers(this); | |
255 | |
256 return; | |
257 } | |
262 | 258 |
263 void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | 259 void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) |
264 { | 260 { |
265 | 261 |
266 for ( i=0; i<numrects; ++i ) | 262 for ( i=0; i<numrects; ++i ) |