zenilib: zenilib/jni/external/sdl/src/video/bwindow/SDL_bopengl.cc Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_bopengl.cc
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 #if SDL_VIDEO_DRIVER_BWINDOW
24
25 #include "SDL_bopengl.h"
26
27 #include <unistd.h>
28 #include <KernelKit.h>
29 #include <OpenGLKit.h>
30 #include "SDL_BWin.h"
31 #include "../../main/beos/SDL_BApp.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37
38 #define BGL_FLAGS BGL_RGB | BGL_DOUBLE
39
40 static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
41 return ((SDL_BWin*)(window->driverdata));
42 }
43
44 static inline SDL_BApp *_GetBeApp() {
45 return ((SDL_BApp*)be_app);
46 }
47
48 /* Passing a NULL path means load pointers from the application */
49 int BE_GL_LoadLibrary(_THIS, const char *path)
50 {
51 /* FIXME: Is this working correctly? */
52 image_info info;
53 int32 cookie = 0;
54 while (get_next_image_info(0, &cookie, &info) == B_OK) {
55 void *location = NULL;
56 if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY,
57 &location) == B_OK) {
58
59 _this->gl_config.dll_handle = (void *) info.id;
60 _this->gl_config.driver_loaded = 1;
61 SDL_strlcpy(_this->gl_config.driver_path, "libGL.so",
62 SDL_arraysize(_this->gl_config.driver_path));
63 }
64 }
65 return 0;
66 }
67
68 void *BE_GL_GetProcAddress(_THIS, const char *proc)
69 {
70 if (_this->gl_config.dll_handle != NULL) {
71 void *location = NULL;
72 status_t err;
73 if ((err =
74 get_image_symbol((image_id) _this->gl_config.dll_handle,
75 proc, B_SYMBOL_TYPE_ANY,
76 &location)) == B_OK) {
77 return location;
78 } else {
79 SDL_SetError("Couldn't find OpenGL symbol");
80 return NULL;
81 }
82 } else {
83 SDL_SetError("OpenGL library not loaded");
84 return NULL;
85 }
86 }
87
88
89
90
91 void BE_GL_SwapWindow(_THIS, SDL_Window * window) {
92 _ToBeWin(window)->SwapBuffers();
93 }
94
95 int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
96 _GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView());
97 return 0;
98 }
99
100
101 SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
102 /* FIXME: Not sure what flags should be included here; may want to have
103 most of them */
104 SDL_BWin *bwin = _ToBeWin(window);
105 bwin->CreateGLView(BGL_FLAGS);
106 return (SDL_GLContext)(bwin);
107 }
108
109 void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
110 /* Currently, automatically unlocks the view */
111 ((SDL_BWin*)context)->RemoveGLView();
112 }
113
114
115 int BE_GL_SetSwapInterval(_THIS, int interval) {
116 /* TODO: Implement this, if necessary? */
117 return 0;
118 }
119
120 int BE_GL_GetSwapInterval(_THIS) {
121 /* TODO: Implement this, if necessary? */
122 return 0;
123 }
124
125
126 void BE_GL_UnloadLibrary(_THIS) {
127 /* TODO: Implement this, if necessary? */
128 }
129
130
131 /* FIXME: This function is meant to clear the OpenGL context when the video
132 mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
133 currently in use. */
134 void BE_GL_RebootContexts(_THIS) {
135 SDL_Window *window = _this->windows;
136 while(window) {
137 SDL_BWin *bwin = _ToBeWin(window);
138 if(bwin->GetGLView()) {
139 bwin->LockLooper();
140 bwin->RemoveGLView();
141 bwin->CreateGLView(BGL_FLAGS);
142 bwin->UnlockLooper();
143 }
144 window = window->next;
145 }
146 }
147
148
149 #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
150
151 int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
152 {
153 /*
154 FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values
155 */
156 switch (attrib) {
157 case SDL_GL_RED_SIZE:
158 glGetIntegerv(GL_RED_BITS, (GLint *) value);
159 break;
160 case SDL_GL_GREEN_SIZE:
161 glGetIntegerv(GL_GREEN_BITS, (GLint *) value);
162 break;
163 case SDL_GL_BLUE_SIZE:
164 glGetIntegerv(GL_BLUE_BITS, (GLint *) value);
165 break;
166 case SDL_GL_ALPHA_SIZE:
167 glGetIntegerv(GL_ALPHA_BITS, (GLint *) value);
168 break;
169 case SDL_GL_DOUBLEBUFFER:
170 glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value);
171 break;
172 case SDL_GL_BUFFER_SIZE:
173 int v;
174 glGetIntegerv(GL_RED_BITS, (GLint *) & v);
175 *value = v;
176 glGetIntegerv(GL_GREEN_BITS, (GLint *) & v);
177 *value += v;
178 glGetIntegerv(GL_BLUE_BITS, (GLint *) & v);
179 *value += v;
180 glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v);
181 *value += v;
182 break;
183 case SDL_GL_DEPTH_SIZE:
184 glGetIntegerv(GL_DEPTH_BITS, (GLint *) value); /* Mesa creates 16 only? r5 always 32 */
185 break;
186 case SDL_GL_STENCIL_SIZE:
187 glGetIntegerv(GL_STENCIL_BITS, (GLint *) value);
188 break;
189 case SDL_GL_ACCUM_RED_SIZE:
190 glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value);
191 break;
192 case SDL_GL_ACCUM_GREEN_SIZE:
193 glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value);
194 break;
195 case SDL_GL_ACCUM_BLUE_SIZE:
196 glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value);
197 break;
198 case SDL_GL_ACCUM_ALPHA_SIZE:
199 glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value);
200 break;
201 case SDL_GL_STEREO:
202 case SDL_GL_MULTISAMPLEBUFFERS:
203 case SDL_GL_MULTISAMPLESAMPLES:
204 default:
205 *value = 0;
206 return (-1);
207 }
208 return 0;
209 }
210
211 #endif
212
213
214
215 #ifdef __cplusplus
216 }
217 #endif
218
219 #endif /* SDL_VIDEO_DRIVER_BWINDOW */
SDL_Window::next
SDL_Window * next
Definition: SDL_sysvideo.h:102
GL_DEPTH_BITS
#define GL_DEPTH_BITS
Definition: gl2.h:206
BE_GL_LoadLibrary
int BE_GL_LoadLibrary(_THIS, const char *path)
BE_GL_UnloadLibrary
void BE_GL_UnloadLibrary(_THIS)
SDL_GL_STEREO
Definition: SDL_video.h:180
NULL
#define NULL
Definition: ftobjs.h:61
SDL_GL_DOUBLEBUFFER
Definition: SDL_video.h:173
GL_GREEN_BITS
#define GL_GREEN_BITS
Definition: gl2.h:203
GLboolean
unsigned char GLboolean
Definition: gl2.h:24
location
GLint location
Definition: gl2ext.h:1164
BE_GL_GetProcAddress
void * BE_GL_GetProcAddress(_THIS, const char *proc)
BE_GL_DeleteContext
void BE_GL_DeleteContext(_THIS, SDL_GLContext context)
BE_GL_RebootContexts
void BE_GL_RebootContexts(_THIS)
glGetIntegerv
#define glGetIntegerv
Definition: gl_mangle.h:679
BE_GL_CreateContext
SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GL_GREEN_SIZE
Definition: SDL_video.h:169
GL_ACCUM_GREEN_BITS
#define GL_ACCUM_GREEN_BITS
Definition: glew_head.h:495
SDL_GLattr
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:166
SDL_GLContext
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:161
SDL_GL_ACCUM_BLUE_SIZE
Definition: SDL_video.h:178
SDL_GL_ACCUM_GREEN_SIZE
Definition: SDL_video.h:177
path
GLsizei const GLchar *const * path
Definition: glew.h:5828
SDL_config.h
SDL_GL_ACCUM_ALPHA_SIZE
Definition: SDL_video.h:179
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:92
SDL_GL_ACCUM_RED_SIZE
Definition: SDL_video.h:176
SDL_BApp
Definition: SDL_BApp.h:80
SDL_GL_MULTISAMPLEBUFFERS
Definition: SDL_video.h:181
v
const GLdouble * v
Definition: glew.h:1377
GL_ACCUM_ALPHA_BITS
#define GL_ACCUM_ALPHA_BITS
Definition: glew_head.h:497
glGetBooleanv
#define glGetBooleanv
Definition: gl_mangle.h:601
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_VideoDevice::driver_loaded
int driver_loaded
Definition: SDL_sysvideo.h:297
SDL_GL_ALPHA_SIZE
Definition: SDL_video.h:171
SDL_strlcpy
DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:448
GL_ACCUM_BLUE_BITS
#define GL_ACCUM_BLUE_BITS
Definition: glew_head.h:496
SDL_VideoDevice::driver_path
char driver_path[256]
Definition: SDL_sysvideo.h:298
SDL_VideoDevice::dll_handle
void * dll_handle
Definition: SDL_sysvideo.h:299
GL_ACCUM_RED_BITS
#define GL_ACCUM_RED_BITS
Definition: glew_head.h:494
BE_GL_GetSwapInterval
int BE_GL_GetSwapInterval(_THIS)
SDL_SetError
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
GL_STENCIL_BITS
#define GL_STENCIL_BITS
Definition: gl2.h:207
SDL_GL_STENCIL_SIZE
Definition: SDL_video.h:175
SDL_VideoDevice::windows
SDL_Window * windows
Definition: SDL_sysvideo.h:266
GL_BLUE_BITS
#define GL_BLUE_BITS
Definition: gl2.h:204
SDL_GL_BLUE_SIZE
Definition: SDL_video.h:170
SDL_GL_RED_SIZE
Definition: SDL_video.h:168
SDL_GL_DEPTH_SIZE
Definition: SDL_video.h:174
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:83
SDL_GL_BUFFER_SIZE
Definition: SDL_video.h:172
GLint
int GLint
Definition: gl2.h:28
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
SDL_BWin
Definition: SDL_BWin.h:63
BE_GL_SetSwapInterval
int BE_GL_SetSwapInterval(_THIS, int interval)
SDL_Window
Definition: SDL_sysvideo.h:71
BE_GL_MakeCurrent
int BE_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_bopengl.h
SDL_GL_MULTISAMPLESAMPLES
Definition: SDL_video.h:182
GL_RED_BITS
#define GL_RED_BITS
Definition: gl2.h:202
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:99
context
TParseContext * context
Definition: glslang_tab.cpp:1907
BE_GL_SwapWindow
void BE_GL_SwapWindow(_THIS, SDL_Window *window)
SDL_VideoDevice::gl_config
struct SDL_VideoDevice::@87 gl_config
SDL_BWin.h
GL_ALPHA_BITS
#define GL_ALPHA_BITS
Definition: gl2.h:205
GL_DOUBLEBUFFER
#define GL_DOUBLEBUFFER
Definition: glew_head.h:414