Panda3D
dxShaderContext9.h
1 // Filename: dxShaderContext9.h
2 // Created by: aignacio (Jan06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DXSHADERCONTEXT9_H
16 #define DXSHADERCONTEXT9_H
17 
18 #include "dtool_config.h"
19 #include "pandabase.h"
20 #include "string_utils.h"
21 #include "internalName.h"
22 #include "shader.h"
23 #include "shaderContext.h"
24 
25 #define CLP(name) DX##name##9
26 #define CLASSPREFIX_QUOTED "DX"
27 
28 class VertexElementArray;
29 class CLP(GraphicsStateGuardian);
30 
31 // Caution: adding HLSL support is going to be tricky, as the parsing needs
32 // to be done in the cull thread, which cannot use the DX API. - Josh
33 //
34 //
35 // typedef struct
36 // {
37 // int vertex_shader;
38 // int total_constant_descriptions;
39 // D3DXCONSTANT_DESC *constant_description_array;
40 // }
41 // DX_PARAMETER;
42 //
43 // typedef struct
44 // {
45 // int state;
46 // union
47 // {
48 // DIRECT_3D_VERTEX_SHADER direct_3d_vertex_shader;
49 // DIRECT_3D_PIXEL_SHADER direct_3d_pixel_shader;
50 // };
51 // LPD3DXCONSTANTTABLE constant_table;
52 // D3DXCONSTANTTABLE_DESC constant_table_description;
53 //
54 // int total_semantics;
55 // D3DXSEMANTIC *semantic_array;
56 // }
57 // DIRECT_3D_SHADER;
58 
59 ////////////////////////////////////////////////////////////////////
60 // Class : DXShaderContext9
61 // Description : xyz
62 ////////////////////////////////////////////////////////////////////
63 class EXPCL_PANDADX CLP(ShaderContext) : public ShaderContext {
64 public:
65  typedef CLP(GraphicsStateGuardian) GSG;
66 
67  CLP(ShaderContext)(Shader *s, GSG *gsg);
68  ~CLP(ShaderContext)();
69 
70  INLINE bool valid(GSG *gsg);
71  bool bind(GSG *gsg);
72  void unbind(GSG *gsg);
73  void issue_parameters(GSG *gsg, int altered);
74  void issue_transform(GSG *gsg);
75  void disable_shader_vertex_arrays(GSG *gsg);
76  bool update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg,
77  bool force);
78  void disable_shader_texture_bindings(GSG *gsg);
79  void update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg);
80 
81  class VertexElementArray* _vertex_element_array;
82  LPDIRECT3DVERTEXDECLARATION9 _vertex_declaration;
83 
84  int _num_bound_streams;
85 
86  // FOR DEBUGGING
87  string _name;
88 
89 private:
90 #ifdef HAVE_CG
91  CGprogram _cg_program;
92  pvector <CGparameter> _cg_parameter_map;
93 #endif
94 
95 private:
96  void release_resources(void);
97 
98 public:
99  static TypeHandle get_class_type() {
100  return _type_handle;
101  }
102  static void init_type() {
104  register_type(_type_handle, CLASSPREFIX_QUOTED "ShaderContext",
105  TypedObject::get_class_type());
106  }
107  virtual TypeHandle get_type() const {
108  return get_class_type();
109  }
110  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
111 
112 private:
113  static TypeHandle _type_handle;
114 };
115 
116 #include "dxShaderContext9.I"
117 
118 #endif
A GraphicsStateGuardian for rendering into DirectX9 contexts.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
Definition: shader.h:50
The ShaderContext is meant to contain the compiled version of a shader string.
Definition: shaderContext.h:35
This class gives the ability for a user-friendly way of creating a vertex declaration for DirectX 9...
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
Encapsulates all the communication with a particular instance of a given rendering backend...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85