DI-Guy SDK Documentation  13.2
diguyOglGraphicsShaderProgram.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 // needed for function prototypes
5 #include <GL/glew.h>
6 #include <GL/gl.h>
7 
9 
10 class diguyGraphicsLink;
12 
36 {
37 
38 public:
39 
40  diguyOglGraphicsShaderProgram(void* internal_data);
42 
43  virtual int load_vertex_shader_source(const char* filename_base);
44  virtual int load_pixel_shader_source(const char* filename_base);
45  virtual int link();
46 
47  virtual int bind();
48  virtual int unbind();
49 
50  virtual int get_gl_program_object() {return m_gl_program_object;}
51 
52 
53  /*
54  * Though looked up here, these bind locations are used in
55  * diguyOglGraphicsMesh.cpp.
56  */
59 
64 
67 
70 
73 
78 
81 
84 
88 
91 
94 
97 
104 
124 
126 
127  /*
128  * Uniform for controlling whether links matrices are applied to
129  * vertices in the vertex shader. Set from the mesh draw() function.
130  */
131  virtual void set_apply_matrices_flag(int apply_matrices_flag);
132  virtual void set_textures_enabled(int enabled);
133 
134  /*
135  * Called by diguy internal code to send data to the shaders.
136  */
137  virtual int bind_color_array(int num_colors,
138  const float* color_data);
139 
140 
141  virtual int bind_matrix(int bind_location, const float* mat_data);
142 
143  virtual int bind_link_matrices(int num_mats, const float* mat_data);
144 
145  virtual int bind_uniform_with_location(int location,
146  const char* name,
147  int value_size,
148  float* values);
149  virtual int bind_uniform_with_location(int location,
150  const char* name,
151  int value_size,
152  int* values);
153 
154  /*
155  * Called by diguy internal find out what capabilities the shader has.
156  */
157  virtual int get_attrib_bind_location(const char* name);
158  virtual int get_uniform_bind_location(const char* name);
161 
162  static int s_bound;
163 
164 protected:
165 
166  int load_and_compile_shader(GLhandleARB shader_object,
167  const char* shader_filename,
168  int shader_type,
169  bool& shader_loaded);
170 
171  char* load_shader_source(const char* shader_filename);
172  void update_light_uniforms();
174  GLhandleARB m_gl_program_object;
186  bool m_linked;
188  const float * m_last_matrix_data;
189 
191 };
192 
193 
199 
200 
diguyOglGraphicsShaderProgram(void *internal_data)
Definition: diguyOglGraphicsShaderProgram.cpp:40
bool m_linked
Definition: diguyOglGraphicsShaderProgram.h:183
int m_bind_location_attr_weight_array
Skeletal animation bone weight.
Definition: diguyOglGraphicsShaderProgram.h:67
int m_bind_location_ufrm_component_row
uniform to control which row of the shared variation texture to use for this draw call ...
Definition: diguyOglGraphicsShaderProgram.h:117
virtual int load_vertex_shader_source(const char *filename_base)
This function will be called by DI-Guy when it is time for the vertex part of this shader to be loade...
Definition: diguyOglGraphicsShaderProgram.cpp:159
int m_bind_location_ufrm_link_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:100
int m_bind_location_ufrm_specular_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:110
bool m_vertex_shader_valid
Definition: diguyOglGraphicsShaderProgram.h:175
GLhandleARB m_gl_vertex_shader_object
Definition: diguyOglGraphicsShaderProgram.h:176
~diguyOglGraphicsShaderProgram()
Definition: diguyOglGraphicsShaderProgram.cpp:125
int m_ubo_transform_block_index
Definition: diguyOglGraphicsShaderProgram.h:119
int m_bind_location_ufrm_component_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:111
int m_bind_location_ufrm_bump_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:109
virtual int get_attrib_bind_location(const char *name)
This function will be called by DI-Guy when core code is attempting to identify the capabilities of t...
Definition: diguyOglGraphicsShaderProgram.cpp:616
int m_bind_location_attr_index_array
Skeletal animation bone index.
Definition: diguyOglGraphicsShaderProgram.h:70
int m_bind_location_ufrm_base_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:98
bool m_vertex_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:174
int m_bind_location_ufrm_blend_weight
uniform for controlling the amount of a blend shape
Definition: diguyOglGraphicsShaderProgram.h:78
int m_bind_location_ufrm_link_colors
Uniform for sending bone link colors, needed for per pixel intersection tests.
Definition: diguyOglGraphicsShaderProgram.h:94
This class is part of the DI-Guy Graphics API.
Definition: diguyOglGraphicsShaderProgram.h:34
int m_include_point_lights
Definition: diguyOglGraphicsShaderProgram.h:123
virtual void set_apply_matrices_flag(int apply_matrices_flag)
Definition: diguyOglGraphicsShaderProgram.cpp:1226
int m_ubo_material_block_index
Definition: diguyOglGraphicsShaderProgram.h:120
virtual int bind_link_matrices(int num_mats, const float *mat_data)
This function will be called by DI-Guy when the matrix data of a character's links needs to be sent t...
Definition: diguyOglGraphicsShaderProgram.cpp:1120
virtual int bind_color_array(int num_colors, const float *color_data)
This function will be called by DI-Guy when the color data of a character's links needs to be sent to...
Definition: diguyOglGraphicsShaderProgram.cpp:1188
const float * m_last_matrix_data
Definition: diguyOglGraphicsShaderProgram.h:185
int m_ubo_per_frame_block_index
Definition: diguyOglGraphicsShaderProgram.h:121
int m_bind_location_ufrm_extra_per_instance_data
Definition: diguyOglGraphicsShaderProgram.h:103
int m_bind_location_ufrm_link_matrices
matrix array used to transform a skinned mesh
Definition: diguyOglGraphicsShaderProgram.h:91
diguyOglUniformBufferUpdater * m_uniform_buffer_updater
Definition: diguyOglGraphicsShaderProgram.h:187
virtual int link()
This function will be called by DI-Guy when it is time for the shader program to be linked...
Definition: diguyOglGraphicsShaderProgram.cpp:272
int m_bind_location_ufrm_misc_1_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:113
virtual int get_uniform_bind_location(const char *name)
This function will be called by DI-Guy when core code is attempting to identify the capabilities of t...
Definition: diguyOglGraphicsShaderProgram.cpp:637
bool m_pixel_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:179
static int s_bound
4 Header files and forward declarations
Definition: diguyOglGraphicsShaderProgram.h:159
GLhandleARB m_gl_program_object
Definition: diguyOglGraphicsShaderProgram.h:171
int m_bind_location_attr_normal
Definition: diguyOglGraphicsShaderProgram.h:60
bool m_pixel_shader_valid
Definition: diguyOglGraphicsShaderProgram.h:180
int m_bind_location_ufrm_link_matrix
matrix used to transform a rigid drawable
Definition: diguyOglGraphicsShaderProgram.h:88
virtual void set_textures_enabled(int enabled)
Definition: diguyOglGraphicsShaderProgram.cpp:1274
float m_last_light_update_time
Definition: diguyOglGraphicsShaderProgram.h:184
virtual int bind_matrix(int bind_location, const float *mat_data)
Definition: diguyOglGraphicsShaderProgram.cpp:1157
void update_light_uniforms()
b Description:
Definition: diguyOglGraphicsShaderProgram.cpp:685
int m_bind_location_attr_blend_tangent
Definition: diguyOglGraphicsShaderProgram.h:75
int m_bind_location_ufrm_link_matrices_tbo
Instancing uniforms:
Definition: diguyOglGraphicsShaderProgram.h:97
virtual int bind_uniform_with_location(int location, const char *name, int value_size, float *values)
These functions will be called by DI-Guy when there is a shader uniform that needs to be updated and ...
Definition: diguyOglGraphicsShaderProgram.cpp:1252
int m_bind_location_ufrm_pbr_enabled
General state variables.
Definition: diguyOglGraphicsShaderProgram.h:106
diguyOglUniformBufferUpdater * get_ogl_uniform_buffer_updater()
Definition: diguyOglGraphicsShaderProgram.h:157
virtual int unbind()
In general variables that were set in bind() should be unset or unbound here.
Definition: diguyOglGraphicsShaderProgram.cpp:761
char m_vertex_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:173
int m_bind_location_attr_blend_normal
Definition: diguyOglGraphicsShaderProgram.h:74
int m_bind_location_ufrm_apply_matrices_flag
should bone matrices be used for this drawable, if 0 assumed to be a rigid drawable ...
Definition: diguyOglGraphicsShaderProgram.h:85
int m_bind_location_attr_blend_vertex
blend shape per vertex attributes
Definition: diguyOglGraphicsShaderProgram.h:73
int m_bind_location_ufrm_link_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:101
virtual int bind()
This function will be called by DI-Guy when this program is being bound for rendering.
Definition: diguyOglGraphicsShaderProgram.cpp:659
char * load_shader_source(const char *shader_filename)
Definition: diguyOglGraphicsShaderProgram.cpp:1049
int m_bind_location_attr_vertex
base default attrib locations
Definition: diguyOglGraphicsShaderProgram.h:59
int m_bind_location_attr_tangent
Per vertex tangent for bump mapping.
Definition: diguyOglGraphicsShaderProgram.h:64
int m_bind_location_ufrm_base_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:99
diguyGraphicsShaderProgram * diguyOglGraphicsShaderProgram_create_func(void *internal_data)
Create function declaration.
Definition: diguyOglGraphicsShaderProgram.cpp:1328
int m_bind_location_attr_color
needed for IM and particle systems
Definition: diguyOglGraphicsShaderProgram.h:56
virtual int get_gl_program_object()
This function will be called by DI-Guy when core code is attempting to identify send shader low level...
Definition: diguyOglGraphicsShaderProgram.h:49
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:96
int load_and_compile_shader(GLhandleARB shader_object, const char *shader_filename, int shader_type, bool &shader_loaded)
Definition: diguyOglGraphicsShaderProgram.cpp:796
This is an example implementation of a diguyUniformBufferUpdater it's responsible for translating api...
Definition: diguyOglUniformBuffer.h:140
int m_bind_location_ufrm_emission_color
uniform for controlling emission color
Definition: diguyOglGraphicsShaderProgram.h:81
GLhandleARB m_gl_pixel_shader_object
Definition: diguyOglGraphicsShaderProgram.h:181
int m_bind_location_ufrm_misc_2_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:114
int m_bind_location_ufrm_textures_enabled
Definition: diguyOglGraphicsShaderProgram.h:108
virtual int load_pixel_shader_source(const char *filename_base)
This function is the pixel shader (AKA fragment shader in OpenGL) equivalent of load_vertex_shader_so...
Definition: diguyOglGraphicsShaderProgram.cpp:222
char m_pixel_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:178
int m_bind_location_attr_texture
Definition: diguyOglGraphicsShaderProgram.h:61