annotate src/video/ataricommon/SDL_atarigl.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
rev   line source
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1 /*
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
4
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
9
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
13 Library General Public License for more details.
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
14
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
18
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
19 Sam Lantinga
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
20 slouken@libsdl.org
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
21 */
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
22
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
23 /* Atari OSMesa.ldg implementation of SDL OpenGL support */
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
24
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
25 /*--- Includes ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
26
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
27 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
28 #include <GL/osmesa.h>
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
29 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
30
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
31 #include <mint/osbind.h>
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
32
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
33 #include "SDL_stdlib.h"
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
34 #include "SDL_string.h"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35 #include "SDL_video.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
36 #include "SDL_error.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
37 #include "SDL_endian.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
38 #include "SDL_atarigl_c.h"
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
39 #ifdef ENABLE_OSMESA_SHARED
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
40 #include "SDL_loadso.h"
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
41 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
42
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
43 /*--- Defines ---*/
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
44
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
45 #define PATH_OSMESA_LDG "osmesa.ldg"
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
46 #define PATH_MESAGL_LDG "mesa_gl.ldg"
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
47 #define PATH_TINYGL_LDG "tiny_gl.ldg"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
48
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
49 #define VDI_RGB 0xf
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
50
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
51 /*--- Functions prototypes ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
52
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
53 static void SDL_AtariGL_UnloadLibrary(_THIS);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
54
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
55 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
56 static void CopyShadowNull(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
57 static void CopyShadowDirect(_THIS, SDL_Surface *surface);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
58 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
59 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
60 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
61 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
62 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
63 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
64 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
65 static void CopyShadow8888To555(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
66 static void CopyShadow8888To565(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
67
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
68 static void ConvertNull(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
69 static void Convert565To555be(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
70 static void Convert565To555le(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
71 static void Convert565le(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
72 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
73
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
74 static int InitNew(_THIS, SDL_Surface *current);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
75 static int InitOld(_THIS, SDL_Surface *current);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
76 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
77
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
78 /*--- Public functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
79
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
80 int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
81 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
82 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
83 if (gl_oldmesa) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
84 gl_active = InitOld(this, current);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
85 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
86 gl_active = InitNew(this, current);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
87 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
88 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
89
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
90 return (gl_active);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
91 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
92
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
93 void SDL_AtariGL_Quit(_THIS, SDL_bool unload)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
94 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
95 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
96 if (gl_oldmesa) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
97 /* Old mesa implementations */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
98 if (this->gl_data->OSMesaDestroyLDG) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
99 this->gl_data->OSMesaDestroyLDG();
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
100 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
101 if (gl_shadow) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
102 Mfree(gl_shadow);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
103 gl_shadow = NULL;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
104 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
105 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
106 /* New mesa implementation */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
107 if (gl_ctx) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
108 if (this->gl_data->OSMesaDestroyContext) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
109 this->gl_data->OSMesaDestroyContext(gl_ctx);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
110 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
111 gl_ctx = NULL;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
112 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
113 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
114
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
115 if (unload) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
116 SDL_AtariGL_UnloadLibrary(this);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
117 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
118
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
119 #endif /* HAVE_OPENGL */
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
120 gl_active = 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
121 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
122
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
123 int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
124 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
125 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
126
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
127 #ifdef ENABLE_OSMESA_SHARED
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
128 void *handle;
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
129 SDL_bool cancel_load;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
130
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
131 if (gl_active) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
132 SDL_SetError("OpenGL context already created");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
133 return -1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
134 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
135
1239
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
136 /* Unload previous driver */
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
137 SDL_AtariGL_UnloadLibrary(this);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
138
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
139 /* Load library given by path */
1239
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
140 handle = SDL_LoadObject(path);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
141 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
142 /* Try to load another one */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
143 path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
144 if ( path != NULL ) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
145 handle = SDL_LoadObject(path);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
146 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
147
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
148 /* If it does not work, try some other */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
149 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
150 path = PATH_OSMESA_LDG;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
151 handle = SDL_LoadObject(path);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
152 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
153
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
154 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
155 path = PATH_MESAGL_LDG;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
156 handle = SDL_LoadObject(path);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
157 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
158
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
159 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
160 path = PATH_TINYGL_LDG;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
161 handle = SDL_LoadObject(path);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
162 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
163 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
164
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
165 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
166 SDL_SetError("Could not load OpenGL library");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
167 return -1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
168 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
169
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
170 this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv");
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
171 this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish");
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
172 this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush");
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
173
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
174 cancel_load = SDL_FALSE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
175 if (this->gl_data->glGetIntegerv == NULL) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
176 cancel_load = SDL_TRUE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
177 } else {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
178 /* We need either glFinish (OSMesa) or glFlush (TinyGL) */
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
179 if ((this->gl_data->glFinish == NULL) &&
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
180 (this->gl_data->glFlush == NULL)) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
181 cancel_load = SDL_TRUE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
182 }
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
183 }
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
184 if (cancel_load) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
185 SDL_SetError("Could not retrieve OpenGL functions");
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
186 SDL_UnloadObject(handle);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
187 /* Restore pointers to static library */
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
188 SDL_AtariGL_InitPointers(this);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
189 return -1;
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
190 }
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
191
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
192 /* Load functions pointers (osmesa.ldg) */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
193 this->gl_data->OSMesaCreateContextExt = SDL_LoadFunction(handle, "OSMesaCreateContextExt");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
194 this->gl_data->OSMesaDestroyContext = SDL_LoadFunction(handle, "OSMesaDestroyContext");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
195 this->gl_data->OSMesaMakeCurrent = SDL_LoadFunction(handle, "OSMesaMakeCurrent");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
196 this->gl_data->OSMesaPixelStore = SDL_LoadFunction(handle, "OSMesaPixelStore");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
197 this->gl_data->OSMesaGetProcAddress = SDL_LoadFunction(handle, "OSMesaGetProcAddress");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
198
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
199 /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
200 this->gl_data->OSMesaCreateLDG = SDL_LoadFunction(handle, "OSMesaCreateLDG");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
201 this->gl_data->OSMesaDestroyLDG = SDL_LoadFunction(handle, "OSMesaDestroyLDG");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
202
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
203 gl_oldmesa = 0;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
204
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
205 if ( (this->gl_data->OSMesaCreateContextExt == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
206 (this->gl_data->OSMesaDestroyContext == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
207 (this->gl_data->OSMesaMakeCurrent == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
208 (this->gl_data->OSMesaPixelStore == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
209 (this->gl_data->OSMesaGetProcAddress == NULL)) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
210 /* Hum, maybe old library ? */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
211 if ( (this->gl_data->OSMesaCreateLDG == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
212 (this->gl_data->OSMesaDestroyLDG == NULL)) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
213 SDL_SetError("Could not retrieve OSMesa functions");
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
214 SDL_UnloadObject(handle);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
215 /* Restore pointers to static library */
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
216 SDL_AtariGL_InitPointers(this);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
217 return -1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
218 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
219 gl_oldmesa = 1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
220 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
221 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
222
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
223 this->gl_config.dll_handle = handle;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
224 if ( path ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
225 SDL_strncpy(this->gl_config.driver_path, path,
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
226 sizeof(this->gl_config.driver_path)-1);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
227 } else {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
228 SDL_strcpy(this->gl_config.driver_path, "");
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
229 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
230
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
231 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
232 this->gl_config.driver_loaded = 1;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
233
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
234 return 0;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
235 #else
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
236 return -1;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
237 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
238 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
239
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
240 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
241 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
242 void *func = NULL;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
243 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
244
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
245 if (this->gl_config.dll_handle) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
246 func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
247 } else if (this->gl_data->OSMesaGetProcAddress) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
248 func = this->gl_data->OSMesaGetProcAddress(proc);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
249 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
250
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
251 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
252 return func;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
253 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
254
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
255 int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
256 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
257 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
258 GLenum mesa_attrib;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
259 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
260
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
261 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
262 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
263 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
264
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
265 switch(attrib) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
266 case SDL_GL_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
267 mesa_attrib = GL_RED_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
268 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
269 case SDL_GL_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
270 mesa_attrib = GL_GREEN_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
271 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
272 case SDL_GL_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
273 mesa_attrib = GL_BLUE_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
274 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
275 case SDL_GL_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
276 mesa_attrib = GL_ALPHA_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
277 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
278 case SDL_GL_DOUBLEBUFFER:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
279 surface = this->screen;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
280 *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
281 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
282 case SDL_GL_DEPTH_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
283 mesa_attrib = GL_DEPTH_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
284 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
285 case SDL_GL_STENCIL_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
286 mesa_attrib = GL_STENCIL_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
287 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
288 case SDL_GL_ACCUM_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
289 mesa_attrib = GL_ACCUM_RED_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
290 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
291 case SDL_GL_ACCUM_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
292 mesa_attrib = GL_ACCUM_GREEN_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
293 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
294 case SDL_GL_ACCUM_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
295 mesa_attrib = GL_ACCUM_BLUE_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
296 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
297 case SDL_GL_ACCUM_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
298 mesa_attrib = GL_ACCUM_ALPHA_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
299 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
300 default :
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
301 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
302 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
303
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
304 this->gl_data->glGetIntegerv(mesa_attrib, value);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
305 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
306 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
307 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
308 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
309 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
310
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
311 int SDL_AtariGL_MakeCurrent(_THIS)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
312 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
313 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
314 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
315 GLenum type;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
316
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
317 if (gl_oldmesa && gl_active) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
318 return 0;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
319 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
320
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
321 if (this->gl_config.dll_handle) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
322 if ((this->gl_data->OSMesaMakeCurrent == NULL) ||
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
323 (this->gl_data->OSMesaPixelStore == NULL)) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
324 return -1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
325 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
326 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
327
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
328 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
329 SDL_SetError("Invalid OpenGL context");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
330 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
331 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
332
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
333 surface = this->screen;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
334
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
335 if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
336 type = GL_UNSIGNED_SHORT_5_6_5;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
337 } else {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
338 type = GL_UNSIGNED_BYTE;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
339 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
340
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
341 if (!(this->gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, surface->h))) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
342 SDL_SetError("Can not make OpenGL context current");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
343 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
344 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
345
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
346 /* OSMesa draws upside down */
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
347 this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
348
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
349 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
350 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
351 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
352 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
353 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
354
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
355 void SDL_AtariGL_SwapBuffers(_THIS)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
356 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
357 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
358 if (gl_active) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
359 if (this->gl_config.dll_handle) {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
360 if (this->gl_data->glFinish) {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
361 this->gl_data->glFinish();
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
362 } else if (this->gl_data->glFlush) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
363 this->gl_data->glFlush();
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
364 }
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
365 } else {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
366 this->gl_data->glFinish();
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
367 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
368 gl_copyshadow(this, this->screen);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
369 gl_convert(this, this->screen);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
370 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
371 #endif
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
372 }
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
373
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
374 void SDL_AtariGL_InitPointers(_THIS)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
375 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
376 #if defined(HAVE_OPENGL)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
377 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
378 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
379 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
380 this->gl_data->OSMesaPixelStore = OSMesaPixelStore;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
381 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
382
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
383 this->gl_data->glGetIntegerv = glGetIntegerv;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
384 this->gl_data->glFinish = glFinish;
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
385 this->gl_data->glFlush = glFlush;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
386
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
387 this->gl_data->OSMesaCreateLDG = NULL;
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
388 this->gl_data->OSMesaDestroyLDG = NULL;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
389 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
390 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
391
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
392 /*--- Private functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
393
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
394 static void SDL_AtariGL_UnloadLibrary(_THIS)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
395 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
396 #if defined(HAVE_OPENGL)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
397 if (this->gl_config.dll_handle) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
398 SDL_UnloadObject(this->gl_config.dll_handle);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
399 this->gl_config.dll_handle = NULL;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
400
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
401 /* Restore pointers to static library */
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
402 SDL_AtariGL_InitPointers(this);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
403 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
404 #endif
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
405 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
406
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
407 /*--- Creation of an OpenGL context using new/old functions ---*/
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
408
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
409 #ifdef HAVE_OPENGL
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
410 static int InitNew(_THIS, SDL_Surface *current)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
411 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
412 GLenum osmesa_format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
413 SDL_PixelFormat *pixel_format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
414 Uint32 redmask;
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
415 int recreatecontext;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
416 GLint newaccumsize;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
417
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
418 if (this->gl_config.dll_handle) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
419 if (this->gl_data->OSMesaCreateContextExt == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
420 return 0;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
421 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
422 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
423
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
424 /* Init OpenGL context using OSMesa */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
425 gl_convert = ConvertNull;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
426 gl_copyshadow = CopyShadowNull;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
427 gl_upsidedown = SDL_FALSE;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
428
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
429 pixel_format = current->format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
430 redmask = pixel_format->Rmask;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
431 switch (pixel_format->BitsPerPixel) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
432 case 15:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
433 /* 1555, big and little endian, unsupported */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
434 gl_pixelsize = 2;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
435 osmesa_format = OSMESA_RGB_565;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
436 if (redmask == 31<<10) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
437 gl_convert = Convert565To555be;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
438 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
439 gl_convert = Convert565To555le;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
440 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
441 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
442 case 16:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
443 gl_pixelsize = 2;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
444 if (redmask == 31<<11) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
445 osmesa_format = OSMESA_RGB_565;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
446 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
447 /* 565, little endian, unsupported */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
448 osmesa_format = OSMESA_RGB_565;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
449 gl_convert = Convert565le;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
450 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
451 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
452 case 24:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
453 gl_pixelsize = 3;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
454 if (redmask == 255<<16) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
455 osmesa_format = OSMESA_RGB;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
456 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
457 osmesa_format = OSMESA_BGR;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
458 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
459 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
460 case 32:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
461 gl_pixelsize = 4;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
462 if (redmask == 255<<16) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
463 osmesa_format = OSMESA_ARGB;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
464 } else if (redmask == 255<<8) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
465 osmesa_format = OSMESA_BGRA;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
466 } else if (redmask == 255<<24) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
467 osmesa_format = OSMESA_RGBA;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
468 } else {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
469 /* ABGR format unsupported */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
470 osmesa_format = OSMESA_BGRA;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
471 gl_convert = ConvertBGRAToABGR;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
472 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
473 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
474 default:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
475 gl_pixelsize = 1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
476 osmesa_format = OSMESA_COLOR_INDEX;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
477 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
478 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
479
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
480 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
481 newaccumsize =
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
482 this->gl_config.accum_red_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
483 this->gl_config.accum_green_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
484 this->gl_config.accum_blue_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
485 this->gl_config.accum_alpha_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
486 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
487 if (gl_ctx &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
488 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
489 (gl_curdepth == this->gl_config.depth_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
490 (gl_curstencil == this->gl_config.stencil_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
491 (gl_curaccum == newaccumsize)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
492 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
493 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
494 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
495 SDL_AtariGL_Quit(this, SDL_FALSE);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
496
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
497 gl_ctx = this->gl_data->OSMesaCreateContextExt(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
498 osmesa_format, this->gl_config.depth_size,
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
499 this->gl_config.stencil_size, newaccumsize, NULL );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
500
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
501 if (gl_ctx) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
502 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
503 gl_curdepth = this->gl_config.depth_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
504 gl_curstencil = this->gl_config.stencil_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
505 gl_curaccum = newaccumsize;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
506 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
507 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
508 gl_curdepth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
509 gl_curstencil = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
510 gl_curaccum = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
511 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
512 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
513
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
514 return (gl_ctx != NULL);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
515 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
516
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
517
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
518 static int InitOld(_THIS, SDL_Surface *current)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
519 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
520 GLenum osmesa_format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
521 SDL_PixelFormat *pixel_format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
522 Uint32 redmask;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
523 int recreatecontext, tinygl_present;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
524
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
525 if (this->gl_config.dll_handle) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
526 if (this->gl_data->OSMesaCreateLDG == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
527 return 0;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
528 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
529 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
530
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
531 /* TinyGL only supports VDI_RGB (OSMESA_RGB) */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
532 tinygl_present=0;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
533 if (this->gl_config.dll_handle) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
534 if (this->gl_data->glFinish == NULL) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
535 tinygl_present=1;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
536 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
537 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
538
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
539 /* Init OpenGL context using OSMesa */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
540 gl_convert = ConvertNull;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
541 gl_copyshadow = CopyShadowNull;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
542 gl_upsidedown = SDL_FALSE;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
543
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
544 pixel_format = current->format;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
545 redmask = pixel_format->Rmask;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
546 switch (pixel_format->BitsPerPixel) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
547 case 15:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
548 /* 15 bits unsupported */
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
549 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
550 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
551 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
552 if (redmask == 31<<10) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
553 gl_copyshadow = CopyShadowRGBTo555;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
554 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
555 gl_copyshadow = CopyShadowRGBTo565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
556 gl_convert = Convert565To555le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
557 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
558 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
559 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
560 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
561 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
562 if (redmask == 31<<10) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
563 gl_copyshadow = CopyShadow8888To555;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
564 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
565 gl_copyshadow = CopyShadow8888To565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
566 gl_convert = Convert565To555le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
567 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
568 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
569 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
570 case 16:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
571 /* 16 bits unsupported */
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
572 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
573 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
574 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
575 gl_copyshadow = CopyShadowRGBTo565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
576 if (redmask != 31<<11) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
577 /* 565, little endian, unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
578 gl_convert = Convert565le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
579 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
580 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
581 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
582 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
583 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
584 gl_copyshadow = CopyShadow8888To565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
585 if (redmask != 31<<11) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
586 /* 565, little endian, unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
587 gl_convert = Convert565le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
588 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
589 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
590 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
591 case 24:
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
592 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
593 if (tinygl_present) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
594 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
595 gl_copyshadow = CopyShadowDirect;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
596 if (redmask != 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
597 gl_copyshadow = CopyShadowRGBSwap;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
598 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
599 } else {
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
600 gl_copyshadow = CopyShadowDirect;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
601 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
602 if (redmask == 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
603 osmesa_format = OSMESA_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
604 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
605 osmesa_format = OSMESA_BGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
606 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
607 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
608 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
609 case 32:
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
610 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
611 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
612 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
613 gl_copyshadow = CopyShadowRGBToARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
614 if (redmask == 255) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
615 gl_convert = CopyShadowRGBToABGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
616 } else if (redmask == 255<<8) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
617 gl_convert = CopyShadowRGBToBGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
618 } else if (redmask == 255<<24) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
619 gl_convert = CopyShadowRGBToRGBA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
620 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
621 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
622 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
623 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
624 gl_copyshadow = CopyShadowDirect;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
625 if (redmask == 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
626 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
627 } else if (redmask == 255<<8) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
628 osmesa_format = OSMESA_BGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
629 } else if (redmask == 255<<24) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
630 osmesa_format = OSMESA_RGBA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
631 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
632 /* ABGR format unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
633 osmesa_format = OSMESA_BGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
634 gl_convert = ConvertBGRAToABGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
635 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
636 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
637 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
638 default:
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
639 if (tinygl_present) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
640 SDL_AtariGL_Quit(this, SDL_FALSE);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
641 return 0;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
642 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
643 gl_pixelsize = 1;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
644 gl_copyshadow = CopyShadowDirect;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
645 osmesa_format = OSMESA_COLOR_INDEX;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
646 break;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
647 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
648
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
649 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
650 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
651 if (gl_shadow &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
652 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
653 (gl_curwidth == current->w) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
654 (gl_curheight == current->h)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
655 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
656 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
657 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
658 SDL_AtariGL_Quit(this, SDL_FALSE);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
659
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
660 gl_shadow = this->gl_data->OSMesaCreateLDG(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
661 osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
662 );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
663
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
664 if (gl_shadow) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
665 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
666 gl_curwidth = current->w;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
667 gl_curheight = current->h;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
668 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
669 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
670 gl_curwidth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
671 gl_curheight = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
672 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
673 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
674
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
675 return (gl_shadow != NULL);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
676 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
677
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
678 /*--- Conversions routines from shadow buffer to the screen ---*/
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
679
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
680 static void CopyShadowNull(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
681 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
682 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
683
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
684 static void CopyShadowDirect(_THIS, SDL_Surface *surface)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
685 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
686 int y, srcpitch, dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
687 Uint8 *srcline, *dstline;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
688
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
689 srcline = gl_shadow;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
690 srcpitch = surface->w * gl_pixelsize;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
691 dstline = surface->pixels;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
692 dstpitch = surface->pitch;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
693 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
694 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
695 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
696 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
697
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
698 for (y=0; y<surface->h; y++) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
699 SDL_memcpy(dstline, srcline, srcpitch);
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
700
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
701 srcline += srcpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
702 dstline += dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
703 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
704 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
705
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
706 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
707 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
708 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
709 Uint16 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
710 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
711
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
712 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
713 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
714 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
715 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
716 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
717 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
718 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
719 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
720
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
721 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
722 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
723 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
724 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
725 Uint16 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
726
1003
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
727 dstcolor = ((*srccol++)<<7) & (31<<10);
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
728 dstcolor |= ((*srccol++)<<2) & (31<<5);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
729 dstcolor |= ((*srccol++)>>3) & 31;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
730 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
731 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
732
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
733 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
734 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
735 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
736 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
737
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
738 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
739 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
740 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
741 Uint16 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
742 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
743
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
744 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
745 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
746 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
747 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
748 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
749 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
750 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
751 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
752
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
753 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
754 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
755 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
756
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
757 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
758 Uint16 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
759
1003
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
760 dstcolor = ((*srccol++)<<8) & (31<<11);
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
761 dstcolor |= ((*srccol++)<<3) & (63<<5);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
762 dstcolor |= ((*srccol++)>>3) & 31;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
763 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
764 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
765
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
766 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
767 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
768 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
769 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
770
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
771 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
772 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
773 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
774 Uint8 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
775 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
776
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
777 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
778 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
779 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
780 dstpitch = surface->pitch;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
781 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
782 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
783 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
784 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
785
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
786 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
787 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
788 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
789
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
790 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
791 *dstcol++ = srccol[2];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
792 *dstcol++ = srccol[1];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
793 *dstcol++ = srccol[0];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
794 srccol += 3;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
795 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
796
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
797 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
798 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
799 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
800 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
801
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
802 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
803 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
804 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
805 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
806 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
807
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
808 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
809 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
810 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
811 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
812 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
813 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
814 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
815 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
816
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
817 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
818 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
819 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
820
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
821 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
822 Uint32 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
823
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
824 dstcolor = (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
825 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
826 dstcolor |= *srccol++;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
827
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
828 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
829 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
830
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
831 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
832 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
833 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
834 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
835
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
836 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
837 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
838 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
839 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
840 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
841
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
842 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
843 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
844 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
845 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
846 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
847 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
848 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
849 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
850
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
851 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
852 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
853 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
854
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
855 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
856 Uint32 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
857
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
858 dstcolor = *srccol++;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
859 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
860 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
861
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
862 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
863 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
864
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
865 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
866 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
867 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
868 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
869
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
870 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
871 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
872 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
873 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
874 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
875
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
876 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
877 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
878 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
879 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
880 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
881 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
882 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
883 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
884
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
885 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
886 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
887 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
888
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
889 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
890 Uint32 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
891
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
892 dstcolor = (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
893 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
894 dstcolor |= (*srccol++)<<24;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
895
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
896 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
897 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
898
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
899 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
900 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
901 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
902 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
903
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
904 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
905 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
906 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
907 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
908 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
909
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
910 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
911 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
912 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
913 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
914 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
915 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
916 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
917 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
918
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
919 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
920 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
921 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
922
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
923 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
924 Uint32 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
925
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
926 dstcolor = (*srccol++)<<24;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
927 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
928 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
929
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
930 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
931 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
932
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
933 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
934 dstline += dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
935 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
936 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
937
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
938 static void CopyShadow8888To555(_THIS, SDL_Surface *surface)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
939 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
940 int x,y, srcpitch, dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
941 Uint16 *dstline, *dstcol;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
942 Uint32 *srcline, *srccol;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
943
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
944 srcline = (Uint32 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
945 srcpitch = (surface->w * gl_pixelsize) >>2;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
946 dstline = surface->pixels;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
947 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
948 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
949 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
950 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
951 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
952
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
953 for (y=0; y<surface->h; y++) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
954 srccol = srcline;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
955 dstcol = dstline;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
956 for (x=0; x<surface->w; x++) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
957 Uint32 srccolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
958 Uint16 dstcolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
959
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
960 srccolor = *srccol++;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
961 dstcolor = (srccolor>>9) & (31<<10);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
962 dstcolor |= (srccolor>>6) & (31<<5);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
963 dstcolor |= (srccolor>>3) & 31;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
964 *dstcol++ = dstcolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
965 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
966
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
967 srcline += srcpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
968 dstline += dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
969 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
970 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
971
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
972 static void CopyShadow8888To565(_THIS, SDL_Surface *surface)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
973 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
974 int x,y, srcpitch, dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
975 Uint16 *dstline, *dstcol;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
976 Uint32 *srcline, *srccol;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
977
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
978 srcline = (Uint32 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
979 srcpitch = (surface->w * gl_pixelsize) >> 2;
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
980 dstline = surface->pixels;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
981 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
982 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
983 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
984 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
985 }
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
986
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
987 for (y=0; y<surface->h; y++) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
988 srccol = srcline;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
989 dstcol = dstline;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
990
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
991 for (x=0; x<surface->w; x++) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
992 Uint32 srccolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
993 Uint16 dstcolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
994
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
995 srccolor = *srccol++;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
996 dstcolor = (srccolor>>8) & (31<<11);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
997 dstcolor |= (srccolor>>5) & (63<<5);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
998 dstcolor |= (srccolor>>3) & 31;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
999 *dstcol++ = dstcolor;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1000 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1001
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1002 srcline += srcpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1003 dstline += dstpitch;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1004 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1005 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1006
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1007 /*--- Conversions routines in the screen ---*/
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1008
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1009 static void ConvertNull(_THIS, SDL_Surface *surface)
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1010 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1011 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1012
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1013 static void Convert565To555be(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1014 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1015 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1016 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1017
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1018 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1019 pitch = surface->pitch >> 1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1020 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1021 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1022 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1023 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1024
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1025 *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1026 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1027
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1028 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1029 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1030 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1031
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1032 static void Convert565To555le(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1033 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1034 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1035 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1036
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1037 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1038 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1039 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1040 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1041 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1042 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1043
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1044 color = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1045 *pixel++ = SDL_Swap16(color);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1046 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1047
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1048 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1049 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1050 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1051
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1052 static void Convert565le(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1053 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1054 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1055 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1056
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1057 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1058 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1059 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1060 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1061 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1062 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1063
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1064 *pixel++ = SDL_Swap16(color);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1065 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1066
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1067 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1068 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1069 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1070
991
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
1071 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1072 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1073 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1074 unsigned long *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1075
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1076 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1077 pitch = surface->pitch >>2;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1078 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1079 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1080 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1081 unsigned long color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1082
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1083 *pixel++ = (color<<24)|(color>>8);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1084 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1085
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1086 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1087 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1088 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
1089
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
1090 #endif /* HAVE_OPENGL */