~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • 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_FONT__
 
22
#define  __CAIRO_DOCK_OPENGL_FONT__
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include <gdk/x11/gdkglx.h>
 
27
#include <gtk/gtkgl.h>
 
28
#include <GL/glu.h>
 
29
 
 
30
#include "cairo-dock-struct.h"
 
31
 
 
32
G_BEGIN_DECLS
 
33
 
 
34
/**
 
35
*@file cairo-dock-opengl-font.h This class provides different ways to draw text directly in OpenGL.
 
36
* \ref cairo_dock_create_texture_from_text_simple lets you draw any text in any font, by creating a texture from a Pango font description. This is a convenient function but not very fast.
 
37
* For a more efficient way, you load a font into a CairoDockGLFont with either :
 
38
* \ref cairo_dock_load_bitmap_font to load a subset of any font into bitmaps (bitmaps are not influenced by the transformation matrix)
 
39
* \ref cairo_dock_load_textured_font to load a subset of a Mono font into textures.
 
40
* You then use \ref cairo_dock_draw_gl_text_at_position to draw the text.
 
41
*/
 
42
 
 
43
/** Create a texture from a text. The text is drawn in white, so that you can later colorize it with a mere glColor.
 
44
*@param cText the text
 
45
*@param cFontDescription a description of the font, for instance "Monospace Bold 12"
 
46
*@param pSourceContext a cairo context, not altered by the function.
 
47
*@param iWidth a pointer that will be filled with the width of the texture.
 
48
*@param iHeight a pointer that will be filled with the height of the texture.
 
49
*@return a newly allocated texture.
 
50
*/
 
51
GLuint cairo_dock_create_texture_from_text_simple (const gchar *cText, const gchar *cFontDescription, cairo_t* pSourceContext, int *iWidth, int *iHeight);
 
52
 
 
53
/// Structure used to load a font for OpenGL text rendering.
 
54
struct _CairoDockGLFont {
 
55
        GLuint iListBase;
 
56
        GLuint iTexture;
 
57
        gint iNbRows;
 
58
        gint iNbColumns;
 
59
        gint iCharBase;
 
60
        gint iNbChars;
 
61
        gdouble iCharWidth;
 
62
        gdouble iCharHeight;
 
63
};
 
64
 
 
65
/** Load a font into bitmaps. You can load any characters of font with this function. The drawback is that each character is a bitmap, that is to say you can't zoom them.
 
66
*@param cFontDescription a description of the font, for instance "Monospace Bold 12"
 
67
*@param first first character to load.
 
68
*@param count number of characters to load.
 
69
*@return a newly allocated opengl font.
 
70
*/
 
71
CairoDockGLFont *cairo_dock_load_bitmap_font (const gchar *cFontDescription, int first, int count);
 
72
 
 
73
/** Load a font into textures. You can then render your text like a normal texture (zoom, etc). The drawback is that only a mono font can be used with this function.
 
74
*@param cFontDescription a description of the font, for instance "Monospace Bold 12"
 
75
*@param first first character to load.
 
76
*@param count number of characters to load.
 
77
*@return a newly allocated opengl font.
 
78
*/
 
79
CairoDockGLFont *cairo_dock_load_textured_font (const gchar *cFontDescription, int first, int count);
 
80
 
 
81
/** Like the previous function, but loads the characters from an image. The image must be squared and contain the 256 extended ASCII characters in the alphabetic order.
 
82
*@param cImagePath path to the image.
 
83
*@return a newly allocated opengl font.
 
84
*/
 
85
CairoDockGLFont *cairo_dock_load_textured_font_from_image (const gchar *cImagePath);
 
86
 
 
87
/** Free an opengl font.
 
88
*@param pFont the font.
 
89
*/
 
90
void cairo_dock_free_gl_font (CairoDockGLFont *pFont);
 
91
 
 
92
/** Compute the size a text will take for a given font.
 
93
*@param cText the text
 
94
*@param pFont the font.
 
95
*@param iWidth a pointer that will be filled with the width of the text.
 
96
*@param iHeight a pointer that will be filled with the height of the text.
 
97
*/
 
98
void cairo_dock_get_gl_text_extent (const gchar *cText, CairoDockGLFont *pFont, int *iWidth, int *iHeight);
 
99
 
 
100
/** Render a text for a given font. In the case of a bitmap font, the current raster position is used. In the case of a texture font, the current model view is used.
 
101
*@param cText the text
 
102
*@param pFont the font.
 
103
*/
 
104
void cairo_dock_draw_gl_text (const guchar *cText, CairoDockGLFont *pFont);
 
105
 
 
106
/** Like /ref cairo_dock_draw_gl_text but at a given position.
 
107
*@param cText the text
 
108
*@param pFont the font.
 
109
*@param x x position of the left bottom corner of the text.
 
110
*@param y y position of the left bottom corner of the text.
 
111
*/
 
112
void cairo_dock_draw_gl_text_at_position (const guchar *cText, CairoDockGLFont *pFont, int x, int y);
 
113
 
 
114
/** Like /ref cairo_dock_draw_gl_text but resize the text so that it fits into a given area. Only works for a texture font.
 
115
*@param cText the text
 
116
*@param pFont the font.
 
117
*@param iWidth iWidth of the area.
 
118
*@param iHeight iHeight of the area
 
119
*@param bCentered whether the text is centered on the current position or not.
 
120
*/
 
121
void cairo_dock_draw_gl_text_in_area (const guchar *cText, CairoDockGLFont *pFont, int iWidth, int iHeight, gboolean bCentered);
 
122
 
 
123
/** Like /ref cairo_dock_draw_gl_text_in_area and /ref cairo_dock_draw_gl_text_at_position.
 
124
*@param cText the text
 
125
*@param pFont the font.
 
126
*@param x x position of the left bottom corner of the text.
 
127
*@param y y position of the left bottom corner of the text.
 
128
*@param iWidth iWidth of the area.
 
129
*@param iHeight iHeight of the area
 
130
*@param bCentered whether the text is centered on the given position or not.
 
131
*/
 
132
void cairo_dock_draw_gl_text_at_position_in_area (const guchar *cText, CairoDockGLFont *pFont, int x, int y, int iWidth, int iHeight, gboolean bCentered);
 
133
 
 
134
 
 
135
G_END_DECLS
 
136
#endif