73= {{ 10, 30, 45, 50, 45, 30, 10 },
74 { 30, 65, 85, 100, 85, 65, 30 },
75 { 45, 85, 200, 256, 200, 85, 45 },
76 { 50, 100, 256, 256, 256, 100, 50 },
77 { 45, 85, 200, 256, 200, 85, 45 },
78 { 30, 65, 85, 100, 85, 65, 30 },
79 { 10, 30, 45, 50, 45, 30, 10 }};
191 new_string = g_malloc0 (
sizeof*new_string);
192 if (! new_string)
return NULL;
194 int csize = cwidth * cheight;
198 if (! rawbitmap)
return NULL;
201 for (j = 0; j < cheight; j++)
203 for (i = 0; i < cwidth; i++)
205 x = (GLubyte)(pixels [n])/255.0;
207 rawbitmap[n] = (int)(255.0 *
y);
214 if (! neighborhood)
return NULL;
216 for (i = 0; i < cheight; i++)
218 for (j = 0; j < cwidth; j++)
227 if (fi >= 0 && fi < cheight && fj >= 0 && fj < cwidth)
229 fn = fj + fi * cwidth;
230 neighborhood[fn] =
max (neighborhood[fn],
241 GLubyte * channels[2];
244 channels[i] = g_malloc (csize*
sizeof*channels[i]);
245 if (! channels[i])
return NULL;
248 for (n = 0; n < csize; n++)
250 channels[1][n] = (GLubyte)rawbitmap[n];
251 i = (neighborhood[n] >> 8) + rawbitmap[n];
256 channels[0][n] = (GLubyte)i;
259 g_free (neighborhood);
261 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
278 glTexParameteri (
ogl_texture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
279 glTexParameteri (
ogl_texture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
301 PangoRectangle prect;
308 pango_layout_get_extents (
layout, NULL, & prect);
309 if (prect.width == 0 || prect.height == 0)
return NULL;
310 cheight = bitmap.rows = PANGO_PIXELS (prect.height) + 2*
OUTLINE_WIDTH;
311 cwidth = bitmap.width = PANGO_PIXELS (prect.width) + 2*
OUTLINE_WIDTH;
313 normalize_text_size (
ogl_texture, & cwidth, & cheight);
315 bitmap.pitch = cwidth;
316 csize = cheight*cwidth;
317 bitmap.buffer = g_malloc (csize);
318 memset (bitmap.buffer, 0, csize);
320 bitmap.num_grays = 256;
321 bitmap.pixel_mode = ft_pixel_mode_grays;
323 pixels =
paint_bitmap (vec4(1.0,0.0,0.0,0.0), 1.0, cwidth, cheight, bitmap.buffer);
324 if (!
plot -> labels_render[
id])
326 new_string = g_malloc0 (
sizeof*new_string);
327 new_string -> texture = -1;
328 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
329 glGenTextures (1, & new_string -> texture);
330 if (! new_string -> texture)
return NULL;
331 glBindTexture (
ogl_texture, new_string -> texture);
342 glTexParameteri (
ogl_texture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
343 glTexParameteri (
ogl_texture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
356 new_string -> num_vertices = 4;
359 float x = (float) cwidth;
360 float y = (float) cheight;
361 float twidth = (
ogl_texture == GL_TEXTURE_2D) ? 1.0 :
x;
362 float theight = (
ogl_texture == GL_TEXTURE_2D) ? 1.0 :
y;
364 new_string -> vertices[0] = -
x;
365 new_string -> vertices[1] =
y;
366 new_string -> vertices[2] = 0.0;
367 new_string -> vertices[3] = theight;
369 new_string -> vertices[4] = -
x;
370 new_string -> vertices[5] = -
y;
371 new_string -> vertices[6] = 0.0;
372 new_string -> vertices[7] = 0.0;
374 new_string -> vertices[8] =
x;
375 new_string -> vertices[9] =
y;
376 new_string -> vertices[10] = twidth;
377 new_string -> vertices[11] = theight;
379 new_string -> vertices[12] =
x;
380 new_string -> vertices[13] = -
y;
381 new_string -> vertices[14] = twidth;
382 new_string -> vertices[15] = 0.0;
384 new_string -> num_instances = this_string -> num_instances;
385 int i = (this_string -> type == 3) ? 1 : (this_string -> type == 4) ? 3 : 4;
386 new_string -> inst_buffer_size = 3*i;
387 new_string -> instances =
duplicate_float (this_string -> num_instances*3*i, this_string -> instances);
423 PangoContext * pcontext;
424 PangoLayout * playout;
425 PangoFontDescription * pfont;
427 int arr_size = (this_string -> type == 4) ? 5 : (this_string -> type == 5) ? 6 : this_string -> type;
430 pcontext = pango_font_map_create_context (pango_ft2_font_map_new ());
431 playout = pango_layout_new (pcontext);
432 pango_layout_set_alignment (playout, PANGO_ALIGN_CENTER);
433 pfont = pango_font_description_from_string (
plot -> labels_font[
id]);
434 j = pango_font_description_get_size (pfont);
435 font_size = j / PANGO_SCALE;
441 l = (
wingl -> pixels[0] >
wingl -> pixels[1]) ? 1 : 0;
444 pango_font_description_set_absolute_size (pfont, font_size*PANGO_SCALE);
445 pango_layout_set_font_description (playout, pfont);
446 pango_layout_set_text (playout, this_string -> word, strlen(this_string -> word));
448 if (string_to_render == NULL)
450 g_warning (
"TEXT_RENDER:: For some reason it is impossible to render");
451 g_warning (
"TEXT_RENDER:: this string: '%s', using this font: %s", this_string -> word,
plot -> labels_font[
id]);
455 for (k=0; k<3; k++) string_to_render ->
shift[k] = this_string ->
shift[k];
456 string_to_render ->
shift[3] = (float)
plot -> labels_position[
id];
457 string_to_render -> quality = this_string -> type;
458 j = this_string -> id;
459 j *= (
plot -> labels_render[id] + 1);
460 if (
id == 1 &&
plot -> labels_list[0] != NULL)
462 j += (
plot -> labels_render[0] + 1) * (
plot -> labels_list[0] -> last ->
id + 1);
468 else if (
id == 3 ||
id == 4)
472 if (!
plot -> labels_render[
id])
477 NULL,
string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
482 NULL,
string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
492 NULL,
string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
496 NULL,
string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
503 NULL,
string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
507 NULL,
string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
511 g_free (string_to_render);
513 pango_font_description_free (pfont);
514 g_object_unref (G_OBJECT(pcontext));
515 g_object_unref (G_OBJECT(playout));
glsl_program * init_shader_program(int object, int object_id, const GLchar *vertex, const GLchar *geometry, const GLchar *fragment, GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d *obj)
create an OpenGL shader program
screen_string * was_not_rendered_already(char *word, screen_string *list)
check if a string was not already rendered and the corresponding screen string created
#define GL_TEXTURE_WRAP_R
void prepare_string(char *text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom *at, atom *bt, atom *ct)
prepare a screen string to be rendered
ColRGBA * opposite_color(ColRGBA col)
compute the opposite color
void add_string(char *text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom *at, atom *bt, atom *ct)
Add a screen string to the list of screen string to render.
const int OUTLINE_BRUSH[2 *OUTLINE_WIDTH+1][2 *OUTLINE_WIDTH+1]
void debug_string(screen_string *this_string)
debug screen string data
void add_string_instance(screen_string *string, vec3_t pos, atom *at, atom *bt, atom *ct)
add an instance to a screen string
object_3d * gl_pango_render_layout(PangoLayout *layout, GLenum texture, int id, screen_string *this_string)
OpenGL 3D pango layout object rendering.
object_3d * create_string_texture(int cwidth, int cheight, int *pixels)
OpenGL 3D string object rendering.
void render_all_strings(int glsl, int id)
render all string to be rendered for a label list
int * paint_bitmap(vec4_t color, GLfloat a, int cw, int ch, unsigned char *buff)
paint bitmap data using color
void update_string_instances(glsl_program *glsl, object_3d *obj)
Update OpenGL string texture instances.
void render_string(int glsl, int id, screen_string *this_string)
render a screen string