atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
ogl_shading.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
23/*
24* This file: 'ogl_shading.c'
25*
26* Contains:
27*
28
29 - The functions to create GLSL programs
30 - The functions to manage GLSL programs
31
32*
33*
34* List of functions:
35
36 GLuint create_shader (int type, const GLchar * src);
37 GLuint * alloc_shader_pointer (GLuint * pointer, int shaders);
38 GLuint * glsl_add_lights (glsl_program * glsl);
39
40 gboolean in_md_shaders (project * this_proj, int id);
41 gboolean glsl_disable_cull_face (glsl_program * glsl);
42
43 void set_light_uniform_location (GLuint * lightning, int id, int j, int k, char * string);
44 void glsl_bind_points (glsl_program * glsl, object_3d * obj);
45 void glsl_bind_spheres (glsl_program * glsl, object_3d * obj);
46 void glsl_bind_lines (glsl_program * glsl, object_3d * obj);
47 void glsl_bind_cylinders (glsl_program * glsl, object_3d * obj);
48 void glsl_bind_caps (glsl_program * glsl, object_3d * obj);
49 void glsl_bind_polyhedra (glsl_program * glsl, object_3d * obj);
50 void update_string_instances (glsl_program * glsl, object_3d * obj);
51 void glsl_bind_string (glsl_program * glsl, object_3d * obj);
52 void re_create_all_md_shaders (glwin * view);
53 void re_create_md_shaders (int nshaders, int shaders[nshaders], project * this_proj);
54 void cleaning_shaders (glwin * view, int shader);
55 void recreate_all_shaders (glwin * view);
56 void init_default_shaders (glwin * view);
57 void init_shaders (glwin * view);
58 void set_lights_data (glsl_program * glsl);
59 void shading_glsl_text (glsl_program * glsl);
60 void render_this_shader (glsl_program * glsl, int ids);
61 void draw_vertices (int id);
62
63 glsl_program * init_shader_program (int object, int object_id,
64 const GLchar * vertex, const GLchar * geometry, const GLchar * fragment,
65 GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d * obj);
66
67 object_3d * duplicate_object_3d (object_3d * old_obj);
68
69*/
70
71#include "global.h"
72#include "interface.h"
73#include "glview.h"
74#include "ogl_shading.h"
75
76/* Create and compile a shader */
85GLuint create_shader (int type, const GLchar * src)
86{
87 GLuint shader;
88 int status;
89
90 shader = glCreateShader (type);
91 glShaderSource (shader, 1, & src, NULL);
92 glCompileShader (shader);
93
94 glGetShaderiv (shader, GL_COMPILE_STATUS, & status);
95 if (status == GL_FALSE)
96 {
97 int log_len;
98 char *buffer;
99 glGetShaderiv (shader, GL_INFO_LOG_LENGTH, & log_len);
100 buffer = g_malloc (log_len + 1);
101 glGetShaderInfoLog (shader, log_len, NULL, buffer);
102 g_warning ("Compile failure in %s shader:\n%s",
103 type == GL_VERTEX_SHADER ? "vertex" : "fragment",
104 buffer);
105
106 g_free (buffer);
107 glDeleteShader (shader);
108 return 0;
109 }
110 return shader;
111}
112
121GLuint * alloc_shader_pointer (GLuint * pointer, int shaders)
122{
123 if (pointer != NULL)
124 {
125 g_free (pointer);
126 pointer = NULL;
127 }
128 return allocgluint(shaders);
129}
130
131#define LIGHT_INFO 3
132#define MATERIAL_DATA 6
133#define FOG_DATA 5
134#define LIGHT_DATA 10
135
136
148void set_light_uniform_location (GLuint * lightning, int id, int j, int k, char * string)
149{
150 lightning[LIGHT_INFO+MATERIAL_DATA+FOG_DATA+LIGHT_DATA*j+k] = glGetUniformLocation (id, g_strdup_printf ("AllLights[%d].%s", j, string));
151}
152
161{
162 int tot = MATERIAL_DATA + plot -> lights * LIGHT_DATA + LIGHT_INFO + FOG_DATA;
163 GLuint * lightning = allocgluint(tot);
164 lightning[0] = glGetUniformLocation (glsl -> id, "m_view");
165 lightning[1] = glGetUniformLocation (glsl -> id, "lights_on");
166 lightning[2] = glGetUniformLocation (glsl -> id, "mat.albedo");
167 lightning[3] = glGetUniformLocation (glsl -> id, "mat.metallic");
168 lightning[4] = glGetUniformLocation (glsl -> id, "mat.roughness");
169 lightning[5] = glGetUniformLocation (glsl -> id, "mat.back_light");
170 lightning[6] = glGetUniformLocation (glsl -> id, "mat.gamma");
171 lightning[7] = glGetUniformLocation (glsl -> id, "mat.alpha");
172 lightning[8] = glGetUniformLocation (glsl -> id, "fog.mode");
173 lightning[9] = glGetUniformLocation (glsl -> id, "fog.based");
174 lightning[10] = glGetUniformLocation (glsl -> id, "fog.density");
175 lightning[11] = glGetUniformLocation (glsl -> id, "fog.depth");
176 lightning[12] = glGetUniformLocation (glsl -> id, "fog.color");
177 lightning[13] = glGetUniformLocation (glsl -> id, "numLights");
178 int j;
179 for (j=0; j<plot -> lights; j++)
180 {
181 set_light_uniform_location (lightning, glsl -> id, j, 0, "type");
182 set_light_uniform_location (lightning, glsl -> id, j, 1, "position");
183 set_light_uniform_location (lightning, glsl -> id, j, 2, "direction");
184 set_light_uniform_location (lightning, glsl -> id, j, 3, "intensity");
185 set_light_uniform_location (lightning, glsl -> id, j, 4, "constant");
186 set_light_uniform_location (lightning, glsl -> id, j, 5, "linear");
187 set_light_uniform_location (lightning, glsl -> id, j, 6, "quadratic");
188 set_light_uniform_location (lightning, glsl -> id, j, 7, "cone_angle");
189 set_light_uniform_location (lightning, glsl -> id, j, 8, "spot_inner");
190 set_light_uniform_location (lightning, glsl -> id, j, 9, "spot_outer");
191 }
192 return lightning;
193}
194
204{
205 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "offset");
206 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "size");
207 glsl -> array_pointer[3] = glGetAttribLocation (glsl -> id, "vertColor");
208
209 // The points vertices
210 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
211 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
212 glEnableVertexAttribArray(glsl -> array_pointer[0]);
213 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
214 // The instances (pos + col)
215 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[1]);
216 glBufferData(GL_ARRAY_BUFFER, obj -> inst_buffer_size * obj -> num_instances * sizeof(GLfloat), obj -> instances, GL_STATIC_DRAW);
217 glEnableVertexAttribArray (glsl -> array_pointer[1]);
218 glVertexAttribPointer (glsl -> array_pointer[1], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
219 glVertexAttribDivisor (glsl -> array_pointer[1], 1);
220 glEnableVertexAttribArray (glsl -> array_pointer[2]);
221 glVertexAttribPointer (glsl -> array_pointer[2], 1, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
222 glVertexAttribDivisor (glsl -> array_pointer[2], 1);
223 glEnableVertexAttribArray (glsl -> array_pointer[3]);
224 glVertexAttribPointer (glsl -> array_pointer[3], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (4*sizeof(GLfloat)));
225 glVertexAttribDivisor (glsl -> array_pointer[3], 1);
226}
227
237{
238 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "offset");
239 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "radius");
240 glsl -> array_pointer[3] = glGetAttribLocation (glsl -> id, "vertColor");
241
242 // The sphere vertices
243 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
244 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
245 glEnableVertexAttribArray(glsl -> array_pointer[0]);
246 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
247 // The sphere indices
248 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glsl -> vbo[1]);
249 glBufferData(GL_ELEMENT_ARRAY_BUFFER, obj -> num_indices*sizeof(GLint), obj -> indices, GL_STATIC_DRAW);
250 // The instances (pos + col)
251 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[2]);
252 glBufferData(GL_ARRAY_BUFFER, obj -> inst_buffer_size * obj -> num_instances * sizeof(GLfloat), obj -> instances, GL_STATIC_DRAW);
253 glEnableVertexAttribArray (glsl -> array_pointer[1]);
254 glVertexAttribPointer (glsl -> array_pointer[1], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
255 glVertexAttribDivisor (glsl -> array_pointer[1], 1);
256 glEnableVertexAttribArray (glsl -> array_pointer[2]);
257 glVertexAttribPointer (glsl -> array_pointer[2], 1, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
258 glVertexAttribDivisor (glsl -> array_pointer[2], 1);
259 glEnableVertexAttribArray (glsl -> array_pointer[3]);
260 glVertexAttribPointer (glsl -> array_pointer[3], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (4*sizeof(GLfloat)));
261 glVertexAttribDivisor (glsl -> array_pointer[3], 1);
262}
263
273{
274 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "vertColor");
275 // The line vertices
276 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
277 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
278 glEnableVertexAttribArray(glsl -> array_pointer[0]);
279 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size *sizeof(GLfloat), (GLvoid*) 0);
280 glEnableVertexAttribArray(glsl -> array_pointer[1]);
281 glVertexAttribPointer(glsl -> array_pointer[1], 4, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size *sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
282
283 if (glsl -> object == MEASU)
284 {
285 glsl -> uniform_loc[1] = glGetUniformLocation (glsl -> id, "factor");
286 glsl -> uniform_loc[2] = glGetUniformLocation (glsl -> id, "pattern");
287 glsl -> uniform_loc[3] = glGetUniformLocation (glsl -> id, "text_proj");
288 glsl -> uniform_loc[4] = glGetUniformLocation (glsl -> id, "un_view");
289 glsl -> uniform_loc[5] = glGetUniformLocation (glsl -> id, "viewp");
290 glsl -> uniform_loc[6] = glGetUniformLocation (glsl -> id, "depth");
291 }
292}
293
303{
304 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "offset");
305 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "height");
306 glsl -> array_pointer[3] = glGetAttribLocation (glsl -> id, "radius");
307 glsl -> array_pointer[4] = glGetAttribLocation (glsl -> id, "quat");
308 glsl -> array_pointer[5] = glGetAttribLocation (glsl -> id, "vertColor");
309
310 // The cylinder vertices
311 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
312 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
313 glEnableVertexAttribArray(glsl -> array_pointer[0]);
314 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
315
316 // The cylinder indices
317 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glsl -> vbo[1]);
318 glBufferData(GL_ELEMENT_ARRAY_BUFFER, obj -> num_indices*sizeof(GLint), obj -> indices, GL_STATIC_DRAW);
319
320 // The instances (pos + lenght, + rad + rot + col)
321 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[2]);
322 glBufferData(GL_ARRAY_BUFFER, obj -> inst_buffer_size * obj -> num_instances * sizeof(GLfloat), obj -> instances, GL_STATIC_DRAW);
323 glEnableVertexAttribArray (glsl -> array_pointer[1]);
324 glVertexAttribPointer (glsl -> array_pointer[1], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
325 glVertexAttribDivisor (glsl -> array_pointer[1], 1);
326 glEnableVertexAttribArray (glsl -> array_pointer[2]);
327 glVertexAttribPointer (glsl -> array_pointer[2], 1, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
328 glVertexAttribDivisor (glsl -> array_pointer[2], 1);
329 glEnableVertexAttribArray (glsl -> array_pointer[3]);
330 glVertexAttribPointer (glsl -> array_pointer[3], 1, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (4*sizeof(GLfloat)));
331 glVertexAttribDivisor (glsl -> array_pointer[3], 1);
332 glEnableVertexAttribArray (glsl -> array_pointer[4]);
333 glVertexAttribPointer (glsl -> array_pointer[4], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (5*sizeof(GLfloat)));
334 glVertexAttribDivisor (glsl -> array_pointer[4], 1);
335 glEnableVertexAttribArray (glsl -> array_pointer[5]);
336 glVertexAttribPointer (glsl -> array_pointer[5], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (9*sizeof(GLfloat)));
337 glVertexAttribDivisor (glsl -> array_pointer[5], 1);
338}
339
349{
350 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "offset");
351 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "radius");
352 glsl -> array_pointer[3] = glGetAttribLocation (glsl -> id, "quat");
353 glsl -> array_pointer[4] = glGetAttribLocation (glsl -> id, "vertColor");
354
355 // The cylinder vertices
356 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
357 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
358 glEnableVertexAttribArray(glsl -> array_pointer[0]);
359 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
360
361 // The cylinder indices
362 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glsl -> vbo[1]);
363 glBufferData(GL_ELEMENT_ARRAY_BUFFER, obj -> num_indices*sizeof(GLint), obj -> indices, GL_STATIC_DRAW);
364
365 // The instances (pos + length, + rad + rot + col)
366 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[2]);
367 glBufferData(GL_ARRAY_BUFFER, obj -> inst_buffer_size * obj -> num_instances * sizeof(GLfloat), obj -> instances, GL_STATIC_DRAW);
368 glEnableVertexAttribArray (glsl -> array_pointer[1]);
369 glVertexAttribPointer (glsl -> array_pointer[1], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
370 glVertexAttribDivisor (glsl -> array_pointer[1], 1);
371 glEnableVertexAttribArray (glsl -> array_pointer[2]);
372 glVertexAttribPointer (glsl -> array_pointer[2], 1, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
373 glVertexAttribDivisor (glsl -> array_pointer[2], 1);
374 glEnableVertexAttribArray (glsl -> array_pointer[3]);
375 glVertexAttribPointer (glsl -> array_pointer[3], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (4*sizeof(GLfloat)));
376 glVertexAttribDivisor (glsl -> array_pointer[3], 1);
377 glEnableVertexAttribArray (glsl -> array_pointer[4]);
378 glVertexAttribPointer (glsl -> array_pointer[4], 4, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (8*sizeof(GLfloat)));
379 glVertexAttribDivisor (glsl -> array_pointer[4], 1);
380}
381
391{
392 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "vertNormal");
393 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "vertColor");
394
395 // The polyhedra vertices (triangles + normal orientation)
396 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
397 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
398 glEnableVertexAttribArray(glsl -> array_pointer[0]);
399 glVertexAttribPointer(glsl -> array_pointer[0], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
400 glEnableVertexAttribArray(glsl -> array_pointer[1]);
401 glVertexAttribPointer(glsl -> array_pointer[1], 3, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
402 glEnableVertexAttribArray(glsl -> array_pointer[2]);
403 glVertexAttribPointer(glsl -> array_pointer[2], 4, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) (6*sizeof(GLfloat)));
404}
405
415{
416 // The instances (pos)
417 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[1]);
418 glBufferData(GL_ARRAY_BUFFER, obj -> inst_buffer_size * obj -> num_instances * sizeof(GLfloat), obj -> instances, GL_STATIC_DRAW);
419 glEnableVertexAttribArray (glsl -> array_pointer[2]);
420
421 glVertexAttribPointer (glsl -> array_pointer[2], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
422 glVertexAttribDivisor (glsl -> array_pointer[2], 1);
423 if (glsl -> object == MEASU)
424 {
425 glEnableVertexAttribArray (glsl -> array_pointer[3]);
426 glVertexAttribPointer (glsl -> array_pointer[3], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (3*sizeof(GLfloat)));
427 glVertexAttribDivisor (glsl -> array_pointer[3], 1);
428 glEnableVertexAttribArray (glsl -> array_pointer[4]);
429 glVertexAttribPointer (glsl -> array_pointer[4], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (6*sizeof(GLfloat)));
430 glVertexAttribDivisor (glsl -> array_pointer[4], 1);
431 if (obj -> inst_buffer_size == 12)
432 {
433 glEnableVertexAttribArray (glsl -> array_pointer[5]);
434 glVertexAttribPointer (glsl -> array_pointer[5], 3, GL_FLOAT, GL_FALSE, obj -> inst_buffer_size*sizeof(GLfloat), (GLvoid*) (9*sizeof(GLfloat)));
435 glVertexAttribDivisor (glsl -> array_pointer[5], 1);
436 }
437 }
438}
439
449{
450 glActiveTexture (GL_TEXTURE0);
451 glBindTexture (ogl_texture, obj -> texture);
452 glsl -> uniform_loc[1] = glGetUniformLocation (glsl -> id, "tex");
453 glUniform1i (glsl -> uniform_loc[1], 0);
454 glsl -> uniform_loc[2] = glGetUniformLocation (glsl -> id, "text_proj");
455 glsl -> uniform_loc[3] = glGetUniformLocation (glsl -> id, "un_view");
456 glsl -> uniform_loc[4] = glGetUniformLocation (glsl -> id, "viewp");
457 glsl -> uniform_loc[5] = glGetUniformLocation (glsl -> id, "pos_shift");
458 glsl -> uniform_loc[6] = glGetUniformLocation (glsl -> id, "vert_color");
459
460 glsl -> array_pointer[1] = glGetAttribLocation (glsl -> id, "tcoord");
461 glsl -> array_pointer[2] = glGetAttribLocation (glsl -> id, "offset");
462 if (glsl -> object == MEASU)
463 {
464 glsl -> uniform_loc[7] = glGetUniformLocation (glsl -> id, "tilted");
465 glsl -> array_pointer[3] = glGetAttribLocation (glsl -> id, "at_a");
466 glsl -> array_pointer[4] = glGetAttribLocation (glsl -> id, "at_b");
467 if (obj -> inst_buffer_size == 12) glsl -> array_pointer[5] = glGetAttribLocation (glsl -> id, "at_c");
468 }
469
470 // The string (rendered using triangles and textures + colors)
471 glBindBuffer(GL_ARRAY_BUFFER, glsl -> vbo[0]);
472 glBufferData(GL_ARRAY_BUFFER, obj -> vert_buffer_size * obj -> num_vertices*sizeof(GLfloat), obj -> vertices, GL_STATIC_DRAW);
473 glEnableVertexAttribArray(glsl -> array_pointer[0]);
474 glVertexAttribPointer(glsl -> array_pointer[0], 2, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) 0);
475 glEnableVertexAttribArray(glsl -> array_pointer[1]);
476 glVertexAttribPointer(glsl -> array_pointer[1], 2, GL_FLOAT, GL_FALSE, obj -> vert_buffer_size*sizeof(GLfloat), (GLvoid*) (2*sizeof(GLfloat)));
477 update_string_instances (glsl, obj);
478}
479
488{
489 object_3d * new_obj = g_malloc0 (sizeof*new_obj);
490 new_obj -> quality = old_obj -> quality;
491 // Vertices
492 new_obj -> num_vertices = old_obj -> num_vertices;
493 new_obj -> vert_buffer_size = old_obj -> vert_buffer_size;
494 new_obj -> vertices = duplicate_float (new_obj -> num_vertices*old_obj -> vert_buffer_size, old_obj -> vertices);
495 // Indices
496 new_obj -> num_indices = old_obj -> num_indices;
497 new_obj -> ind_buffer_size = old_obj -> ind_buffer_size;
498 if (old_obj -> indices != NULL)
499 {
500 new_obj -> indices = duplicate_int (new_obj -> num_indices*old_obj -> ind_buffer_size, old_obj -> indices);
501 }
502 // Instances
503 new_obj -> num_instances = old_obj -> num_instances;
504 new_obj -> inst_buffer_size = old_obj -> inst_buffer_size;
505 if (old_obj -> instances != NULL)
506 {
507 new_obj -> instances = duplicate_float (new_obj -> num_instances*old_obj -> inst_buffer_size, old_obj -> instances);
508 }
509 new_obj -> texture = old_obj -> texture;
510 int i;
511 for (i=0; i<5; i++) new_obj -> shift[i] = old_obj -> shift[i];
512 return new_obj;
513}
514
533glsl_program * init_shader_program (int object, int object_id,
534 const GLchar * vertex, const GLchar * geometry, const GLchar * fragment,
535 GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d * obj)
536{
537 glsl_program * glsl = g_malloc0 (sizeof * glsl);
538
539 glsl -> id = glCreateProgram ();
540 glsl -> object = object;
541 glsl -> draw_type = object_id;
542
543 glsl -> vertex_shader = create_shader (GL_VERTEX_SHADER, vertex);
544 glAttachShader (glsl -> id, glsl -> vertex_shader);
545 if (geometry != NULL)
546 {
547 glsl -> geometry_shader = create_shader (GL_GEOMETRY_SHADER, geometry);
548 glAttachShader (glsl -> id, glsl -> geometry_shader);
549 }
550 glsl -> fragment_shader = create_shader (GL_FRAGMENT_SHADER, fragment);
551 glAttachShader (glsl -> id, glsl -> fragment_shader);
552
553 glBindFragDataLocation (glsl -> id, 0, "fragment_color");
554 glLinkProgram(glsl -> id);
555
556 glsl -> vert_type = type_of_vertices;
557
558 glGenVertexArrays (1, & glsl -> vao);
559
560 glBindVertexArray (glsl -> vao);
561
562 glsl -> array_pointer = alloc_shader_pointer (glsl -> array_pointer, narray);
563 glsl -> uniform_loc = alloc_shader_pointer (glsl -> uniform_loc, nunif);
564
565 // Always the MVP matrix as uniform 0
566 glsl -> uniform_loc[0] = glGetUniformLocation (glsl -> id, "mvp");
567 // and always the vertices as array 0
568 glsl -> array_pointer[0] = glGetAttribLocation (glsl -> id, "vert");
569
570 glsl -> light_uniform = NULL;
571 if (lightning) glsl -> light_uniform = glsl_add_lights (glsl);
572
573 glsl -> obj = duplicate_object_3d (obj);
574
575 glsl -> draw_instanced = FALSE;
576
577 int nvbo = 1;
578 if (glsl -> obj -> num_indices > 0) nvbo ++;
579 if (glsl -> obj -> num_instances > 0)
580 {
581 nvbo ++;
582 if (glsl -> obj -> num_instances > 1) glsl -> draw_instanced = TRUE;
583 }
584
585 glsl -> vbo = allocgluint (nvbo);
586 glGenBuffers (nvbo, glsl -> vbo);
587
588 switch (object_id)
589 {
590 case GLSL_SPHERES:
591 // narray = 4
592 glsl_bind_spheres (glsl, glsl -> obj);
593 break;
594 case GLSL_POINTS:
595 // narray = 4
596 glsl_bind_points (glsl, glsl -> obj);
597 break;
598 case GLSL_LINES:
599 // narray = 3
600 glsl_bind_lines (glsl, glsl -> obj);
601 break;
602 case GLSL_CYLINDERS:
603 // narray = 6
604 glsl_bind_cylinders (glsl, glsl -> obj);
605 break;
606 case GLSL_CAPS:
607 // narray = 5
608 glsl_bind_caps (glsl, glsl -> obj);
609 break;
610 case GLSL_POLYEDRA:
611 glsl_bind_polyhedra (glsl, glsl -> obj);
612 break;
613 case GLSL_STRING:
614 glsl_bind_string (glsl, glsl -> obj);
615 break;
616 }
617 glDetachShader (glsl -> id,glsl -> vertex_shader);
618 if (geometry != NULL) glDetachShader (glsl -> id, glsl -> geometry_shader);
619 glDetachShader (glsl -> id, glsl -> fragment_shader);
620
621 return glsl;
622}
623
632gboolean in_md_shaders (project * this_proj, int id)
633{
634 if (id == ATOMS) return TRUE;
635 if (id == BONDS) return TRUE;
636 if (id == POLYS) return TRUE;
637 if (id == RINGS) return TRUE;
638 if (id == SELEC) return TRUE;
639 if (id == MDBOX) return this_proj -> cell.npt;
640 if (id == VOLMS) return TRUE;
641 return FALSE;
642}
643
652{
653 int i, j;
654 project * this_proj = get_project_by_id(view -> proj);
655 for (i=0; i<NGLOBAL_SHADERS; i++)
656 {
657 if (in_md_shaders (this_proj, i))
658 {
659 for (j=0; j< this_proj -> steps; j++) view -> n_shaders[i][j] = -1;
660 }
661 }
662}
663
673void re_create_md_shaders (int nshaders, int shaders[nshaders], project * this_proj)
674{
675 int i, j, k;
676 for (i=0; i<nshaders; i++)
677 {
678 k = shaders[i];
679 this_proj -> modelgl -> create_shaders[k] = TRUE;
680 for (j=0; j<this_proj -> steps; j++)
681 {
682 this_proj -> modelgl -> n_shaders[k][j] = -1;
683 }
684 }
685}
686
695void cleaning_shaders (glwin * view, int shader)
696{
697 int i = (in_md_shaders(get_project_by_id(view -> proj), shader)) ? step : 0;
698 if (view -> ogl_glsl[shader][i] != NULL)
699 {
700 g_free (view -> ogl_glsl[shader][i]);
701 view -> ogl_glsl[shader][i] = NULL;
702 }
703 view -> n_shaders[shader][i] = (in_md_shaders(get_project_by_id(view -> proj), shader)) ? -1 : 0;
704}
705
714{
715 int i;
716 for (i=0; i<NGLOBAL_SHADERS; i++)
717 {
718 view -> create_shaders[i] = TRUE;
719 }
720}
721
730{
731 int shaders[6] = {ATOMS, BONDS, SELEC, POLYS, RINGS, VOLMS};
733 view -> create_shaders[LABEL] = TRUE;
734 view -> create_shaders[PICKS] = TRUE;
735 view -> create_shaders[MEASU] = TRUE;
736 update (view);
737 int i;
738 if (is_atom_win_active(view) || (view -> mode == EDITION && (view -> anim -> last -> img -> selected[1] -> selected || view -> selection_mode == 5)))
739 {
740 if (view -> measure_win != NULL)
741 {
742 for (i=0; i<3; i++)
743 {
744 if (view -> measure_win -> selection_tree[i] != NULL) update_selection_tree (view, 1, i);
745 }
746 }
747 }
748}
749
757void init_shaders (glwin * view)
758{
759 int i, j;
760 project * this_proj = get_project_by_id (view -> proj);
761 for (i=0; i<NGLOBAL_SHADERS; i++)
762 {
763 view -> ogl_glsl[i] = NULL;
764 if (in_md_shaders (this_proj, i))
765 {
766 view -> ogl_glsl[i] = g_malloc0 (this_proj -> steps*sizeof*view -> ogl_glsl[i]);
767 view -> n_shaders[i] = allocint (this_proj -> steps);
768 for (j=0; j<this_proj -> steps; j++)
769 {
770 view -> n_shaders[i][j] = -1;
771 }
772 }
773 else
774 {
775 j = (i == MEASU) ? 2 : 1;
776 view -> ogl_glsl[i] = g_malloc0 (j*sizeof*view -> ogl_glsl[i]);
777 view -> ogl_glsl[i][0] = NULL;
778 view -> n_shaders[i] = allocint (j);
779 }
780 view -> create_shaders[i] = TRUE;
781 }
782}
783
792{
793 if (glsl -> draw_type == GLSL_POINTS)
794 {
795 return FALSE;
796 }
797 else if (glsl -> draw_type == GLSL_LINES)
798 {
799 return FALSE;
800 }
801 else if (glsl -> draw_type == GLSL_LIGHT)
802 {
803 return FALSE;
804 }
805 else
806 {
807 return TRUE;
808 }
809}
810
819{
820 int j, k;
821 vec3_t l_pos, l_dir;
822 k = (glsl -> draw_type == GLSL_LIGHT) ? 0 : plot -> m_terial.param[0];
823 glUniformMatrix4fv (glsl -> light_uniform[0], 1, GL_FALSE, & wingl -> model_view_matrix.m00);
824 glUniform1i (glsl -> light_uniform[1], k);
825 glUniform3f (glsl -> light_uniform[2], plot -> m_terial.albedo.x, plot -> m_terial.albedo.y, plot -> m_terial.albedo.z);
826 for (j=0; j<5; j++) glUniform1f (glsl -> light_uniform[3+j], plot -> m_terial.param[j+1]);
827 glUniform1i (glsl -> light_uniform[8], plot -> f_g.mode);
828 glUniform1i (glsl -> light_uniform[9], plot -> f_g.based);
829 glUniform1f (glsl -> light_uniform[10], plot -> f_g.density);
830 glUniform2f (glsl -> light_uniform[11], plot -> f_g.depth[0]*plot -> p_depth/100.0 + plot -> p_depth, plot -> f_g.depth[1]*plot -> p_depth/100.0+ plot -> p_depth);
831 glUniform3f (glsl -> light_uniform[12], plot -> f_g.color.x, plot -> f_g.color.y, plot -> f_g.color.z);
832 glUniform1i (glsl -> light_uniform[13], plot -> lights);
833 for (j=0; j<plot -> lights; j++)
834 {
836 glUniform1i (glsl -> light_uniform[k], plot -> l_ght[j].type);
837 if (plot -> l_ght[j].fix == 0)
838 {
839 l_pos = m4_mul_pos (wingl -> model_matrix, plot -> l_ght[j].position);
840 }
841 else
842 {
843 l_pos = m4_mul_pos (wingl -> model_view_matrix, plot -> l_ght[j].position);
844 }
845 glUniform3f (glsl -> light_uniform[k+1], l_pos.x, l_pos.y, l_pos.z);
846 if (plot -> l_ght[j].fix == 0)
847 {
848 l_dir = m4_mul_pos (wingl -> model_matrix, plot -> l_ght[j].direction);
849 }
850 else
851 {
852 l_dir = m4_mul_pos (wingl -> model_view_matrix, plot -> l_ght[j].direction);
853 }
854 glUniform3f (glsl -> light_uniform[k+2], l_dir.x, l_dir.y, l_dir.z);
855 glUniform3f (glsl -> light_uniform[k+3], plot -> l_ght[j].intensity.x, plot -> l_ght[j].intensity.y, plot -> l_ght[j].intensity.z);
856 glUniform1f (glsl -> light_uniform[k+4], plot -> l_ght[j].attenuation.x);
857 glUniform1f (glsl -> light_uniform[k+5], plot -> l_ght[j].attenuation.y);
858 glUniform1f (glsl -> light_uniform[k+6], plot -> l_ght[j].attenuation.z);
859 glUniform1f (glsl -> light_uniform[k+7], cos(plot -> l_ght[j].spot_data.x*pi/180.0));
860 glUniform1f (glsl -> light_uniform[k+8], cos(plot -> l_ght[j].spot_data.y*pi/180.0));
861 glUniform1f (glsl -> light_uniform[k+9], cos(plot -> l_ght[j].spot_data.z*pi/180.0));
862 }
863}
864
865uint16_t stipple_pattern[NDOTS]={ 0xAAAA, 0x1111, 0x0000, 0x55FF, 0x24FF, 0x3F3F, 0x33FF, 0x27FF};
866
875{
876 wingl -> label_projection_matrix = create_label_matrices ();
877 glUniformMatrix4fv (glsl -> uniform_loc[2], 1, GL_FALSE, & wingl -> label_projection_matrix.m00);
878 glUniformMatrix4fv (glsl -> uniform_loc[3], 1, GL_FALSE, & wingl -> un_view_matrix.m00);
879 glUniform4f (glsl -> uniform_loc[4], wingl -> view_port.w, wingl -> view_port.x, wingl -> view_port.y, wingl -> view_port.z);
880 glUniform4f (glsl -> uniform_loc[5], glsl -> obj -> shift[0], glsl -> obj -> shift[1],
881 glsl -> obj -> shift[2], glsl -> obj -> shift[3]);
882 glUniform4f (glsl -> uniform_loc[6], glsl -> col -> red, glsl -> col -> green,
883 glsl -> col -> blue, glsl -> col -> alpha);
884 if (glsl -> object == MEASU) glUniform1i (glsl -> uniform_loc[7], (plot -> mtilt) ? 1 : 0);
885}
886
895void render_this_shader (glsl_program * glsl, int ids)
896{
897 int j, k;
898 if (glsl -> object == MAXIS)
899 {
900 j = 0;
902 {
903 k = wingl -> atom_win -> active;
904 if (wingl -> atom_win -> show_axis[k])
905 {
906 j = wingl -> atom_win -> axis[k];
907 }
908 }
909 wingl -> axis_proj_model_view_matrix = create_axis_matrices (j);
910 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> axis_proj_model_view_matrix.m00);
911 j = (plot -> box_axis[AXIS] == WIREFRAME) ? 1 : 3;
912 if (ids > j) shading_glsl_text (glsl);
913 }
914 else if (glsl -> object == LABEL)
915 {
916 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> proj_model_view_matrix.m00);
917 shading_glsl_text (glsl);
918 }
919 else if (glsl -> object == MEASU)
920 {
921 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> proj_model_view_matrix.m00);
922 if (glsl -> vert_type == GL_TRIANGLE_STRIP)
923 {
924 shading_glsl_text (glsl);
925 }
926 else
927 {
928 glUniform1i (glsl -> uniform_loc[1], plot -> mfactor);
929 glUniform1ui (glsl -> uniform_loc[2], stipple_pattern[plot -> mpattern]);
930 if (glsl -> vert_type == GL_TRIANGLES)
931 {
932 wingl -> label_projection_matrix = create_label_matrices ();
933 glUniformMatrix4fv (glsl -> uniform_loc[3], 1, GL_FALSE, & wingl -> label_projection_matrix.m00);
934 }
935 glUniformMatrix4fv (glsl -> uniform_loc[4], 1, GL_FALSE, & wingl -> un_view_matrix.m00);
936 glUniform4f (glsl -> uniform_loc[5], wingl -> view_port.w, wingl -> view_port.x, wingl -> view_port.y, wingl -> view_port.z);
937 if (plot -> rep == PERSPECTIVE)
938 {
939 glUniform1f (glsl -> uniform_loc[6], 1.0);
940 }
941 else
942 {
943 glUniform1f (glsl -> uniform_loc[6], plot -> p_depth);
944 }
945 }
946 }
947 else if (glsl -> object == LIGHT)
948 {
949 if (plot -> light_loc[ids])
950 {
951 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> proj_model_matrix.m00);
952 }
953 else
954 {
955 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> proj_model_view_matrix.m00);
956 }
957 }
958 else
959 {
960 glUniformMatrix4fv (glsl -> uniform_loc[0], 1, GL_FALSE, & wingl -> proj_model_view_matrix.m00);
961 }
962
963 if (glsl -> line_width != 0.0) glLineWidth (glsl -> line_width);
964
965 if (glsl -> light_uniform != NULL) set_lights_data (glsl);
966
967 glBindVertexArray (glsl -> vao);
968
969 if (glsl_disable_cull_face (glsl)) glDisable (GL_CULL_FACE);
970 if (plot -> render == LINE)
971 {
972 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
973 glLineWidth (1.0);
974 }
975 else if (plot -> render == PTS)
976 {
977 glPolygonMode (GL_FRONT_AND_BACK, GL_POINT);
978 }
979 else
980 {
981 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
982 }
983
984 if (glsl -> draw_type == GLSL_SPHERES || glsl -> draw_type == GLSL_CYLINDERS || glsl -> draw_type == GLSL_CAPS)
985 {
986 if (glsl -> draw_instanced)
987 {
988 glDrawElementsInstanced (glsl -> vert_type, glsl -> obj -> num_indices, GL_UNSIGNED_INT, 0, glsl -> obj -> num_instances);
989 }
990 else
991 {
992 glDrawElements (glsl -> vert_type, glsl -> obj -> num_indices, GL_UNSIGNED_INT, 0);
993 }
994 }
995 else if (glsl -> draw_type == GLSL_POINTS || glsl -> draw_type == GLSL_LINES || glsl -> draw_type == GLSL_STRING)
996 {
997 if (glsl -> draw_type == GLSL_STRING)
998 {
999 glEnable (ogl_texture);
1000 glActiveTexture (GL_TEXTURE0);
1001 glBindTexture (ogl_texture, glsl -> obj -> texture);
1002 }
1003 if (glsl -> draw_instanced)
1004 {
1005 j = (glsl -> draw_type == GLSL_STRING) ? 4 : 3*(glsl -> draw_type+1);
1006 glDrawArraysInstanced (glsl -> vert_type, 0, j, glsl -> obj -> num_instances);
1007 }
1008 else
1009 {
1010 glDrawArrays (glsl -> vert_type, 0, glsl -> obj -> num_vertices);
1011 }
1012 }
1013 else
1014 {
1015 glDrawArrays (glsl -> vert_type, 0, glsl -> obj -> num_vertices);
1016 }
1017 if (glsl_disable_cull_face (glsl)) glEnable (GL_CULL_FACE);
1018 glBindVertexArray (0);
1019}
1020
1028void draw_vertices (int id)
1029{
1030 int i, j;
1031 glsl_program * glsl;
1032
1033 i = (in_md_shaders(proj_gl, id)) ? step : 0;
1034 for (j=0; j<wingl -> n_shaders[id][i]; j++)
1035 {
1036 if (wingl -> ogl_glsl[id][i][j])
1037 {
1038 glsl = wingl -> ogl_glsl[id][i][j];
1039 glUseProgram (glsl -> id);
1040 render_this_shader (glsl, j);
1041 }
1042 }
1043}
gchar * axis[3]
Definition w_axis.c:65
mat4_t create_axis_matrices(int type)
create axis OpenGL rendering matrices
Definition d_axis.c:101
mat4_t create_label_matrices()
create label projection matrices
Definition d_label.c:56
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
dint rep
Definition dlp_edit.c:2239
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:592
double pi
Definition global.c:195
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
Global variable declarations Global convenience function declarations Global data structure defin...
gboolean is_atom_win_active(glwin *view)
is the model edition window visible ?
Definition atom_edit.c:71
project * proj
GLuint * allocgluint(int val)
allocate a GLuint * pointer
Definition glview.c:123
#define NDOTS
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
GLenum ogl_texture
Definition glview.c:114
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:66
project * proj_gl
Definition ogl_draw.c:60
glwin * wingl
Definition ogl_draw.c:59
@ EDITION
Definition glview.h:158
render
Definition glview.h:182
@ LINE
Definition glview.h:184
@ PTS
Definition glview.h:185
@ PERSPECTIVE
Definition glview.h:152
int step
Definition ogl_draw.c:70
void update_selection_tree(glwin *view, int pi, int id)
update measurements tree view
Definition w_measures.c:381
@ WIREFRAME
Definition glview.h:174
#define AXIS
Definition glwin.h:55
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ PICKS
Definition glwin.h:97
@ LABEL
Definition glwin.h:98
@ VOLMS
Definition glwin.h:102
@ POLYS
Definition glwin.h:92
@ MAXIS
Definition glwin.h:94
@ SELEC
Definition glwin.h:91
@ MDBOX
Definition glwin.h:93
@ MEASU
Definition glwin.h:99
@ ATOMS
Definition glwin.h:89
@ RINGS
Definition glwin.h:96
@ LIGHT
Definition glwin.h:100
#define NGLOBAL_SHADERS
Definition glwin.h:69
Messaging function declarations.
position
Definition m_proj.c:47
void recreate_all_shaders(glwin *view)
re-initialize all OpenGL shaders
void re_create_all_md_shaders(glwin *view)
re-initialize all MD dependent OpenGL shaders
void set_light_uniform_location(GLuint *lightning, int id, int j, int k, char *string)
set lightning uniform location
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
void glsl_bind_spheres(glsl_program *glsl, object_3d *obj)
bind a 3D object sphere to an OpenGL shader program
#define LIGHT_DATA
GLuint * glsl_add_lights(glsl_program *glsl)
add lightning to an OpenGL shader program
void init_shaders(glwin *view)
initialize all the OpenGL shaders
void set_lights_data(glsl_program *glsl)
set lightning data for an OpenGL progam
void glsl_bind_lines(glsl_program *glsl, object_3d *obj)
bind a 3D object line to an OpenGL shader program
void shading_glsl_text(glsl_program *glsl)
Render text in OpenGL.
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
void render_this_shader(glsl_program *glsl, int ids)
render an OpenGL shader
void glsl_bind_string(glsl_program *glsl, object_3d *obj)
bind a 3D object text string to an OpenGL shader program
void draw_vertices(int id)
Draw OpenGL shader program.
#define MATERIAL_DATA
gboolean glsl_disable_cull_face(glsl_program *glsl)
Disable or enable cull face for OpenGL rendering.
GLuint create_shader(int type, const GLchar *src)
create an OpenGL GLSL shader
Definition ogl_shading.c:85
gboolean in_md_shaders(project *this_proj, int id)
is this shader MD dependent ?
void glsl_bind_cylinders(glsl_program *glsl, object_3d *obj)
bind a 3D object cylinder to an OpenGL shader program
#define LIGHT_INFO
uint16_t stipple_pattern[NDOTS]
#define FOG_DATA
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
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
void update_string_instances(glsl_program *glsl, object_3d *obj)
Update OpenGL string texture instances.
void glsl_bind_polyhedra(glsl_program *glsl, object_3d *obj)
bind a 3D object polyhedra to an OpenGL shader program
void glsl_bind_points(glsl_program *glsl, object_3d *obj)
bind a 3D object point to an OpenGL shader program
void glsl_bind_caps(glsl_program *glsl, object_3d *obj)
bind a 3D object cylinder cap to an OpenGL shader program
object_3d * duplicate_object_3d(object_3d *old_obj)
create a copy of an object_3d data structure
GLuint * alloc_shader_pointer(GLuint *pointer, int shaders)
allocate GLuint data pointer, ensure that it is clean
Variable declarations related to GLSL programs Data structure declarations related to GLSL programs...
@ GLSL_LIGHT
Definition ogl_shading.h:45
@ GLSL_CAPS
Definition ogl_shading.h:42
@ GLSL_POINTS
Definition ogl_shading.h:38
@ GLSL_STRING
Definition ogl_shading.h:44
@ GLSL_LINES
Definition ogl_shading.h:40
@ GLSL_POLYEDRA
Definition ogl_shading.h:43
@ GLSL_SPHERES
Definition ogl_shading.h:39
@ GLSL_CYLINDERS
Definition ogl_shading.h:41
Definition glwin.h:875
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130
GtkWidget * show_axis
Definition tab-4.c:97
int status
Definition w_advance.c:160
GtkWidget * img
Definition workspace.c:70