shader_framebuffer.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:      carsten
00006 // Created:     27.02.08
00007 // Module:      api
00008 // Purpose:     mental ray C++ shader interface extensions
00010 
00019 
00020 
00021 #ifndef SHADER_FRAMEBUFFER_H
00022 #define SHADER_FRAMEBUFFER_H
00023 #include "mi_shader_if.h"
00024 
00025 namespace mi {
00026 namespace shader_v3 {
00027 
00028 
00040 class Framebuffer {
00041     public:
00046         virtual bool set(
00047             const char  *buffer, 
00048             const char  *param, 
00049             const       bool value) = 0;
00050 
00055         virtual bool set(
00056             const char  *buffer, 
00057             const char  *param, 
00058             const float value) = 0;
00059 
00064         virtual bool set(
00065             const char  *buffer, 
00066             const char  *param, 
00067             const int   value) = 0;
00068 
00073         virtual bool set(
00074             const char  *buffer, 
00075             const char  *param, 
00076             const char  *value) = 0;
00077 
00084         virtual bool get(
00085             const char  *buffer, 
00086             const char  *param, 
00087             bool        &value) const = 0;
00088 
00095         virtual bool get(
00096             const char  *buffer, 
00097             const char  *param, 
00098             float       &value) const = 0;
00099 
00106         virtual bool get(
00107             const char  *buffer, 
00108             const char  *param, 
00109             int         &value) const = 0;
00110 
00117         virtual bool get(
00118             const char  *buffer, 
00119             const char  *param, 
00120             const char  *&value) const = 0;
00121 
00128         virtual bool get_index(const char *buffer, size_t &index) const = 0;
00129 
00133         virtual bool reset() = 0;
00134 
00136         virtual void echo(FILE *) const = 0;
00137 
00141         virtual bool get_buffercount(size_t &buffercount) const = 0;
00142 
00149         virtual bool get_buffername(size_t num, const char *&name) const = 0;
00150 
00154         virtual bool remove(const char *buffer) = 0;
00155 };
00156 
00161 class Access_fb {
00162     public:
00165         Access_fb(
00166             miTag tag);
00167 
00169         ~Access_fb();
00170 
00172         const Framebuffer * operator->() const;
00173     private:
00174         Access_fb();
00175         Access_fb(const Access_fb &);
00176         const Access_fb & operator=(const Access_fb &);
00177         mi::shader_v3::Interface        *m_iface;
00178         const Framebuffer               *const m_fb;
00179         const miTag                     m_tag;
00180 };
00181 
00182 
00186 
00187 class Edit_fb {
00188     public:
00191         Edit_fb(
00192             miTag tag);
00193 
00195         ~Edit_fb();
00196 
00198         Framebuffer * operator->() const;
00199     private:
00200         Edit_fb();
00201         Edit_fb(const Edit_fb &);
00202         const Edit_fb & operator=(const Edit_fb &);
00203         mi::shader_v3::Interface        *m_iface;
00204         Framebuffer                     *const m_fb;
00205         const miTag                     m_tag;
00206 };
00207 
00210 inline Access_fb::Access_fb(
00211     miTag tag)
00212   : m_iface(mi_get_shader_interface())
00213   , m_fb(m_iface->accessFramebuffer(tag))
00214   , m_tag(tag)
00215 {
00216 }
00217 
00218 inline Access_fb::~Access_fb()
00219 {
00220     if (m_fb != 0) {
00221         m_iface->releaseFramebuffer(m_fb, m_tag);
00222     }
00223     m_iface->release();
00224 }
00225 
00226 inline const Framebuffer * Access_fb::operator->() const
00227 {
00228     return m_fb;
00229 }
00230 
00233 inline Edit_fb::Edit_fb(
00234     miTag tag)
00235   : m_iface(mi_get_shader_interface())
00236   , m_fb(m_iface->editFramebuffer(tag))
00237   , m_tag(tag)
00238 {
00239 }
00240 
00241 inline Edit_fb::~Edit_fb()
00242 {
00243     if (m_fb != 0) {
00244         m_iface->releaseFramebuffer(m_fb, m_tag);
00245     }
00246     m_iface->release();
00247 }
00248 
00249 inline Framebuffer * Edit_fb::operator->() const
00250 {
00251     return m_fb;
00252 }
00253 
00254 
00255 }}
00256 
00257 #endif //SHADER_FRAMEBUFFER_H

Copyright © 1986-2008 by mental images GmbH