annotate src/video/ataricommon/SDL_atarigl.c @ 992:0324ce32b2d9

Keep current OpenGL context when possible
author Patrice Mandin <patmandin@gmail.com>
date Fri, 26 Nov 2004 22:11:30 +0000
parents 12b13601a544
children 2662da16d668
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
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
27 #include <stdio.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
28 #include <stdlib.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
29 #include <string.h>
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
30 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
31 #include <GL/osmesa.h>
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
32 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
33
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
34 #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
35
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
36 #include "SDL_video.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
37 #include "SDL_error.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
38 #include "SDL_endian.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
39 #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
40 #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
41 #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
42 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
43
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
44 /*--- 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
45
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
46 #define PATH_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
47 #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
48 #define PATH_TINYGL_LDG "tiny_gl.ldg"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
49
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
50 /*--- Functions prototypes ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
51
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
52 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
53
12b13601a544 Final touches to OSMesa 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 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
55 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
56 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
57 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
58
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
59 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
60 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
61 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
62 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
63 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
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 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
66 static int InitOld(_THIS, SDL_Surface *current);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
67
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
68 /*--- Public functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
69
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
70 int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
71 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
72 #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
73 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
74 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
75 } 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
76 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
77 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
78 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
79
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
80 return (gl_active);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
81 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
82
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
83 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
84 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
85 #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
86 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
87 /* 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
88 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
89 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
90 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
91 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
92 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
93 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
94 }
12b13601a544 Final touches to OSMesa 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 } 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
96 /* 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
97 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
98 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
99 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
100 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
101 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
102 }
12b13601a544 Final touches to OSMesa 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 }
12b13601a544 Final touches to OSMesa 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
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
105 if (unload) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
106 SDL_AtariGL_UnloadLibrary(this);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
107 }
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
108
12b13601a544 Final touches to OSMesa 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 #endif /* HAVE_OPENGL */
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
110 gl_active = 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
111 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
112
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
113 int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
114 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
115 #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
116
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
117 #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
118 void *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
119
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
120 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
121 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
122 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
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
12b13601a544 Final touches to OSMesa 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 /* Unload previous driver */
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
126 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
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 /* Load library given by 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
129 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
130 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
131 /* Try to load another one */
12b13601a544 Final touches to OSMesa 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 path = getenv("SDL_VIDEO_GL_DRIVER");
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
133 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
134 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
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
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
137 /* 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
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 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
140 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
141 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
144 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
145 handle = SDL_LoadObject(path);
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
146 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
147
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
148 if (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
149 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
150 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
151 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
152 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
153
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
154 if (handle == NULL) {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
155 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
156 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
157 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
158
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
159 /* 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
160 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
161 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
162 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
163 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
164 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
165 this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv");
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
167 /* 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
168 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
169 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
170
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
171 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
172
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
173 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
174 (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
175 (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
176 (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
177 (this->gl_data->glGetIntegerv == 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
178 (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
179 /* 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
180 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
181 (this->gl_data->OSMesaDestroyLDG == 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
182 SDL_SetError("Could not retrieve OpenGL 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
183 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
184 } 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
185 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
186 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
187 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
188
12b13601a544 Final touches to OSMesa 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 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
190 if ( 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
191 strncpy(this->gl_config.driver_path, 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
192 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
193 } 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
194 strcpy(this->gl_config.driver_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
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
12b13601a544 Final touches to OSMesa 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 #endif
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
198 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
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 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
201 #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
202 return -1;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
203 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
204 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
205
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
206 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
207 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
208 void *func = NULL;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
209 #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
210
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
211 if (this->gl_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
212 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
213 } 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
214 func = this->gl_data->OSMesaGetProcAddress(proc);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
215 }
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
216
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
217 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
218 return func;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
219 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
220
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
221 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
222 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
223 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
224 GLenum mesa_attrib;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
225 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
226
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
227 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
228 if (this->gl_data->glGetIntegerv == 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
229 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
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 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
234 return -1;
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 switch(attrib) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
238 case SDL_GL_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
239 mesa_attrib = GL_RED_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
240 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
241 case SDL_GL_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
242 mesa_attrib = GL_GREEN_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
243 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
244 case SDL_GL_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
245 mesa_attrib = GL_BLUE_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
246 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
247 case SDL_GL_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
248 mesa_attrib = GL_ALPHA_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
249 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
250 case SDL_GL_DOUBLEBUFFER:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
251 surface = this->screen;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
252 *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
253 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
254 case SDL_GL_DEPTH_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
255 mesa_attrib = GL_DEPTH_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
256 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
257 case SDL_GL_STENCIL_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
258 mesa_attrib = GL_STENCIL_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
259 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
260 case SDL_GL_ACCUM_RED_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
261 mesa_attrib = GL_ACCUM_RED_BITS;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
262 break;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
263 case SDL_GL_ACCUM_GREEN_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
264 mesa_attrib = GL_ACCUM_GREEN_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_ACCUM_BLUE_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
267 mesa_attrib = GL_ACCUM_BLUE_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_ACCUM_ALPHA_SIZE:
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
270 mesa_attrib = GL_ACCUM_ALPHA_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 default :
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
273 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
274 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
275
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
276 this->gl_data->glGetIntegerv(mesa_attrib, value);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
277 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
278 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
279 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
280 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
281 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
282
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
283 int SDL_AtariGL_MakeCurrent(_THIS)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
284 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
285 #ifdef HAVE_OPENGL
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
286 SDL_Surface *surface;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
287 GLenum type;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
288
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
289 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
290 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
291 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
292
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
293 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
294 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
295 (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
296 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
297 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
298 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
299
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
300 if (!gl_active) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
301 SDL_SetError("Invalid OpenGL context");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
302 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
303 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
304
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
305 surface = this->screen;
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 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
308 type = GL_UNSIGNED_SHORT_5_6_5;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
309 } else {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
310 type = GL_UNSIGNED_BYTE;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
311 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
312
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
313 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
314 SDL_SetError("Can not make OpenGL context current");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
315 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
316 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
317
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
318 /* 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
319 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
320
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
321 return 0;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
322 #else
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
323 return -1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
324 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
325 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
326
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
327 void SDL_AtariGL_SwapBuffers(_THIS)
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 #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
330 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
331 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
332 gl_convert(this, this->screen);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
333 }
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
334 #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
335 }
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
336
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
337 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
338 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
339 #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
340 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
341 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
342 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
343 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
344 this->gl_data->OSMesaGetProcAddress = 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
345 this->gl_data->glGetIntegerv = glGetIntegerv;
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
346 #endif
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
347 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
348
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
349 /*--- Private functions ---*/
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
350
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
351 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
352 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
353 #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
354 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
355 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
356 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
357
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
358 /* Restore pointers to static 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
359 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
360 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
361 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
362 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
363 this->gl_data->OSMesaGetProcAddress = 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
364 this->gl_data->glGetIntegerv = glGetIntegerv;
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
367 this->gl_data->OSMesaDestroyLDG = 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
368 }
12b13601a544 Final touches to OSMesa 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 #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
370 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 /*--- 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
373
12b13601a544 Final touches to OSMesa 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 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
375 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
376 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
377 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
378 Uint32 redmask;
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
379 int recreatecontext;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
380 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
381
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
382 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
383 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
384 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
385 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
386 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
387
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
388 /* 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
389 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
390 gl_copyshadow = CopyShadowNull;
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
393 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
394 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
395 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
396 /* 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
397 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
398 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
399 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
400 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
401 } 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
402 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
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 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
405 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
406 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
407 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
408 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
409 } 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
410 /* 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
411 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
412 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
413 }
12b13601a544 Final touches to OSMesa 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 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
415 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
416 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
417 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
418 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
419 } 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
420 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
421 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
422 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
423 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
424 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
425 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
426 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
427 } 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
428 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
429 } 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
430 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
431 } 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
432 /* 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
433 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
434 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
435 }
12b13601a544 Final touches to OSMesa 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 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
437 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
438 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
439 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
440 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
441 }
12b13601a544 Final touches to OSMesa 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
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
443 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
444 newaccumsize =
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
445 this->gl_config.accum_red_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
446 this->gl_config.accum_green_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
447 this->gl_config.accum_blue_size +
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
448 this->gl_config.accum_alpha_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
449 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
450 if (gl_ctx &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
451 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
452 (gl_curdepth == this->gl_config.depth_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
453 (gl_curstencil == this->gl_config.stencil_size) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
454 (gl_curaccum == newaccumsize)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
455 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
456 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
457 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
458 SDL_AtariGL_Quit(this, SDL_FALSE);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
459
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
460 gl_ctx = this->gl_data->OSMesaCreateContextExt(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
461 osmesa_format, this->gl_config.depth_size,
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
462 this->gl_config.stencil_size, newaccumsize, NULL );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
463
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
464 if (gl_ctx) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
465 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
466 gl_curdepth = this->gl_config.depth_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
467 gl_curstencil = this->gl_config.stencil_size;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
468 gl_curaccum = newaccumsize;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
469 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
470 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
471 gl_curdepth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
472 gl_curstencil = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
473 gl_curaccum = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
474 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
475 }
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
476
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
477 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
478 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
479
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
480 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
481 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
482 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
483 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
484 Uint32 redmask;
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
485 int recreatecontext;
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
486
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
487 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
488 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
489 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
490 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
491 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
492
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
493 /* 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
494 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
495 gl_copyshadow = CopyShadowNull;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
496
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
497 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
498 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
499 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
500 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
501 /* 15 bits 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
502 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
503 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
504 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
505 gl_copyshadow = CopyShadow8888To555;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
506 } 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
507 gl_copyshadow = CopyShadow8888To565;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
508 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
509 }
12b13601a544 Final touches to OSMesa 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 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
511 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
512 /* 16 bits 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
513 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
514 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
515 gl_copyshadow = CopyShadow8888To565;
12b13601a544 Final touches to OSMesa 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 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
517 /* 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
518 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
519 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
520 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
521 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
522 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
523 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
524 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
525 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
526 } 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
527 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
528 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
529 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
530 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
531 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
532 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
533 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
534 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
535 } 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
536 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
537 } 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
538 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
539 } 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
540 /* 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
541 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
542 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
543 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
544 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
545 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
546 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
547 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
548 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
549 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
550 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
551
992
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
552 /* Try to keep current context if possible */
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
553 recreatecontext=1;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
554 if (gl_shadow &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
555 (gl_curformat == osmesa_format) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
556 (gl_curwidth == current->w) &&
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
557 (gl_curheight == current->h)) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
558 recreatecontext = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
559 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
560 if (recreatecontext) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
561 SDL_AtariGL_Quit(this, SDL_FALSE);
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
562
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
563 gl_shadow = this->gl_data->OSMesaCreateLDG(
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
564 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
565 );
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
566
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
567 if (gl_shadow) {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
568 gl_curformat = osmesa_format;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
569 gl_curwidth = current->w;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
570 gl_curheight = current->h;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
571 } else {
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
572 gl_curformat = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
573 gl_curwidth = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
574 gl_curheight = 0;
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
575 }
0324ce32b2d9 Keep current OpenGL context when possible
Patrice Mandin <patmandin@gmail.com>
parents: 991
diff changeset
576 }
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
577
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
578 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
579 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
580
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
581 /*--- 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
582
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
583 static void CopyShadowNull(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
584 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
585 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
586
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
587 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
588 {
12b13601a544 Final touches to OSMesa 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 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
590 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
591
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
592 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
593 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
594 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
595 dstpitch = surface->pitch;
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
597 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
598 memcpy(dstline, 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
599
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
600 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
601 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
602 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
603 }
12b13601a544 Final touches to OSMesa 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 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
606 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
607 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
608 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
609 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
610
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
611 srcline = (Uint32 *)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
612 srcpitch = surface->w;
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
613 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
614 dstpitch = surface->pitch >>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
615
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
616 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
617 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
618 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
619 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
620 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
621 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
622
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
623 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
624 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
625 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
626 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
627 *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
628 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
629
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
630 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
631 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
632 }
12b13601a544 Final touches to OSMesa 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
12b13601a544 Final touches to OSMesa 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 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
636 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
637 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
638 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
639 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
640
12b13601a544 Final touches to OSMesa 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 srcline = (Uint32 *)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
642 srcpitch = surface->w;
12b13601a544 Final touches to OSMesa 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 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
644 dstpitch = surface->pitch >>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
645
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
646 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
647 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
648 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
649
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
650 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
651 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
652 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
653
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
654 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
655 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
656 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
657 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
658 *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
659 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
660
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
661 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
662 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
663 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
664 }
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
665
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
666 /*--- 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
667
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
668 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
669 {
12b13601a544 Final touches to OSMesa OpenGL support on Atari, using loadable libraries. Hope SDL 1.2.8 is out soon.
Patrice Mandin <patmandin@gmail.com>
parents: 989
diff changeset
670 }
12b13601a544 Final touches to OSMesa 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 static void Convert565To555be(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
673 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
674 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
675 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
676
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
677 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
678 pitch = surface->pitch >> 1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
679 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
680 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
681 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
682 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
683
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
684 *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
685 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
686
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
687 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
688 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
689 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
690
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
691 static void Convert565To555le(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
692 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
693 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
694 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
695
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
696 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
697 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
698 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
699 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
700 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
701 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
702
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
703 color = (color & 0x1f)|((color>>1) & 0xffe0);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
704 *pixel++ = SDL_Swap16(color);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
705 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
706
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
707 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
708 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
709 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
710
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
711 static void Convert565le(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
712 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
713 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
714 unsigned short *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
715
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
716 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
717 pitch = surface->pitch >>1;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
718 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
719 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
720 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
721 unsigned short color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
722
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
723 *pixel++ = SDL_Swap16(color);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
724 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
725
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
726 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
727 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
728 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
729
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
730 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface)
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
731 {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
732 int x,y, pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
733 unsigned long *line, *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
734
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
735 line = surface->pixels;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
736 pitch = surface->pitch >>2;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
737 for (y=0; y<surface->h; y++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
738 pixel = line;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
739 for (x=0; x<surface->w; x++) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
740 unsigned long color = *pixel;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
741
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
742 *pixel++ = (color<<24)|(color>>8);
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
743 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
744
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
745 line += pitch;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
746 }
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
747 }