00001 #ifndef CGBINDING_H
00002
00003 #define CGBINDING_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #pragma warning( disable:4786 ) // warning C4503: ' ' : decorated name length exceeded, name was truncated
00016
00017 #include "cgbindingtype.h"
00018
00019 #include <vector>
00020 #include <map>
00021
00022 class CgBinding;
00023 class CgVertexShader;
00024 class CgPixelShader;
00025
00045 class CgVertexBind
00046 {
00047 public:
00048 CgVertexBind(void) { };
00049
00050 CgVertexBind(VertexBindingType b,unsigned int handle)
00051 {
00052 mBind = b;
00053 mHandle = handle;
00054 };
00055
00056 bool Activate(CgBinding *bindings,unsigned int program_handle,void *context1,void *context2);
00057
00058 private:
00059 VertexBindingType mBind;
00060 unsigned int mHandle;
00061 };
00062
00063
00064 typedef std::vector< CgVertexBind > CgVertexBindVector;
00065
00084 class CgVertexShader
00085 {
00086 public:
00087
00088 CgVertexShader(int guid,VertexBindingFormat format,unsigned int handle)
00089 {
00090 mGuid = guid;
00091 mFormat = format;
00092 mHandle = handle;
00093 }
00094
00095 int GetGuid(void) const { return mGuid; };
00096
00097 void AddBinding(VertexBindingType type,unsigned int bind_handle)
00098 {
00099 CgVertexBind b(type,bind_handle);
00100 mBindings.push_back(b);
00101 }
00102
00103 bool Activate(void);
00104
00105 bool ActivateBindings(CgBinding *bindings,void *context1,void *context2);
00106
00107 private:
00108 int mGuid;
00109 unsigned int mHandle;
00110 VertexBindingFormat mFormat;
00111 CgVertexBindVector mBindings;
00112 };
00113
00114 typedef std::map< int , CgVertexShader * > CgVertexShaderMap;
00115
00116
00136 class CgPixelBind
00137 {
00138 public:
00139 CgPixelBind(void) { };
00140
00141 CgPixelBind(PixelBindingType b,unsigned int handle)
00142 {
00143 mBind = b;
00144 mHandle = handle;
00145 };
00146
00147 bool Activate(CgBinding *bindings,unsigned int program_handle,void *context1,void *context2);
00148
00149 private:
00150 PixelBindingType mBind;
00151 unsigned int mHandle;
00152 };
00153
00154
00155 typedef std::vector< CgPixelBind > CgPixelBindVector;
00156
00157
00172 class CgPixelShader
00173 {
00174 public:
00175
00176 CgPixelShader(int guid,unsigned int handle)
00177 {
00178 mGuid = guid;
00179 mHandle = handle;
00180 }
00181
00182 int GetGuid(void) const { return mGuid; };
00183
00184 void AddBinding(PixelBindingType type,unsigned int bind_handle)
00185 {
00186 CgPixelBind b(type,bind_handle);
00187 mBindings.push_back(b);
00188 }
00189
00190 bool Activate(void);
00191
00192 bool ActivateBindings(CgBinding *bindings,void *context1,void *context2);
00193
00194 private:
00195 int mGuid;
00196 unsigned int mHandle;
00197 CgPixelBindVector mBindings;
00198 };
00199
00200 typedef std::map< int , CgPixelShader * > CgPixelShaderMap;
00201
00221 class CgBinding
00222 {
00223 public:
00224
00225 CgBinding(void);
00226 ~CgBinding(void);
00227
00228
00229
00230
00231 virtual bool ValidateVertexBindingType(VertexBindingType type) =0;
00232
00233 virtual void * GetVertexBindingType(VertexBindingType type,
00234 void *context1,
00235 void *context2) = 0;
00236
00237
00238
00239 virtual bool ValidatePixelBindingType(VertexBindingType type) =0;
00240
00241 virtual void * GetPixelBindingType(PixelBindingType type,
00242 void *context1,
00243 void *context2) = 0;
00244
00245
00246
00247 VertexBindingType AsciiToVertexBindingType(const char *bind_name);
00248 PixelBindingType AsciiToPixelBindingType(const char *bind_name);
00249
00250 CgVertexShader * CreateVertexShader(const char *program,VertexBindingFormat type,unsigned int device);
00251 CgPixelShader * CreatePixelShader(const char *program,unsigned int device);
00252
00253 bool ReleaseVertexShader(CgVertexShader *shader);
00254 bool ReleasePixelShader(CgPixelShader *shader);
00255
00256 void * GetVertexAttributes(VertexBindingFormat type);
00257
00258 const char * GetLastListing(void) const { return mLastListing; };
00259 const char * GetLastError(void) const { return mLastError; };
00260
00261 private:
00262 int mGuid;
00263 void *mContextContainer;
00264 CgVertexShaderMap mVertexShaders;
00265 CgPixelShaderMap mPixelShaders;
00266 const char *mLastListing;
00267 char mLastError[1024];
00268 };
00269
00270
00271 #endif