atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
ogl_shading.c File Reference

Functions to create GLSL programs
Functions to manage GLSL programs. More...

#include "global.h"
#include "interface.h"
#include "glview.h"
#include "ogl_shading.h"
+ Include dependency graph for ogl_shading.c:

Go to the source code of this file.

Macros

#define LIGHT_INFO   3
 
#define MATERIAL_DATA   6
 
#define FOG_DATA   5
 
#define LIGHT_DATA   10
 

Functions

GLuint create_shader (int type, const GLchar *src)
 create an OpenGL GLSL shader
 
GLuint * alloc_shader_pointer (GLuint *pointer, int shaders)
 allocate GLuint data pointer, ensure that it is clean
 
void set_light_uniform_location (GLuint *lightning, int id, int j, int k, char *string)
 set lightning uniform location
 
GLuint * glsl_add_lights (glsl_program *glsl)
 add lightning 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_spheres (glsl_program *glsl, object_3d *obj)
 bind a 3D object sphere to an OpenGL shader program
 
void glsl_bind_lines (glsl_program *glsl, object_3d *obj)
 bind a 3D object line to an OpenGL shader program
 
void glsl_bind_cylinders (glsl_program *glsl, object_3d *obj)
 bind a 3D object cylinder 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
 
void glsl_bind_polyhedra (glsl_program *glsl, object_3d *obj)
 bind a 3D object polyhedra to an OpenGL shader program
 
void update_string_instances (glsl_program *glsl, object_3d *obj)
 Update OpenGL string texture instances.
 
void glsl_bind_string (glsl_program *glsl, object_3d *obj)
 bind a 3D object text string to an OpenGL shader program
 
object_3dduplicate_object_3d (object_3d *old_obj)
 create a copy of an object_3d data structure
 
glsl_programinit_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
 
gboolean in_md_shaders (project *this_proj, int id)
 is this shader MD dependent ?
 
void re_create_all_md_shaders (glwin *view)
 re-initialize all MD dependent OpenGL shaders
 
void re_create_md_shaders (int nshaders, int shaders[nshaders], project *this_proj)
 re-initialize some MD dependent OpenGL shaders
 
void cleaning_shaders (glwin *view, int shader)
 re-initialize an OpenGL shader
 
void recreate_all_shaders (glwin *view)
 re-initialize all OpenGL shaders
 
void init_default_shaders (glwin *view)
 re-initialize the default OpenGL shaders
 
void init_shaders (glwin *view)
 initialize all the OpenGL shaders
 
gboolean glsl_disable_cull_face (glsl_program *glsl)
 Disable or enable cull face for OpenGL rendering.
 
void set_lights_data (glsl_program *glsl)
 set lightning data for an OpenGL progam
 
void shading_glsl_text (glsl_program *glsl)
 Render text in OpenGL.
 
void render_this_shader (glsl_program *glsl, int ids)
 render an OpenGL shader
 
void draw_vertices (int id)
 Draw OpenGL shader program.
 

Variables

uint16_t stipple_pattern [NDOTS] ={ 0xAAAA, 0x1111, 0x0000, 0x55FF, 0x24FF, 0x3F3F, 0x33FF, 0x27FF}
 

Detailed Description

Functions to create GLSL programs
Functions to manage GLSL programs.

Author
Sébastien Le Roux sebas.nosp@m.tien.nosp@m..lero.nosp@m.ux@i.nosp@m.pcms..nosp@m.unis.nosp@m.tra.f.nosp@m.r

Definition in file ogl_shading.c.

Macro Definition Documentation

◆ FOG_DATA

#define FOG_DATA   5

Definition at line 133 of file ogl_shading.c.

◆ LIGHT_DATA

#define LIGHT_DATA   10

Definition at line 134 of file ogl_shading.c.

◆ LIGHT_INFO

#define LIGHT_INFO   3

Definition at line 131 of file ogl_shading.c.

◆ MATERIAL_DATA

#define MATERIAL_DATA   6

Definition at line 132 of file ogl_shading.c.

Function Documentation

◆ alloc_shader_pointer()

GLuint * alloc_shader_pointer ( GLuint * pointer,
int shaders )

allocate GLuint data pointer, ensure that it is clean

Parameters
pointerthe data pointer to allocate
shadersthe data size to allocate

Definition at line 121 of file ogl_shading.c.

◆ cleaning_shaders()

void cleaning_shaders ( glwin * view,
int shader )

re-initialize an OpenGL shader

Parameters
viewthe target glwin
shaderthe shader to initialize

Definition at line 695 of file ogl_shading.c.

◆ create_shader()

GLuint create_shader ( int type,
const GLchar * src )

create an OpenGL GLSL shader

Parameters
typetype of the shader
srcname of the shader

Definition at line 85 of file ogl_shading.c.

◆ draw_vertices()

void draw_vertices ( int id)

Draw OpenGL shader program.

Parameters
idthe ID of the program to render

Definition at line 1028 of file ogl_shading.c.

◆ duplicate_object_3d()

object_3d * duplicate_object_3d ( object_3d * old_obj)

create a copy of an object_3d data structure

Parameters
old_objthe data structure to copy

Definition at line 487 of file ogl_shading.c.

◆ glsl_add_lights()

GLuint * glsl_add_lights ( glsl_program * glsl)

add lightning to an OpenGL shader program

Parameters
glslthe target glsl

Definition at line 160 of file ogl_shading.c.

◆ glsl_bind_caps()

void glsl_bind_caps ( glsl_program * glsl,
object_3d * obj )

bind a 3D object cylinder cap to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object, cylinder cap to bind

Definition at line 348 of file ogl_shading.c.

◆ glsl_bind_cylinders()

void glsl_bind_cylinders ( glsl_program * glsl,
object_3d * obj )

bind a 3D object cylinder to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object, cylinder to bind

Definition at line 302 of file ogl_shading.c.

◆ glsl_bind_lines()

void glsl_bind_lines ( glsl_program * glsl,
object_3d * obj )

bind a 3D object line to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object line to bind

Definition at line 272 of file ogl_shading.c.

◆ glsl_bind_points()

void glsl_bind_points ( glsl_program * glsl,
object_3d * obj )

bind a 3D object point to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object point to bind

Definition at line 203 of file ogl_shading.c.

◆ glsl_bind_polyhedra()

void glsl_bind_polyhedra ( glsl_program * glsl,
object_3d * obj )

bind a 3D object polyhedra to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object polyhedra to bind

Definition at line 390 of file ogl_shading.c.

◆ glsl_bind_spheres()

void glsl_bind_spheres ( glsl_program * glsl,
object_3d * obj )

bind a 3D object sphere to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object sphere to bind

Definition at line 236 of file ogl_shading.c.

◆ glsl_bind_string()

void glsl_bind_string ( glsl_program * glsl,
object_3d * obj )

bind a 3D object text string to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object text string to bind

Definition at line 448 of file ogl_shading.c.

◆ glsl_disable_cull_face()

gboolean glsl_disable_cull_face ( glsl_program * glsl)

Disable or enable cull face for OpenGL rendering.

Parameters
glslthe target glsl

Definition at line 791 of file ogl_shading.c.

◆ in_md_shaders()

gboolean in_md_shaders ( project * this_proj,
int id )

is this shader MD dependent ?

Parameters
this_projthe target project
idthe shader id

Definition at line 632 of file ogl_shading.c.

◆ init_default_shaders()

void init_default_shaders ( glwin * view)

re-initialize the default OpenGL shaders

Parameters
viewthe target glwin

Definition at line 729 of file ogl_shading.c.

◆ init_shader_program()

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

Parameters
objectshader id (in enum shaders)
object_idshader type in: GLSL_SPHERES, GLSL_POINTS, GLSL_LINES, GLSL_CYLINDERS, GLSL_CAPS, GLSL_POLYEDRA, GLSL_STRING
vertexgeneral shader: in the shaders defined in 'ogl_shaders.c'
geometrygeometry shader, if any: in the shaders defined in 'ogl_shaders.c'
fragmentcolor shader, if any: in the shaders defined in 'ogl_shaders.c'
type_of_verticestype of vertices in: GL_POINTS, GL_LINES, GL_TRIANGLE GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP
narraynumber of vertices to allocate
nunifnumber of uniform location(s) to allocate
lightninguse lightning (1/0)
objthe object 3D to bind to the shader

Definition at line 533 of file ogl_shading.c.

◆ init_shaders()

void init_shaders ( glwin * view)

initialize all the OpenGL shaders

Parameters
viewthe target glwin

Definition at line 757 of file ogl_shading.c.

◆ re_create_all_md_shaders()

void re_create_all_md_shaders ( glwin * view)

re-initialize all MD dependent OpenGL shaders

Parameters
viewthe target glwin

Definition at line 651 of file ogl_shading.c.

◆ re_create_md_shaders()

void re_create_md_shaders ( int nshaders,
int shaders[nshaders],
project * this_proj )

re-initialize some MD dependent OpenGL shaders

Parameters
nshadersthe number of shader(s) to initialize
shadersthe list of shaders
this_projthe target project

Definition at line 673 of file ogl_shading.c.

◆ recreate_all_shaders()

void recreate_all_shaders ( glwin * view)

re-initialize all OpenGL shaders

Parameters
viewthe target glwin

Definition at line 713 of file ogl_shading.c.

◆ render_this_shader()

void render_this_shader ( glsl_program * glsl,
int ids )

render an OpenGL shader

Parameters
glslthe target glsl
ids

Definition at line 895 of file ogl_shading.c.

◆ set_light_uniform_location()

void set_light_uniform_location ( GLuint * lightning,
int id,
int j,
int k,
char * string )

set lightning uniform location

Parameters
lightning
idshader id
jlight id
kuniform id
stringuniform string

Definition at line 148 of file ogl_shading.c.

◆ set_lights_data()

void set_lights_data ( glsl_program * glsl)

set lightning data for an OpenGL progam

Parameters
glslthe target glsl

Definition at line 818 of file ogl_shading.c.

◆ shading_glsl_text()

void shading_glsl_text ( glsl_program * glsl)

Render text in OpenGL.

Parameters
glslthe target glsl

Definition at line 874 of file ogl_shading.c.

◆ update_string_instances()

void update_string_instances ( glsl_program * glsl,
object_3d * obj )

Update OpenGL string texture instances.

Parameters
glslthe target glsl
obj

Definition at line 414 of file ogl_shading.c.

Variable Documentation

◆ stipple_pattern

uint16_t stipple_pattern[NDOTS] ={ 0xAAAA, 0x1111, 0x0000, 0x55FF, 0x24FF, 0x3F3F, 0x33FF, 0x27FF}

Definition at line 865 of file ogl_shading.c.