2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (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.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __CAIRO_DOCK_OPENGL__
22
#define __CAIRO_DOCK_OPENGL__
26
#include <gdk/x11/gdkglx.h>
28
#include "cairo-dock-struct.h"
29
#include "cairo-dock-container.h"
34
*@file cairo-dock-opengl.h This class manages the OpenGL backend and context.
37
/// This strucure summarizes the available OpenGL configuration on the system.
38
struct _CairoDockGLConfig {
39
GdkGLConfig *pGlConfig;
40
gboolean bHasBeenForced;
41
gboolean bIndirectRendering;
42
gboolean bAlphaAvailable;
43
gboolean bStencilBufferAvailable;
44
gboolean bPBufferAvailable;
45
gboolean bNonPowerOfTwoAvailable;
46
gboolean bTextureFromPixmapAvailable;
47
gint iGlxMajor, iGlxMinor;
48
GLXPbuffer iconPbuffer;
49
GLXContext iconContext;
50
gint iIconPbufferWidth, iIconPbufferHeight;
51
void (*bindTexImage) (Display *display, GLXDrawable drawable, int buffer, int *attribList);
52
void (*releaseTexImage) (Display *display, GLXDrawable drawable, int buffer);
59
/** Initialize the OpenGL backend, by trying to get a suitable GLX configuration.
60
*@param bToggleIndirectRendering whether to toggle on/off the indirect rendering mode that have been detected by the function (for cards like Radeon 35xx).
61
*@param bForceOpenGL whether to force the use of OpenGL, or let the function decide.
62
*@return TRUE if OpenGL is usable.
64
gboolean cairo_dock_initialize_opengl_backend (gboolean bToggleIndirectRendering, gboolean bForceOpenGL);
66
#define cairo_dock_opengl_is_safe(...) (g_openglConfig.pGlConfig != NULL && ! g_openglConfig.bIndirectRendering && g_openglConfig.bAlphaAvailable && g_openglConfig.bStencilBufferAvailable && g_openglConfig.bPBufferAvailable && g_openglConfig.bNonPowerOfTwoAvailable)
68
#define cairo_dock_deactivate_opengl(...) do {\
69
g_bUseOpenGL = FALSE;\
70
g_openglConfig.pGlConfig = NULL; } while (0)
72
///////////////////////
73
// RENDER TO TEXTURE //
74
///////////////////////
75
/** Create a pbuffer that will fit the icons of the docks. Do nothing it a pbuffer with the correct size already exists.
77
void cairo_dock_create_icon_pbuffer (void);
78
/** Destroy the icons pbuffer.
80
void cairo_dock_destroy_icon_pbuffer (void);
82
/** Initiate an OpenGL drawing session on an icon's texture.
83
*@param pIcon the icon on which to draw.
84
*@param pContainer its container.
85
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
87
gboolean cairo_dock_begin_draw_icon (Icon *pIcon, CairoContainer *pContainer);
88
/** Finish an OpenGL drawing session on an icon.
89
*@param pIcon the icon on which to draw.
90
*@param pContainer its container.
91
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
93
void cairo_dock_end_draw_icon (Icon *pIcon, CairoContainer *pContainer);
99
/** Set a perspective view to the current GL context. Perspective view accentuates the depth effect of the scene, but can distort it on the edges, and is difficult to manipulate because the size of objects depends on their position.
100
*@param iWidth width of the container
101
*@param iHeight height of the container
103
void cairo_dock_set_perspective_view (int iWidth, int iHeight);
104
/** Set an orthogonal view to the current GL context. Orthogonal view is convenient to draw classic 2D, because the objects are not zoomed according to their position. The drawback is a poor depth effect.
105
*@param iWidth width of the container
106
*@param iHeight height of the container
108
void cairo_dock_set_ortho_view (int iWidth, int iHeight);
110
/** Apply the desktop background onto a container, to emulate fake transparency.
111
*@param pContainer the container
113
void cairo_dock_apply_desktop_background_opengl (CairoContainer *pContainer);
115
/** Set a shared default-initialized GL context on a window.
116
*@param pWindow the window, not yet realized.
118
void cairo_dock_set_gl_capabilities (GtkWidget *pWindow);