00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SOGLRENDERTOBUFFER_H
00024 #define SOGLRENDERTOBUFFER_H
00025
00026 #include <Inventor/SbLinear.h>
00027 #include <Inventor/sys/SoGLType.h>
00028 #include <Inventor/helpers/SbGlContextHelper.h>
00029
00030 class SoGLGraphicConfigTemplate;
00031 class SoGLContext;class SoDEPRECATED SoGLRenderToBuffer
00044 {
00045 public:
00050 enum TextureFormat {
00051 TEXTURE_RGB = 0,
00052 TEXTURE_RGBA,
00053 TEXTURE_DEPTH,
00054 TEXTURE_DEPTH16,
00055 TEXTURE_DEPTH_RGBA,
00056 TEXTURE_RGB_FLOAT16,
00057 TEXTURE_RGBA_FLOAT16,
00058 TEXTURE_RGB_FLOAT32,
00059 TEXTURE_RGBA_FLOAT32,
00060 TEXTURE_STENCIL_INDEX8,
00061 TEXTURE_STENCIL_INDEX,
00062 TEXTURE_DEPTH_STENCIL,
00063 TEXTURE_UNKNOW
00064 };
00065
00071 enum TextureTarget {
00072 TEXTURE_1D = 0,
00073 TEXTURE_2D,
00074 TEXTURE_3D,
00075 TEXTURE_CUBE_MAP,
00076 TEXTURE_RECTANGLE
00077 };
00078
00083 enum CubeMapTextureFace {
00084 TEXTURE_CUBE_MAP_POSITIVE_X = 0,
00085 TEXTURE_CUBE_MAP_POSITIVE_Y,
00086 TEXTURE_CUBE_MAP_POSITIVE_Z,
00087 TEXTURE_CUBE_MAP_NEGATIVE_X,
00088 TEXTURE_CUBE_MAP_NEGATIVE_Y,
00089 TEXTURE_CUBE_MAP_NEGATIVE_Z
00090 };
00091
00095 virtual ~SoGLRenderToBuffer();
00096
00106 static SbBool isAvailable(SbGlContextHelper::Display display = NULL);
00107
00113 virtual SbBool create(SbVec2s size) = 0;
00114
00120 virtual SbBool create(SbVec2i32 size) = 0;
00121
00126 virtual SbBool makeCurrent() = 0;
00127
00132 virtual void disable() = 0;
00133
00138 void shareCurrentContext() {}
00139
00149 virtual void setDisplayConnection(SbGlContextHelper::Display ) {};
00150
00158 virtual void setContextForSharing(SoGLContext* ) {};
00159
00165 virtual SbBool resize(const SbVec2s &size) = 0;
00166
00172 virtual SbBool resize(const SbVec2i32 &size) = 0;
00173
00177 virtual SbVec2s getSize() const = 0;
00178
00182 virtual const SbVec2i32& getSize_i32() const = 0;
00183
00189 virtual void setPixelFormat(int format) { m_pfd = format; }
00190
00196 virtual int getPixelFormat() { return m_pfd; }
00197
00202 virtual void setRenderToTexture(SbBool enable, TextureFormat format = TEXTURE_RGB, TextureTarget target = TEXTURE_2D,
00203 SbBool autoMipmap = FALSE, SbBool hasDepth = FALSE) = 0;
00204
00210 virtual SbBool bindToTexture(SbBool bindDepth = FALSE, GLuint texObj=-1) = 0;
00211
00217 virtual SbBool releaseTexImage(SbBool bindDepth = FALSE) = 0;
00218
00222 virtual SbBool selectCubeMapFace(CubeMapTextureFace face) = 0;
00223
00227 virtual SoGLGraphicConfigTemplate* getGraphicConfigTemplate() { return m_currentGraphicConfigTemplate; }
00228
00232 virtual void setGraphicConfigTemplate(SoGLGraphicConfigTemplate* gTemplate) { m_currentGraphicConfigTemplate = gTemplate; }
00233
00239 static SoGLRenderToBuffer* createInstance(bool forcePbuffer, SbGlContextHelper::Display display = NULL);
00240
00244 virtual SbBool isPBuffer()
00245 { return FALSE; }
00246
00247 private:
00248 static GLenum getGLInternalFormat(SoGLRenderToBuffer::TextureFormat fmt);
00249 static GLenum getGLTextureTarget(TextureTarget target);
00250 static GLenum getGLCubeMapTextureFace(CubeMapTextureFace face);
00251
00252 static SoGLRenderToBuffer::TextureFormat getTextureFormatFromGLFormat(GLenum fmt);
00253
00254 virtual void setFaceTarget(int ) {};
00255
00256 private:
00257 SoGLRenderToBuffer();
00258
00259 SoGLGraphicConfigTemplate* m_currentGraphicConfigTemplate;
00260
00261 int m_pfd;
00262 private:
00263 };
00264
00265
00266 #endif // SOGLRENDERTOBUFFER_H
00267
00268
00269