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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne, Matthieu Baerts (matttbe), Julien Lavergne
  • Date: 2009-10-04 16:33:52 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20091004163352-ttbbjfmpb8uzl8j4
Tags: 2.0.9-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New Upstream Version. (LP: #435587)
* Added apport hook in debian/apport
 - Add debian/apport
 - debian/cairo-dock-core.install: Added debian/apport/cairo-dock.py
* Use .desktop provided by upstream
 - Removed debian/*.desktop
 - debian/cairo-dock-core.install: install upstream desktop files. 

[ Julien Lavergne ]
* Adjust debian/changelog with Daniel Holbach suggestions.
* debian/patches/01_rename_cairo-dock-package-theme.patch: drop, 
  merged upstream.
* debian/patches/01-desktop-file-category.patch:
 - Remove Encoding field and set category to Utility.
* debian/patches/02-merge-changelog.patch:
 - Merge ChangeLog and ChangeLog-2.0.9.
* debian/apport: Remove commands with grep, python doesn't like it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
* Draw in OpenGL headers for Cairo-Dock
 
2
* This file is a part of the Cairo-Dock project
3
3
*
4
 
* Copyright : (C) 2009 by Fabrice Rey
5
 
* E-mail    : fabounet@users.berlios.de
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
6
6
*
7
7
* This program is free software; you can redistribute it and/or
8
8
* modify it under the terms of the GNU General Public License
13
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
15
* GNU General Public License for more details.
16
 
*   http://www.gnu.org/licenses/licenses.html#GPL
 
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/>.
17
18
*/
18
19
 
 
20
 
19
21
#ifndef __CAIRO_DOCK_DRAW_OPENGL__
20
22
#define  __CAIRO_DOCK_DRAW_OPENGL__
21
23
 
30
32
 
31
33
G_BEGIN_DECLS
32
34
 
 
35
/**
 
36
*@file cairo-dock-draw-opengl.h This class provides some useful functions to draw with OpenGL.
 
37
*/
33
38
 
34
39
void cairo_dock_set_icon_scale (Icon *pIcon, CairoContainer *pContainer, double fZoomFactor);
35
40
 
36
41
gboolean cairo_dock_render_icon_notification (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bHasBeenRendered, cairo_t *pCairoContext);
37
42
 
 
43
/** Draw an icon, according to its current parameters : position, transparency, reflect, rotation, stretching. Also draws its indicators, label, and quick-info. It generates a CAIRO_DOCK_RENDER_ICON notification.
 
44
*@param icon the icon to draw.
 
45
*@param pDock the dock containing the icon.
 
46
*@param fDockMagnitude current magnitude of the dock.
 
47
*@param bUseText TRUE to draw the labels.
 
48
*/
38
49
void cairo_dock_render_one_icon_opengl (Icon *icon, CairoDock *pDock, double fDockMagnitude, gboolean bUseText);
39
50
 
40
51
void cairo_dock_render_hidden_dock_opengl (CairoDock *pDock);
41
52
 
42
 
////////////////////
43
 
/// LOAD TEXTURE ///
44
 
////////////////////
 
53
  //////////////////
 
54
 // LOAD TEXTURE //
 
55
//////////////////
 
56
/** Load a cairo surface into an OpenGL texture. The surface can be destroyed after that if you don't need it. The texture will have the same size as the surface.
 
57
*@param pImageSurface the surface, created with one of the 'cairo_dock_create_surface_xxx' functions.
 
58
*@return the newly allocated texture, to be destroyed with _cairo_dock_delete_texture.
 
59
*/
45
60
GLuint cairo_dock_create_texture_from_surface (cairo_surface_t *pImageSurface);
46
61
 
 
62
/** Load a pixels buffer representing an image into an OpenGL texture.
 
63
*@param pTextureRaw a buffer of pixels.
 
64
*@param iWidth width of the image.
 
65
*@param iHeight height of the image.
 
66
*@return the newly allocated texture, to be destroyed with _cairo_dock_delete_texture.
 
67
*/
47
68
GLuint cairo_dock_load_texture_from_raw_data (const guchar *pTextureRaw, int iWidth, int iHeight);
48
69
 
 
70
/** Load an image on the dick into an OpenGL texture. The texture will have the same size as the image. The size is given as an output, if you need it for some reason.
 
71
*@param cImagePath path to an image.
 
72
*@param fImageWidth pointer that will be filled with the width of the image.
 
73
*@param fImageHeight pointer that will be filled with the height of the image.
 
74
*@return the newly allocated texture, to be destroyed with _cairo_dock_delete_texture.
 
75
*/
49
76
GLuint cairo_dock_create_texture_from_image_full (const gchar *cImagePath, double *fImageWidth, double *fImageHeight);
 
77
 
 
78
/** Load an image on the dick into an OpenGL texture. The texture will have the same size as the image.
 
79
*@param cImagePath path to an image.
 
80
*@return the newly allocated texture, to be destroyed with _cairo_dock_delete_texture.
 
81
*/
50
82
#define cairo_dock_create_texture_from_image(cImagePath) cairo_dock_create_texture_from_image_full (cImagePath, NULL, NULL)
51
83
 
52
 
GLuint cairo_dock_load_local_texture (const gchar *cImageName, const gchar *cDirPath);
53
 
 
 
84
/** Delete an OpenGL texture from the Graphic Card.
 
85
*@param iTexture variable containing the ID of a texture.
 
86
*/
54
87
#define _cairo_dock_delete_texture(iTexture) glDeleteTextures (1, &iTexture)
55
88
 
56
 
 
 
89
/** Update the icon's texture with its current cairo surface. This allows you to draw an icon with libcairo, and just copy the result to the OpenGL texture to be able to draw the icon in OpenGL too.
 
90
*@param pIcon the icon.
 
91
*/
57
92
void cairo_dock_update_icon_texture (Icon *pIcon);
 
93
/** Update the icon's label texture with its current label surface.
 
94
*@param pIcon the icon.
 
95
*/
58
96
void cairo_dock_update_label_texture (Icon *pIcon);
 
97
/** Update the icon's quick-info texture with its current quick-info surface.
 
98
*@param pIcon the icon.
 
99
*/
59
100
void cairo_dock_update_quick_info_texture (Icon *pIcon);
60
101
 
61
 
////////////////////
62
 
/// DRAW TEXTURE ///
63
 
////////////////////
 
102
  //////////////////
 
103
 // DRAW TEXTURE //
 
104
//////////////////
 
105
/** Enable texture drawing.
 
106
*/
64
107
#define _cairo_dock_enable_texture(...) do { \
65
108
        glEnable (GL_BLEND);\
66
109
        glEnable (GL_TEXTURE_2D);\
67
110
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\
68
 
        glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);\
69
111
        glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);\
70
112
        glEnable (GL_LINE_SMOOTH);\
71
113
        glPolygonMode (GL_FRONT, GL_FILL); } while (0)
72
114
 
 
115
/** Disable texture drawing.
 
116
*/
73
117
#define _cairo_dock_disable_texture(...) do { \
74
118
        glDisable (GL_TEXTURE_2D);\
75
119
        glDisable (GL_LINE_SMOOTH);\
76
120
        glDisable (GL_BLEND); } while (0)
77
121
 
 
122
/** Set the alpha channel to a current value, other channels are set to 1.
 
123
*@param fAlpha 
 
124
*/
78
125
#define _cairo_dock_set_alpha(fAlpha) glColor4f (1., 1., 1., fAlpha)
79
126
 
 
127
/** Set the color blending to overwrite.
 
128
*/
80
129
#define _cairo_dock_set_blend_source(...) glBlendFunc (GL_ONE, GL_ZERO)
81
130
 
 
131
/** Set the color blending to mix, for premultiplied texture.
 
132
*/
82
133
#define _cairo_dock_set_blend_alpha(...) glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
83
134
 
 
135
/** Set the color blending to mix.
 
136
*/
84
137
#define _cairo_dock_set_blend_over(...) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
85
138
 
 
139
/** Set the color blending to mix on a pbuffer.
 
140
*/
86
141
#define _cairo_dock_set_blend_pbuffer(...) glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
87
142
 
88
143
#define _cairo_dock_apply_current_texture_at_size(w, h) do { \
107
162
        glTexCoord2f(u, v+dv); glVertex3f(x-.5*w, y-.5*h, 0.);\
108
163
        glEnd(); } while (0)
109
164
 
110
 
 
 
165
/** Draw a texture centered on the current point, at a given size.
 
166
*@param iTexture the texture
 
167
*@param w width
 
168
*@param h height
 
169
*/
111
170
#define _cairo_dock_apply_texture_at_size(iTexture, w, h) do { \
112
171
        glBindTexture (GL_TEXTURE_2D, iTexture);\
113
172
        _cairo_dock_apply_current_texture_at_size (w, h); } while (0)
114
173
 
 
174
/** Apply a texture centered on the current point and at the given scale.
 
175
*@param iTexture the texture
 
176
*/
115
177
#define _cairo_dock_apply_texture(iTexture) _cairo_dock_apply_texture_at_size (iTexture, 1, 1)
116
178
 
 
179
/** Draw a texture centered on the current point, at a given size, and with a given transparency.
 
180
*@param iTexture the texture
 
181
*@param w width
 
182
*@param h height
 
183
*@param fAlpha the transparency, between 0 and 1.
 
184
*/
117
185
#define _cairo_dock_apply_texture_at_size_with_alpha(iTexture, w, h, fAlpha) do { \
118
186
        _cairo_dock_set_alpha (fAlpha);\
119
187
        _cairo_dock_apply_texture_at_size (iTexture, w, h); } while (0)
120
188
 
121
 
void cairo_dock_apply_texture (GLuint iTexture);
122
 
void cairo_dock_apply_texture_at_size (GLuint iTexture, int iWidth, int iHeight);
 
189
#define cairo_dock_apply_texture _cairo_dock_apply_texture
 
190
#define cairo_dock_apply_texture_at_size _cairo_dock_apply_texture_at_size
123
191
void cairo_dock_draw_texture_with_alpha (GLuint iTexture, int iWidth, int iHeight, double fAlpha);
124
192
void cairo_dock_draw_texture (GLuint iTexture, int iWidth, int iHeight);
125
193
 
127
195
void cairo_dock_apply_icon_texture_at_current_size (Icon *pIcon, CairoContainer *pContainer);
128
196
void cairo_dock_draw_icon_texture (Icon *pIcon, CairoContainer *pContainer);
129
197
 
130
 
/////////////////
131
 
/// DRAW PATH ///
132
 
/////////////////
 
198
  ///////////////
 
199
 // DRAW PATH //
 
200
///////////////
133
201
#define _CAIRO_DOCK_PATH_DIM 2
134
202
#define _cairo_dock_define_static_vertex_tab(iNbVertices) static GLfloat pVertexTab[(iNbVertices) * _CAIRO_DOCK_PATH_DIM]
135
203
#define _cairo_dock_return_vertex_tab(...) return pVertexTab
146
214
 
147
215
void cairo_dock_draw_frame_background_opengl (GLuint iBackgroundTexture, double fDockWidth, double fFrameHeight, double fDockOffsetX, double fDockOffsetY, const GLfloat *pVertexTab, int iNbVertex, CairoDockTypeHorizontality bHorizontal, gboolean bDirectionUp, double fDecorationsOffsetX);
148
216
void cairo_dock_draw_current_path_opengl (double fLineWidth, double *fLineColor, int iNbVertex);
 
217
 
 
218
/** Draw a rectangle with rounded corners. The rectangle will be centered at the current point.
 
219
*@param fRadius radius if the corners.
 
220
*@param fLineWidth width of the line. If set to 0, the background will be filled with the provided color, otherwise the path will be stroke.
 
221
*@param fFrameWidth width of the rectangle, without the corners.
 
222
*@param fFrameHeight height of the rectangle, including the corners.
 
223
*@param fDockOffsetX translation on X before drawing the rectangle.
 
224
*@param fDockOffsetY translation on Y before drawing the rectangle.
 
225
*@param fLineColor color of the line if fLineWidth is non nul, or color of the background otherwise.
 
226
*/
149
227
void cairo_dock_draw_rounded_rectangle_opengl (double fRadius, double fLineWidth, double fFrameWidth, double fFrameHeight, double fDockOffsetX, double fDockOffsetY, double *fLineColor);
150
228
 
151
229
GLfloat *cairo_dock_generate_string_path_opengl (CairoDock *pDock, gboolean bIsLoop, gboolean bForceConstantSeparator, int *iNbPoints);
152
230
void cairo_dock_draw_string_opengl (CairoDock *pDock, double fStringLineWidth, gboolean bIsLoop, gboolean bForceConstantSeparator);
153
231
 
154
232
 
155
 
  /////////////////////////
156
 
 /// RENDER TO TEXTURE ///
157
 
/////////////////////////
 
233
  ///////////////////////
 
234
 // RENDER TO TEXTURE //
 
235
///////////////////////
158
236
GLXPbuffer cairo_dock_create_pbuffer (int iWidth, int iHeight, GLXContext *pContext);
159
237
void cairo_dock_create_icon_pbuffer (void);
160
238
void cairo_dock_destroy_icon_pbuffer (void);
 
239
 
 
240
/** Initiate an OpenGL drawing session on an icon's texture.
 
241
*@param pIcon the icon on which to draw.
 
242
*@param pContainer its container.
 
243
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
 
244
*/
161
245
gboolean cairo_dock_begin_draw_icon (Icon *pIcon, CairoContainer *pContainer);
 
246
/** Finish an OpenGL drawing session on an icon.
 
247
*@param pIcon the icon on which to draw.
 
248
*@param pContainer its container.
 
249
*@return TRUE if you can proceed to the drawing, FALSE if an error occured.
 
250
*/
162
251
void cairo_dock_end_draw_icon (Icon *pIcon, CairoContainer *pContainer);
163
252
 
164
253
 
165
 
  ///////////////
166
 
 /// CONTEXT ///
167
 
///////////////
 
254
  /////////////
 
255
 // CONTEXT //
 
256
/////////////
 
257
/** 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.
 
258
*@param iWidth width of the container
 
259
*@param iHeight height of the container
 
260
*/
168
261
void cairo_dock_set_perspective_view (int iWidth, int iHeight);
 
262
/** 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.
 
263
*@param iWidth width of the container
 
264
*@param iHeight height of the container
 
265
*/
169
266
void cairo_dock_set_ortho_view (int iWidth, int iHeight);
170
267
 
171
268
GdkGLConfig *cairo_dock_get_opengl_config (gboolean bForceOpenGL, gboolean *bHasBeenForced);