aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h410
1 files changed, 205 insertions, 205 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h
index 8bff1a8..4e01d55 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h
+++ b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLTexture.h
@@ -1,205 +1,205 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#ifndef __C_OPEN_GL_TEXTURE_H_INCLUDED__ 5#ifndef __C_OPEN_GL_TEXTURE_H_INCLUDED__
6#define __C_OPEN_GL_TEXTURE_H_INCLUDED__ 6#define __C_OPEN_GL_TEXTURE_H_INCLUDED__
7 7
8#include "ITexture.h" 8#include "ITexture.h"
9#include "IImage.h" 9#include "IImage.h"
10 10
11#include "IrrCompileConfig.h" 11#include "IrrCompileConfig.h"
12#ifdef _IRR_COMPILE_WITH_OPENGL_ 12#ifdef _IRR_COMPILE_WITH_OPENGL_
13 13
14#if defined(_IRR_OPENGL_USE_EXTPOINTER_) 14#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
15 #define GL_GLEXT_LEGACY 1 15 #define GL_GLEXT_LEGACY 1
16#else 16#else
17 #define GL_GLEXT_PROTOTYPES 1 17 #define GL_GLEXT_PROTOTYPES 1
18#endif 18#endif
19#ifdef _IRR_WINDOWS_API_ 19#ifdef _IRR_WINDOWS_API_
20 // include windows headers for HWND 20 // include windows headers for HWND
21 #define WIN32_LEAN_AND_MEAN 21 #define WIN32_LEAN_AND_MEAN
22 #include <windows.h> 22 #include <windows.h>
23 #include <GL/gl.h> 23 #include <GL/gl.h>
24#ifdef _MSC_VER 24#ifdef _MSC_VER
25 #pragma comment(lib, "OpenGL32.lib") 25 #pragma comment(lib, "OpenGL32.lib")
26#endif 26#endif
27#elif defined(_IRR_OSX_PLATFORM_) 27#elif defined(_IRR_OSX_PLATFORM_)
28 #include <OpenGL/gl.h> 28 #include <OpenGL/gl.h>
29#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) 29#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
30 #define NO_SDL_GLEXT 30 #define NO_SDL_GLEXT
31 #include <SDL/SDL_video.h> 31 #include <SDL/SDL_video.h>
32 #include <SDL/SDL_opengl.h> 32 #include <SDL/SDL_opengl.h>
33#else 33#else
34 #if defined(_IRR_OSX_PLATFORM_) 34 #if defined(_IRR_OSX_PLATFORM_)
35 #include <OpenGL/gl.h> 35 #include <OpenGL/gl.h>
36 #else 36 #else
37 #include <GL/gl.h> 37 #include <GL/gl.h>
38 #endif 38 #endif
39#endif 39#endif
40 40
41 41
42namespace irr 42namespace irr
43{ 43{
44namespace video 44namespace video
45{ 45{
46 46
47class COpenGLDriver; 47class COpenGLDriver;
48//! OpenGL texture. 48//! OpenGL texture.
49class COpenGLTexture : public ITexture 49class COpenGLTexture : public ITexture
50{ 50{
51public: 51public:
52 52
53 //! constructor 53 //! constructor
54 COpenGLTexture(IImage* surface, const io::path& name, void* mipmapData=0, COpenGLDriver* driver=0); 54 COpenGLTexture(IImage* surface, const io::path& name, void* mipmapData=0, COpenGLDriver* driver=0);
55 55
56 //! destructor 56 //! destructor
57 virtual ~COpenGLTexture(); 57 virtual ~COpenGLTexture();
58 58
59 //! lock function 59 //! lock function
60 virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0); 60 virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
61 61
62 //! unlock function 62 //! unlock function
63 virtual void unlock(); 63 virtual void unlock();
64 64
65 //! Returns original size of the texture (image). 65 //! Returns original size of the texture (image).
66 virtual const core::dimension2d<u32>& getOriginalSize() const; 66 virtual const core::dimension2d<u32>& getOriginalSize() const;
67 67
68 //! Returns size of the texture. 68 //! Returns size of the texture.
69 virtual const core::dimension2d<u32>& getSize() const; 69 virtual const core::dimension2d<u32>& getSize() const;
70 70
71 //! returns driver type of texture (=the driver, that created it) 71 //! returns driver type of texture (=the driver, that created it)
72 virtual E_DRIVER_TYPE getDriverType() const; 72 virtual E_DRIVER_TYPE getDriverType() const;
73 73
74 //! returns color format of texture 74 //! returns color format of texture
75 virtual ECOLOR_FORMAT getColorFormat() const; 75 virtual ECOLOR_FORMAT getColorFormat() const;
76 76
77 //! returns pitch of texture (in bytes) 77 //! returns pitch of texture (in bytes)
78 virtual u32 getPitch() const; 78 virtual u32 getPitch() const;
79 79
80 //! return open gl texture name 80 //! return open gl texture name
81 GLuint getOpenGLTextureName() const; 81 GLuint getOpenGLTextureName() const;
82 82
83 //! return whether this texture has mipmaps 83 //! return whether this texture has mipmaps
84 virtual bool hasMipMaps() const; 84 virtual bool hasMipMaps() const;
85 85
86 //! Regenerates the mip map levels of the texture. 86 //! Regenerates the mip map levels of the texture.
87 /** Useful after locking and modifying the texture 87 /** Useful after locking and modifying the texture
88 \param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image. If not set the mipmaps are derived from the main image. */ 88 \param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image. If not set the mipmaps are derived from the main image. */
89 virtual void regenerateMipMapLevels(void* mipmapData=0); 89 virtual void regenerateMipMapLevels(void* mipmapData=0);
90 90
91 //! Is it a render target? 91 //! Is it a render target?
92 virtual bool isRenderTarget() const; 92 virtual bool isRenderTarget() const;
93 93
94 //! Is it a FrameBufferObject? 94 //! Is it a FrameBufferObject?
95 virtual bool isFrameBufferObject() const; 95 virtual bool isFrameBufferObject() const;
96 96
97 //! Bind RenderTargetTexture 97 //! Bind RenderTargetTexture
98 virtual void bindRTT(); 98 virtual void bindRTT();
99 99
100 //! Unbind RenderTargetTexture 100 //! Unbind RenderTargetTexture
101 virtual void unbindRTT(); 101 virtual void unbindRTT();
102 102
103 //! sets whether this texture is intended to be used as a render target. 103 //! sets whether this texture is intended to be used as a render target.
104 void setIsRenderTarget(bool isTarget); 104 void setIsRenderTarget(bool isTarget);
105 105
106protected: 106protected:
107 107
108 //! protected constructor with basic setup, no GL texture name created, for derived classes 108 //! protected constructor with basic setup, no GL texture name created, for derived classes
109 COpenGLTexture(const io::path& name, COpenGLDriver* driver); 109 COpenGLTexture(const io::path& name, COpenGLDriver* driver);
110 110
111 //! get the desired color format based on texture creation flags and the input format. 111 //! get the desired color format based on texture creation flags and the input format.
112 ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format); 112 ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
113 113
114 //! Get the OpenGL color format parameters based on the given Irrlicht color format 114 //! Get the OpenGL color format parameters based on the given Irrlicht color format
115 GLint getOpenGLFormatAndParametersFromColorFormat( 115 GLint getOpenGLFormatAndParametersFromColorFormat(
116 ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type); 116 ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type);
117 117
118 //! get important numbers of the image and hw texture 118 //! get important numbers of the image and hw texture
119 void getImageValues(IImage* image); 119 void getImageValues(IImage* image);
120 120
121 //! copies the texture into an OpenGL texture. 121 //! copies the texture into an OpenGL texture.
122 /** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling. 122 /** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
123 \param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image. 123 \param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.
124 \param mipLevel If set to non-zero, only that specific miplevel is updated, using the MipImage member. */ 124 \param mipLevel If set to non-zero, only that specific miplevel is updated, using the MipImage member. */
125 void uploadTexture(bool newTexture=false, void* mipmapData=0, u32 mipLevel=0); 125 void uploadTexture(bool newTexture=false, void* mipmapData=0, u32 mipLevel=0);
126 126
127 core::dimension2d<u32> ImageSize; 127 core::dimension2d<u32> ImageSize;
128 core::dimension2d<u32> TextureSize; 128 core::dimension2d<u32> TextureSize;
129 ECOLOR_FORMAT ColorFormat; 129 ECOLOR_FORMAT ColorFormat;
130 COpenGLDriver* Driver; 130 COpenGLDriver* Driver;
131 IImage* Image; 131 IImage* Image;
132 IImage* MipImage; 132 IImage* MipImage;
133 133
134 GLuint TextureName; 134 GLuint TextureName;
135 GLint InternalFormat; 135 GLint InternalFormat;
136 GLenum PixelFormat; 136 GLenum PixelFormat;
137 GLenum PixelType; 137 GLenum PixelType;
138 138
139 u8 MipLevelStored; 139 u8 MipLevelStored;
140 bool HasMipMaps; 140 bool HasMipMaps;
141 bool MipmapLegacyMode; 141 bool MipmapLegacyMode;
142 bool IsRenderTarget; 142 bool IsRenderTarget;
143 bool AutomaticMipmapUpdate; 143 bool AutomaticMipmapUpdate;
144 bool ReadOnlyLock; 144 bool ReadOnlyLock;
145 bool KeepImage; 145 bool KeepImage;
146}; 146};
147 147
148//! OpenGL FBO texture. 148//! OpenGL FBO texture.
149class COpenGLFBOTexture : public COpenGLTexture 149class COpenGLFBOTexture : public COpenGLTexture
150{ 150{
151public: 151public:
152 152
153 //! FrameBufferObject constructor 153 //! FrameBufferObject constructor
154 COpenGLFBOTexture(const core::dimension2d<u32>& size, const io::path& name, 154 COpenGLFBOTexture(const core::dimension2d<u32>& size, const io::path& name,
155 COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN); 155 COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN);
156 156
157 //! destructor 157 //! destructor
158 virtual ~COpenGLFBOTexture(); 158 virtual ~COpenGLFBOTexture();
159 159
160 //! Is it a FrameBufferObject? 160 //! Is it a FrameBufferObject?
161 virtual bool isFrameBufferObject() const; 161 virtual bool isFrameBufferObject() const;
162 162
163 //! Bind RenderTargetTexture 163 //! Bind RenderTargetTexture
164 virtual void bindRTT(); 164 virtual void bindRTT();
165 165
166 //! Unbind RenderTargetTexture 166 //! Unbind RenderTargetTexture
167 virtual void unbindRTT(); 167 virtual void unbindRTT();
168 168
169 ITexture* DepthTexture; 169 ITexture* DepthTexture;
170protected: 170protected:
171 GLuint ColorFrameBuffer; 171 GLuint ColorFrameBuffer;
172}; 172};
173 173
174 174
175//! OpenGL FBO depth texture. 175//! OpenGL FBO depth texture.
176class COpenGLFBODepthTexture : public COpenGLTexture 176class COpenGLFBODepthTexture : public COpenGLTexture
177{ 177{
178public: 178public:
179 //! FrameBufferObject depth constructor 179 //! FrameBufferObject depth constructor
180 COpenGLFBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COpenGLDriver* driver=0, bool useStencil=false); 180 COpenGLFBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COpenGLDriver* driver=0, bool useStencil=false);
181 181
182 //! destructor 182 //! destructor
183 virtual ~COpenGLFBODepthTexture(); 183 virtual ~COpenGLFBODepthTexture();
184 184
185 //! Bind RenderTargetTexture 185 //! Bind RenderTargetTexture
186 virtual void bindRTT(); 186 virtual void bindRTT();
187 187
188 //! Unbind RenderTargetTexture 188 //! Unbind RenderTargetTexture
189 virtual void unbindRTT(); 189 virtual void unbindRTT();
190 190
191 bool attach(ITexture*); 191 bool attach(ITexture*);
192 192
193protected: 193protected:
194 GLuint DepthRenderBuffer; 194 GLuint DepthRenderBuffer;
195 GLuint StencilRenderBuffer; 195 GLuint StencilRenderBuffer;
196 bool UseStencil; 196 bool UseStencil;
197}; 197};
198 198
199 199
200} // end namespace video 200} // end namespace video
201} // end namespace irr 201} // end namespace irr
202 202
203#endif 203#endif
204#endif // _IRR_COMPILE_WITH_OPENGL_ 204#endif // _IRR_COMPILE_WITH_OPENGL_
205 205