~ubuntu-branches/ubuntu/oneiric/cairo-dock/oneiric

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-opengl.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: (18.1.1 cairo-dock) (19.1.1 cairo-dock)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
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.
 
11
*
 
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/>.
 
18
*/
 
19
 
 
20
 
 
21
#ifndef __CAIRO_DOCK_OPENGL__
 
22
#define  __CAIRO_DOCK_OPENGL__
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include <gdk/x11/gdkglx.h>
 
27
 
 
28
#include "cairo-dock-struct.h"
 
29
#include "cairo-dock-container.h"
 
30
 
 
31
G_BEGIN_DECLS
 
32
 
 
33
/**
 
34
*@file cairo-dock-opengl.h This class manages the OpenGL backend and context.
 
35
*/
 
36
 
 
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 bAccumBufferAvailable;
 
45
        gboolean bFboAvailable;
 
46
        gboolean bNonPowerOfTwoAvailable;
 
47
        gboolean bTextureFromPixmapAvailable;
 
48
        GLuint iFboId;
 
49
        GLuint iRedirectedTexture;
 
50
        gint iRedirectWidth, iRedirectHeight;
 
51
        gboolean bRedirected;
 
52
        gboolean bSetPerspective;
 
53
        /**gboolean bPBufferAvailable;
 
54
        gint iGlxMajor, iGlxMinor;
 
55
        GLXPbuffer iconPbuffer;
 
56
        GLXContext iconContext;
 
57
        gint iIconPbufferWidth, iIconPbufferHeight;*/
 
58
        void (*bindTexImage) (Display *display, GLXDrawable drawable, int buffer, int *attribList);
 
59
        void (*releaseTexImage) (Display *display, GLXDrawable drawable, int buffer);
 
60
        } ;
 
61
 
 
62
 
 
63
  ///////////////////
 
64
 // CONFIGURATION //
 
65
///////////////////
 
66
/** Initialize the OpenGL backend, by trying to get a suitable GLX configuration.
 
67
*@param bToggleIndirectRendering whether to toggle on/off the indirect rendering mode that have been detected by the function (for cards like Radeon 35xx).
 
68
*@param bForceOpenGL whether to force the use of OpenGL, or let the function decide.
 
69
*@return TRUE if OpenGL is usable.
 
70
*/
 
71
gboolean cairo_dock_initialize_opengl_backend (gboolean bToggleIndirectRendering, gboolean bForceOpenGL);
 
72
 
 
73
#define cairo_dock_opengl_is_safe(...) (g_openglConfig.pGlConfig != NULL && ! g_openglConfig.bIndirectRendering && g_openglConfig.bAlphaAvailable && g_openglConfig.bStencilBufferAvailable)  // bNonPowerOfTwoAvailable et FBO sont detectes une fois qu'on a un contexte OpenGL, on ne peut donc pas les inclure ici.
 
74
 
 
75
#define cairo_dock_deactivate_opengl(...) do {\
 
76
        g_bUseOpenGL = FALSE;\
 
77
        g_openglConfig.pGlConfig = NULL; } while (0)
 
78
 
 
79
  ///////////////////////
 
80
 // RENDER TO TEXTURE //
 
81
///////////////////////
 
82
/** Create an FBO to render the icons inside a dock.
 
83
*/
 
84
void cairo_dock_create_icon_fbo (void);
 
85
/** Destroy the icons FBO.
 
86
*/
 
87
void cairo_dock_destroy_icon_fbo (void);
 
88
 
 
89
/** Create a pbuffer that will fit the icons of the docks. Do nothing it a pbuffer with the correct size already exists.
 
90
*/
 
91
///void cairo_dock_create_icon_pbuffer (void);
 
92
/** Destroy the icons pbuffer.
 
93
*/
 
94
///void cairo_dock_destroy_icon_pbuffer (void);
 
95
 
 
96
/** Initiate an OpenGL drawing session on an icon's texture.
 
97
*@param pIcon the icon on which to draw.
 
98
*@param pContainer its container, or NULL if the icon is not yet inside a container.
 
99
*@param iRenderingMode rendering mode. 0:normal, 1:don't clear the current texture, so that the drawing will be superimposed on it, 2:keep the current icon texture unchanged for all the drawing (the drawing is made on another texture).
 
100
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
 
101
*/
 
102
gboolean cairo_dock_begin_draw_icon (Icon *pIcon, CairoContainer *pContainer, gint iRenderingMode);
 
103
/** Finish an OpenGL drawing session on an icon.
 
104
*@param pIcon the icon on which to draw.
 
105
*@param pContainer its container, or NULL if the icon is not yet inside a container.
 
106
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
 
107
*/
 
108
void cairo_dock_end_draw_icon (Icon *pIcon, CairoContainer *pContainer);
 
109
 
 
110
 
 
111
  /////////////
 
112
 // CONTEXT //
 
113
/////////////
 
114
/** Set a perspective view to the current GL context to fit a given ontainer. 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.
 
115
*@param pContainer the container
 
116
*/
 
117
void cairo_dock_set_perspective_view (CairoContainer *pContainer);
 
118
 
 
119
void cairo_dock_set_perspective_view_for_icon (Icon *pIcon, CairoContainer *pContainer);
 
120
 
 
121
/** Set an orthogonal view to the current GL context to fit a given ontainer. 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.
 
122
*@param pContainer the container
 
123
*/
 
124
void cairo_dock_set_ortho_view (CairoContainer *pContainer);
 
125
 
 
126
void cairo_dock_set_ortho_view_for_icon (Icon *pIcon, CairoContainer *pContainer);
 
127
 
 
128
 
 
129
/** Apply the desktop background onto a container, to emulate fake transparency.
 
130
*@param pContainer the container
 
131
*/
 
132
void cairo_dock_apply_desktop_background_opengl (CairoContainer *pContainer);
 
133
 
 
134
/** Set a shared default-initialized GL context on a window.
 
135
*@param pWindow the window, not yet realized.
 
136
*/
 
137
void cairo_dock_set_gl_capabilities (GtkWidget *pWindow);
 
138
 
 
139
 
 
140
#endif