00001 00002 // Copyright 1986-2009 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin, 00003 // Germany. All rights reserved. 00005 // Created: 09.01.06 00006 // Module: api 00007 // Purpose: mental ray C++ shader interface extensions 00009 00030 00031 #ifndef MI_SHADER_IF_H 00032 #define MI_SHADER_IF_H 00033 00034 // if file is included internally 00035 #if !defined(SHADER_H) 00036 #include <mi_raylib.h> 00037 #include <mi_lib.h> 00038 #include <mi_shader.h> 00039 #endif 00040 00041 #ifndef __cplusplus 00042 #error mi_shader_if.h requires C++ compilation 00043 #endif 00044 00045 00047 static const int mi_ray_interface_version = 3; 00048 00049 namespace mi { 00050 namespace shader_v3 { 00051 class Interface; 00052 }} 00053 00054 00072 00073 extern "C" mi::shader_v3::Interface *mi_get_shader_interface( 00074 int version = mi_ray_interface_version); 00075 00077 namespace mi { 00078 00079 00085 namespace shader_v3 { 00086 00087 00089 class Options; 00090 class LightList; 00091 class Framebuffer; 00092 class Map_status; 00093 class Map_base; 00094 class Edit_map_dbhandle; 00095 class Access_map_dbhandle; 00096 class Access_map; 00097 class Edit_map; 00098 class Map_declaration_base; 00099 class Map_iterator_base; 00100 class Map_element_base; 00101 class Map_lookup_base; 00102 class Bsdf; 00103 class Subdivision34; 00104 00105 00106 00126 00127 class Interface { 00128 public: 00145 static inline Interface* get( 00146 int version = mi_ray_interface_version) 00147 { 00148 return mi_get_shader_interface(version); 00149 } 00150 00164 virtual Options *getOptions( 00165 miTag string_options); 00166 00170 virtual miTag createFramebuffer(); 00171 00176 virtual miTag copyFramebuffer( 00177 miTag old_buffer_tag); 00178 00190 virtual LightList *createLightList( 00191 miState *state, 00192 miTag *slist = 0, 00193 int n = 0); 00194 00201 virtual void release(); 00202 00203 00217 virtual LightList *createLightList( 00218 miState *state, 00219 const miVector &axis, 00220 miScalar spread_cos, 00221 miTag *slist = 0, 00222 int n = 0); 00223 00224 00231 virtual Edit_map_dbhandle *createMap( 00232 const Map_declaration_base *map_declaration = 0); 00233 00240 virtual Access_map_dbhandle *accessMap( 00241 const miTag map_tag); 00242 00249 virtual Edit_map_dbhandle *editMap( 00250 const miTag map_tag); 00251 00259 virtual Access_map_dbhandle *accessMap( 00260 const char *filename, 00261 Map_status *status); 00262 00270 virtual Edit_map_dbhandle *editMap( 00271 const char *filename, 00272 Map_status *status); 00273 00280 virtual Map_declaration_base *createMapDeclaration( 00281 const miUint dimension); 00282 00290 virtual Map_declaration_base *copyMapDeclaration( 00291 const Map_declaration_base *other, 00292 Map_status *status); 00293 00301 virtual Map_declaration_base *copyMapDeclaration( 00302 const Map_element_base *map_element, 00303 Map_status *status); 00304 00312 virtual Map_declaration_base *copyMapDeclaration( 00313 const Map_base *map, 00314 Map_status *status); 00315 00322 virtual Map_element_base *createMapElement( 00323 const Map_declaration_base *declaration = 0); 00324 00331 virtual Map_element_base *copyMapElement( 00332 const Map_element_base *other); 00333 00341 virtual Map_iterator_base *createMapIterator( 00342 const Map_base *map, 00343 Map_status *status); 00344 00352 virtual Map_iterator_base *copyMapIterator( 00353 const Map_iterator_base *other, 00354 Map_status *status); 00355 00363 virtual Map_lookup_base *createMapLookup( 00364 const Map_base *map, 00365 Map_status *status); 00366 00374 virtual Map_lookup_base *copyMapLookup( 00375 const Map_lookup_base *other, 00376 Map_status *status); 00377 00386 virtual const Framebuffer *accessFramebuffer( 00387 miTag buffer_tag); 00388 00398 virtual bool releaseFramebuffer( 00399 const Framebuffer *buffer, 00400 miTag buffer_tag); 00401 00410 virtual Framebuffer *editFramebuffer( 00411 miTag buffer_tag); 00412 00422 virtual bool releaseFramebuffer( 00423 Framebuffer *buffer, 00424 miTag buffer_tag); 00425 00433 virtual Bsdf* allocBsdf( 00434 miState* state); 00435 00443 virtual void releaseBsdf( 00444 Bsdf* bsdf, 00445 miState* state); 00446 00449 virtual Subdivision34 * accessSubdivision34( 00450 miTag tag); 00451 00454 virtual void releaseSubdivision34( 00455 const Subdivision34 *subdiv34); 00456 }; 00457 00458 00497 00498 class Options { 00499 public: 00501 00505 virtual void set( 00506 const char *name, 00507 bool value) = 0; 00508 00514 virtual void set( 00515 const char *name, 00516 const char * value) = 0; 00517 00522 virtual void set( 00523 const char *name, 00524 int value) = 0; 00525 00529 virtual void set( 00530 const char *name, 00531 float value) = 0; 00532 00538 virtual void set( 00539 const char *name, 00540 float value1, 00541 float value2, 00542 float value3) = 0; 00543 00550 virtual void set( 00551 const char *name, 00552 float value1, 00553 float value2, 00554 float value3, 00555 float value4) = 0; 00556 00562 virtual bool get( 00563 const char *name, 00564 bool *value) const = 0; 00565 00573 virtual bool get( 00574 const char *name, 00575 const char **value) const = 0; 00576 00582 virtual bool get( 00583 const char *name, 00584 int *value) const = 0; 00585 00594 virtual bool get( 00595 const char *name, 00596 float *value) const = 0; 00597 00610 virtual bool get( 00611 const char *name, 00612 float *value1, 00613 float *value2, 00614 float *value3) const = 0; 00615 00630 virtual bool get( 00631 const char *name, 00632 float *value1, 00633 float *value2, 00634 float *value3, 00635 float *value4) const = 0; 00636 00642 virtual bool remove( 00643 const char *name) = 0; 00644 00648 virtual void release() = 0; 00649 }; 00650 00651 00652 00655 class Access_interface { 00656 public: 00658 Access_interface() 00659 : m_iface (mi_get_shader_interface()) 00660 {} 00661 00663 ~Access_interface() 00664 { 00665 m_iface->release(); 00666 m_iface = 0; 00667 } 00668 00670 mi::shader_v3::Interface * operator->() 00671 { 00672 return m_iface; 00673 } 00674 00675 private: 00676 mi::shader_v3::Interface *m_iface; 00677 }; 00678 00679 00683 typedef Access_interface Interface_access; 00684 00685 00686 } // namespace shader_v3 00687 00688 00689 // namespace alias, shaders should use it 00690 namespace shader = shader_v3; 00691 00692 } // namespace mi 00693 00694 #include "shader_framebuffer.h" 00695 #include "shader_map.h" 00696 #include "shader_lightlist.h" 00697 #include "shader_sds34.h" 00698 00699 #endif // MI_SHADER_IF_H
Copyright © 1986-2009 by
mental images GmbH