]> Shamusworld >> Repos - virtualjaguar/blob - src/sdlemu_opengl.c
7b4e01e61bb419bf3876a367602738e35b557045
[virtualjaguar] / src / sdlemu_opengl.c
1 /*
2  * SDLEMU library - Free sdl related functions library
3  * Copyrigh(c) 1999-2004 sdlemu development crew
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program 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
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 /*  SDLEMU_OPENGL.C
21     SDLEMU related sources for using OpenGL with SDL.
22     By Niels Wagenaar | http://sdlemu.ngemu.com | shalafi@xs4all.nl
23
24     Version 1.0.001 - 4-10-2004
25
26     - Added support for 16, 24 and 32 bit textures;
27     - Added support for 16, 24 and 32 bit texture rendering;
28
29     Version 1.0.002 - 6-10-2004
30
31     - Cleaned up a lot of code and removed non functional and obsolete code;
32     - Removed sdlemu_resize_texture function because of double code;
33     - Removed the texture creation from the sdlemu_init_opengl;
34     - Added sdlemu_create_texture function to replace the sdlemu_resize_texture function
35       and the texture creation in sdlemu_init_opengl;
36     - Added the usage of OPENGL_16BPP_CORRECT_RGBA for activating the correct 16bpp RGBA masks;
37     - Added the usage of WANT_OPENGL_ALPHA for using ALPHA blending with 32bpp textures;
38     - Added automatic and override texture bpp depth setting (based upon the src surface);
39
40 */
41
42 #include "sdlemu_opengl.h"
43
44 #include "log.h"
45
46 // We want alpha on our OpenGL contexts...!
47 // Or do we? Seems to kill performance on X...
48 // Or does it? Could it be bad blitter performance?
49 #define WANT_OPENGL_ALPHA
50
51 static SDL_Surface *texture      = 0;
52 static GLuint       texid        = 0;
53 static GLfloat      texcoord[4];
54 static unsigned int glFilter;
55 static unsigned int texturebpp  = 0; // 16, 24 or 32 bpp
56
57 static SDL_Surface * overlay = 0;
58 static GLuint overlayID = 0;
59 static GLfloat overlayCoord[4];
60 void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp);
61
62 static int showOverlay = 0;
63
64 static inline int power_of_two(int input)
65 {
66         int value = 1;
67
68         while (value < input)
69                 value <<= 1;
70
71         return value;
72 }
73
74 void sdlemu_init_opengl(SDL_Surface * src, SDL_Surface * dst, int texturetype, int filter, int src_bpp)
75 {
76         WriteLog("\nOpenGL driver information :\n");
77         WriteLog("\n");
78         WriteLog("Vendor:             %s\n", glGetString(GL_VENDOR));
79         WriteLog("Renderer:           %s\n", glGetString(GL_RENDERER));
80         WriteLog("Version:            %s\n", glGetString(GL_VERSION));
81         WriteLog("OpenGL drawmethod: ");
82
83         switch (texturetype)
84         {
85         case 1:
86                 WriteLog("GL_QUAD rendering\n\n");
87                 break;
88         default:
89                 WriteLog("GL_TRIANGLE rendering\n\n");
90                 break;
91         }
92
93         glFilter = filter;
94
95         // Let us create the texture information :
96         sdlemu_create_texture(src, dst, filter, src_bpp);
97         sdlemu_create_overlay(dst, src_bpp);
98 }
99
100 void sdlemu_draw_texture(SDL_Surface * dst, SDL_Surface * src, int texturetype)
101 {
102 /*
103         This is needed when we want to render OpenGL textures with the Alpha mask set.
104         Be warned! This only works with the bpp of texture en *src set to 32.
105 */
106 #ifdef WANT_OPENGL_ALPHA
107         Uint32 saved_flags;
108         Uint8  saved_alpha;
109
110         /* Save the alpha blending attributes */
111         saved_flags = src->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
112         saved_alpha = src->format->alpha;
113         if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
114                 SDL_SetAlpha(src, 0, 0);
115         }
116
117         // Blit the src display to the texture.
118         SDL_BlitSurface(src, NULL, texture, NULL);
119
120         /* Restore the alpha blending attributes */
121         if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
122                 SDL_SetAlpha(src, saved_flags, saved_alpha);
123         }
124 #else
125         SDL_BlitSurface(src, NULL, texture, NULL);
126 #endif
127 //      SDL_BlitSurface(src, NULL, overlay, NULL);
128 /*Uint32 * pix = (Uint32 *)overlay->pixels;
129 Uint32 y,x;
130 for(y=10; y<200; y++)
131 for(x=30; x<250; x++)
132 pix[x+(y*1024)] = 0x800000FF;//*/
133
134 glBlendFunc(GL_ONE, GL_ZERO);
135 glBindTexture(GL_TEXTURE_2D, texid);
136         // Texturemap complete texture to surface so we have free scaling
137         // and antialiasing
138         switch (texturebpp)
139         {
140         case 16:
141                 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
142                         GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texture->pixels);
143                 break;
144         case 24:
145                 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
146                         GL_RGB, GL_UNSIGNED_BYTE, texture->pixels);
147                 break;
148         case 32:
149         default:
150                 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
151                         GL_RGBA, GL_UNSIGNED_BYTE, texture->pixels);
152                 break;
153         }
154
155         // Render the texture to the screen using OpenGL!
156         switch (texturetype)
157         {
158         case 1:
159                 glBegin(GL_QUADS);
160                         glTexCoord2f(texcoord[0], texcoord[1]);
161                         glVertex2f(0, 0);
162                         glTexCoord2f(texcoord[2], texcoord[1]);
163                         glVertex2f(dst->w, 0);
164                         glTexCoord2f(texcoord[2], texcoord[3]);
165                         glVertex2f(dst->w, dst->h);
166                         glTexCoord2f(texcoord[0], texcoord[3]);
167                         glVertex2f(0, dst->h);
168                 glEnd();
169
170         default:
171                 glBegin(GL_TRIANGLE_STRIP);
172                         glTexCoord2f(texcoord[0], texcoord[1]); glVertex3i(0, 0, 0);
173                         glTexCoord2f(texcoord[2], texcoord[1]); glVertex3i(dst->w, 0, 0);
174                         glTexCoord2f(texcoord[0], texcoord[3]); glVertex3i(0, dst->h, 0);
175                         glTexCoord2f(texcoord[2], texcoord[3]); glVertex3i(dst->w, dst->h, 0);
176                 glEnd();
177         }//*/
178
179         if (showOverlay)
180         {
181                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
182                 glBindTexture(GL_TEXTURE_2D, overlayID);
183                 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, overlay->w, overlay->h, GL_RGBA, GL_UNSIGNED_BYTE, overlay->pixels);
184                 glBegin(GL_QUADS);
185                         glTexCoord2f(overlayCoord[0], overlayCoord[1]);
186                         glVertex2f(0, 0);
187                         glTexCoord2f(overlayCoord[2], overlayCoord[1]);
188                         glVertex2f(dst->w, 0);
189                         glTexCoord2f(overlayCoord[2], overlayCoord[3]);
190                         glVertex2f(dst->w, dst->h);
191                         glTexCoord2f(overlayCoord[0], overlayCoord[3]);
192                         glVertex2f(0, dst->h);
193                 glEnd();
194         }
195
196 //Do some OpenGL stuff here...
197 //Doesn't work...
198 /*unsigned long int map[25] = {
199         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
200         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
201         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
202         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
203         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
204 };
205 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
206 glRasterPos2i(10, 10);
207 glDrawPixels(5, 5, GL_RGBA, GL_UNSIGNED_INT, map);//*/
208
209 //  glFlush();
210         SDL_GL_SwapBuffers();
211 //      glFinish();
212 }
213
214 void sdlemu_close_opengl(void)
215 {
216         if (texture)
217                 SDL_FreeSurface(texture);
218
219         if (overlay)
220                 SDL_FreeSurface(overlay);
221 }
222
223 void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int src_bpp)
224 {
225     // Local variables.
226         int w , h;                         // w and h contain the width and height of the OpenGL texture.
227         Uint32 rmask, gmask, bmask, amask; // Needed for creating RGBA masks.
228         int bpp;
229
230         // Delete old texture (if allocated). Useful when there is a screen resize.
231         if (texture)
232                 SDL_FreeSurface(texture);
233
234         // Texture width/height should be power of 2 of the SDL_Surface *src when using OpenGL.
235         // So, find the largest power of two that will contain both the width and height
236         w = power_of_two(src->w);
237         h = power_of_two(src->h);
238
239         WriteLog("OpenGL - Texture size : %d x %d\n", w, h);
240
241         // Setting bpp based upon src_bpp.
242         bpp = src_bpp;
243
244         // We allow the developer to set its own texture bpp. But if the value is NULL or
245         // not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src.
246         if (bpp == 16 || bpp == 24 || bpp == 32)
247                 texturebpp = bpp;
248         else
249                 texturebpp = src->format->BitsPerPixel;
250
251         WriteLog("OpenGL - Texture depth : %d bpp\n", texturebpp);
252
253         // Now were are going to create a SDL_Surface named texture. This will be our surface
254         // which will function as a buffer between the SDL_Surface *src and SDL_Surface *dst.
255         // This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL
256         // texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst
257         // using OpenGL.
258         //
259         // NOTE: Seems the byte order here *is* important!
260         switch (texturebpp)
261         {
262         case 16: // *src has depth of 16 bpp
263 /*
264         According to information on the SDL mailinglist and on internet, the following
265         rgba masks should be the ones to use. But somehow the screen gets f*cked up and
266         the RGB colours are incorrect (at least in Virtual Jaguar/SDL).
267
268         Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values.
269 */
270 #ifdef OPENGL_16BPP_CORRECT_RGBA
271                 rmask = 0x7C00;
272                 gmask = 0x03E0;
273                 bmask = 0x001F;
274                 amask = 0x0000;
275 #else
276                 rmask = 0x0000;
277                 gmask = 0x0000;
278                 bmask = 0x0000;
279                 amask = 0x0000;
280 #endif
281                 break;
282         case 24: // *src has depth of 24 bpp
283         #if SDL_BYTEORDER == SDL_BIG_ENDIAN
284                 rmask = 0x00FF0000;
285                 gmask = 0x0000FF00;
286                 bmask = 0x000000FF;
287                 amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
288         #else
289                 rmask = 0x000000FF;
290                 gmask = 0x0000FF00;
291                 bmask = 0x00FF0000;
292                 amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
293         #endif
294                 break;
295         case 32: //*src has depth of 32 bpp
296         default: //which is also the default.
297         #if SDL_BYTEORDER == SDL_BIG_ENDIAN
298                 rmask = 0xFF000000;
299                 gmask = 0x00FF0000;
300                 bmask = 0x0000FF00;
301                 amask = 0x000000FF;
302         #else
303                 rmask = 0x000000FF;
304                 gmask = 0x0000FF00;
305                 bmask = 0x00FF0000;
306                 amask = 0xFF000000;
307         #endif
308                 break;
309         }
310
311         // Creating SDL_Surface texture based upon the above settings.
312         texture = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask);
313
314         if (texture == NULL)
315         {
316                 WriteLog("sdlemu_opengl: Could not create texture surface! (SDL: %s)\n", SDL_GetError());
317         }
318
319         // Setting up OpenGL
320         glDisable(GL_FOG);
321         glDisable(GL_LIGHTING);
322         glDisable(GL_CULL_FACE);
323         glDisable(GL_DEPTH_TEST);
324 //      glDisable(GL_BLEND);
325         glEnable(GL_BLEND);
326         glDisable(GL_NORMALIZE);
327         glDisable(GL_ALPHA_TEST);
328         glEnable(GL_TEXTURE_2D);
329 //      glBlendFunc(GL_SRC_ALPHA, GL_ONE);
330 //      glBlendFunc(GL_ONE, GL_SRC_ALPHA);
331 //This works, but in a wrong way...
332 //      glBlendFunc(GL_ONE, GL_ONE);
333
334         // Definitely needed for screen resolution larger then the *src.
335         // This way we can have automatic scaling functionality.
336         glViewport(0, 0, dst->w, dst->h);
337         glMatrixMode(GL_PROJECTION);
338         glPushMatrix();
339         glLoadIdentity();
340         glOrtho(0.0, (GLdouble)dst->w, (GLdouble)dst->h, 0.0, 0.0, 1.0);
341         glMatrixMode(GL_MODELVIEW);
342         glPushMatrix();
343         glLoadIdentity();
344
345         // Setting up the texture coordinates.
346         texcoord[0] = 0.0f;
347         texcoord[1] = 0.0f;
348         texcoord[2] = (GLfloat)(src->w) / texture->w;
349         texcoord[3] = (GLfloat)(src->h) / texture->h;
350
351         // create a RGB(A) texture for the texture surface
352         glGenTextures(1, &texid);
353         glBindTexture(GL_TEXTURE_2D, texid);
354
355         // Setting up the OpenGL Filters. These filters are important when we/you
356         // want to scale the texture.
357         if (filter)
358         {
359                 // Textures are rendered in best quality.
360                 WriteLog("OpenGL filters: enabled\n");
361                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
362                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
363         }
364         else
365         {
366                 // Textures are rendered in normal quality.
367                 WriteLog("OpenGL filters: disabled\n");
368                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
369                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
370         }
371
372         // Setting texture mode.
373         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
374         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
375
376         // Generate the texture using the above information.
377         switch (texturebpp)
378         {
379         case 16:
380                 // Normal 16bpp depth based textures consist out of GL_RGB5 and doesn't have support for Alpha channels.
381                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
382                 break;
383         case 24:
384                 // The 24bpp depth based textures consist out of GL_RGB8 and doesn't have support for Alpha channels.
385                 //
386                 // IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp.
387                 //             If you use Alpha. Use textures with a depth of 32bpp.
388                 //             24bpp textures are SLOW and avoid them at all costs!
389                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
390                 break;
391         case 32:
392         default:
393                 // The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels.
394                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture->w, texture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
395                 break;
396         }
397 }
398
399 void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp)
400 {
401     // Local variables.
402         Uint32 rmask, gmask, bmask, amask; // Needed for creating RGBA masks.
403
404         // Delete old texture (if allocated). Useful when there is a screen resize.
405         if (overlay)
406                 SDL_FreeSurface(overlay);
407
408         // Texture width/height should be power of 2 of the SDL_Surface *src when using OpenGL.
409         // So, find the largest power of two that will contain both the width and height
410         int w = power_of_two(dst->w);
411         int h = power_of_two(dst->h);
412
413         WriteLog("OpenGL - Overlay size : %d x %d\n", w, h);
414
415         // Setting bpp based upon src_bpp.
416         int bpp = src_bpp;
417
418         // We allow the developer to set its own texture bpp. But if the value is NULL or
419         // not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src.
420         if (bpp == 16 || bpp == 24 || bpp == 32)
421                 texturebpp = bpp;
422         else
423                 texturebpp = dst->format->BitsPerPixel;
424
425         WriteLog("OpenGL - Overlay depth : %d bpp\n", texturebpp);
426
427         // Now were are going to create a SDL_Surface named texture. This will be our surface
428         // which will function as a buffer between the SDL_Surface *src and SDL_Surface *dst.
429         // This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL
430         // texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst
431         // using OpenGL.
432         //
433         // NOTE: Seems the byte order here *is* important!
434         switch (texturebpp)
435         {
436         case 16: // *src has depth of 16 bpp
437 /*
438         According to information on the SDL mailinglist and on internet, the following
439         rgba masks should be the ones to use. But somehow the screen gets f*cked up and
440         the RGB colours are incorrect (at least in Virtual Jaguar/SDL).
441
442         Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values.
443 */
444 #ifdef OPENGL_16BPP_CORRECT_RGBA
445                 rmask = 0x7C00;
446                 gmask = 0x03E0;
447                 bmask = 0x001F;
448                 amask = 0x0000;
449 #else
450                 rmask = 0x0000;
451                 gmask = 0x0000;
452                 bmask = 0x0000;
453                 amask = 0x0000;
454 #endif
455                 break;
456         case 24: // *src has depth of 24 bpp
457         #if SDL_BYTEORDER == SDL_BIG_ENDIAN
458                 rmask = 0x00FF0000;
459                 gmask = 0x0000FF00;
460                 bmask = 0x000000FF;
461                 amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
462         #else
463                 rmask = 0x000000FF;
464                 gmask = 0x0000FF00;
465                 bmask = 0x00FF0000;
466                 amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
467         #endif
468                 break;
469         case 32: //*src has depth of 32 bpp
470         default: //which is also the default.
471         #if SDL_BYTEORDER == SDL_BIG_ENDIAN
472                 rmask = 0xFF000000;
473                 gmask = 0x00FF0000;
474                 bmask = 0x0000FF00;
475                 amask = 0x000000FF;
476         #else
477                 rmask = 0x000000FF;
478                 gmask = 0x0000FF00;
479                 bmask = 0x00FF0000;
480                 amask = 0xFF000000;
481         #endif
482                 break;
483         }
484
485         // Creating SDL_Surface texture based upon the above settings.
486         overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask);
487
488         if (overlay == NULL)
489         {
490                 WriteLog("sdlemu_opengl: Could not create overlay surface! (SDL: %s)\n", SDL_GetError());
491         }
492
493         // Setting up the texture coordinates.
494         overlayCoord[0] = 0.0f;
495         overlayCoord[1] = 0.0f;
496         overlayCoord[2] = (GLfloat)(dst->w) / overlay->w;
497         overlayCoord[3] = (GLfloat)(dst->h) / overlay->h;
498
499         // create a RGB(A) texture for the texture surface
500         glGenTextures(1, &overlayID);
501         glBindTexture(GL_TEXTURE_2D, overlayID);
502
503         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
504         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
505
506         // Setting texture mode.
507         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
508         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
509
510         // Generate the texture using the above information.
511         switch (texturebpp)
512         {
513         case 16:
514                 // Normal 16bpp depth based textures consist out of GL_RGB5 and doesn't have support for Alpha channels.
515                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, overlay->w, overlay->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
516                 break;
517         case 24:
518                 // The 24bpp depth based textures consist out of GL_RGB8 and doesn't have support for Alpha channels.
519                 //
520                 // IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp.
521                 //             If you use Alpha. Use textures with a depth of 32bpp.
522                 //             24bpp textures are SLOW and avoid them at all costs!
523                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, overlay->w, overlay->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
524                 break;
525         case 32:
526         default:
527                 // The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels.
528                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, overlay->w, overlay->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
529                 break;
530         }
531 }
532
533 void * sdlemuGetOverlayPixels(void)
534 {
535         return overlay->pixels;
536 }
537
538 Uint32 sdlemuGetOverlayWidthInPixels(void)
539 {
540         return overlay->pitch / 4;
541 }
542
543 void sdlemuEnableOverlay(void)
544 {
545         showOverlay = 1;
546 }
547
548 void sdlemuDisableOverlay(void)
549 {
550         showOverlay = 0;
551 }