annotate src/video/ataricommon/SDL_atarigl.c @ 1358:c71e05b4dc2e

More header massaging... works great on Windows. ;-)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 10 Feb 2006 06:48:43 +0000
parents 604d73db6802
children 19418e4422cb
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
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
33 #include "SDL_endian.h"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
34 #include "SDL_video.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35 #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
36 #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
37 #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
38 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
39
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
40 /*--- 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
41
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
42 #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
43 #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
44 #define PATH_TINYGL_LDG "tiny_gl.ldg"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
45
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
46 #define VDI_RGB 0xf
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
47
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
48 /*--- Functions prototypes ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
49
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
50 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
51
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
52 #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
53 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
54 static void CopyShadowDirect(_THIS, SDL_Surface *surface);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
55 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
56 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
57 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
58 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
59 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
60 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
61 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
62 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
63 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
64
12b13601a544 Final touches to OSMesa 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 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
66 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
67 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
68 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
69 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
70
12b13601a544 Final touches to OSMesa 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 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
72 static int InitOld(_THIS, SDL_Surface *current);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
73 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
74
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
75 /*--- Public functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
76
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
77 int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
78 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
79 #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
80 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
81 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
82 } 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
83 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
84 }
12b13601a544 Final touches to OSMesa 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 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
86
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
87 return (gl_active);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
88 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
89
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
90 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
91 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
92 #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
93 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
94 /* 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
95 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
96 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
97 }
12b13601a544 Final touches to OSMesa 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 (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
99 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
100 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
101 }
12b13601a544 Final touches to OSMesa 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 } 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
103 /* 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
104 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
105 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
106 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
107 }
12b13601a544 Final touches to OSMesa 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 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
109 }
12b13601a544 Final touches to OSMesa 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
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
112 if (unload) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
113 SDL_AtariGL_UnloadLibrary(this);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
114 }
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
115
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
116 #endif /* HAVE_OPENGL */
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
117 gl_active = 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
118 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
119
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
120 int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
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 #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
123
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
124 #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
125 void *handle;
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
126 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
127
12b13601a544 Final touches to OSMesa 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 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
129 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
130 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
131 }
12b13601a544 Final touches to OSMesa 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
1239
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
133 /* Unload previous driver */
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
134 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
135
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
136 /* Load library given by path */
1239
cbdb2c156aca Rollback
Patrice Mandin <patmandin@gmail.com>
parents: 1238
diff changeset
137 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
138 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
139 /* Try to load another one */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
140 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
141 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
142 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
143 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 /* 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
146 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
147 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
148 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
149 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
152 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
153 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
154 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
157 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
158 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
159 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
163 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
164 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
165 }
12b13601a544 Final touches to OSMesa 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
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
167 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
168 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
169 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
170
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
171 cancel_load = SDL_FALSE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
172 if (this->gl_data->glGetIntegerv == NULL) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
173 cancel_load = SDL_TRUE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
174 } else {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
175 /* 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
176 if ((this->gl_data->glFinish == NULL) &&
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
177 (this->gl_data->glFlush == NULL)) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
178 cancel_load = SDL_TRUE;
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
179 }
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
180 }
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
181 if (cancel_load) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
182 SDL_SetError("Could not retrieve OpenGL functions");
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
183 SDL_UnloadObject(handle);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
184 /* Restore pointers to static library */
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
185 SDL_AtariGL_InitPointers(this);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
186 return -1;
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
187 }
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
188
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
189 /* 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
190 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
191 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
192 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
193 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
194 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
195
12b13601a544 Final touches to OSMesa 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 /* 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
197 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
198 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
199
12b13601a544 Final touches to OSMesa 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 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
201
12b13601a544 Final touches to OSMesa 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 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
203 (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
204 (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
205 (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
206 (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
207 /* 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
208 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
209 (this->gl_data->OSMesaDestroyLDG == NULL)) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
210 SDL_SetError("Could not retrieve OSMesa functions");
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
211 SDL_UnloadObject(handle);
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
212 /* Restore pointers to static library */
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
213 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
214 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
215 } 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
216 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
217 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
221 if ( path ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
222 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
223 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
224 } else {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1239
diff changeset
225 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
226 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
228 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
229 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
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 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
232 #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
233 return -1;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
234 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
235 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
236
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
237 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
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 void *func = NULL;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
240 #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
241
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
242 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
243 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
244 } 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
245 func = this->gl_data->OSMesaGetProcAddress(proc);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
246 }
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
247
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
248 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
249 return func;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
250 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
251
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
252 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
253 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
254 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
255 GLenum mesa_attrib;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
256 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
257
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
258 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
259 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
260 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
261
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
262 switch(attrib) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
263 case SDL_GL_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
264 mesa_attrib = GL_RED_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
265 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
266 case SDL_GL_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
267 mesa_attrib = GL_GREEN_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_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
270 mesa_attrib = GL_BLUE_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_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
273 mesa_attrib = GL_ALPHA_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_DOUBLEBUFFER:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
276 surface = this->screen;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
277 *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
278 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
279 case SDL_GL_DEPTH_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
280 mesa_attrib = GL_DEPTH_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
281 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
282 case SDL_GL_STENCIL_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
283 mesa_attrib = GL_STENCIL_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_ACCUM_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
286 mesa_attrib = GL_ACCUM_RED_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_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
289 mesa_attrib = GL_ACCUM_GREEN_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_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
292 mesa_attrib = GL_ACCUM_BLUE_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_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
295 mesa_attrib = GL_ACCUM_ALPHA_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 default :
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
298 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
299 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
300
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
301 this->gl_data->glGetIntegerv(mesa_attrib, value);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
302 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
303 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
304 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
305 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
306 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
307
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
308 int SDL_AtariGL_MakeCurrent(_THIS)
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 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
311 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
312 GLenum type;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
313
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
314 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
315 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
316 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
319 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
320 (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
321 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
322 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
326 SDL_SetError("Invalid OpenGL context");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
327 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
328 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
329
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
330 surface = this->screen;
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 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
333 type = GL_UNSIGNED_SHORT_5_6_5;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
334 } else {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
335 type = GL_UNSIGNED_BYTE;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
336 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
337
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
338 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
339 SDL_SetError("Can not make OpenGL context current");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
340 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
341 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
342
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
343 /* 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
344 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
345
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
346 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
347 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
348 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
349 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
350 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
351
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
352 void SDL_AtariGL_SwapBuffers(_THIS)
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 #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
355 if (gl_active) {
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
356 if (this->gl_config.dll_handle) {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
357 if (this->gl_data->glFinish) {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
358 this->gl_data->glFinish();
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
359 } else if (this->gl_data->glFlush) {
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
360 this->gl_data->glFlush();
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
361 }
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
362 } else {
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
363 this->gl_data->glFinish();
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
364 }
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
365 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
366 gl_convert(this, this->screen);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
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 #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
369 }
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 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
372 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
373 #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
374 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
375 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
376 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
377 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
378 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
379
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
380 this->gl_data->glGetIntegerv = glGetIntegerv;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
381 this->gl_data->glFinish = glFinish;
995
22fc5f45bbb7 TinyGL does not have glFinish, only glFlush
Patrice Mandin <patmandin@gmail.com>
parents: 993
diff changeset
382 this->gl_data->glFlush = glFlush;
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
383
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
384 this->gl_data->OSMesaCreateLDG = NULL;
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
385 this->gl_data->OSMesaDestroyLDG = NULL;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
386 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
387 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
388
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
389 /*--- Private functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
390
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
391 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
392 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
393 #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
394 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
395 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
396 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
397
12b13601a544 Final touches to OSMesa 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 /* Restore pointers to static library */
993
2662da16d668 Forgot to flush OpenGL buffer using glFinish
Patrice Mandin <patmandin@gmail.com>
parents: 992
diff changeset
399 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
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 #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
402 }
12b13601a544 Final touches to OSMesa 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 /*--- 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
405
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
406 #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
407 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
408 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
409 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
410 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
411 Uint32 redmask;
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
412 int recreatecontext;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
413 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
414
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
415 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
416 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
417 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
418 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 /* 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
422 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
423 gl_copyshadow = CopyShadowNull;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
424 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
425
12b13601a544 Final touches to OSMesa 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 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
427 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
428 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
429 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
430 /* 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
431 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
432 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
433 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
434 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
435 } 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
436 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
437 }
12b13601a544 Final touches to OSMesa 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 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
439 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
440 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
441 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
442 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
443 } 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
444 /* 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
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 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
447 }
12b13601a544 Final touches to OSMesa 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 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
449 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
450 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
451 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
452 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
453 } 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
454 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
455 }
12b13601a544 Final touches to OSMesa 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 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
457 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
458 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
459 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
460 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
461 } 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
462 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
463 } 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
464 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
465 } 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
466 /* 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
467 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
468 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
469 }
12b13601a544 Final touches to OSMesa 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 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
471 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
472 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
473 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
474 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
475 }
12b13601a544 Final touches to OSMesa 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
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
477 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
478 newaccumsize =
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
479 this->gl_config.accum_red_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
480 this->gl_config.accum_green_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
481 this->gl_config.accum_blue_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
482 this->gl_config.accum_alpha_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
483 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
484 if (gl_ctx &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
485 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
486 (gl_curdepth == this->gl_config.depth_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
487 (gl_curstencil == this->gl_config.stencil_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
488 (gl_curaccum == newaccumsize)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
489 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
490 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
491 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
492 SDL_AtariGL_Quit(this, SDL_FALSE);
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 gl_ctx = this->gl_data->OSMesaCreateContextExt(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
495 osmesa_format, this->gl_config.depth_size,
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
496 this->gl_config.stencil_size, newaccumsize, NULL );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
497
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
498 if (gl_ctx) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
499 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
500 gl_curdepth = this->gl_config.depth_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
501 gl_curstencil = this->gl_config.stencil_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
502 gl_curaccum = newaccumsize;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
503 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
504 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
505 gl_curdepth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
506 gl_curstencil = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
507 gl_curaccum = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
508 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
509 }
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
510
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
511 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
512 }
12b13601a544 Final touches to OSMesa 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
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
514
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
515 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
516 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
517 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
518 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
519 Uint32 redmask;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
520 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
521
12b13601a544 Final touches to OSMesa 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 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
523 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
524 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
525 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
528 /* TinyGL only supports VDI_RGB (OSMESA_RGB) */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
529 tinygl_present=0;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
530 if (this->gl_config.dll_handle) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
531 if (this->gl_data->glFinish == NULL) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
532 tinygl_present=1;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
533 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
534 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
535
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
536 /* 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
537 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
538 gl_copyshadow = CopyShadowNull;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
539 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
540
12b13601a544 Final touches to OSMesa 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 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
542 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
543 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
544 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
545 /* 15 bits unsupported */
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
546 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
547 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
548 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
549 if (redmask == 31<<10) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
550 gl_copyshadow = CopyShadowRGBTo555;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
551 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
552 gl_copyshadow = CopyShadowRGBTo565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
553 gl_convert = Convert565To555le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
554 }
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
555 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
556 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
557 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
558 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
559 if (redmask == 31<<10) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
560 gl_copyshadow = CopyShadow8888To555;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
561 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
562 gl_copyshadow = CopyShadow8888To565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
563 gl_convert = Convert565To555le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
564 }
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
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
566 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
567 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
568 /* 16 bits unsupported */
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
569 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
570 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
571 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
572 gl_copyshadow = CopyShadowRGBTo565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
573 if (redmask != 31<<11) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
574 /* 565, little endian, unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
575 gl_convert = Convert565le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
576 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
577 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
578 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
579 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
580 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
581 gl_copyshadow = CopyShadow8888To565;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
582 if (redmask != 31<<11) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
583 /* 565, little endian, unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
584 gl_convert = Convert565le;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
585 }
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
586 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
587 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
588 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
589 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
590 if (tinygl_present) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
591 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
592 gl_copyshadow = CopyShadowDirect;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
593 if (redmask != 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
594 gl_copyshadow = CopyShadowRGBSwap;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
595 }
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
596 } else {
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
597 gl_copyshadow = CopyShadowDirect;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
598 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
599 if (redmask == 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
600 osmesa_format = OSMESA_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
601 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
602 osmesa_format = OSMESA_BGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
603 }
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
604 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
605 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
606 case 32:
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
607 if (tinygl_present) {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
608 gl_pixelsize = 3;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
609 osmesa_format = VDI_RGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
610 gl_copyshadow = CopyShadowRGBToARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
611 if (redmask == 255) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
612 gl_convert = CopyShadowRGBToABGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
613 } else if (redmask == 255<<8) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
614 gl_convert = CopyShadowRGBToBGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
615 } else if (redmask == 255<<24) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
616 gl_convert = CopyShadowRGBToRGBA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
617 }
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
618 } else {
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
619 gl_pixelsize = 4;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
620 gl_upsidedown = SDL_TRUE;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
621 gl_copyshadow = CopyShadowDirect;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
622 if (redmask == 255<<16) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
623 osmesa_format = OSMESA_ARGB;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
624 } else if (redmask == 255<<8) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
625 osmesa_format = OSMESA_BGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
626 } else if (redmask == 255<<24) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
627 osmesa_format = OSMESA_RGBA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
628 } else {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
629 /* ABGR format unsupported */
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
630 osmesa_format = OSMESA_BGRA;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
631 gl_convert = ConvertBGRAToABGR;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
632 }
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
633 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
634 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
635 default:
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
636 if (tinygl_present) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
637 SDL_AtariGL_Quit(this, SDL_FALSE);
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
638 return 0;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
639 }
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
640 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
641 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
642 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
643 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
644 }
12b13601a544 Final touches to OSMesa 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
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
646 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
647 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
648 if (gl_shadow &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
649 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
650 (gl_curwidth == current->w) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
651 (gl_curheight == current->h)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
652 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
653 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
654 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
655 SDL_AtariGL_Quit(this, SDL_FALSE);
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 gl_shadow = this->gl_data->OSMesaCreateLDG(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
658 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
659 );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
660
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
661 if (gl_shadow) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
662 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
663 gl_curwidth = current->w;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
664 gl_curheight = current->h;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
665 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
666 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
667 gl_curwidth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
668 gl_curheight = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
669 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
670 }
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
671
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
672 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
673 }
12b13601a544 Final touches to OSMesa 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 /*--- 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
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 static void CopyShadowNull(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
678 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
679 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
680
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
681 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
682 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
683 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
684 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
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 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
687 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
688 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
689 dstpitch = surface->pitch;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
690 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
691 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
692 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
693 }
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
694
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
695 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
696 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
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 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
699 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
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 }
12b13601a544 Final touches to OSMesa 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
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
703 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface)
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
704 {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
705 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
706 Uint16 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
707 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
708
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
709 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
710 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
711 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
712 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
713 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
714 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
715 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
716 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
717
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
718 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
719 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
720 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
721 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
722 Uint16 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
723
1003
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
724 dstcolor = ((*srccol++)<<7) & (31<<10);
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
725 dstcolor |= ((*srccol++)<<2) & (31<<5);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
726 dstcolor |= ((*srccol++)>>3) & 31;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
727 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
728 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
729
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
730 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
731 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
734
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
735 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
738 Uint16 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
739 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
740
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
741 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
742 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
743 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
744 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
745 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
746 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
747 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
748 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
749
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
750 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
751 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
752 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
753
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
754 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
755 Uint16 dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
756
1003
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
757 dstcolor = ((*srccol++)<<8) & (31<<11);
ece5ab8acd1c Wrong RGB24 to RGB16 conversion
Patrice Mandin <patmandin@gmail.com>
parents: 1002
diff changeset
758 dstcolor |= ((*srccol++)<<3) & (63<<5);
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
759 dstcolor |= ((*srccol++)>>3) & 31;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
760 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
761 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
762
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
763 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
764 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
767
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
768 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
771 Uint8 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
772 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
773
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
774 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
775 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
776 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
777 dstpitch = surface->pitch;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
778 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
779 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
780 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
781 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
782
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
783 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
784 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
785 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
786
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
787 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
788 *dstcol++ = srccol[2];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
789 *dstcol++ = srccol[1];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
790 *dstcol++ = srccol[0];
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
791 srccol += 3;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
792 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
793
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
794 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
795 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
798
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
799 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
802 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
803 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
804
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
805 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
806 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
807 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
808 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
809 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
810 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
811 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
812 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
813
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
814 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
815 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
816 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
817
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
818 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
819 Uint32 dstcolor;
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 dstcolor = (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
822 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
823 dstcolor |= *srccol++;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
824
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
825 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
826 }
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 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
829 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
832
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
833 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
836 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
837 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
838
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
839 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
840 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
841 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
842 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
843 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
844 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
845 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
846 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
847
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
848 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
849 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
850 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
851
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
852 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
853 Uint32 dstcolor;
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 dstcolor = *srccol++;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
856 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
857 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
858
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
859 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
860 }
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 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
863 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
866
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
867 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
870 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
871 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
872
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
873 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
874 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
875 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
876 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
877 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
878 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
879 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
880 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
881
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
882 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
883 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
884 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
885
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
886 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
887 Uint32 dstcolor;
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 dstcolor = (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
890 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
891 dstcolor |= (*srccol++)<<24;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
892
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
893 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
894 }
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 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
897 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
900
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
901 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface)
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 int x,y, srcpitch, dstpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
904 Uint32 *dstline, *dstcol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
905 Uint8 *srcline, *srccol;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
906
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
907 srcline = (Uint8 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
908 srcpitch = surface->w * gl_pixelsize;
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
909 dstline = surface->pixels;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
910 dstpitch = surface->pitch >>2;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
911 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
912 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
913 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
914 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
915
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
916 for (y=0; y<surface->h; y++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
917 srccol = srcline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
918 dstcol = dstline;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
919
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
920 for (x=0; x<surface->w; x++) {
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
921 Uint32 dstcolor;
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 dstcolor = (*srccol++)<<24;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
924 dstcolor |= (*srccol++)<<16;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
925 dstcolor |= (*srccol++)<<8;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
926
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
927 *dstcol++ = dstcolor;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
928 }
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 srcline += srcpitch;
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
931 dstline += dstpitch;
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 }
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
934
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
935 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
936 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
937 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
938 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
939 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
940
12b13601a544 Final touches to OSMesa 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 srcline = (Uint32 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
942 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
943 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
944 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
945 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
946 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
947 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
948 }
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
949
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
950 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
951 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
952 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
953 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
954 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
955 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
956
12b13601a544 Final touches to OSMesa 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 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
958 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
959 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
960 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
961 *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
962 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
965 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
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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
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 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
972 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
973 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
974
12b13601a544 Final touches to OSMesa 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 srcline = (Uint32 *)gl_shadow;
1002
13aa96c76e86 Wrong pixel size for source buffer for old drivers
Patrice Mandin <patmandin@gmail.com>
parents: 1000
diff changeset
976 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
977 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
978 dstpitch = surface->pitch >>1;
1005
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
979 if (gl_upsidedown) {
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
980 srcline += (surface->h-1)*srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
981 srcpitch = -srcpitch;
2ab1cb02a44e Some Atari OpenGL implementations draw upside down
Patrice Mandin <patmandin@gmail.com>
parents: 1003
diff changeset
982 }
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
983
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
984 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
985 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
986 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
987
12b13601a544 Final touches to OSMesa 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 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
989 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
990 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
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
992 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
993 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
994 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
995 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
996 *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
997 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
1000 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
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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 /*--- 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
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 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
1007 {
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 static void Convert565To555be(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1011 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1012 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1013 unsigned short *line, *pixel;
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 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1016 pitch = surface->pitch >> 1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1017 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1018 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1019 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1020 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1021
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1022 *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1023 }
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 line += pitch;
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
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
1029 static void Convert565To555le(_THIS, SDL_Surface *surface)
989
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 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1032 unsigned short *line, *pixel;
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 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1035 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1036 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1037 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1038 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1039 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1040
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1041 color = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1042 *pixel++ = SDL_Swap16(color);
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
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1045 line += pitch;
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
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
1049 static void Convert565le(_THIS, SDL_Surface *surface)
989
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 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1052 unsigned short *line, *pixel;
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 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1055 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1056 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1057 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1058 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1059 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1060
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1061 *pixel++ = SDL_Swap16(color);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1062 }
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 line += pitch;
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
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
1068 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface)
989
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 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1071 unsigned long *line, *pixel;
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 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1074 pitch = surface->pitch >>2;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1075 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1076 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1077 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1078 unsigned long color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1079
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1080 *pixel++ = (color<<24)|(color>>8);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1081 }
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 line += pitch;
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 }
1000
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
1086
fbeac9312843 TinyGL only support RGB24 color buffer
Patrice Mandin <patmandin@gmail.com>
parents: 995
diff changeset
1087 #endif /* HAVE_OPENGL */