1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #ifndef KWIN_GLUTILS_FUNCS_H
22 #define KWIN_GLUTILS_FUNCS_H
24 #include <kdemacros.h>
26 #define KWIN_EXPORT KDE_EXPORT
28 #include <kwinconfig.h> // KWIN_HAVE_OPENGL
30 #ifdef KWIN_HAVE_OPENGL
32 // gcc-3.3.3 apparently cannot resolve KWin's namespaced versions properly,
33 // so hide possible global functions
34 #define glXQueryDrawable kwinhide_glXQueryDrawable
35 #define glXGetFBConfigAttrib kwinhide_glXGetFBConfigAttrib
36 #define glXGetVisualFromFBConfig kwinhide_glXGetVisualFromFBConfig
37 #define glXDestroyWindow kwinhide_glXDestroyWindow
38 #define glXDestroyPixmap kwinhide_glXDestroyPixmap
39 #define glXCreateWindow kwinhide_glXCreateWindow
40 #define glXCreatePixmap kwinhide_glXCreatePixmap
41 #define glXGetFBConfigs kwinhide_glXGetFBConfigs
42 #define glXGetProcAddress kwinhide_glXGetProcAddress
43 #define glXReleaseTexImageEXT kwinhide_glXReleaseTexImageEXT
44 #define glXBindTexImageEXT kwinhide_glXBindTexImageEXT
45 #define glXCopySubBuffer kwinhide_glXCopySubBuffer
46 #define glXGetVideoSync kwinhide_glXGetVideoSync
47 #define glXWaitVideoSync kwinhide_glXWaitVideoSync
52 #undef glXQueryDrawable
53 #undef glXGetFBConfigAttrib
54 #undef glXGetVisualFromFBConfig
55 #undef glXDestroyWindow
56 #undef glXDestroyPixmap
57 #undef glXCreateWindow
58 #undef glXCreatePixmap
59 #undef glXGetFBConfigs
60 #undef glXGetProcAddress
61 #undef glXReleaseTexImageEXT
62 #undef glXBindTexImageEXT
63 #undef glXCopySubBuffer
64 #undef glXGetVideoSync
65 #undef glXWaitVideoSync
72 void KWIN_EXPORT
glxResolveFunctions();
73 void KWIN_EXPORT
glResolveFunctions();
78 ** GLX_EXT_texture_from_pixmap
80 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
81 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
82 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
83 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
84 #define GLX_Y_INVERTED_EXT 0x20D4
86 #define GLX_TEXTURE_FORMAT_EXT 0x20D5
87 #define GLX_TEXTURE_TARGET_EXT 0x20D6
88 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7
90 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
91 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
92 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
94 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001
95 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002
96 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
98 #define GLX_TEXTURE_1D_EXT 0x20DB
99 #define GLX_TEXTURE_2D_EXT 0x20DC
100 #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
102 #define GLX_FRONT_LEFT_EXT 0x20DE
105 #define GL_COMPILE_STATUS 0x8B81
106 #define GL_LINK_STATUS 0x8B82
107 #define GL_INFO_LOG_LENGTH 0x8B84
108 #define GL_FRAGMENT_SHADER 0x8B30
109 #define GL_VERTEX_SHADER 0x8B31
112 #define GL_FRAMEBUFFER_EXT 0x8D40
113 #define GL_RENDERBUFFER_EXT 0x8D41
114 #define GL_STENCIL_INDEX1_EXT 0x8D46
115 #define GL_STENCIL_INDEX4_EXT 0x8D47
116 #define GL_STENCIL_INDEX8_EXT 0x8D48
117 #define GL_STENCIL_INDEX16_EXT 0x8D49
118 #define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
119 #define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
120 #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
121 #define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
122 #define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
123 #define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
124 #define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
125 #define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
126 #define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
127 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
128 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
129 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
130 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
131 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
132 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
133 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
134 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
135 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
136 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
137 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
138 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
139 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
140 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
141 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
142 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
143 #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
144 #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
145 #define GL_COLOR_ATTACHMENT13_EXT 0x8CED
146 #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
147 #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
148 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
149 #define GL_STENCIL_ATTACHMENT_EXT 0x8D20
150 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
151 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
152 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
153 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
154 #define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
155 #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
156 #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
157 #define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
158 #define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
159 #define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
160 #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
161 #define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
162 #define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
165 #define GL_TEXTURE_RECTANGLE_ARB 0x84F5
169 typedef struct __GLXcontextRec
*GLXContext
;
170 /* GLX 1.3 and later */
171 typedef struct __GLXFBConfigRec
*GLXFBConfig
;
177 // finding of OpenGL extensions functions
178 typedef void (*glXFuncPtr
)();
179 typedef glXFuncPtr (*glXGetProcAddress_func
)( const GLubyte
* );
180 extern KWIN_EXPORT glXGetProcAddress_func glXGetProcAddress
;
181 // glXQueryDrawable (added in GLX 1.3)
182 typedef void (*glXQueryDrawable_func
)( Display
* dpy
, GLXDrawable drawable
,
183 int attribute
, unsigned int *value
);
184 extern KWIN_EXPORT glXQueryDrawable_func glXQueryDrawable
;
185 // texture_from_pixmap extension functions
186 typedef void (*glXBindTexImageEXT_func
)( Display
* dpy
, GLXDrawable drawable
,
187 int buffer
, const int* attrib_list
);
188 typedef void (*glXReleaseTexImageEXT_func
)( Display
* dpy
, GLXDrawable drawable
, int buffer
);
189 extern KWIN_EXPORT glXReleaseTexImageEXT_func glXReleaseTexImageEXT
;
190 extern KWIN_EXPORT glXBindTexImageEXT_func glXBindTexImageEXT
;
191 // glXCopySubBufferMESA
192 typedef void (*glXCopySubBuffer_func
) ( Display
* , GLXDrawable
, int, int, int, int );
193 extern KWIN_EXPORT glXCopySubBuffer_func glXCopySubBuffer
;
194 // video_sync extension functions
195 typedef int (*glXGetVideoSync_func
)( unsigned int *count
);
196 typedef int (*glXWaitVideoSync_func
)( int divisor
, int remainder
, unsigned int *count
);
197 extern KWIN_EXPORT glXGetVideoSync_func glXGetVideoSync
;
198 extern KWIN_EXPORT glXWaitVideoSync_func glXWaitVideoSync
;
199 // GLX_SGIX_fbconfig and misc GLX 1.3 stuff
200 typedef int (*glXGetFBConfigAttrib_func
) ( Display
*dpy
, GLXFBConfig config
,
201 int attribute
, int *value
);
202 typedef XVisualInfo
* (*glXGetVisualFromFBConfig_func
) ( Display
*dpy
, GLXFBConfig config
);
203 extern KWIN_EXPORT glXGetFBConfigAttrib_func glXGetFBConfigAttrib
;
204 extern KWIN_EXPORT glXGetVisualFromFBConfig_func glXGetVisualFromFBConfig
;
205 typedef GLXWindow (*glXCreateWindow_func
) ( Display
*dpy
, GLXFBConfig config
,
206 Window win
, const int *attribList
);
207 typedef void (*glXDestroyWindow_func
) ( Display
*dpy
, GLXWindow window
);
208 typedef GLXPixmap (*glXCreatePixmap_func
) ( Display
*dpy
, GLXFBConfig config
,
209 Pixmap pixmap
, const int *attribList
);
210 typedef void (*glXDestroyPixmap_func
) ( Display
*dpy
, GLXPixmap pixmap
);
211 typedef GLXFBConfig
* (*glXGetFBConfigs_func
) ( Display
*dpy
, int screen
, int *nelements
);
212 extern KWIN_EXPORT glXCreateWindow_func glXCreateWindow
;
213 extern KWIN_EXPORT glXDestroyWindow_func glXDestroyWindow
;
214 extern KWIN_EXPORT glXCreatePixmap_func glXCreatePixmap
;
215 extern KWIN_EXPORT glXDestroyPixmap_func glXDestroyPixmap
;
216 extern KWIN_EXPORT glXGetFBConfigs_func glXGetFBConfigs
;
219 typedef void (*glActiveTexture_func
)(GLenum
);
220 extern KWIN_EXPORT glActiveTexture_func glActiveTexture
;
221 // framebuffer_object extension functions
222 typedef GLboolean (*glIsRenderbuffer_func
)( GLuint renderbuffer
);
223 typedef void (*glBindRenderbuffer_func
)( GLenum target
, GLuint renderbuffer
);
224 typedef void (*glDeleteRenderbuffers_func
)( GLsizei n
, const GLuint
*renderbuffers
);
225 typedef void (*glGenRenderbuffers_func
)( GLsizei n
, GLuint
*renderbuffers
);
226 typedef void (*glRenderbufferStorage_func
)( GLenum target
, GLenum internalformat
, GLsizei width
, GLsizei height
);
227 typedef void (*glGetRenderbufferParameteriv_func
)( GLenum target
, GLenum pname
, GLint
*params
);
228 typedef GLboolean (*glIsFramebuffer_func
)( GLuint framebuffer
);
229 typedef void (*glBindFramebuffer_func
)( GLenum target
, GLuint framebuffer
);
230 typedef void (*glDeleteFramebuffers_func
)( GLsizei n
, const GLuint
*framebuffers
);
231 typedef void (*glGenFramebuffers_func
)( GLsizei n
, GLuint
*framebuffers
);
232 typedef GLenum (*glCheckFramebufferStatus_func
)( GLenum target
);
233 typedef void (*glFramebufferTexture1D_func
)( GLenum target
, GLenum attachment
, GLenum textarget
, GLuint texture
, GLint level
);
234 typedef void (*glFramebufferTexture2D_func
)( GLenum target
, GLenum attachment
, GLenum textarget
, GLuint texture
, GLint level
);
235 typedef void (*glFramebufferTexture3D_func
)( GLenum target
, GLenum attachment
, GLenum textarget
, GLuint texture
, GLint level
, GLint zoffset
);
236 typedef void (*glFramebufferRenderbuffer_func
)( GLenum target
, GLenum attachment
, GLenum renderbuffertarget
, GLuint renderbuffer
);
237 typedef void (*glGetFramebufferAttachmentParameteriv_func
)( GLenum target
, GLenum attachment
, GLenum pname
, GLint
*params
);
238 typedef void (*glGenerateMipmap_func
)( GLenum target
);
239 extern KWIN_EXPORT glIsRenderbuffer_func glIsRenderbuffer
;
240 extern KWIN_EXPORT glBindRenderbuffer_func glBindRenderbuffer
;
241 extern KWIN_EXPORT glDeleteRenderbuffers_func glDeleteRenderbuffers
;
242 extern KWIN_EXPORT glGenRenderbuffers_func glGenRenderbuffers
;
243 extern KWIN_EXPORT glRenderbufferStorage_func glRenderbufferStorage
;
244 extern KWIN_EXPORT glGetRenderbufferParameteriv_func glGetRenderbufferParameteriv
;
245 extern KWIN_EXPORT glIsFramebuffer_func glIsFramebuffer
;
246 extern KWIN_EXPORT glBindFramebuffer_func glBindFramebuffer
;
247 extern KWIN_EXPORT glDeleteFramebuffers_func glDeleteFramebuffers
;
248 extern KWIN_EXPORT glGenFramebuffers_func glGenFramebuffers
;
249 extern KWIN_EXPORT glCheckFramebufferStatus_func glCheckFramebufferStatus
;
250 extern KWIN_EXPORT glFramebufferTexture1D_func glFramebufferTexture1D
;
251 extern KWIN_EXPORT glFramebufferTexture2D_func glFramebufferTexture2D
;
252 extern KWIN_EXPORT glFramebufferTexture3D_func glFramebufferTexture3D
;
253 extern KWIN_EXPORT glFramebufferRenderbuffer_func glFramebufferRenderbuffer
;
254 extern KWIN_EXPORT glGetFramebufferAttachmentParameteriv_func glGetFramebufferAttachmentParameteriv
;
255 extern KWIN_EXPORT glGenerateMipmap_func glGenerateMipmap
;
257 typedef GLuint (*glCreateShader_func
)(GLenum
);
258 typedef GLvoid (*glShaderSource_func
)(GLuint
, GLsizei
, const GLchar
**, const GLint
*);
259 typedef GLvoid (*glCompileShader_func
)(GLuint
);
260 typedef GLvoid (*glDeleteShader_func
)(GLuint
);
261 typedef GLuint (*glCreateProgram_func
)();
262 typedef GLvoid (*glAttachShader_func
)(GLuint
, GLuint
);
263 typedef GLvoid (*glLinkProgram_func
)(GLuint
);
264 typedef GLvoid (*glUseProgram_func
)(GLuint
);
265 typedef GLvoid (*glDeleteProgram_func
)(GLuint
);
266 typedef GLvoid (*glGetShaderInfoLog_func
)(GLuint
, GLsizei
, GLsizei
*, GLchar
*);
267 typedef GLvoid (*glGetProgramInfoLog_func
)(GLuint
, GLsizei
, GLsizei
*, GLchar
*);
268 typedef GLvoid (*glGetProgramiv_func
)(GLuint
, GLenum
, GLint
*);
269 typedef GLvoid (*glGetShaderiv_func
)(GLuint
, GLenum
, GLint
*);
270 typedef GLvoid (*glUniform1f_func
)(GLint
, GLfloat
);
271 typedef GLvoid (*glUniform1i_func
)(GLint
, GLint
);
272 typedef GLvoid (*glUniform1fv_func
)(GLint
, GLsizei
, const GLfloat
*);
273 typedef GLvoid (*glUniform2fv_func
)(GLint
, GLsizei
, const GLfloat
*);
274 typedef GLvoid (*glUniform3fv_func
)(GLint
, GLsizei
, const GLfloat
*);
275 typedef GLvoid (*glValidateProgram_func
)(GLuint
);
276 typedef GLint (*glGetUniformLocation_func
)(GLuint
, const GLchar
*);
277 typedef GLvoid (*glVertexAttrib1f_func
)(GLuint
, GLfloat
);
278 typedef GLint (*glGetAttribLocation_func
)(GLuint
, const GLchar
*);
279 extern KWIN_EXPORT glCreateShader_func glCreateShader
;
280 extern KWIN_EXPORT glShaderSource_func glShaderSource
;
281 extern KWIN_EXPORT glCompileShader_func glCompileShader
;
282 extern KWIN_EXPORT glDeleteShader_func glDeleteShader
;
283 extern KWIN_EXPORT glCreateProgram_func glCreateProgram
;
284 extern KWIN_EXPORT glAttachShader_func glAttachShader
;
285 extern KWIN_EXPORT glLinkProgram_func glLinkProgram
;
286 extern KWIN_EXPORT glUseProgram_func glUseProgram
;
287 extern KWIN_EXPORT glDeleteProgram_func glDeleteProgram
;
288 extern KWIN_EXPORT glGetShaderInfoLog_func glGetShaderInfoLog
;
289 extern KWIN_EXPORT glGetProgramInfoLog_func glGetProgramInfoLog
;
290 extern KWIN_EXPORT glGetProgramiv_func glGetProgramiv
;
291 extern KWIN_EXPORT glGetShaderiv_func glGetShaderiv
;
292 extern KWIN_EXPORT glUniform1f_func glUniform1f
;
293 extern KWIN_EXPORT glUniform1i_func glUniform1i
;
294 extern KWIN_EXPORT glUniform1fv_func glUniform1fv
;
295 extern KWIN_EXPORT glUniform2fv_func glUniform2fv
;
296 extern KWIN_EXPORT glValidateProgram_func glValidateProgram
;
297 extern KWIN_EXPORT glGetUniformLocation_func glGetUniformLocation
;
298 extern KWIN_EXPORT glVertexAttrib1f_func glVertexAttrib1f
;
299 extern KWIN_EXPORT glGetAttribLocation_func glGetAttribLocation
;