00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00033
00034 #pragma once
00035
00036 #include "../api_display.h"
00037 #include "../../Core/System/sharedptr.h"
00038 #include "../../Core/Text/string_types.h"
00039 #include "../../Core/IOData/virtual_directory.h"
00040 #include "graphic_context.h"
00041
00042 class CL_ShaderObject;
00043 class CL_ProgramAttribute;
00044 class CL_ProgramUniform;
00045 class CL_ProgramObject_Impl;
00046 class CL_GraphicContext;
00047 class CL_GraphicContextProvider;
00048 class CL_ResourceManager;
00049
00069 class CL_API_DISPLAY CL_ProgramObject
00070 {
00073
00074 public:
00079 CL_ProgramObject();
00080
00084 CL_ProgramObject(CL_GraphicContext &gc);
00085
00089 CL_ProgramObject(CL_GraphicContextProvider *gc_provider);
00090
00098 static CL_ProgramObject load(CL_GraphicContext &gc, const CL_StringRef &resource_id, CL_ResourceManager *resman);
00099
00107 static CL_ProgramObject load(CL_GraphicContext &gc, const CL_StringRef &vertex_fullname, const CL_StringRef &fragment_fullname);
00108
00117 static CL_ProgramObject load(CL_GraphicContext &gc, const CL_StringRef &vertex_filename, const CL_StringRef &fragment_filename, const CL_VirtualDirectory &directory);
00118
00126 static CL_ProgramObject load(CL_GraphicContext &gc, CL_IODevice &vertex_file, CL_IODevice &fragment_file);
00127
00134 static CL_ProgramObject load(CL_GraphicContext &gc, const CL_StringRef &fragment_fullname);
00135
00143 static CL_ProgramObject load(CL_GraphicContext &gc, const CL_StringRef &fragment_filename, const CL_VirtualDirectory &directory);
00144
00151 static CL_ProgramObject load(CL_GraphicContext &gc, CL_IODevice &fragment_file);
00152
00160 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, const CL_StringRef &vertex_fullname, const CL_StringRef &fragment_fullname);
00161
00170 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, const CL_StringRef &vertex_filename, const CL_StringRef &fragment_filename, const CL_VirtualDirectory &directory);
00171
00179 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, CL_IODevice &vertex_file, CL_IODevice &fragment_file);
00180
00187 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, const CL_StringRef &fragment_fullname);
00188
00196 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, const CL_StringRef &fragment_filename, const CL_VirtualDirectory &directory);
00197
00204 static CL_ProgramObject load_and_link(CL_GraphicContext &gc, CL_IODevice &fragment_file);
00205
00206 virtual ~CL_ProgramObject();
00207
00211
00212 public:
00214 bool is_null() const;
00215
00217 unsigned int get_handle() const;
00218
00220 std::vector<CL_ShaderObject> get_shaders() const;
00221
00223 CL_String get_info_log() const;
00224
00226 int get_attribute_count() const;
00227
00229 std::vector<CL_ProgramAttribute> get_attributes() const;
00230
00232 int get_attribute_location(const CL_StringRef &name) const;
00233
00235 int get_uniform_count() const;
00236
00238 std::vector<CL_ProgramUniform> get_uniforms() const;
00239
00241 int get_uniform_location(const CL_StringRef &name) const;
00242
00246
00247 public:
00249 void attach(const CL_ShaderObject &obj);
00250
00252 void detach(const CL_ShaderObject &obj);
00253
00255
00256 void bind_attribute_location(int index, const CL_StringRef &name);
00257
00259
00260 bool link();
00261
00263
00264 bool validate();
00265
00267 void set_uniform1i(const CL_StringRef &name, int);
00268
00273 void set_uniform2i(const CL_StringRef &name, int, int);
00274 void set_uniform3i(const CL_StringRef &name, int, int, int);
00275
00281 void set_uniform4i(const CL_StringRef &name, int, int, int, int);
00282
00289 void set_uniformiv(const CL_StringRef &name, int size, int count, int *data);
00290
00295 void set_uniform2i(const CL_StringRef &name, CL_Vec2i vec) {set_uniform2i(name, vec.x, vec.y);}
00296
00301 void set_uniform3i(const CL_StringRef &name, CL_Vec3i vec) {set_uniform3i(name, vec.x, vec.y, vec.z);}
00302
00307 void set_uniform4i(const CL_StringRef &name, CL_Vec4i vec) {set_uniform4i(name, vec.x, vec.y, vec.z, vec.w);}
00308
00313 void set_uniform2s(const CL_StringRef &name, CL_Vec2s vec) {set_uniform2i(name, vec.x, vec.y);}
00314
00319 void set_uniform3s(const CL_StringRef &name, CL_Vec3s vec) {set_uniform3i(name, vec.x, vec.y, vec.z);}
00320
00325 void set_uniform4s(const CL_StringRef &name, CL_Vec4s vec) {set_uniform4i(name, vec.x, vec.y, vec.z, vec.w);}
00326
00331 void set_uniform2b(const CL_StringRef &name, CL_Vec2b vec) {set_uniform2i(name, vec.x, vec.y);}
00332
00337 void set_uniform3b(const CL_StringRef &name, CL_Vec3b vec) {set_uniform3i(name, vec.x, vec.y, vec.z);}
00338
00343 void set_uniform4b(const CL_StringRef &name, CL_Vec4b vec) {set_uniform4i(name, vec.x, vec.y, vec.z, vec.w);}
00344
00350 void set_uniformiv(const CL_StringRef &name, int count, CL_Vec2i *data) {set_uniformiv(name, 2, count, *data);}
00351
00357 void set_uniformiv(const CL_StringRef &name, int count, CL_Vec3i *data) {set_uniformiv(name, 3, count, *data);}
00358
00364 void set_uniformiv(const CL_StringRef &name, int count, CL_Vec4i *data) {set_uniformiv(name, 4, count, *data);}
00365
00366 void set_uniform1f(const CL_StringRef &name, float);
00367
00372 void set_uniform2f(const CL_StringRef &name, float, float);
00373 void set_uniform3f(const CL_StringRef &name, float, float, float);
00374
00380 void set_uniform4f(const CL_StringRef &name, float, float, float, float);
00381
00388 void set_uniformfv(const CL_StringRef &name, int size, int count, float *data);
00389
00394 void set_uniform2f(const CL_StringRef &name, CL_Vec2f vec) {set_uniform2f(name, vec.x, vec.y);}
00395
00400 void set_uniform3f(const CL_StringRef &name, CL_Vec3f vec) {set_uniform3f(name, vec.x, vec.y, vec.z);}
00401
00406 void set_uniform4f(const CL_StringRef &name, CL_Vec4f vec) {set_uniform4f(name, vec.x, vec.y, vec.z, vec.w);}
00407
00413 void set_uniformfv(const CL_StringRef &name, int count, CL_Vec2f *data) {set_uniformfv(name, 2, count, *data);}
00414
00420 void set_uniformfv(const CL_StringRef &name, int count, CL_Vec3f *data) {set_uniformfv(name, 3, count, *data);}
00421
00427 void set_uniformfv(const CL_StringRef &name, int count, CL_Vec4f *data) {set_uniformfv(name, 4, count, *data);}
00428
00430 void set_uniform_matrix(const CL_StringRef &name, int size, int count, bool transpose, float *data);
00431
00436 void set_uniform_matrix(const CL_StringRef &name, CL_Mat2f matrix) {set_uniform_matrix(name, 2, 1, false, matrix.matrix);}
00437
00442 void set_uniform_matrix(const CL_StringRef &name, CL_Mat3f matrix) {set_uniform_matrix(name, 3, 1, false, matrix.matrix);}
00443
00448 void set_uniform_matrix(const CL_StringRef &name, CL_Mat4f matrix) {set_uniform_matrix(name, 4, 1, false, matrix.matrix);}
00449
00455 void set_uniform_matrix(const CL_StringRef &name, int count, CL_Mat2f *matrix) {set_uniform_matrix(name, 2, count, false, matrix->matrix);}
00456
00462 void set_uniform_matrix(const CL_StringRef &name, int count, CL_Mat3f *matrix) {set_uniform_matrix(name, 3, count, false, matrix->matrix);}
00463
00469 void set_uniform_matrix(const CL_StringRef &name, int count, CL_Mat4f *matrix) {set_uniform_matrix(name, 4, count, false, matrix->matrix);}
00470
00474
00475 private:
00476 CL_SharedPtr<CL_ProgramObject_Impl> impl;
00478 };
00479