Texture.hpp

00001 #ifndef __FIBER_GL_TEXTURE_HPP
00002 #define __FIBER_GL_TEXTURE_HPP
00003 
00004 #include <typeinfo>
00005 #include <eagle/GL/EagleGL.hpp>
00006 #include <ocean/eagle/ColorSpace.hpp>
00007 
00008 #include <ocean/GLvish/GLTexture.hpp>
00009 #include <ocean/GLvish/VGLRenderContext.hpp>
00010 #include <field/MemArray.hpp>
00011 #include <fiberop/SliceSelection.hpp>
00012 #include <ocean/shrimp/Range.hpp>
00013 
00014 #include "fishGLDllApi.h"
00015 
00016 
00017 namespace Fiber
00018 {
00019 
00020 /*
00021 fishGL_API bool LoadLuminanceTexture(RefPtr<Wizt::GLTexture2D>&Texture,
00022                                      int TextureUnit,
00023                                      const RefPtr<MemBase>&Data);
00024 */
00025 
00026 
00030 fishGL_API RefPtr<Wizt::GLTexture2D> createTexture2D(const RefPtr<MemBase>&Data,
00031                                                      const type_info&TextureType,
00032                                                      const Wizt::Range&R,
00033                                                      int TextureUnit,
00034                                                      GLenum format,
00035                                                      GLenum internalformat,
00036                                                      int BitsPerTexel);
00037 
00038 
00039 
00043 fishGL_API RefPtr<Wizt::GLTexture2D> createTexture2D(const RefPtr<MemBase>&Data,
00044                                                      const type_info&TextureType,
00045                                                      const Wizt::Range&R,
00046                                                      const SliceSelection&O, const index_t&SliceNumber,
00047                                                      int TextureUnit,
00048                                                      GLenum format,
00049                                                      GLenum internalformat,
00050                                                      int BitsPerTexel);
00051 
00052 
00057 template <int TextureFormat>
00058 inline RefPtr<Wizt::GLTexture2D> createTexture2D(const RefPtr<MemBase>&DataCreator,
00059                                                  const std::type_info&TextureType,
00060                                                  const Wizt::Range&R,
00061                                                  int TextureUnit = 0,
00062                                                  GLenum format = GL_LUMINANCE,
00063                                                  const glMemSize<TextureFormat>&Format  = glMemSize<GL_RGBA>() )
00064 {
00065         return createTexture2D(DataCreator, TextureType, R,
00066                                TextureUnit, format, TextureFormat, glMemSize<TextureFormat>::bits);
00067 }
00068 
00073 template <int TextureFormat>
00074 inline RefPtr<Wizt::GLTexture2D> createTexture2D(const RefPtr<MemBase>&DataCreator,
00075                                                  const std::type_info&TextureType,
00076                                                  const Wizt::Range&R,
00077                                                  const SliceSelection&O, const index_t&SliceNumber,
00078                                                  int TextureUnit = 0,
00079                                                  GLenum format = GL_LUMINANCE,
00080                                                  const glMemSize<TextureFormat>&Format  = glMemSize<GL_RGBA>() )
00081 {
00082         return createTexture2D(DataCreator, TextureType, R, O, SliceNumber,
00083                                TextureUnit, format, TextureFormat, glMemSize<TextureFormat>::bits);
00084 }
00085 
00093 fishGL_API RefPtr<Wizt::GLTexture3D> createTexture3D(const RefPtr<MemBase>&Data,
00094                                                      const type_info&TextureType,
00095                                                      const Wizt::Range&R,
00096                                                      const MultiIndex<3>&Start,
00097                                                      const MultiIndex<3>&End  ,
00098                                                      const MultiIndex<3>&Step ,
00099                                                      int TextureUnit,
00100                                                      GLenum format,
00101                                                      GLenum internalformat,
00102                                                      int BitsPerTexel );
00103 
00108 template <int TextureFormat>
00109 inline RefPtr<Wizt::GLTexture3D> createTexture3D(const RefPtr<MemBase>&DataCreator,
00110                                                  const std::type_info&TextureType,
00111                                                  const Wizt::Range&R,
00112                                                  const MultiIndex<3>&Start = MIndex(0,0,0),
00113                                                  const MultiIndex<3>&End   = MIndex(0,0,0),
00114                                                  const MultiIndex<3>&Step  = MIndex(1,1,1),
00115                                                  int TextureUnit = 0,
00116                                                  GLenum format = GL_LUMINANCE,
00117                                                  const glMemSize<TextureFormat>&Format = glMemSize<GL_RGBA>() )
00118 {
00119         return createTexture3D(DataCreator, TextureType, R,
00120                                Start, End, Step,
00121                                TextureUnit, format, TextureFormat, glMemSize<TextureFormat>::bits);
00122 }
00123 
00128 template <typename TextureStorageType, int TextureFormat = GL_RGBA>
00129 struct  CreateTexture
00130 {
00131 
00137 static inline RefPtr<Wizt::GLTexture3D> Volume(const RefPtr<MemBase>&DataCreator,
00138                                                const Wizt::Range&R,
00139                                                GLenum format,
00140                                                const MultiIndex<3>&Start = MIndex(0,0,0),
00141                                                const MultiIndex<3>&End   = MIndex(0,0,0),
00142                                                const MultiIndex<3>&Step  = MIndex(1,1,1),
00143                                                int TextureUnit = 0)
00144         {
00145                 return createTexture3D(DataCreator, typeid(TextureStorageType), R,
00146                                        Start, End, Step,
00147                                        TextureUnit, format, glMemSize<TextureFormat>() );
00148         }
00149 
00155 static inline RefPtr<Wizt::GLTexture2D> Plane(const RefPtr<MemBase>&DataCreator,
00156                                               const Wizt::Range&R,
00157                                               int TextureUnit = 0,
00158                                               GLenum format = GL_LUMINANCE)
00159         {
00160                 return createTexture2D(DataCreator, typeid(TextureStorageType), R,
00161                                        TextureUnit, format, glMemSize<TextureFormat>() );
00162         }
00163 
00164 
00170 static inline RefPtr<Wizt::GLTexture2D> Plane(const RefPtr<MemBase>&DataCreator,
00171                                               const Wizt::Range&R,
00172                                               const SliceSelection&O, const index_t&SliceNumber,
00173                                               int TextureUnit = 0,
00174                                               GLenum format = GL_LUMINANCE)
00175         {
00176                 return createTexture2D(DataCreator, typeid(TextureStorageType), R, O, SliceNumber,
00177                                        TextureUnit, format, glMemSize<TextureFormat>() );
00178         }
00179 
00180 
00181 
00182 };
00183 
00194 fishGL_API int  renderVolume(const Wizt::VRenderContext&Context,
00195                              int slices,
00196                              const Eagle::FixedArray<double,3>&TS,
00197                              const Eagle::FixedArray<double,3>&TOffset,
00198                              const Eagle::point3&Observer,
00199                              const Eagle::point3&BBoxMin,
00200                              const Eagle::point3&BBoxMax,
00201                              int CancellationCheck = 0xFF);
00202 
00203 
00204 fishGL_API int  renderVolume(const Wizt::VRenderContext&Context,
00205                              int slices,
00206                              const RefPtr<Wizt::GLTexture3D>&TXT,
00207                              const Eagle::point3&Observer,
00208                              const Eagle::point3&BBoxMin,
00209                              const Eagle::point3&BBoxMax,
00210                              int CancellationCheck = 0xFF);
00211 
00214 fishGL_API void renderQuad(const RefPtr<Wizt::GLTexture2D>&TXT,
00215                            const Eagle::point3&P00,
00216                            const Eagle::point3&P01,
00217                            const Eagle::point3&P10,
00218                            const Eagle::point3&P11);
00219 
00220 
00221 
00222 } // GL
00223 
00224 #endif // __FIBER_GL_TEXTURE_HPP
00225