atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
21
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_malloc0(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_LINEAR);
279 glTexParameteri (ogl_texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
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 for (i=0; i<2; i++) g_free (channels[i]);
286 g_free (rawbitmap);
287 return new_string;
288}
289
300object_3d * gl_pango_render_layout (PangoLayout * layout, GLenum texture, int id, screen_string * this_string)
301{
302 FT_Bitmap bitmap;
303 PangoRectangle prect;
304 object_3d * new_string;
305
306 int * pixels;
307 int cwidth, cheight;
308 int csize;
309
310 pango_layout_get_extents (layout, NULL, & prect);
311 if (prect.width == 0 || prect.height == 0) return NULL;
312 cheight = bitmap.rows = PANGO_PIXELS (prect.height) + 2*OUTLINE_WIDTH;
313 cwidth = bitmap.width = PANGO_PIXELS (prect.width) + 2*OUTLINE_WIDTH;
314
315 normalize_text_size (ogl_texture, & cwidth, & cheight);
316
317 bitmap.pitch = cwidth;
318 csize = cheight*cwidth;
319 bitmap.buffer = g_malloc0(csize);
320 memset (bitmap.buffer, 0, csize);
321
322 bitmap.num_grays = 256;
323 bitmap.pixel_mode = ft_pixel_mode_grays;
324 pango_ft2_render_layout (& bitmap, layout, PANGO_PIXELS (-prect.x)+OUTLINE_WIDTH, OUTLINE_WIDTH);
325 pixels = paint_bitmap (vec4(1.0,0.0,0.0,0.0), 1.0, cwidth, cheight, bitmap.buffer);
326 g_free (bitmap.buffer);
327 if (! plot -> labels[id].render)
328 {
329 new_string = g_malloc0(sizeof*new_string);
330 new_string -> texture = -1;
331 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
332 glGenTextures (1, & new_string -> texture);
333 if (! new_string -> texture) return NULL;
334 glBindTexture (ogl_texture, new_string -> texture);
335 glTexImage2D (ogl_texture,
336 0,
337 GL_RGBA,
338 cwidth,
339 cheight,
340 0,
341 GL_RGBA,
342 GL_UNSIGNED_BYTE,
343 pixels);
344
345 glTexParameteri (ogl_texture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
346 glTexParameteri (ogl_texture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
347 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
348 glTexParameteri (ogl_texture, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
350 glBindTexture (ogl_texture, 0);
351 }
352 else
353 {
354 new_string = create_string_texture (cwidth, cheight, pixels);
355 }
356
357 g_free (pixels);
358
359 new_string -> num_vertices = 4;
360 new_string -> vert_buffer_size = CHAR_BUFF_SIZE;
361 new_string -> vertices = allocfloat (new_string -> num_vertices*CHAR_BUFF_SIZE);
362 float x = (float) cwidth;
363 float y = (float) cheight;
364 float twidth = (ogl_texture == GL_TEXTURE_2D) ? 1.0 : x;
365 float theight = (ogl_texture == GL_TEXTURE_2D) ? 1.0 : y;
366 // 0
367 new_string -> vertices[0] = -x;
368 new_string -> vertices[1] = y;
369 new_string -> vertices[2] = 0.0;
370 new_string -> vertices[3] = theight;
371 // 1
372 new_string -> vertices[4] = -x;
373 new_string -> vertices[5] = -y;
374 new_string -> vertices[6] = 0.0;
375 new_string -> vertices[7] = 0.0;
376 // 2
377 new_string -> vertices[8] = x;
378 new_string -> vertices[9] = y;
379 new_string -> vertices[10] = twidth;
380 new_string -> vertices[11] = theight;
381 // 3
382 new_string -> vertices[12] = x;
383 new_string -> vertices[13] = -y;
384 new_string -> vertices[14] = twidth;
385 new_string -> vertices[15] = 0.0;
386
387 new_string -> num_instances = this_string -> num_instances;
388 int i = (this_string -> type == 3) ? 1 : (this_string -> type == 4) ? 3 : 4;
389 new_string -> inst_buffer_size = 3*i;
390 new_string -> instances = duplicate_float (this_string -> num_instances*3*i, this_string -> instances);
391
392 return new_string;
393}
394
403{
404 ColRGBA * ocol = g_malloc0(sizeof*ocol);
405 ocol -> red = (1.0-col.red)/2.5;
406 ocol -> green = (1.0-col.green)/2.5;
407 ocol -> blue = (1.0-col.blue)/2.5;
408 ocol -> alpha = 1.0;
409 return ocol;
410}
411
421void render_string (int glsl, int id, screen_string * this_string)
422{
423 int j, k, l;
424 double font_size;
425 // Pango elements for labels
426 PangoContext * pcontext;
427 PangoLayout * playout;
428 PangoFontDescription * pfont;
429 object_3d * string_to_render = NULL;
430 int arr_size = (this_string -> type == 4) ? 5 : (this_string -> type == 5) ? 6 : this_string -> type;
431 int shid = (id == 4) ? 1 : 0;
432 //pcontext = pango_ft2_get_context (PANGO_TEXT_SIZE, PANGO_TEXT_SIZE);
433 pcontext = pango_font_map_create_context (pango_ft2_font_map_new ());
434 playout = pango_layout_new (pcontext);
435 pango_layout_set_alignment (playout, PANGO_ALIGN_CENTER);
436 pfont = pango_font_description_from_string (plot -> labels[id].font);
437 j = pango_font_description_get_size (pfont);
438 font_size = j / PANGO_SCALE;
439
440 if (plot -> labels[id].scale) font_size *= ((ZOOM/plot -> zoom)*(plot -> gnear/6.0)*(wingl -> p_moy/plot -> p_depth));
442 {
443 l = (wingl -> pixels[0] > wingl -> pixels[1]) ? 1 : 0;
444 font_size *= ((float)wingl -> pixels[l]/(float)tmp_pixels[l]);
445 }
446 pango_font_description_set_absolute_size (pfont, font_size*PANGO_SCALE);
447 pango_layout_set_font_description (playout, pfont);
448 pango_layout_set_markup (playout, this_string -> word, strlen(this_string -> word));
449 string_to_render = gl_pango_render_layout (playout, ogl_texture, id, this_string);
450 if (string_to_render == NULL)
451 {
452 g_warning (_("Error in text rendering : for some reason it is impossible to render\n - this string : '%s' \n - using this font: %s"), this_string -> word, plot -> labels[id].font);
453 }
454 else
455 {
456 for (k=0; k<3; k++) string_to_render -> shift[k] = this_string -> shift[k];
457 string_to_render -> shift[3] = (float) plot -> labels[id].position;
458 string_to_render -> quality = this_string -> type;
459 j = this_string -> id;
460 j *= (plot -> labels[id].render + 1);
461 if (id == 1 && plot -> labels[0].list != NULL)
462 {
463 j += (plot -> labels[0].render + 1) * (plot -> labels[0].list -> last -> id + 1);
464 }
465 if (id == 2)
466 {
467 j += (plot -> xyz -> axis == WIREFRAME) ? 2 : 4;
468 }
469 else if (id == 3 || id == 4)
470 {
471 j += measures_drawing;
472 }
473 if (! plot -> labels[id].render)
474 {
476 {
477 wingl -> ogl_glsl[glsl][shid][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
478 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
479 }
480 else
481 {
482 wingl -> ogl_glsl[glsl][shid][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
483 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
484 }
485 wingl -> ogl_glsl[glsl][shid][j] -> col = duplicate_color(1, & (this_string -> col));
486 }
487 else
488 {
490 {
491 string_to_render -> texture = textures_id[0];
492 wingl -> ogl_glsl[glsl][shid][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
493 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
494 wingl -> ogl_glsl[glsl][shid][j] -> col = opposite_color(this_string -> col);
495 string_to_render -> texture = textures_id[1];
496 wingl -> ogl_glsl[glsl][shid][j+1] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
497 NULL, string_color, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
498 wingl -> ogl_glsl[glsl][shid][j+1] -> col = duplicate_color(1, & (this_string -> col));
499 }
500 else
501 {
502 string_to_render -> texture = textures_id[0];
503 wingl -> ogl_glsl[glsl][shid][j] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
504 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
505 wingl -> ogl_glsl[glsl][shid][j] -> col = opposite_color(this_string -> col);
506 string_to_render -> texture = textures_id[1];
507 wingl -> ogl_glsl[glsl][shid][j+1] = init_shader_program (glsl, GLSL_STRING, (this_string -> type == 3) ? string_vertex : (this_string -> type == 4) ? angstrom_vertex : degree_vertex,
508 NULL, string_color_2d, GL_TRIANGLE_STRIP, arr_size, (this_string -> type == 3) ? 7 : 8, FALSE, string_to_render);
509 wingl -> ogl_glsl[glsl][shid][j+1] -> col = duplicate_color(1, & (this_string -> col));
510 }
511 }
512 free_object_3d (string_to_render);
513 }
514 pango_font_description_free (pfont);
515 // g_object_unref (pcontext);
516 g_clear_object (& pcontext);
517 // g_object_unref (playout);
518 g_clear_object (& playout);
519}
520
528void debug_string (screen_string * this_string)
529{
530 g_debug ("STRING:: id= %d, text:: %s", this_string -> id, this_string -> word);
531 g_debug ("STRING:: color:: r= %f, g= %f, b= %f, a= %f",
532 this_string -> col.red, this_string -> col.green, this_string -> col.blue, this_string -> col.alpha);
533 int i, j;
534 j = 0;
535 for (i=0; i<this_string -> num_instances; i++, j+=3)
536 {
537 g_debug ("STRING:: %d-th :: pos[%d][x]= %f, pos[%d][y]= %f, pos[%d][z]= %f, theta[%d]= %f",
538 i, i, this_string -> instances[j], i, this_string -> instances[j+1], i, this_string -> instances[j+2], i, this_string -> instances[j+2]);
539 }
540 g_debug ("STRING:: shift:: x= %f, y= %f, z= %f", this_string -> shift[0], this_string -> shift[1], this_string -> shift[2]);
541 g_debug ("STRING:: show :: %f", this_string -> shift[3]);
542}
543
552void render_all_strings (int glsl, int id)
553{
554 if (plot -> labels[id].list != NULL)
555 {
556 screen_string * this_string = plot -> labels[id].list -> last;
557 while (this_string != NULL)
558 {
559 //if (glsl == MEASU) debug_string (this_string);
560 render_string (glsl, id, this_string);
561 this_string = this_string -> prev;
562 }
563 }
564}
565
575{
576 if (list != NULL)
577 {
578 screen_string * tmp_string = list -> last;
579 while (tmp_string != NULL)
580 {
581 if (g_strcmp0 (tmp_string -> word, word) == 0)
582 {
583 return tmp_string;
584 }
585 tmp_string = tmp_string -> prev;
586 }
587 tmp_string = NULL;
588 g_free (tmp_string);
589 }
590 return NULL;
591}
592
604void add_string_instance (screen_string * string, vec3_t pos, atom * at, atom * bt, atom * ct)
605{
606 int i, j;
607 i = 0;
608 j = (string -> type == 3) ? 1 : (type_of_measure == 6) ? 3 : 4;
609 if (string -> num_instances > 0)
610 {
611 float * instances = duplicate_float (3*j*string -> num_instances, string -> instances);
612 g_free (string -> instances);
613 string -> instances = allocfloat (3*j*(string -> num_instances+1));
614 for (i=0; i<3*j*string -> num_instances; i++)
615 {
616 string -> instances[i] = instances[i];
617 }
618 }
619 else
620 {
621 string -> instances = allocfloat (3*j);
622 }
623 string -> num_instances ++;
624 string -> instances[i] = pos.x;
625 string -> instances[i+1] = pos.y;
626 string -> instances[i+2] = pos.z;
627 if (j > 1)
628 {
629 string -> instances[i+3] = at -> x;
630 string -> instances[i+4] = at -> y;
631 string -> instances[i+5] = at -> z;
632 string -> instances[i+6] = bt -> x;
633 string -> instances[i+7] = bt -> y;
634 string -> instances[i+8] = bt -> z;
635 if (j == 4)
636 {
637 string -> instances[i+9] = ct -> x;
638 string -> instances[i+10] = ct -> y;
639 string -> instances[i+11] = ct -> z;
640 }
641 }
642}
643
658void add_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct)
659{
660 if (plot -> labels[id].list == NULL)
661 {
662 plot -> labels[id].list = g_malloc0(sizeof*plot -> labels[id].list);
663 plot -> labels[id].list -> last = plot -> labels[id].list;
664 }
665 else
666 {
667 screen_string * s_tring = g_malloc0(sizeof*s_tring);
668 s_tring -> prev = plot -> labels[id].list -> last;
669 s_tring -> id = plot -> labels[id].list -> last -> id + 1;
670 plot -> labels[id].list -> last = s_tring;
671 }
672 plot -> labels[id].list -> last -> word = g_strdup_printf ("%s", text);
673 plot -> labels[id].list -> last -> col = col;
674 plot -> labels[id].list -> last -> type = (id < 3) ? 3 : (type_of_measure == 6) ? 4 : 5;
675 int i;
676 for (i=0; i<3; i++) plot -> labels[id].list -> last -> shift[i] = lshift[i];
677 add_string_instance (plot -> labels[id].list -> last, pos, at, bt, ct);
678}
679
694void prepare_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom * at, atom * bt, atom * ct)
695{
696 screen_string * this_string = was_not_rendered_already (text, plot -> labels[id].list);
697 if (this_string == NULL)
698 {
699 add_string (text, id, col, pos, lshift, at, bt, ct);
700 }
701 else
702 {
703 add_string_instance (this_string, pos, at, bt, ct);
704 }
705}
double scale(double axe)
find appropriate major tick spacing based on axis length
Definition curve.c:205
PangoLayout * layout
Definition curve.c:80
ColRGBA col
Definition d_measures.c:77
int measures_drawing
Definition d_measures.c:67
int type_of_measure
Definition d_measures.c:66
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:579
gboolean in_movie_encoding
Definition global.c:184
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:385
int tmp_pixels[2]
Definition global.c:177
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:1689
#define max(a, b)
Definition global.h:92
GLenum ogl_texture
Definition glview.c:122
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1028
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:72
glwin * wingl
Definition ogl_draw.c:65
render
Definition glview.h:191
labels
Definition glview.h:223
#define ZOOM
Default value for the OpenGL zoom.
Definition glview.h:124
object_3d * free_object_3d(object_3d *obj)
free the memory allocated to create an object_3d data structure
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:183
#define GL_TEXTURE_RECTANGLE_ARB
Definition glwin.h:51
position
Definition m_proj.c:48
double z
Definition ogl_draw.c:63
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
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:54
@ 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:574
#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:694
#define OUTLINE_WIDTH
Definition ogl_text.c:56
ColRGBA * opposite_color(ColRGBA col)
compute the opposite color
Definition ogl_text.c:402
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:658
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:528
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:604
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:300
object_3d * create_string_texture(int cwidth, int cheight, int *pixels)
OpenGL 3D string object rendering.
Definition ogl_text.c:183
GLuint textures_id[2]
Definition ogl_text.c:70
void render_all_strings(int glsl, int id)
render all string to be rendered for a label list
Definition ogl_text.c:552
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:421
Definition global.h:964
Definition glwin.h:332
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130