DI-Guy SDK Documentation  13.8
diguyOglGraphicsShaderProgram.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2024 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 #pragma once
7 
8 // needed for function prototypes
9 #include <GL/glew.h>
10 #include <GL/gl.h>
11 
13 
14 class diguyGraphicsLink;
16 
40 {
41 
42 public:
43 
44  diguyOglGraphicsShaderProgram(void* internal_data);
46 
47  virtual int load_vertex_shader_source(const char* filename_base) override;
48  virtual int load_pixel_shader_source(const char* filename_base) override;
49  virtual int link() override;
50 
51  virtual int bind() override;
52  virtual int unbind() override;
53 
54  virtual int get_gl_program_object() override {return m_gl_program_object;}
55 
56 
57  /*
58  * Though looked up here, these bind locations are used in
59  * diguyOglGraphicsMesh.cpp.
60  */
63 
68 
71 
74 
77 
78 
83 
86 
90 
93 
96 
99 
106 
137 
138  /*
139  * Uniform for controlling whether links matrices are applied to
140  * vertices in the vertex shader. Set from the mesh draw() function.
141  */
142  virtual void set_apply_matrices_flag(int apply_matrices_flag);
143  virtual void set_textures_enabled(int enabled);
144 
145  /*
146  * Called by diguy internal code to send data to the shaders.
147  */
148  virtual int bind_color_array(int num_colors,
149  const float* color_data);
150 
151 
152  virtual int bind_matrix(int bind_location, const float* mat_data);
153 
154  virtual int bind_link_matrices(int num_mats, const float* mat_data);
155 
156  virtual int bind_uniform_with_location(int location,
157  const char* name,
158  int value_size,
159  float* values);
160  virtual int bind_uniform_with_location(int location,
161  const char* name,
162  int value_size,
163  int* values);
164 
165  /*
166  * Called by diguy internal find out what capabilities the shader has.
167  */
168  virtual int get_attrib_bind_location(const char* name);
169  virtual int get_uniform_bind_location(const char* name);
170 
172 
174  static int s_bound;
175 
176 protected:
177 
178  int load_and_compile_shader(GLhandleARB shader_object,
179  const char* shader_filename,
180  int shader_type,
181  bool& shader_loaded);
182 
183  char* load_shader_source(const char* shader_filename);
184  void update_light_uniforms();
186  GLhandleARB m_gl_program_object;
198  bool m_linked;
200  const float * m_last_matrix_data;
201 
204 };
205 
206 
212 
213 
diguyOglGraphicsShaderProgram(void *internal_data)
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...
bool m_linked
Definition: diguyOglGraphicsShaderProgram.h:195
int m_bind_location_attr_weight_array
Skeletal animation bone weight.
Definition: diguyOglGraphicsShaderProgram.h:72
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:120
int m_bind_location_ufrm_link_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:102
int m_bind_location_ufrm_specular_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:112
bool m_vertex_shader_valid
Definition: diguyOglGraphicsShaderProgram.h:187
GLhandleARB m_gl_vertex_shader_object
Definition: diguyOglGraphicsShaderProgram.h:188
char * load_shader_source(const char *shader_filename)
int m_ubo_transform_block_index
Definition: diguyOglGraphicsShaderProgram.h:129
int m_bind_location_ufrm_component_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:113
int m_bind_location_ufrm_bump_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:111
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...
virtual int load_vertex_shader_source(const char *filename_base) override
This function will be called by DI-Guy when it is time for the vertex part of this shader to be loade...
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 ...
int m_bind_location_attr_index_array
Skeletal animation bone index.
Definition: diguyOglGraphicsShaderProgram.h:75
int m_bind_location_ufrm_base_matrices_start
Definition: diguyOglGraphicsShaderProgram.h:100
bool m_vertex_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:186
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:96
This class is part of the DI-Guy Graphics API.
Definition: diguyOglGraphicsShaderProgram.h:39
int m_include_point_lights
should shader include point light support.
Definition: diguyOglGraphicsShaderProgram.h:134
int m_ubo_material_block_index
Definition: diguyOglGraphicsShaderProgram.h:130
const float * m_last_matrix_data
Definition: diguyOglGraphicsShaderProgram.h:197
int m_ubo_per_frame_block_index
Definition: diguyOglGraphicsShaderProgram.h:131
virtual int link() override
This function will be called by DI-Guy when it is time for the shader program to be linked...
virtual int bind() override
This function will be called by DI-Guy when this program is being bound for rendering.
virtual void set_textures_enabled(int enabled)
int m_bind_location_ufrm_extra_per_instance_data
Definition: diguyOglGraphicsShaderProgram.h:105
int m_bind_location_ufrm_link_matrices
matrix array used to transform a skinned mesh
Definition: diguyOglGraphicsShaderProgram.h:93
diguyOglUniformBufferUpdater * m_uniform_buffer_updater
shared uniform buffer object
Definition: diguyOglGraphicsShaderProgram.h:200
int m_bind_location_ufrm_misc_1_map_enabled
these really aren't use now.
Definition: diguyOglGraphicsShaderProgram.h:116
bool m_pixel_shader_loaded
Definition: diguyOglGraphicsShaderProgram.h:191
virtual int get_gl_program_object() override
This function will be called by DI-Guy when core code is attempting to identify send shader low level...
Definition: diguyOglGraphicsShaderProgram.h:54
static int s_bound
stat for how many shaders were bound this frame
Definition: diguyOglGraphicsShaderProgram.h:171
GLhandleARB m_gl_program_object
Definition: diguyOglGraphicsShaderProgram.h:183
int m_bind_location_attr_normal
Definition: diguyOglGraphicsShaderProgram.h:65
bool m_pixel_shader_valid
Definition: diguyOglGraphicsShaderProgram.h:192
int m_bind_location_ufrm_link_matrix
matrix used to transform a rigid drawable
Definition: diguyOglGraphicsShaderProgram.h:90
virtual int load_pixel_shader_source(const char *filename_base) override
This function is the pixel shader (AKA fragment shader in OpenGL) equivalent of load_vertex_shader_so...
float m_last_light_update_time
Definition: diguyOglGraphicsShaderProgram.h:196
virtual int bind_matrix(int bind_location, const float *mat_data)
int m_bind_location_ufrm_link_matrices_tbo
Instancing uniforms:
Definition: diguyOglGraphicsShaderProgram.h:99
int m_bind_location_ufrm_pbr_enabled
General state variables.
Definition: diguyOglGraphicsShaderProgram.h:108
diguyOglUniformBufferUpdater * get_ogl_uniform_buffer_updater()
Definition: diguyOglGraphicsShaderProgram.h:168
int m_bind_location_ufrm_blend_indecies
Definition: diguyOglGraphicsShaderProgram.h:79
char m_vertex_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:185
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:87
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...
int m_bind_location_ufrm_link_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:103
virtual int unbind() override
In general variables that were set in bind() should be unset or unbound here.
int m_bind_location_attr_vertex
base default attrib locations
Definition: diguyOglGraphicsShaderProgram.h:64
int m_bind_location_attr_tangent
Per vertex tangent for bump mapping.
Definition: diguyOglGraphicsShaderProgram.h:69
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...
int m_bind_location_ufrm_base_matrices_count
Definition: diguyOglGraphicsShaderProgram.h:101
diguyGraphicsShaderProgram * diguyOglGraphicsShaderProgram_create_func(void *internal_data)
Create function declaration.
int m_bind_location_ufrm_decal_enabled
index into texture array sampler
Definition: diguyOglGraphicsShaderProgram.h:123
int m_bind_location_attr_color
needed for IM and particle systems
Definition: diguyOglGraphicsShaderProgram.h:61
int m_bind_location_ufrm_decal_index
Definition: diguyOglGraphicsShaderProgram.h:124
int m_bind_location_ufrm_vert_count
Definition: diguyOglGraphicsShaderProgram.h:80
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:94
int load_and_compile_shader(GLhandleARB shader_object, const char *shader_filename, int shader_type, bool &shader_loaded)
This is an example implementation of a diguyUniformBufferUpdater it's responsible for translating api...
Definition: diguyOglUniformBuffer.h:151
int m_bind_location_ufrm_emission_color
uniform for controlling emission color
Definition: diguyOglGraphicsShaderProgram.h:83
GLhandleARB m_gl_pixel_shader_object
Definition: diguyOglGraphicsShaderProgram.h:193
int m_bind_location_ufrm_fade
uniform for per object alpha fade for lod fade out support.
Definition: diguyOglGraphicsShaderProgram.h:127
virtual void set_apply_matrices_flag(int apply_matrices_flag)
int m_bind_location_ufrm_misc_2_map_enabled
Definition: diguyOglGraphicsShaderProgram.h:117
int m_bind_location_ufrm_textures_enabled
Definition: diguyOglGraphicsShaderProgram.h:110
char m_pixel_shader_filename[512]
Definition: diguyOglGraphicsShaderProgram.h:190
int m_bind_location_attr_texture
Definition: diguyOglGraphicsShaderProgram.h:66