DI-Guy SDK Documentation  13.1
diguyOglGraphicsShaderProgram.h
Go to the documentation of this file.
1 #ifndef __diguyOglGraphicsShaderProgram_H
2 #define __diguyOglGraphicsShaderProgram_H
3 
4 
5 
6 #include "ogl_headers.h"
7 
9 
11 #include <hash_map>
12 
13 
14 /*********************************************************************
15  **
16  *2 diguyOglGraphicsShaderProgram
17  **
18  ** This class is part of the DI-Guy Graphics API. It overrides the class
19  ** diguyGraphicsShaderProgram. Detailed documentation is in the
20  ** implementation file documentation
21  ** <a href="diguyOglGraphicsShaderProgram.cpp.html">here</a>.
22  */
23 
25 {
26 
27 public:
28 
29  diguyOglGraphicsShaderProgram(void* internal_data);
31 
32  virtual int load_vertex_shader_source(const char* filename_base);
33  virtual int load_pixel_shader_source(const char* filename_base);
34  virtual int reload();
35  virtual int link();
36 
37  virtual int bind();
38  virtual int unbind();
39 
41 
42  GLhandleARB m_gl_program_object;
43 
44  /*
45  * Though looked up here, these bind locations are used in
46  * diguyOglGraphicsMesh.cpp.
47  */
51 
57 
63 
66 
68 
72 
75 
78 
79  /*
80  * Uniform for controlling whether links matrices are applied to
81  * vertices in the vertex shader. Set from the mesh draw() function.
82  */
83  virtual void set_apply_matrices_flag(int apply_matrices_flag);
84  virtual void set_textures_enabled(int enabled);
85 
86  /*
87  * Called by diguy internal code to send data to the shaders.
88  */
89  virtual int bind_color_array(int num_colors,
90  const float* color_data);
91  virtual int bind_link_matrices(int num_mats,
92  const float* mat_data);
93 
94  virtual int bind_uniform_with_location(int location,
95  const char* name,
96  int value_size,
97  float* values);
98  virtual int bind_uniform_with_location(int location,
99  const char* name,
100  int value_size,
101  int* values);
102 
103  /*
104  * Called by diguy internal find out what capabilities the shader has.
105  */
106  virtual int get_attrib_bind_location(const char* name);
107  virtual int get_uniform_bind_location(const char* name);
108 
109  /*
110  * These are render state variables whose values are set by DI-Guy.
111  * They should not be set in bind(), but in the appropriate
112  * diguyOglGraphicsShaderInstance virtual functions.
113  */
114 
115 protected:
116 
117  int load_and_compile_shader(GLhandleARB shader_object,
118  const char* shader_filename,
119  bool& shader_loaded);
120 
121  char* load_shader_source(const char* shader_filename);
122  void free_shader_source(char* source_source);
133  bool m_linked;
135  const float * m_last_matrix_data;
136 
137 };
138 
139 
145 
146 
147 #endif
diguyOglGraphicsShaderProgram(void *internal_data)
4 Header files and forward declarations
Definition: diguyOglGraphicsShaderProgram.cpp:66
bool m_linked
Definition: diguyOglGraphicsShaderProgram.h:131
int m_bind_location_attr_weight_array
Definition: diguyOglGraphicsShaderProgram.h:46
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:181
int m_bind_location_ufrm_link_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:59
int m_bind_location_ufrm_specular_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:68
int m_bind_location_ufrm_light_dir_os
Definition: diguyOglGraphicsShaderProgram.h:62
GLhandleARB m_gl_vertex_shader_object
Definition: diguyOglGraphicsShaderProgram.h:125
~diguyOglGraphicsShaderProgram()
Definition: diguyOglGraphicsShaderProgram.cpp:152
int m_bind_location_ufrm_component_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:69
int m_bind_location_ufrm_light_array
Definition: diguyOglGraphicsShaderProgram.h:74
int m_bind_location_ufrm_bump_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:67
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:558
int m_bind_location_attr_index_array
Definition: diguyOglGraphicsShaderProgram.h:47
int m_bind_location_ufrm_base_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:57
bool m_vertex_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:124
int m_bind_location_ufrm_link_colors
Definition: diguyOglGraphicsShaderProgram.h:54
Definition: diguyOglGraphicsShaderProgram.h:22
int m_include_point_lights
Definition: diguyOglGraphicsShaderProgram.h:75
virtual void set_apply_matrices_flag(int apply_matrices_flag)
Definition: diguyOglGraphicsShaderProgram.cpp:1139
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:1051
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:1101
const float * m_last_matrix_data
Definition: diguyOglGraphicsShaderProgram.h:133
int m_bind_location_ufrm_inverse_transform_matrix
Definition: diguyOglGraphicsShaderProgram.h:52
int m_bind_location_ufrm_link_matrices
Definition: diguyOglGraphicsShaderProgram.h:53
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:259
int m_bind_location_ufrm_misc_1_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:71
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:579
bool m_pixel_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:128
GLhandleARB m_gl_program_object
Definition: diguyOglGraphicsShaderProgram.h:40
int m_bind_location_ufrm_link_matrix
Definition: diguyOglGraphicsShaderProgram.h:51
virtual void set_textures_enabled(int enabled)
Definition: diguyOglGraphicsShaderProgram.cpp:1183
float m_last_light_update_time
Definition: diguyOglGraphicsShaderProgram.h:132
int load_and_compile_shader(GLhandleARB shader_object, const char *shader_filename, bool &shader_loaded)
Definition: diguyOglGraphicsShaderProgram.cpp:795
virtual int reload()
This function will be called by DI-Guy if this shader program should be reloaded. ...
Definition: diguyOglGraphicsShaderProgram.cpp:727
void free_shader_source(char *source_source)
Definition: diguyOglGraphicsShaderProgram.cpp:1030
void update_light_uniforms()
b Description:
Definition: diguyOglGraphicsShaderProgram.cpp:627
int m_bind_location_ufrm_link_matrices_tbo
Definition: diguyOglGraphicsShaderProgram.h:56
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:1165
virtual int unbind()
In general variables that were set in bind() should be unset or unbound here.
Definition: diguyOglGraphicsShaderProgram.cpp:696
char m_vertex_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:123
int m_bind_location_ufrm_eye_point_os
Definition: diguyOglGraphicsShaderProgram.h:63
int m_bind_location_ufrm_apply_matrices_flag
Definition: diguyOglGraphicsShaderProgram.h:50
int m_bind_location_ufrm_link_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:60
virtual int bind()
This function will be called by DI-Guy when this program is being bound for rendering.
Definition: diguyOglGraphicsShaderProgram.cpp:600
char * load_shader_source(const char *shader_filename)
Definition: diguyOglGraphicsShaderProgram.cpp:964
int m_bind_location_attr_tangent
Definition: diguyOglGraphicsShaderProgram.h:48
int m_bind_location_ufrm_base_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:58
diguyGraphicsShaderProgram * diguyOglGraphicsShaderProgram_create_func(void *internal_data)
Create function declaration.
Definition: diguyOglGraphicsShaderProgram.cpp:1230
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:38
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:94
GLhandleARB m_gl_pixel_shader_object
Definition: diguyOglGraphicsShaderProgram.h:129
int m_bind_location_ufrm_misc_2_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:72
int m_bind_location_ufrm_textures_enabled
Definition: diguyOglGraphicsShaderProgram.h:65
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:223
char m_pixel_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:127