mi_shader_if.h

Go to the documentation of this file.
00001 
00002 // Copyright 1986-2011 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 struct 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 class Mip_remap;
00105 
00106 
00107 
00127 
00128 struct Interface {
00129   public:
00146     static inline Interface* get(
00147         int             version = mi_ray_interface_version)
00148     { 
00149         return mi_get_shader_interface(version); 
00150     }
00151 
00165     virtual Options *getOptions(
00166         miTag           string_options);
00167 
00171     virtual miTag createFramebuffer();
00172 
00177     virtual miTag copyFramebuffer(
00178         miTag           old_buffer_tag);
00179 
00192     virtual LightList *createLightList(
00193         miState         *state, 
00194         miTag           *slist = 0, 
00195         int             n = 0);
00196 
00203     virtual void release();
00204 
00205 
00219     virtual LightList *createLightList(
00220         miState         *state,
00221         const miVector  &axis,
00222         miScalar        spread_cos,
00223         miTag           *slist = 0, 
00224         int             n = 0);
00225 
00226 
00233     virtual Edit_map_dbhandle *createMap(
00234         const Map_declaration_base  *map_declaration = 0);
00235 
00242     virtual Access_map_dbhandle *accessMap(
00243         const miTag             map_tag);
00244 
00251     virtual Edit_map_dbhandle *editMap(
00252         const miTag             map_tag);
00253 
00261     virtual Access_map_dbhandle *accessMap(
00262         const char              *filename,
00263         Map_status              *status);
00264 
00272     virtual Edit_map_dbhandle *editMap(
00273         const char              *filename,
00274         Map_status              *status);
00275 
00282     virtual Map_declaration_base *createMapDeclaration(
00283         const miUint            dimension);
00284 
00292     virtual Map_declaration_base *copyMapDeclaration(
00293         const Map_declaration_base  *other,
00294         Map_status                  *status);
00295 
00303     virtual Map_declaration_base *copyMapDeclaration(
00304         const Map_element_base  *map_element,
00305         Map_status              *status);
00306 
00314     virtual Map_declaration_base *copyMapDeclaration(
00315         const Map_base          *map,
00316         Map_status              *status);
00317 
00324     virtual Map_element_base *createMapElement(
00325         const Map_declaration_base  *declaration = 0);
00326 
00333     virtual Map_element_base *copyMapElement(
00334         const Map_element_base  *other);
00335 
00343     virtual Map_iterator_base *createMapIterator(
00344         const Map_base          *map,
00345         Map_status              *status);
00346 
00354     virtual Map_iterator_base *copyMapIterator(
00355         const Map_iterator_base *other,
00356         Map_status              *status);
00357 
00365     virtual Map_lookup_base *createMapLookup(
00366         const Map_base          *map,
00367         Map_status              *status);
00368 
00376     virtual Map_lookup_base *copyMapLookup(
00377         const Map_lookup_base   *other,
00378         Map_status              *status);
00379 
00381 
00388     virtual const Framebuffer *accessFramebuffer(
00389         miTag           buffer_tag);
00390 
00398     virtual bool releaseFramebuffer(
00399         const Framebuffer       *buffer,                           
00400         miTag                   buffer_tag);
00401 
00408     virtual Framebuffer *editFramebuffer(
00409         miTag           buffer_tag);
00410 
00418     virtual bool releaseFramebuffer(
00419         Framebuffer             *buffer,                           
00420         miTag                   buffer_tag);
00421 
00423 
00425 
00431     virtual Bsdf* allocBsdf(
00432             miState*            state);
00433  
00439     virtual void releaseBsdf(
00440             Bsdf*               bsdf, 
00441             miState*            state);
00442 
00444 
00447     virtual Subdivision34 * accessSubdivision34(
00448             miTag               tag);
00449 
00452     virtual void releaseSubdivision34(
00453             const Subdivision34 *subdiv34);
00454 
00464     virtual bool lookup_filter_color_texture(
00465             miColor * const     color,
00466             miState * const     state,
00467             const miTag         tex,
00468             Mip_remap &         remap,
00469             miVector *          coord);
00470 };
00471 
00472 
00511 
00512 class Options {
00513   public: 
00515 
00519     virtual void set(
00520         const char      *name, 
00521         bool            value) = 0;
00522 
00528     virtual void set(
00529         const char      *name, 
00530         const char *    value) = 0;
00531 
00536     virtual void set(
00537         const char      *name, 
00538         int             value) = 0;
00539 
00543     virtual void set(
00544         const char      *name, 
00545         float           value) = 0;
00546 
00551     virtual void set(
00552         const char      *name,
00553         float           value1, 
00554         float           value2) = 0;
00555 
00561     virtual void set(
00562         const char      *name,
00563         float           value1, 
00564         float           value2, 
00565         float           value3) = 0;
00566 
00573     virtual void set(
00574         const char      *name, 
00575         float           value1, 
00576         float           value2, 
00577         float           value3, 
00578         float           value4) = 0;
00579 
00585     virtual bool get(
00586         const char      *name, 
00587         bool            *value) const = 0;
00588 
00596     virtual bool get(
00597         const char      *name, 
00598         const char      **value) const = 0;
00599 
00605     virtual bool get(
00606         const char      *name, 
00607         int             *value) const = 0;
00608 
00617     virtual bool get(
00618         const char      *name, 
00619         float           *value) const = 0;
00620 
00631     virtual bool get(
00632         const char      *name, 
00633         float           *value1, 
00634         float           *value2) const = 0;
00635 
00648     virtual bool get(
00649         const char      *name, 
00650         float           *value1, 
00651         float           *value2, 
00652         float           *value3) const = 0;
00653 
00668     virtual bool get(
00669         const char      *name,
00670         float           *value1,
00671         float           *value2,
00672         float           *value3,
00673         float           *value4) const = 0;
00674 
00680     virtual bool remove(
00681         const char      *name) = 0;
00682 
00686     virtual void release() = 0;
00687 };
00688 
00689 
00690 
00693 class Access_interface {
00694 public:
00696     Access_interface(int version = mi_ray_interface_version)
00697         : m_iface (mi_get_shader_interface(version))
00698     {}
00699 
00701     ~Access_interface()
00702     {
00703         m_iface->release();
00704         m_iface = 0;
00705     }
00706 
00708     mi::shader_v3::Interface * operator->()
00709     {
00710         return m_iface;
00711     }
00712 
00713 private:
00714     mi::shader_v3::Interface *m_iface;
00715 };
00716 
00717 
00721 typedef Access_interface Interface_access;
00722 
00723 
00724 } // namespace shader_v3
00725 
00726 
00727 // namespace alias, shaders should use it
00728 namespace shader = shader_v3;
00729 
00730 } // namespace mi
00731 
00732 #include "shader_framebuffer.h"
00733 #include "shader_map.h"
00734 #include "shader_lightlist.h"
00735 #include "shader_sds34.h"
00736 #include "shader_mipremap.h"
00737 
00738 #endif // MI_SHADER_IF_H

Copyright © 1986-2011 by mental images GmbH