36
*@file cairo-dock-draw-opengl.h This class provides some useful functions to draw with OpenGL.
34
39
void cairo_dock_set_icon_scale (Icon *pIcon, CairoContainer *pContainer, double fZoomFactor);
36
41
gboolean cairo_dock_render_icon_notification (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bHasBeenRendered, cairo_t *pCairoContext);
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.
38
49
void cairo_dock_render_one_icon_opengl (Icon *icon, CairoDock *pDock, double fDockMagnitude, gboolean bUseText);
40
51
void cairo_dock_render_hidden_dock_opengl (CairoDock *pDock);
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.
45
60
GLuint cairo_dock_create_texture_from_surface (cairo_surface_t *pImageSurface);
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.
47
68
GLuint cairo_dock_load_texture_from_raw_data (const guchar *pTextureRaw, int iWidth, int iHeight);
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.
49
76
GLuint cairo_dock_create_texture_from_image_full (const gchar *cImagePath, double *fImageWidth, double *fImageHeight);
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.
50
82
#define cairo_dock_create_texture_from_image(cImagePath) cairo_dock_create_texture_from_image_full (cImagePath, NULL, NULL)
52
GLuint cairo_dock_load_local_texture (const gchar *cImageName, const gchar *cDirPath);
84
/** Delete an OpenGL texture from the Graphic Card.
85
*@param iTexture variable containing the ID of a texture.
54
87
#define _cairo_dock_delete_texture(iTexture) glDeleteTextures (1, &iTexture)
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.
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.
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.
59
100
void cairo_dock_update_quick_info_texture (Icon *pIcon);
105
/** Enable texture drawing.
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)
115
/** Disable texture drawing.
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)
122
/** Set the alpha channel to a current value, other channels are set to 1.
78
125
#define _cairo_dock_set_alpha(fAlpha) glColor4f (1., 1., 1., fAlpha)
127
/** Set the color blending to overwrite.
80
129
#define _cairo_dock_set_blend_source(...) glBlendFunc (GL_ONE, GL_ZERO)
131
/** Set the color blending to mix, for premultiplied texture.
82
133
#define _cairo_dock_set_blend_alpha(...) glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
135
/** Set the color blending to mix.
84
137
#define _cairo_dock_set_blend_over(...) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
139
/** Set the color blending to mix on a pbuffer.
86
141
#define _cairo_dock_set_blend_pbuffer(...) glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
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)
165
/** Draw a texture centered on the current point, at a given size.
166
*@param iTexture the texture
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)
174
/** Apply a texture centered on the current point and at the given scale.
175
*@param iTexture the texture
115
177
#define _cairo_dock_apply_texture(iTexture) _cairo_dock_apply_texture_at_size (iTexture, 1, 1)
179
/** Draw a texture centered on the current point, at a given size, and with a given transparency.
180
*@param iTexture the texture
183
*@param fAlpha the transparency, between 0 and 1.
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)
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);
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);
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.
149
227
void cairo_dock_draw_rounded_rectangle_opengl (double fRadius, double fLineWidth, double fFrameWidth, double fFrameHeight, double fDockOffsetX, double fDockOffsetY, double *fLineColor);
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);
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);
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.
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.
162
251
void cairo_dock_end_draw_icon (Icon *pIcon, CairoContainer *pContainer);
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
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
169
266
void cairo_dock_set_ortho_view (int iWidth, int iHeight);
171
268
GdkGLConfig *cairo_dock_get_opengl_config (gboolean bForceOpenGL, gboolean *bHasBeenForced);