2
* Copyright © 2008 Dennis Kasprzyk
3
* Copyright © 2007 Novell, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software
6
* and its documentation for any purpose is hereby granted without
7
* fee, provided that the above copyright notice appear in all copies
8
* and that both that copyright notice and this permission notice
9
* appear in supporting documentation, and that the name of
10
* Dennis Kasprzyk not be used in advertising or publicity pertaining to
11
* distribution of the software without specific, written prior permission.
12
* Dennis Kasprzyk makes no representations about the suitability of this
13
* software for any purpose. It is provided "as is" without express or
16
* DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18
* NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
* Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25
* David Reveman <davidr@novell.com>
28
#ifndef _COMPIZ_OPENGL_H
29
#define _COMPIZ_OPENGL_H
34
#include <opengl/matrix.h>
35
#include <opengl/texture.h>
36
#include <opengl/fragment.h>
38
#define COMPIZ_OPENGL_ABI 1
40
#include <core/privatehandler.h>
42
/* camera distance from screen, 0.5 * tan (FOV) */
43
#define DEFAULT_Z_CAMERA 0.866025404f
45
#define RED_SATURATION_WEIGHT 0.30f
46
#define GREEN_SATURATION_WEIGHT 0.59f
47
#define BLUE_SATURATION_WEIGHT 0.11f
49
class PrivateGLScreen;
50
class PrivateGLWindow;
52
extern GLushort defaultColor[4];
54
#ifndef GLX_EXT_texture_from_pixmap
55
#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
56
#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
57
#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
58
#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
59
#define GLX_Y_INVERTED_EXT 0x20D4
60
#define GLX_TEXTURE_FORMAT_EXT 0x20D5
61
#define GLX_TEXTURE_TARGET_EXT 0x20D6
62
#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
63
#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
64
#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
65
#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
66
#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
67
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
68
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
69
#define GLX_TEXTURE_1D_EXT 0x20DB
70
#define GLX_TEXTURE_2D_EXT 0x20DC
71
#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
72
#define GLX_FRONT_LEFT_EXT 0x20DE
77
typedef void (*FuncPtr) (void);
78
typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
80
typedef void (*GLXBindTexImageProc) (Display *display,
84
typedef void (*GLXReleaseTexImageProc) (Display *display,
87
typedef void (*GLXQueryDrawableProc) (Display *display,
92
typedef void (*GLXCopySubBufferProc) (Display *display,
99
typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
100
typedef int (*GLXWaitVideoSyncProc) (int divisor,
102
unsigned int *count);
104
#ifndef GLX_VERSION_1_3
105
typedef struct __GLXFBConfigRec *GLXFBConfig;
108
typedef GLXFBConfig *(*GLXGetFBConfigsProc) (Display *display,
111
typedef int (*GLXGetFBConfigAttribProc) (Display *display,
115
typedef GLXPixmap (*GLXCreatePixmapProc) (Display *display,
118
const int *attribList);
120
typedef void (*GLActiveTextureProc) (GLenum texture);
121
typedef void (*GLClientActiveTextureProc) (GLenum texture);
122
typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
124
typedef void (*GLGenProgramsProc) (GLsizei n,
126
typedef void (*GLDeleteProgramsProc) (GLsizei n,
128
typedef void (*GLBindProgramProc) (GLenum target,
130
typedef void (*GLProgramStringProc) (GLenum target,
133
const GLvoid *string);
134
typedef void (*GLProgramParameter4fProc) (GLenum target,
140
typedef void (*GLGetProgramivProc) (GLenum target,
144
typedef void (*GLGenFramebuffersProc) (GLsizei n,
145
GLuint *framebuffers);
146
typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
147
GLuint *framebuffers);
148
typedef void (*GLBindFramebufferProc) (GLenum target,
150
typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
151
typedef void (*GLFramebufferTexture2DProc) (GLenum target,
156
typedef void (*GLGenerateMipmapProc) (GLenum target);
158
extern GLXBindTexImageProc bindTexImage;
159
extern GLXReleaseTexImageProc releaseTexImage;
160
extern GLXQueryDrawableProc queryDrawable;
161
extern GLXCopySubBufferProc copySubBuffer;
162
extern GLXGetVideoSyncProc getVideoSync;
163
extern GLXWaitVideoSyncProc waitVideoSync;
164
extern GLXGetFBConfigsProc getFBConfigs;
165
extern GLXGetFBConfigAttribProc getFBConfigAttrib;
166
extern GLXCreatePixmapProc createPixmap;
168
extern GLActiveTextureProc activeTexture;
169
extern GLClientActiveTextureProc clientActiveTexture;
170
extern GLMultiTexCoord2fProc multiTexCoord2f;
172
extern GLGenProgramsProc genPrograms;
173
extern GLDeleteProgramsProc deletePrograms;
174
extern GLBindProgramProc bindProgram;
175
extern GLProgramStringProc programString;
176
extern GLProgramParameter4fProc programEnvParameter4f;
177
extern GLProgramParameter4fProc programLocalParameter4f;
178
extern GLGetProgramivProc getProgramiv;
180
extern GLGenFramebuffersProc genFramebuffers;
181
extern GLDeleteFramebuffersProc deleteFramebuffers;
182
extern GLBindFramebufferProc bindFramebuffer;
183
extern GLCheckFramebufferStatusProc checkFramebufferStatus;
184
extern GLFramebufferTexture2DProc framebufferTexture2D;
185
extern GLGenerateMipmapProc generateMipmap;
187
extern bool textureFromPixmap;
188
extern bool textureRectangle;
189
extern bool textureNonPowerOfTwo;
190
extern bool textureEnvCombine;
191
extern bool textureEnvCrossbar;
192
extern bool textureBorderClamp;
193
extern bool textureCompression;
194
extern GLint maxTextureSize;
196
extern bool fragmentProgram;
197
extern GLint maxTextureUnits;
199
extern bool canDoSaturated;
200
extern bool canDoSlightlySaturated;
203
struct GLScreenPaintAttrib {
216
GLXFBConfig fbConfig;
223
#define NOTHING_TRANS_FILTER 0
224
#define SCREEN_TRANS_FILTER 1
225
#define WINDOW_TRANS_FILTER 2
228
extern GLScreenPaintAttrib defaultScreenPaintAttrib;
232
class GLScreenInterface :
233
public WrapableInterface<GLScreen, GLScreenInterface>
236
virtual bool glPaintOutput (const GLScreenPaintAttrib &,
237
const GLMatrix &, const CompRegion &,
238
CompOutput *, unsigned int);
239
virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &,
242
CompOutput *, unsigned int);
243
virtual void glApplyTransform (const GLScreenPaintAttrib &,
244
CompOutput *, GLMatrix *);
246
virtual void glEnableOutputClipping (const GLMatrix &,
249
virtual void glDisableOutputClipping ();
255
public WrapableHandler<GLScreenInterface, 5>,
256
public PrivateHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>
259
GLScreen (CompScreen *s);
262
CompOption::Vector & getOptions ();
263
bool setOption (const char *name, CompOption::Value &value);
264
CompOption * getOption (const char *name);
266
GLenum textureFilter ();
267
void setTextureFilter (GLenum);
269
void clearTargetOutput (unsigned int mask);
271
GL::FuncPtr getProcAddress (const char *name);
273
void updateBackground ();
275
GLTexture::Filter filter (int);
276
void setFilter (int, GLTexture::Filter);
278
GLFragment::Storage * fragmentStorage ();
280
void setTexEnvMode (GLenum mode);
281
void setLighting (bool lighting);
284
void clearOutput (CompOutput *output, unsigned int mask);
286
void setDefaultViewport ();
288
GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);
289
void unregisterBindPixmap (GLTexture::BindPixmapHandle);
291
GLFBConfig * glxPixmapFBConfig (unsigned int depth);
293
GLTexture *defaultIcon ();
295
void resetRasterPos ();
297
const float * projectionMatrix ();
299
WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
300
const GLScreenPaintAttrib &, const GLMatrix &,
301
const CompRegion &, CompOutput *, unsigned int);
302
WRAPABLE_HND (1, GLScreenInterface, void, glPaintTransformedOutput,
303
const GLScreenPaintAttrib &,
304
const GLMatrix &, const CompRegion &, CompOutput *,
306
WRAPABLE_HND (2, GLScreenInterface, void, glApplyTransform,
307
const GLScreenPaintAttrib &, CompOutput *, GLMatrix *);
309
WRAPABLE_HND (3, GLScreenInterface, void, glEnableOutputClipping,
310
const GLMatrix &, const CompRegion &, CompOutput *);
311
WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);
313
friend class GLTexture;
316
PrivateGLScreen *priv;
319
struct GLWindowPaintAttrib {
331
class GLWindowInterface :
332
public WrapableInterface<GLWindow, GLWindowInterface>
335
virtual bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
336
const CompRegion &, unsigned int);
337
virtual bool glDraw (const GLMatrix &, GLFragment::Attrib &,
338
const CompRegion &, unsigned int);
339
virtual void glAddGeometry (const GLTexture::MatrixList &,
340
const CompRegion &,const CompRegion &);
341
virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,
343
virtual void glDrawGeometry ();
347
public WrapableHandler<GLWindowInterface, 5>,
348
public PrivateHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
359
bool moreVertices (int newSize);
360
bool moreIndices (int newSize);
374
static GLWindowPaintAttrib defaultPaintAttrib;
377
GLWindow (CompWindow *w);
380
const CompRegion & clip () const;
382
GLWindowPaintAttrib & paintAttrib ();
383
GLWindowPaintAttrib & lastPaintAttrib ();
385
unsigned int lastMask () const;
390
const GLTexture::List & textures () const;
391
const GLTexture::MatrixList & matrices () const;
393
void updatePaintAttribs ();
395
Geometry & geometry ();
397
GLTexture *getIcon (int width, int height);
399
WRAPABLE_HND (0, GLWindowInterface, bool, glPaint,
400
const GLWindowPaintAttrib &, const GLMatrix &,
401
const CompRegion &, unsigned int);
402
WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,
403
GLFragment::Attrib &, const CompRegion &, unsigned int);
404
WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,
405
const GLTexture::MatrixList &, const CompRegion &,
407
WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
408
GLTexture *texture, GLFragment::Attrib &, unsigned int);
409
WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);
411
friend class GLScreen;
412
friend class PrivateGLScreen;
415
PrivateGLWindow *priv;