DI-Guy SDK Documentation  13.8
diguyDx9GraphicsShaderProgram.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2024 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 /*********************************************************************
7  **
8  *2 diguyDx9GraphicsShaderProgram
9  **
10  ** This class is part of the DI-Guy Graphics API. It overrides the class
11  ** diguyGraphicsShaderProgram. Detailed documentation is in the
12  ** implementation file documentation
13  ** <a href="diguyDx9GraphicsShaderProgram.cpp.html">here</a>.
14  */
15 
16 #ifndef diguyDx9GraphicsShaderProgram_h__
17 #define diguyDx9GraphicsShaderProgram_h__
18 
19 class diguyGraphicsLink;
20 
22 #include <dx9_headers.h>
23 
24 struct ID3DXEffect;
25 
26 
27 /****************************************************************************/
29 {
30 
31 public:
32 
33  diguyDx9GraphicsShaderProgram(void* internal_data);
35 
36  virtual int load_vertex_shader_source(const char* filename_base);
37  virtual int load_pixel_shader_source(const char* filename_base);
38  virtual int reload();
39  virtual int link();
40 
41  virtual int bind();
42  virtual int unbind();
43 
44 
45  virtual int bind_link_matrices(int num_mats,
46  const float* mat_data);
47  virtual int bind_color_array(int num_colors,
48  const float* color_data);
49  virtual void set_apply_matrices_flag(int apply_matrices_flag);
50 
51 protected:
52 
54  const char* shader_filename,
55  bool& shader_loaded);
56 
57  char* load_shader_source(const char* shader_filename);
58  void free_shader_source(char* source_source);
59 
60  LPD3DXBUFFER m_vertex_code;
61  LPDIRECT3DVERTEXSHADER9 m_vertex_shader;
62  char m_vertex_shader_filename[512];
64 
65  LPD3DXBUFFER m_pixel_code;
66  LPDIRECT3DPIXELSHADER9 m_pixel_shader;
67  char m_pixel_shader_filename[512];
69 
70  bool m_linked;
71 };
72 
73 
79 
80 #endif /* diguyDx9GraphicsShaderProgram_h__ */
81 
void free_shader_source(char *source_source)
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...
LPD3DXBUFFER m_pixel_code
Definition: diguyDx9GraphicsShaderProgram.h:63
char m_vertex_shader_filename[512]
Definition: diguyDx9GraphicsShaderProgram.h:60
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...
LPDIRECT3DVERTEXSHADER9 m_vertex_shader
Definition: diguyDx9GraphicsShaderProgram.h:59
char m_pixel_shader_filename[512]
Definition: diguyDx9GraphicsShaderProgram.h:65
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...
diguyGraphicsShaderProgram * diguyDx9GraphicsShaderProgram_create_func(void *internal_data)
Create function declaration.
virtual int unbind()
In general variables that were set in bind() should be unset or unbound here.
int load_and_compile_shader(const char *shader_filename, bool &shader_loaded)
Definition: diguyDx9GraphicsShaderProgram.h:27
LPD3DXBUFFER m_vertex_code
Definition: diguyDx9GraphicsShaderProgram.h:58
bool m_vertex_shader_loaded
Definition: diguyDx9GraphicsShaderProgram.h:61
LPDIRECT3DPIXELSHADER9 m_pixel_shader
Definition: diguyDx9GraphicsShaderProgram.h:64
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...
virtual int bind()
This function will be called by DI-Guy when this program is being bound for rendering.
char * load_shader_source(const char *shader_filename)
bool m_pixel_shader_loaded
Definition: diguyDx9GraphicsShaderProgram.h:66
virtual int link()
This function will be called by DI-Guy when it is time for the shader program to be linked...
diguyDx9GraphicsShaderProgram(void *internal_data)
virtual void set_apply_matrices_flag(int apply_matrices_flag)
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:94
bool m_linked
Definition: diguyDx9GraphicsShaderProgram.h:68
virtual int reload()
Forces the underlying shader to reload. Returns 0 on success.