atomes 1.3.1
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   8
#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 allocate_instances (object_3d *object)
 allocate the instances buffer of a 3D object
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 glsl_bind_background (glsl_program *glsl, object_3d *obj)
 bind background data 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
object_3dfree_object_3d (object_3d *obj)
 free the memory allocated to create an object_3d data structure
glsl_programfree_this_glsl_program (glsl_program *glsl)
 free memory allocated to create a glsl program
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}
int this_tilt
int this_pattern
int this_factor

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 141 of file ogl_shading.c.

◆ LIGHT_DATA

#define LIGHT_DATA   10

Definition at line 142 of file ogl_shading.c.

◆ LIGHT_INFO

#define LIGHT_INFO   3

Definition at line 139 of file ogl_shading.c.

◆ MATERIAL_DATA

#define MATERIAL_DATA   8

Definition at line 140 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 129 of file ogl_shading.c.

◆ allocate_instances()

void allocate_instances ( object_3d * object)

allocate the instances buffer of a 3D object

Parameters
objectthe target object_3d

Definition at line 151 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 792 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 93 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 1167 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 546 of file ogl_shading.c.

◆ free_object_3d()

object_3d * free_object_3d ( object_3d * obj)

free the memory allocated to create an object_3d data structure

Parameters
objthe target object_3d data structure to free

Definition at line 581 of file ogl_shading.c.

◆ free_this_glsl_program()

glsl_program * free_this_glsl_program ( glsl_program * glsl)

free memory allocated to create a glsl program

Parameters
glslthe target glsl program

Definition at line 597 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 181 of file ogl_shading.c.

◆ glsl_bind_background()

void glsl_bind_background ( glsl_program * glsl,
object_3d * obj )

bind background data to an OpenGL shader program

Parameters
glslthe target glsl
objthe 3D object to bind

Definition at line 451 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 385 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 326 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 296 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 227 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 427 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 260 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 507 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 889 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 729 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 827 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, GLSL_BACK
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 626 of file ogl_shading.c.

◆ init_shaders()

void init_shaders ( glwin * view)

initialize all the OpenGL shaders

Parameters
viewthe target glwin

Definition at line 855 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 748 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 770 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 811 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 998 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 167 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 916 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 977 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 473 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 965 of file ogl_shading.c.

◆ this_factor

int this_factor

Definition at line 968 of file ogl_shading.c.

◆ this_pattern

int this_pattern

Definition at line 967 of file ogl_shading.c.

◆ this_tilt

int this_tilt

Definition at line 966 of file ogl_shading.c.