atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
ogl_text.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'ogl_text.c'
24*
25* Contains:
26*
27
28 - The functions to prepare OpenGL rendering for text
29
30*
31* List of functions:
32
33 int * paint_bitmap (vec4_t color, GLfloat a, int cw, int ch, unsigned char * buff);
34
35 void render_string (int glsl, int id, screen_string * this_string);
36 void debug_string (screen_string * this_string);
37 void render_all_strings (int glsl, int id);
38 void add_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct);
39 void prepare_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct);
40
41 static void normalize_text_size (GLenum texture, int * width, int * height);
42
43 screen_string * was_not_rendered_already (char * word, screen_string * list);
44
45 ColRGBA * opposite_color (ColRGBA col);
46
47 object_3d * create_string_texture (int cwidth, int cheight, int * pixels);
48 object_3d * gl_pango_render_layout (PangoLayout * layout, GLenum texture, int id, screen_string * this_string);
49
50*/
51
52#include "global.h"
53#include "glview.h"
54
55#define PANGO_TEXT_SIZE 500
56#define OUTLINE_WIDTH 3
57
58#ifndef GL_CLAMP_TO_EDGE
59# define GL_CLAMP_TO_EDGE 0x812F
60#endif
61
62#ifndef GL_TEXTURE_WRAP_R
63# define GL_TEXTURE_WRAP_R 0x8072
64#endif
65
66extern int measures_drawing;
67extern int type_of_measure;
68extern void update_string_instances (glsl_program * glsl, object_3d * obj);
69
70GLuint textures_id[2];
71
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 }};
80
90static void normalize_text_size (GLenum texture, int * width, int * height)
91{
92 // if the texture target is GL_TEXTURE_2D, that means that
93 // the texture_rectangle OpenGL extension is unsupported and we must
94 // use only square, power-of-two textures.
95 if (texture == GL_TEXTURE_2D)
96 {
97 int x = max (* width, * height);
98 // find next power of two
99 int n;
100 for (n = 1; n < x; n = n << 1);
101 // the texture must be square, and its size must be a power of two.
102 * width = * height = n;
103 }
104}
105
117int * paint_bitmap (vec4_t color, GLfloat a, int cw, int ch, unsigned char * buff)
118{
119 int i;
120 guint8 * row, * row_end;
121 guint32 rgb;
122 guint32 * p;
123 int * bitmap;
124
125#if ! defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
126 rgb = ((guint32) (color.x* 255.0)) |
127 (((guint32) (color.y * 255.0)) << 8) |
128 (((guint32) (color.z * 255.0)) << 16);
129#else
130 rgb = (((guint32) (color.x * 255.0)) << 24) |
131 (((guint32) (color.y * 255.0)) << 16) |
132 (((guint32) (color.z * 255.0)) << 8);
133#endif
134 bitmap = allocint (cw * ch * 4);
135 p = (guint32 *) bitmap;
136 row = buff + cw*ch; /* past-the-end */
137 row_end = buff; /* beginning */
138 if (a == 1.0)
139 {
140 while (row != row_end)
141 {
142 row -= cw;
143 for (i = 0; i < cw; i++)
144 {
145#if ! defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
146 * p++ = rgb | (((guint32) row[i]) << 24);
147#else
148 * p++ = rgb | ((guint32) row[i]);
149#endif
150 }
151 }
152 }
153 else
154 {
155 while (row != row_end)
156 {
157 row -= cw;
158 for (i = 0; i < cw; i++)
159 {
160#if ! defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
161 * p++ = rgb | (((guint32) (a * row[i])) << 24);
162#else
163 * p++ = rgb | ((guint32) (a * row[i]));
164#endif
165 }
166 }
167 }
168
169 return bitmap;
170}
171
173
183object_3d * create_string_texture (int cwidth, int cheight, int * pixels)
184{
185 int i, j, n;
186 int di, dj;
187 int fi, fj, fn;
188 double x, y;
189 object_3d * new_string;
190
191 new_string = g_malloc0 (sizeof*new_string);
192 if (! new_string) return NULL;
193
194 int csize = cwidth * cheight;
195
196 int * rawbitmap;
197 rawbitmap = allocint(csize);
198 if (! rawbitmap) return NULL;
199
200 n = 0;
201 for (j = 0; j < cheight; j++)
202 {
203 for (i = 0; i < cwidth; i++)
204 {
205 x = (GLubyte)(pixels [n])/255.0;
206 y = pow(x, 0.75);
207 rawbitmap[n] = (int)(255.0 * y);
208 n++;
209 }
210 }
211
212 int * neighborhood;
213 neighborhood = allocint (csize);
214 if (! neighborhood) return NULL;
215
216 for (i = 0; i < cheight; i++)
217 {
218 for (j = 0; j < cwidth; j++)
219 {
220 n = j + i * cwidth;
221 for (di = -OUTLINE_WIDTH; di <= OUTLINE_WIDTH; di++)
222 {
223 for (dj = -OUTLINE_WIDTH; dj <= OUTLINE_WIDTH; dj++)
224 {
225 fi = i + di;
226 fj = j + dj;
227 if (fi >= 0 && fi < cheight && fj >= 0 && fj < cwidth)
228 {
229 fn = fj + fi * cwidth;
230 neighborhood[fn] = max (neighborhood[fn],
231 rawbitmap[n]
233 [OUTLINE_WIDTH + dj]);
234 }
235 }
236 }
237 }
238 }
239
240 // Two channels, for the outline and the glyph
241 GLubyte * channels[2];
242 for (i=0; i<2; i++)
243 {
244 channels[i] = g_malloc (csize*sizeof*channels[i]);
245 if (! channels[i]) return NULL;
246 }
247
248 for (n = 0; n < csize; n++)
249 {
250 channels[1][n] = (GLubyte)rawbitmap[n];
251 i = (neighborhood[n] >> 8) + rawbitmap[n];
252 if (i > 255)
253 {
254 i = 255;
255 }
256 channels[0][n] = (GLubyte)i;
257 }
258
259 g_free (neighborhood);
260
261 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
262
263 for (i=0; i<2; i++)
264 {
265 glGenTextures (1, & textures_id[i]);
266 if (! textures_id[i]) return NULL;
267 glBindTexture (ogl_texture, textures_id[i]);
268 glTexImage2D (ogl_texture,
269 0,
270 GL_RED,
271 cwidth,
272 cheight,
273 0,
274 GL_RED,
275 GL_UNSIGNED_BYTE,
276 channels[i]);
277
278 glTexParameteri (ogl_texture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
279 glTexParameteri (ogl_texture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
280 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
281 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
283 glBindTexture (ogl_texture, 0);
284 }
285 return new_string;
286}
287
298object_3d * gl_pango_render_layout (PangoLayout * layout, GLenum texture, int id, screen_string * this_string)
299{
300 FT_Bitmap bitmap;
301 PangoRectangle prect;
302 object_3d * new_string;
303
304 int * pixels;
305 int cwidth, cheight;
306 int csize;
307
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;
312
313 normalize_text_size (ogl_texture, & cwidth, & cheight);
314
315 bitmap.pitch = cwidth;
316 csize = cheight*cwidth;
317 bitmap.buffer = g_malloc (csize);
318 memset (bitmap.buffer, 0, csize);
319
320 bitmap.num_grays = 256;
321 bitmap.pixel_mode = ft_pixel_mode_grays;
322 pango_ft2_render_layout (& bitmap, layout, PANGO_PIXELS (-prect.x)+OUTLINE_WIDTH, OUTLINE_WIDTH);
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])
325 {
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);
332 glTexImage2D (ogl_texture,
333 0,
334 GL_RGBA,
335 cwidth,
336 cheight,
337 0,
338 GL_RGBA,
339 GL_UNSIGNED_BYTE,
340 pixels);
341
342 glTexParameteri (ogl_texture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
343 glTexParameteri (ogl_texture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
344 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
345 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
347 glBindTexture (ogl_texture, 0);
348 }
349 else
350 {
351 new_string = create_string_texture (cwidth, cheight, pixels);
352 }
353
354 g_free (pixels);
355
356 new_string -> num_vertices = 4;
357 new_string -> vert_buffer_size = CHAR_BUFF_SIZE;
358 new_string -> vertices = allocfloat (new_string -> num_vertices*CHAR_BUFF_SIZE);
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;
363 // 0
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;
368 // 1
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;
373 // 2
374 new_string -> vertices[8] = x;
375 new_string -> vertices[9] = y;
376 new_string -> vertices[10] = twidth;
377 new_string -> vertices[11] = theight;
378 // 3
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;
383
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);
388
389 return new_string;
390}
391
400{
401 ColRGBA * ocol = g_malloc0 (sizeof*ocol);
402 ocol -> red = (1.0-col.red)/2.5;
403 ocol -> green = (1.0-col.green)/2.5;
404 ocol -> blue = (1.0-col.blue)/2.5;
405 ocol -> alpha = 1.0;
406 return ocol;
407}
408
418void render_string (int glsl, int id, screen_string * this_string)
419{
420 int j, k, l;
421 double font_size;
422 // Pango elements for labels
423 PangoContext * pcontext;
424 PangoLayout * playout;
425 PangoFontDescription * pfont;
426 object_3d * string_to_render = NULL;
427 int arr_size = (this_string -> type == 4) ? 5 : (this_string -> type == 5) ? 6 : this_string -> type;
428
429 //pcontext = pango_ft2_get_context (PANGO_TEXT_SIZE, PANGO_TEXT_SIZE);
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;
436
437 //g_debug ("Zoom = %f, gnear= %f, p_moy= %f, p_depth= %f", plot -> zoom, plot -> gnear, wingl -> p_moy, plot -> p_depth);
438 if (plot -> labels_scale[id]) font_size *= ((ZOOM/plot -> zoom)*(plot -> gnear/6.0)*(wingl -> p_moy/plot -> p_depth));
440 {
441 l = (wingl -> pixels[0] > wingl -> pixels[1]) ? 1 : 0;
442 font_size *= ((float)wingl -> pixels[l]/(float)tmp_pixels[l]);
443 }
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));
447 string_to_render = gl_pango_render_layout (playout, ogl_texture, id, this_string);
448 if (string_to_render == NULL)
449 {
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]);
452 }
453 else
454 {
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)
461 {
462 j += (plot -> labels_render[0] + 1) * (plot -> labels_list[0] -> last -> id + 1);
463 }
464 if (id == 2)
465 {
466 j += (plot -> box_axis[AXIS] == WIREFRAME) ? 2 : 4;
467 }
468 else if (id == 3 || id == 4)
469 {
470 j += measures_drawing;
471 }
472 if (! plot -> labels_render[id])
473 {
475 {
476 wingl -> ogl_glsl[glsl][0][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
477 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
478 }
479 else
480 {
481 wingl -> ogl_glsl[glsl][0][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
482 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
483 }
484 wingl -> ogl_glsl[glsl][0][j] -> col = duplicate_color(1, & (this_string -> col));
485 }
486 else
487 {
489 {
490 string_to_render -> texture = textures_id[0];
491 wingl -> ogl_glsl[glsl][0][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
492 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
493 wingl -> ogl_glsl[glsl][0][j] -> col = opposite_color(this_string -> col);
494 string_to_render -> texture = textures_id[1];
495 wingl -> ogl_glsl[glsl][0][j+1] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
496 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
497 wingl -> ogl_glsl[glsl][0][j+1] -> col = duplicate_color(1, & (this_string -> col));
498 }
499 else
500 {
501 string_to_render -> texture = textures_id[0];
502 wingl -> ogl_glsl[glsl][0][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
503 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
504 wingl -> ogl_glsl[glsl][0][j] -> col = opposite_color(this_string -> col);
505 string_to_render -> texture = textures_id[1];
506 wingl -> ogl_glsl[glsl][0][j+1] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
507 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
508 wingl -> ogl_glsl[glsl][0][j+1] -> col = duplicate_color(1, & (this_string -> col));
509 }
510 }
511 g_free (string_to_render);
512 }
513 pango_font_description_free (pfont);
514 g_object_unref (G_OBJECT(pcontext));
515 g_object_unref (G_OBJECT(playout));
516}
517
525void debug_string (screen_string * this_string)
526{
527 g_debug ("STRING:: id= %d, text:: %s", this_string -> id, this_string -> word);
528 g_debug ("STRING:: color:: r= %f, g= %f, b= %f, a= %f",
529 this_string -> col.red, this_string -> col.green, this_string -> col.blue, this_string -> col.alpha);
530 int i, j;
531 j = 0;
532 for (i=0; i<this_string -> num_instances; i++, j+=3)
533 {
534 g_debug ("STRING:: %d-th :: pos[%d][x]= %f, pos[%d][y]= %f, pos[%d][z]= %f, theta[%d]= %f",
535 i, i, this_string -> instances[j], i, this_string -> instances[j+1], i, this_string -> instances[j+2], i, this_string -> instances[j+2]);
536 }
537 g_debug ("STRING:: shift:: x= %f, y= %f, z= %f", this_string -> shift[0], this_string -> shift[1], this_string -> shift[2]);
538 g_debug ("STRING:: show :: %f", this_string -> shift[3]);
539}
540
549void render_all_strings (int glsl, int id)
550{
551 if (plot -> labels_list[id] != NULL)
552 {
553 screen_string * this_string = plot -> labels_list[id] -> last;
554 while (this_string != NULL)
555 {
556 //if (glsl == MEASU) debug_string (this_string);
557 render_string (glsl, id, this_string);
558 this_string = this_string -> prev;
559 }
560 }
561}
562
572{
573 if (list != NULL)
574 {
575 screen_string * tmp_string = list -> last;
576 while (tmp_string != NULL)
577 {
578 if (g_strcmp0 (tmp_string -> word, word) == 0)
579 {
580 return tmp_string;
581 }
582 tmp_string = tmp_string -> prev;
583 }
584 tmp_string = NULL;
585 g_free (tmp_string);
586 }
587 return NULL;
588}
589
601void add_string_instance (screen_string * string, vec3_t pos, atom * at, atom * bt, atom * ct)
602{
603 int i, j;
604 i = 0;
605 j = (string -> type == 3) ? 1 : (type_of_measure == 6) ? 3 : 4;
606 if (string -> num_instances > 0)
607 {
608 float * instances = duplicate_float (3*j*string -> num_instances, string -> instances);
609 g_free (string -> instances);
610 string -> instances = allocfloat (3*j*(string -> num_instances+1));
611 for (i=0; i<3*j*string -> num_instances; i++)
612 {
613 string -> instances[i] = instances[i];
614 }
615 }
616 else
617 {
618 string -> instances = allocfloat (3*j);
619 }
620 string -> num_instances ++;
621 string -> instances[i] = pos.x;
622 string -> instances[i+1] = pos.y;
623 string -> instances[i+2] = pos.z;
624 if (j > 1)
625 {
626 string -> instances[i+3] = at -> x;
627 string -> instances[i+4] = at -> y;
628 string -> instances[i+5] = at -> z;
629 string -> instances[i+6] = bt -> x;
630 string -> instances[i+7] = bt -> y;
631 string -> instances[i+8] = bt -> z;
632 if (j == 4)
633 {
634 string -> instances[i+9] = ct -> x;
635 string -> instances[i+10] = ct -> y;
636 string -> instances[i+11] = ct -> z;
637 }
638 }
639}
640
655void add_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct)
656{
657 if (plot -> labels_list[id] == NULL)
658 {
659 plot -> labels_list[id] = g_malloc0 (sizeof*plot -> labels_list[id]);
660 plot -> labels_list[id] -> last = plot -> labels_list[id];
661 }
662 else
663 {
664 screen_string * s_tring = g_malloc0 (sizeof*s_tring);
665 s_tring -> prev = plot -> labels_list[id] -> last;
666 s_tring -> id = plot -> labels_list[id] -> last -> id + 1;
667 plot -> labels_list[id] -> last = s_tring;
668 }
669 plot -> labels_list[id] -> last -> word = g_strdup_printf ("%s", text);
670 plot -> labels_list[id] -> last -> col = col;
671 plot -> labels_list[id] -> last -> type = (id < 3) ? 3 : (type_of_measure == 6) ? 4 : 5;
672 int i;
673 for (i=0; i<3; i++) plot -> labels_list[id] -> last -> shift[i] = lshift[i];
674 add_string_instance (plot -> labels_list[id] -> last, pos, at, bt, ct);
675}
676
691void prepare_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct)
692{
693 screen_string * this_string = was_not_rendered_already (text, plot -> labels_list[id]);
694 if (this_string == NULL)
695 {
696 add_string (text, id, col, pos, lshift, at, bt, ct);
697 }
698 else
699 {
700 add_string_instance (this_string, pos, at, bt, ct);
701 }
702}
PangoLayout * layout
Definition curve.c:79
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
gchar * text
Definition datab.c:105
GtkTreeIter row
Definition datab.c:104
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:592
gboolean in_movie_encoding
Definition global.c:180
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
int tmp_pixels[2]
Definition global.c:173
Global variable declarations Global convenience function declarations Global data structure defin...
ColRGBA * duplicate_color(int num, ColRGBA *col)
duplicate a ColRGBA pointer
Definition gtk-misc.c:1602
#define max(a, b)
Definition global.h:80
GLenum ogl_texture
Definition glview.c:114
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1006
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:66
glwin * wingl
Definition ogl_draw.c:59
#define ZOOM
Default value for the OpenGL zoom.
Definition glview.h:115
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
@ WIREFRAME
Definition glview.h:174
#define AXIS
Definition glwin.h:55
#define GL_TEXTURE_RECTANGLE_ARB
Definition glwin.h:51
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
const GLchar * string_color_2d
const GLchar * string_vertex
const GLchar * string_color
const GLchar * degree_vertex
const GLchar * angstrom_vertex
#define CHAR_BUFF_SIZE
Definition ogl_shading.h:53
@ GLSL_STRING
Definition ogl_shading.h:44
gboolean render_format
Definition ogl_text.c:172
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
Definition ogl_text.c:571
#define GL_TEXTURE_WRAP_R
Definition ogl_text.c:63
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
Definition ogl_text.c:691
#define OUTLINE_WIDTH
Definition ogl_text.c:56
ColRGBA * opposite_color(ColRGBA col)
compute the opposite color
Definition ogl_text.c:399
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.
Definition ogl_text.c:655
const int OUTLINE_BRUSH[2 *OUTLINE_WIDTH+1][2 *OUTLINE_WIDTH+1]
Definition ogl_text.c:73
void debug_string(screen_string *this_string)
debug screen string data
Definition ogl_text.c:525
void add_string_instance(screen_string *string, vec3_t pos, atom *at, atom *bt, atom *ct)
add an instance to a screen string
Definition ogl_text.c:601
object_3d * gl_pango_render_layout(PangoLayout *layout, GLenum texture, int id, screen_string *this_string)
OpenGL 3D pango layout object rendering.
Definition ogl_text.c:298
object_3d * create_string_texture(int cwidth, int cheight, int *pixels)
OpenGL 3D string object rendering.
Definition ogl_text.c:183
int measures_drawing
Definition d_measures.c:67
GLuint textures_id[2]
Definition ogl_text.c:70
int type_of_measure
Definition d_measures.c:66
void render_all_strings(int glsl, int id)
render all string to be rendered for a label list
Definition ogl_text.c:549
int * paint_bitmap(vec4_t color, GLfloat a, int cw, int ch, unsigned char *buff)
paint bitmap data using color
Definition ogl_text.c:117
#define GL_CLAMP_TO_EDGE
Definition ogl_text.c:59
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
Definition ogl_text.c:418
float blue
Definition global.h:124
float alpha
Definition global.h:125
float red
Definition global.h:122
float green
Definition global.h:123
Definition global.h:886
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130
int a
Definition tab-1.c:95