mi_shader_if.h

Go to the documentation of this file.
00001 
00002 // Copyright 1986-2008 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin,
00003 // Germany. All rights reserved.
00005 // Author:      kjs
00006 // Created:     09.01.06
00007 // Module:      api
00008 // Purpose:     mental ray C++ shader interface extensions
00010 
00031 
00032 #ifndef MI_SHADER_IF_H
00033 #define MI_SHADER_IF_H
00034 
00035 // if file is included internally
00036 #if !defined(SHADER_H)
00037 #include <mi_raylib.h>
00038 #include <mi_lib.h>
00039 #include <mi_shader.h>
00040 #endif
00041 
00042 #ifndef __cplusplus
00043 #error mi_shader_if.h requires C++ compilation
00044 #endif
00045 
00046 
00048 static const int mi_ray_interface_version = 3;
00049 
00050 namespace mi {
00051 namespace shader_v3 {
00052 class Interface;
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 Map_edit_dbhandle;
00095 class Map_access_dbhandle;
00096 class Map_access;
00097 class Map_edit;
00098 class Map_declaration_base;
00099 class Map_iterator_base;
00100 class Map_element_base;
00101 class Map_lookup_base;
00102 class Bsdf;
00103 
00104 
00105 
00125 
00126 class Interface {
00127   public:
00144     static inline Interface* get(
00145         int             version = mi_ray_interface_version)
00146     { 
00147         return mi_get_shader_interface(version); 
00148     }
00149 
00163     virtual Options *getOptions(
00164         miTag           string_options);
00165 
00169     virtual miTag createFramebuffer();
00170 
00175     virtual miTag copyFramebuffer(
00176         miTag           old_buffer_tag);
00177 
00189     virtual LightList *createLightList(
00190         miState         *state, 
00191         miTag           *slist = 0, 
00192         int             n = 0);
00193 
00200     virtual void release();
00201 
00202 
00216     virtual LightList *createLightList(
00217         miState         *state,
00218         const miVector  &axis,
00219         miScalar        spread_cos,
00220         miTag           *slist = 0, 
00221         int             n = 0);
00222 
00223 
00230     virtual Map_edit_dbhandle *createMap(
00231         const Map_declaration_base  *map_declaration = 0);
00232 
00239     virtual Map_access_dbhandle *accessMap(
00240         const miTag             map_tag);
00241 
00248     virtual Map_edit_dbhandle *editMap(
00249         const miTag             map_tag);
00250 
00258     virtual Map_access_dbhandle *accessMap(
00259         const char              *filename,
00260         Map_status              *status);
00261 
00269     virtual Map_edit_dbhandle *editMap(
00270         const char              *filename,
00271         Map_status              *status);
00272 
00279     virtual Map_declaration_base *createMapDeclaration(
00280         const miUint            dimension);
00281 
00289     virtual Map_declaration_base *copyMapDeclaration(
00290         const Map_declaration_base  *other,
00291         Map_status                  *status);
00292 
00300     virtual Map_declaration_base *copyMapDeclaration(
00301         const Map_element_base  *map_element,
00302         Map_status              *status);
00303 
00311     virtual Map_declaration_base *copyMapDeclaration(
00312         const Map_base          *map,
00313         Map_status              *status);
00314 
00321     virtual Map_element_base *createMapElement(
00322         const Map_declaration_base  *declaration = 0);
00323 
00330     virtual Map_element_base *copyMapElement(
00331         const Map_element_base  *other);
00332 
00340     virtual Map_iterator_base *createMapIterator(
00341         const Map_base          *map,
00342         Map_status              *status);
00343 
00351     virtual Map_iterator_base *copyMapIterator(
00352         const Map_iterator_base *other,
00353         Map_status              *status);
00354 
00362     virtual Map_lookup_base *createMapLookup(
00363         const Map_base          *map,
00364         Map_status              *status);
00365 
00373     virtual Map_lookup_base *copyMapLookup(
00374         const Map_lookup_base   *other,
00375         Map_status              *status);
00376 
00385     virtual const Framebuffer *accessFramebuffer(
00386         miTag           buffer_tag);
00387 
00397     virtual bool releaseFramebuffer(
00398         const Framebuffer       *buffer,                           
00399         miTag                   buffer_tag);
00400 
00409     virtual Framebuffer *editFramebuffer(
00410         miTag           buffer_tag);
00411 
00421     virtual bool releaseFramebuffer(
00422         Framebuffer             *buffer,                           
00423         miTag                   buffer_tag);
00424 
00430     virtual Bsdf* allocBsdf(
00431             miState*            state);
00432  
00438     virtual void releaseBsdf(
00439             Bsdf*               bsdf, 
00440             miState*            state);
00441 
00442 };
00443 
00444 
00483 
00484 class Options {
00485   public: 
00487 
00491     virtual void set(
00492         const char      *name, 
00493         bool            value) = 0;
00494 
00500     virtual void set(
00501         const char      *name, 
00502         const char *    value) = 0;
00503 
00508     virtual void set(
00509         const char      *name, 
00510         int             value) = 0;
00511 
00515     virtual void set(
00516         const char      *name, 
00517         float           value) = 0;
00518 
00524     virtual void set(
00525         const char      *name,
00526         float           value1, 
00527         float           value2, 
00528         float           value3) = 0;
00529 
00536     virtual void set(
00537         const char      *name, 
00538         float           value1, 
00539         float           value2, 
00540         float           value3, 
00541         float           value4) = 0;
00542 
00548     virtual bool get(
00549         const char      *name, 
00550         bool            *value) const = 0;
00551 
00559     virtual bool get(
00560         const char      *name, 
00561         const char      **value) const = 0;
00562 
00568     virtual bool get(
00569         const char      *name, 
00570         int             *value) const = 0;
00571 
00580     virtual bool get(
00581         const char      *name, 
00582         float           *value) const = 0;
00583 
00596     virtual bool get(
00597         const char      *name, 
00598         float           *value1, 
00599         float           *value2, 
00600         float           *value3) const = 0;
00601 
00616     virtual bool get(
00617         const char      *name,
00618         float           *value1,
00619         float           *value2,
00620         float           *value3,
00621         float           *value4) const = 0;
00622 
00628     virtual bool remove(
00629         const char      *name) = 0;
00630 
00634     virtual void release() = 0;
00635 };
00636 
00637 
00638 
00641 class Interface_access {
00642 public:
00644     Interface_access()
00645         : m_iface (mi_get_shader_interface())
00646     {}
00647 
00649     ~Interface_access()
00650     {
00651         m_iface->release();
00652         m_iface = 0;
00653     }
00654 
00656     mi::shader_v3::Interface * operator->()
00657     {
00658         return m_iface;
00659     }
00660 
00661 private:
00662     mi::shader_v3::Interface *m_iface;
00663 };
00664 
00665 
00666 } // namespace shader_v3
00667 
00668 
00669 // namespace alias, shaders should use it
00670 namespace shader = shader_v3;
00671 
00672 } // namespace mi
00673 
00674 #include "shader_framebuffer.h"
00675 #include "shader_map.h"
00676 #include "shader_lightlist.h"
00677 
00678 #endif // MI_SHADER_IF_H

Copyright © 1986-2008 by mental images GmbH