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