shader_framebuffer.h

Go to the documentation of this file.
00001 
00002 // Copyright 1986-2009 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin,
00003 // Germany. All rights reserved.
00005 // Created:     27.02.08
00006 // Module:      api
00007 // Purpose:     mental ray C++ shader interface extensions
00009 
00018 
00019 
00020 #ifndef SHADER_FRAMEBUFFER_H
00021 #define SHADER_FRAMEBUFFER_H
00022 #include "mi_shader_if.h"
00023 
00024 namespace mi {
00025 namespace shader_v3 {
00026 
00027 
00039 class Framebuffer {
00040     public:
00045         virtual bool set(
00046             const char  *buffer, 
00047             const char  *param, 
00048             const       bool value) = 0;
00049 
00054         virtual bool set(
00055             const char  *buffer, 
00056             const char  *param, 
00057             const float value) = 0;
00058 
00063         virtual bool set(
00064             const char  *buffer, 
00065             const char  *param, 
00066             const int   value) = 0;
00067 
00072         virtual bool set(
00073             const char  *buffer, 
00074             const char  *param, 
00075             const char  *value) = 0;
00076 
00083         virtual bool get(
00084             const char  *buffer, 
00085             const char  *param, 
00086             bool        &value) const = 0;
00087 
00094         virtual bool get(
00095             const char  *buffer, 
00096             const char  *param, 
00097             float       &value) const = 0;
00098 
00105         virtual bool get(
00106             const char  *buffer, 
00107             const char  *param, 
00108             int         &value) const = 0;
00109 
00116         virtual bool get(
00117             const char  *buffer, 
00118             const char  *param, 
00119             const char  *&value) const = 0;
00120 
00127         virtual bool get_index(const char *buffer, size_t &index) const = 0;
00128 
00132         virtual bool reset() = 0;
00133 
00135         virtual void echo(FILE *) const = 0;
00136 
00140         virtual bool get_buffercount(size_t &buffercount) const = 0;
00141 
00148         virtual bool get_buffername(size_t num, const char *&name) const = 0;
00149 
00153         virtual bool remove(const char *buffer) = 0;
00154 };
00155 
00160 class Access_fb {
00161     public:
00164         Access_fb(
00165             miTag tag);
00166 
00168         ~Access_fb();
00169 
00171         const Framebuffer * operator->() const;
00172     private:
00173         Access_fb();
00174         Access_fb(const Access_fb &);
00175         const Access_fb & operator=(const Access_fb &);
00176         mi::shader_v3::Interface        *m_iface;
00177         const Framebuffer               *const m_fb;
00178         const miTag                     m_tag;
00179 };
00180 
00181 
00185 
00186 class Edit_fb {
00187     public:
00190         Edit_fb(
00191             miTag tag);
00192 
00194         ~Edit_fb();
00195 
00197         Framebuffer * operator->() const;
00198     private:
00199         Edit_fb();
00200         Edit_fb(const Edit_fb &);
00201         const Edit_fb & operator=(const Edit_fb &);
00202         mi::shader_v3::Interface        *m_iface;
00203         Framebuffer                     *const m_fb;
00204         const miTag                     m_tag;
00205 };
00206 
00209 inline Access_fb::Access_fb(
00210     miTag tag)
00211   : m_iface(mi_get_shader_interface())
00212   , m_fb(m_iface->accessFramebuffer(tag))
00213   , m_tag(tag)
00214 {
00215 }
00216 
00217 inline Access_fb::~Access_fb()
00218 {
00219     if (m_fb != 0) {
00220         m_iface->releaseFramebuffer(m_fb, m_tag);
00221     }
00222     m_iface->release();
00223 }
00224 
00225 inline const Framebuffer * Access_fb::operator->() const
00226 {
00227     return m_fb;
00228 }
00229 
00232 inline Edit_fb::Edit_fb(
00233     miTag tag)
00234   : m_iface(mi_get_shader_interface())
00235   , m_fb(m_iface->editFramebuffer(tag))
00236   , m_tag(tag)
00237 {
00238 }
00239 
00240 inline Edit_fb::~Edit_fb()
00241 {
00242     if (m_fb != 0) {
00243         m_iface->releaseFramebuffer(m_fb, m_tag);
00244     }
00245     m_iface->release();
00246 }
00247 
00248 inline Framebuffer * Edit_fb::operator->() const
00249 {
00250     return m_fb;
00251 }
00252 
00253 
00254 }}
00255 
00256 #endif //SHADER_FRAMEBUFFER_H

Copyright © 1986-2010 by mental images GmbH