- Clean-up OGL ES2 driver (mainly stuff related to textures).
git-svn-id: http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4481 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
2a776c3647
commit
49c11b0690
@ -1,14 +1,14 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=Google Inc.:Google APIs:16
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-10
|
||||
|
@ -220,7 +220,7 @@ namespace video
|
||||
#endif
|
||||
os::Printer::log("Creating EglContext...");
|
||||
EglContext = eglCreateContext(EglDisplay, config, EGL_NO_CONTEXT, contextAttrib);
|
||||
if (testEGLError())
|
||||
if (EGL_NO_CONTEXT == EglContext)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
os::Printer::log("Could not create Context for OpenGL-ES2 display.");
|
||||
@ -349,9 +349,9 @@ namespace video
|
||||
|
||||
DriverAttributes->setAttribute("MaxTextures", MaxTextureUnits);
|
||||
DriverAttributes->setAttribute("MaxSupportedTextures", MaxSupportedTextures);
|
||||
DriverAttributes->setAttribute("MaxLights", MaxLights);
|
||||
// DriverAttributes->setAttribute("MaxLights", MaxLights);
|
||||
DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy);
|
||||
DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes);
|
||||
// DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes);
|
||||
// DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers);
|
||||
// DriverAttributes->setAttribute("MaxMultipleRenderTargets", MaxMultipleRenderTargets);
|
||||
DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices);
|
||||
@ -363,7 +363,7 @@ namespace video
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
// Reset The Current Viewport
|
||||
glViewport(0, 0, screenSize.Width, screenSize.Height);
|
||||
BridgeCalls->setViewport(core::rect<s32>(0, 0, screenSize.Width, screenSize.Height));
|
||||
|
||||
UserClipPlane.reallocate(0);
|
||||
|
||||
@ -1743,7 +1743,7 @@ namespace video
|
||||
//! returns a device dependent texture from a software surface (IImage)
|
||||
video::ITexture* COGLES2Driver::createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData)
|
||||
{
|
||||
return new COGLES2Texture(surface, name, this);
|
||||
return new COGLES2Texture(surface, name, mipmapData, this);
|
||||
}
|
||||
|
||||
|
||||
@ -2204,7 +2204,7 @@ namespace video
|
||||
//! returns the maximal amount of dynamic lights the device can handle
|
||||
u32 COGLES2Driver::getMaximalDynamicLightAmount() const
|
||||
{
|
||||
return MaxLights;
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
@ -2228,11 +2228,7 @@ namespace video
|
||||
vp.clipAgainst(rendert);
|
||||
|
||||
if (vp.getHeight() > 0 && vp.getWidth() > 0)
|
||||
{
|
||||
glViewport(vp.UpperLeftCorner.X,
|
||||
getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(),
|
||||
vp.getWidth(), vp.getHeight());
|
||||
}
|
||||
BridgeCalls->setViewport(core::rect<s32>(vp.UpperLeftCorner.X, getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), vp.getWidth(), vp.getHeight()));
|
||||
|
||||
ViewPort = vp;
|
||||
testGLError();
|
||||
@ -2404,7 +2400,7 @@ namespace video
|
||||
void COGLES2Driver::OnResize(const core::dimension2d<u32>& size)
|
||||
{
|
||||
CNullDriver::OnResize(size);
|
||||
glViewport(0, 0, size.Width, size.Height);
|
||||
BridgeCalls->setViewport(core::rect<s32>(0, 0, size.Width, size.Height));
|
||||
testGLError();
|
||||
}
|
||||
|
||||
@ -2541,42 +2537,28 @@ namespace video
|
||||
|
||||
video::ITexture* rtt = 0;
|
||||
|
||||
// if driver supports FrameBufferObjects, use them
|
||||
if (queryFeature(EVDF_FRAMEBUFFER_OBJECT))
|
||||
rtt = new COGLES2FBOTexture(size, name, this, format);
|
||||
if (rtt)
|
||||
{
|
||||
rtt = new COGLES2FBOTexture(size, name, this, format);
|
||||
if (rtt)
|
||||
{
|
||||
bool success = false;
|
||||
addTexture(rtt);
|
||||
bool success = false;
|
||||
addTexture(rtt);
|
||||
|
||||
ITexture* tex = createDepthTexture(rtt);
|
||||
if (tex)
|
||||
{
|
||||
success = static_cast<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
||||
if (!success)
|
||||
{
|
||||
removeDepthTexture(tex);
|
||||
}
|
||||
tex->drop();
|
||||
}
|
||||
rtt->drop();
|
||||
ITexture* tex = createDepthTexture(rtt);
|
||||
if (tex)
|
||||
{
|
||||
success = static_cast<video::COGLES2FBODepthTexture*>(tex)->attach(rtt);
|
||||
if (!success)
|
||||
{
|
||||
removeTexture(rtt);
|
||||
rtt=0;
|
||||
removeDepthTexture(tex);
|
||||
}
|
||||
tex->drop();
|
||||
}
|
||||
rtt->drop();
|
||||
if (!success)
|
||||
{
|
||||
removeTexture(rtt);
|
||||
rtt=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the simple texture is only possible for size <= screensize
|
||||
// we try to find an optimal size with the original constraints
|
||||
core::dimension2du destSize(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height));
|
||||
destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false);
|
||||
rtt = addTexture(destSize, name, ECF_A8R8G8B8);
|
||||
if (rtt)
|
||||
static_cast<video::COGLES2Texture*>(rtt)->setIsRenderTarget(true);
|
||||
}
|
||||
|
||||
//restore mip-mapping
|
||||
@ -2617,13 +2599,14 @@ namespace video
|
||||
if (texture)
|
||||
{
|
||||
// we want to set a new target. so do this.
|
||||
BridgeCalls->setViewport(core::rect<s32>(0, 0, texture->getSize().Width, texture->getSize().Height));
|
||||
RenderTargetTexture = static_cast<COGLES2Texture*>(texture);
|
||||
RenderTargetTexture->bindRTT();
|
||||
CurrentRendertargetSize = texture->getSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
glViewport(0, 0, ScreenSize.Width, ScreenSize.Height);
|
||||
BridgeCalls->setViewport(core::rect<s32>(0, 0, ScreenSize.Width, ScreenSize.Height));
|
||||
RenderTargetTexture = 0;
|
||||
CurrentRendertargetSize = core::dimension2d<u32>(0, 0);
|
||||
}
|
||||
@ -2816,9 +2799,6 @@ namespace video
|
||||
//! Enable/disable a clipping plane.
|
||||
void COGLES2Driver::enableClipPlane(u32 index, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return;
|
||||
|
||||
UserClipPlane[index].Enabled = enable;
|
||||
}
|
||||
|
||||
@ -2861,6 +2841,38 @@ namespace video
|
||||
return r;
|
||||
}
|
||||
|
||||
GLenum COGLES2Driver::getZBufferBits() const
|
||||
{
|
||||
/*#if defined(GL_OES_depth24)
|
||||
if (Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_OES_depth24))
|
||||
InternalFormat = GL_DEPTH_COMPONENT24_OES;
|
||||
else
|
||||
#endif
|
||||
#if defined(GL_OES_depth32)
|
||||
if (Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_OES_depth32))
|
||||
InternalFormat = GL_DEPTH_COMPONENT32_OES;
|
||||
else
|
||||
#endif*/
|
||||
|
||||
GLenum bits = GL_DEPTH_COMPONENT16;//0;
|
||||
/*switch (Params.ZBufferBits)
|
||||
{
|
||||
case 16:
|
||||
bits = GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
case 24:
|
||||
bits = GL_DEPTH_COMPONENT24;
|
||||
break;
|
||||
case 32:
|
||||
bits = GL_DEPTH_COMPONENT32;
|
||||
break;
|
||||
default:
|
||||
bits = GL_DEPTH_COMPONENT;
|
||||
break;
|
||||
}*/
|
||||
return bits;
|
||||
}
|
||||
|
||||
const SMaterial& COGLES2Driver::getCurrentMaterial() const
|
||||
{
|
||||
return Material;
|
||||
@ -2875,7 +2887,7 @@ namespace video
|
||||
BlendSource(GL_ONE), BlendDestination(GL_ZERO), Blend(false),
|
||||
CullFaceMode(GL_BACK), CullFace(false),
|
||||
DepthFunc(GL_LESS), DepthMask(true), DepthTest(false),
|
||||
Program(0), ActiveTexture(GL_TEXTURE0)
|
||||
Program(0), ActiveTexture(GL_TEXTURE0), Viewport(core::rect<s32>(0, 0, 0, 0))
|
||||
{
|
||||
// Initial OpenGL values from specification.
|
||||
|
||||
@ -3003,13 +3015,22 @@ namespace video
|
||||
setActiveTexture(GL_TEXTURE0 + stage);
|
||||
|
||||
if(Driver->CurrentTexture[stage])
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const COGLES2Texture*>(Driver->CurrentTexture[stage])->getOGLES2TextureName());
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const COGLES2Texture*>(Driver->CurrentTexture[stage])->getOpenGLTextureName());
|
||||
|
||||
Texture[stage] = Driver->CurrentTexture[stage];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void COGLES2CallBridge::setViewport(const core::rect<s32>& viewport)
|
||||
{
|
||||
if (Viewport != viewport)
|
||||
{
|
||||
glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
Viewport = viewport;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
@ -58,6 +58,7 @@ namespace video
|
||||
class COGLES2Driver : public CNullDriver, public IMaterialRendererServices, public COGLES2ExtensionHandler
|
||||
{
|
||||
friend class COGLES2CallBridge;
|
||||
friend class COGLES2Texture;
|
||||
|
||||
public:
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_CONSOLE_DEVICE_)
|
||||
@ -361,6 +362,9 @@ namespace video
|
||||
//! Convert E_BLEND_FACTOR to OpenGL equivalent
|
||||
GLenum getGLBlend(E_BLEND_FACTOR factor) const;
|
||||
|
||||
//! Get ZBuffer bits.
|
||||
GLenum getZBufferBits() const;
|
||||
|
||||
//! Get current material.
|
||||
const SMaterial& getCurrentMaterial() const;
|
||||
|
||||
@ -503,6 +507,10 @@ namespace video
|
||||
void setActiveTexture(GLenum texture);
|
||||
|
||||
void setTexture(u32 stage);
|
||||
|
||||
// Viewport calls.
|
||||
|
||||
void setViewport(const core::rect<s32>& viewport);
|
||||
|
||||
private:
|
||||
COGLES2Driver* Driver;
|
||||
@ -523,6 +531,8 @@ namespace video
|
||||
GLenum ActiveTexture;
|
||||
|
||||
const ITexture* Texture[MATERIAL_MAX_TEXTURES];
|
||||
|
||||
core::rect<s32> Viewport;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
|
@ -160,9 +160,9 @@ namespace video
|
||||
|
||||
COGLES2ExtensionHandler::COGLES2ExtensionHandler() :
|
||||
EGLVersion(0), Version(0), MaxTextureUnits(0), MaxSupportedTextures(0),
|
||||
MaxLights(0), MaxAnisotropy(1), MaxUserClipPlanes(6), MaxTextureSize(1),
|
||||
MaxIndices(0xffff), MaxTextureLODBias(0.f), MultiTextureExtension(false),
|
||||
MultiSamplingExtension(false), StencilBuffer(false)
|
||||
MaxAnisotropy(1), MaxTextureSize(1),
|
||||
MaxIndices(0xffff), MaxTextureLODBias(0.f),
|
||||
StencilBuffer(false)
|
||||
{
|
||||
for (u32 i=0; i<IRR_OGLES2_Feature_Count; ++i)
|
||||
FeatureAvailable[i] = false;
|
||||
@ -227,26 +227,30 @@ namespace video
|
||||
delete [] str;
|
||||
}
|
||||
|
||||
GLint val = 0;
|
||||
GLint val=0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &val);
|
||||
MaxSupportedTextures = core::min_(MATERIAL_MAX_TEXTURES, static_cast<u32>(val));
|
||||
MultiTextureExtension = true;
|
||||
//TODO : OpenGL ES 2.0 Port
|
||||
//glGetIntegerv(GL_MAX_LIGHTS, &val);
|
||||
MaxLights = 8;
|
||||
#ifdef GL_EXT_texture_filter_anisotropic
|
||||
|
||||
#ifdef GL_EXT_texture_filter_anisotropic
|
||||
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
|
||||
{
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val);
|
||||
MaxAnisotropy = static_cast<u8>(val);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef GL_MAX_ELEMENTS_INDICES
|
||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val);
|
||||
MaxIndices=val;
|
||||
#endif
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
|
||||
MaxTextureSize=static_cast<u32>(val);
|
||||
#ifdef GL_EXT_texture_lod_bias
|
||||
#ifdef GL_EXT_texture_lod_bias
|
||||
if (FeatureAvailable[IRR_EXT_texture_lod_bias])
|
||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias);
|
||||
#endif
|
||||
#endif
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
|
||||
MaxTextureUnits = core::min_(MaxSupportedTextures, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
}
|
||||
|
||||
|
@ -190,9 +190,7 @@ namespace video
|
||||
{
|
||||
case EVDF_RENDER_TO_TARGET:
|
||||
case EVDF_HARDWARE_TL:
|
||||
return true;
|
||||
case EVDF_MULTITEXTURE:
|
||||
return MultiTextureExtension;
|
||||
case EVDF_BILINEAR_FILTER:
|
||||
case EVDF_MIP_MAP:
|
||||
case EVDF_MIP_MAP_AUTO_UPDATE:
|
||||
@ -235,15 +233,14 @@ namespace video
|
||||
u16 Version;
|
||||
u8 MaxTextureUnits;
|
||||
u8 MaxSupportedTextures;
|
||||
u8 MaxLights;
|
||||
u8 MaxAnisotropy;
|
||||
u8 MaxUserClipPlanes;
|
||||
u32 MaxTextureSize;
|
||||
u32 MaxIndices;
|
||||
u32 MaxTextureSize;
|
||||
f32 MaxTextureLODBias;
|
||||
|
||||
bool MultiTextureExtension;
|
||||
bool MultiSamplingExtension;
|
||||
//! Minimal and maximal supported thickness for lines without smoothing
|
||||
GLfloat DimAliasedLine[2];
|
||||
//! Minimal and maximal supported thickness for points without smoothing
|
||||
GLfloat DimAliasedPoint[2];
|
||||
bool StencilBuffer;
|
||||
bool FeatureAvailable[IRR_OGLES2_Feature_Count];
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,180 +8,196 @@
|
||||
#ifndef __C_OGLES2_TEXTURE_H_INCLUDED__
|
||||
#define __C_OGLES2_TEXTURE_H_INCLUDED__
|
||||
|
||||
#include "SMaterialLayer.h"
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
|
||||
#include "ITexture.h"
|
||||
#include "IImage.h"
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
#include "SMaterialLayer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2Driver;
|
||||
class COGLES2Driver;
|
||||
|
||||
//! OGLES2 texture.
|
||||
class COGLES2Texture : public ITexture
|
||||
//! OpenGL ES 2.0 texture.
|
||||
class COGLES2Texture : public ITexture
|
||||
{
|
||||
public:
|
||||
|
||||
//! Cache structure.
|
||||
struct SStatesCache
|
||||
{
|
||||
public:
|
||||
|
||||
//! Cache structure.
|
||||
struct SStatesCache
|
||||
SStatesCache() : WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), BilinearFilter(false),
|
||||
TrilinearFilter(false), AnisotropicFilter(0), MipMapStatus(false), IsCached(false), LODBias(0)
|
||||
{
|
||||
SStatesCache() : WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), BilinearFilter(false),
|
||||
TrilinearFilter(false), AnisotropicFilter(0), MipMapStatus(false), IsCached(false), LODBias(0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
u8 WrapU;
|
||||
u8 WrapV;
|
||||
bool BilinearFilter;
|
||||
bool TrilinearFilter;
|
||||
u8 AnisotropicFilter;
|
||||
bool MipMapStatus;
|
||||
s8 LODBias;
|
||||
u8 WrapU;
|
||||
u8 WrapV;
|
||||
bool BilinearFilter;
|
||||
bool TrilinearFilter;
|
||||
u8 AnisotropicFilter;
|
||||
bool MipMapStatus;
|
||||
s8 LODBias;
|
||||
|
||||
bool IsCached;
|
||||
};
|
||||
|
||||
//! constructor
|
||||
COGLES2Texture(IImage* surface, const io::path& name, COGLES2Driver* driver = 0);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES2Texture();
|
||||
|
||||
//! lock function
|
||||
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
|
||||
|
||||
//! unlock function
|
||||
virtual void unlock();
|
||||
|
||||
//! Returns original size of the texture (image).
|
||||
virtual const core::dimension2d<u32>& getOriginalSize() const;
|
||||
|
||||
//! Returns size of the texture.
|
||||
virtual const core::dimension2d<u32>& getSize() const;
|
||||
|
||||
//! returns driver type of texture (=the driver, that created it)
|
||||
virtual E_DRIVER_TYPE getDriverType() const;
|
||||
|
||||
//! returns color format of texture
|
||||
virtual ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! returns pitch of texture (in bytes)
|
||||
virtual u32 getPitch() const;
|
||||
|
||||
//! return open gl texture name
|
||||
u32 getOGLES2TextureName() const;
|
||||
|
||||
//! return whether this texture has mipmaps
|
||||
virtual bool hasMipMaps() const;
|
||||
|
||||
//! Regenerates the mip map levels of the texture.
|
||||
virtual void regenerateMipMapLevels(void* mipmapData=0);
|
||||
|
||||
//! Is it a render target?
|
||||
virtual bool isRenderTarget() const;
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
void unbindRTT();
|
||||
|
||||
//! sets whether this texture is intended to be used as a render target.
|
||||
void setIsRenderTarget(bool isTarget);
|
||||
|
||||
//! Get an access to texture states cache.
|
||||
SStatesCache& getStatesCache() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! protected constructor with basic setup, no GL texture name created, for derived classes
|
||||
COGLES2Texture(const io::path& name, COGLES2Driver* driver);
|
||||
|
||||
//! get the desired color format based on texture creation flags and the input format.
|
||||
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
|
||||
|
||||
//! convert the image into an internal image with better properties for this driver.
|
||||
void getImageData(IImage* image);
|
||||
|
||||
//! copies the the texture into an open gl texture.
|
||||
void copyTexture(bool newTexture = true);
|
||||
|
||||
core::dimension2d<u32> ImageSize;
|
||||
COGLES2Driver* Driver;
|
||||
IImage* Image;
|
||||
|
||||
u32 TextureName;
|
||||
s32 InternalFormat;
|
||||
u32 PixelFormat;
|
||||
u32 PixelType;
|
||||
|
||||
bool HasMipMaps;
|
||||
bool IsRenderTarget;
|
||||
bool AutomaticMipmapUpdate;
|
||||
bool UseStencil;
|
||||
bool ReadOnlyLock;
|
||||
|
||||
mutable SStatesCache StatesCache;
|
||||
bool IsCached;
|
||||
};
|
||||
|
||||
//! constructor
|
||||
COGLES2Texture(IImage* surface, const io::path& name, void* mipmapData=0, COGLES2Driver* driver=0);
|
||||
|
||||
//! OGLES2 FBO texture.
|
||||
class COGLES2FBOTexture : public COGLES2Texture
|
||||
{
|
||||
public:
|
||||
//! destructor
|
||||
virtual ~COGLES2Texture();
|
||||
|
||||
//! FrameBufferObject constructor
|
||||
COGLES2FBOTexture(const core::dimension2d<u32>& size, const io::path& name, COGLES2Driver* driver = 0, ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
//! lock function
|
||||
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES2FBOTexture();
|
||||
//! unlock function
|
||||
virtual void unlock();
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
//! Returns original size of the texture (image).
|
||||
virtual const core::dimension2d<u32>& getOriginalSize() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
//! Returns size of the texture.
|
||||
virtual const core::dimension2d<u32>& getSize() const;
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
//! returns driver type of texture (=the driver, that created it)
|
||||
virtual E_DRIVER_TYPE getDriverType() const;
|
||||
|
||||
ITexture* DepthTexture;
|
||||
protected:
|
||||
u32 ColorFrameBuffer;
|
||||
};
|
||||
//! returns color format of texture
|
||||
virtual ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! returns pitch of texture (in bytes)
|
||||
virtual u32 getPitch() const;
|
||||
|
||||
//! return open gl texture name
|
||||
GLuint getOpenGLTextureName() const;
|
||||
|
||||
//! return whether this texture has mipmaps
|
||||
virtual bool hasMipMaps() const;
|
||||
|
||||
//! Regenerates the mip map levels of the texture.
|
||||
/** Useful after locking and modifying the texture
|
||||
\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. */
|
||||
virtual void regenerateMipMapLevels(void* mipmapData=0);
|
||||
|
||||
//! Is it a render target?
|
||||
virtual bool isRenderTarget() const;
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
//! sets whether this texture is intended to be used as a render target.
|
||||
void setIsRenderTarget(bool isTarget);
|
||||
|
||||
//! Get an access to texture states cache.
|
||||
SStatesCache& getStatesCache() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! protected constructor with basic setup, no GL texture name created, for derived classes
|
||||
COGLES2Texture(const io::path& name, COGLES2Driver* driver);
|
||||
|
||||
//! get the desired color format based on texture creation flags and the input format.
|
||||
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
|
||||
|
||||
//! get important numbers of the image and hw texture
|
||||
void getImageValues(IImage* image);
|
||||
|
||||
//! copies the texture into an OpenGL texture.
|
||||
/** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
|
||||
\param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.
|
||||
\param mipLevel If set to non-zero, only that specific miplevel is updated, using the MipImage member. */
|
||||
void uploadTexture(bool newTexture=false, void* mipmapData=0, u32 mipLevel=0);
|
||||
|
||||
core::dimension2d<u32> ImageSize;
|
||||
core::dimension2d<u32> TextureSize;
|
||||
ECOLOR_FORMAT ColorFormat;
|
||||
COGLES2Driver* Driver;
|
||||
IImage* Image;
|
||||
IImage* MipImage;
|
||||
|
||||
GLuint TextureName;
|
||||
GLint InternalFormat;
|
||||
GLenum PixelFormat;
|
||||
GLenum PixelType;
|
||||
|
||||
u8 MipLevelStored;
|
||||
bool HasMipMaps;
|
||||
bool IsRenderTarget;
|
||||
bool AutomaticMipmapUpdate;
|
||||
bool ReadOnlyLock;
|
||||
bool KeepImage;
|
||||
|
||||
mutable SStatesCache StatesCache;
|
||||
};
|
||||
|
||||
//! OpenGL ES 2.0 FBO texture.
|
||||
class COGLES2FBOTexture : public COGLES2Texture
|
||||
{
|
||||
public:
|
||||
|
||||
//! FrameBufferObject constructor
|
||||
COGLES2FBOTexture(const core::dimension2d<u32>& size, const io::path& name,
|
||||
COGLES2Driver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES2FBOTexture();
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
ITexture* DepthTexture;
|
||||
protected:
|
||||
GLuint ColorFrameBuffer;
|
||||
};
|
||||
|
||||
|
||||
//! OGLES2 FBO depth texture.
|
||||
class COGLES2FBODepthTexture : public COGLES2FBOTexture
|
||||
{
|
||||
public:
|
||||
//! FrameBufferObject depth constructor
|
||||
COGLES2FBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COGLES2Driver* driver = 0, bool useStencil = false);
|
||||
//! OpenGL ES 2.0 FBO depth texture.
|
||||
class COGLES2FBODepthTexture : public COGLES2Texture
|
||||
{
|
||||
public:
|
||||
//! FrameBufferObject depth constructor
|
||||
COGLES2FBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COGLES2Driver* driver=0, bool useStencil=false);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES2FBODepthTexture();
|
||||
//! destructor
|
||||
virtual ~COGLES2FBODepthTexture();
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
bool attach(ITexture* rtt);
|
||||
bool attach(ITexture*);
|
||||
|
||||
protected:
|
||||
u32 DepthRenderBuffer;
|
||||
u32 StencilRenderBuffer;
|
||||
bool UseStencil;
|
||||
};
|
||||
protected:
|
||||
GLuint DepthRenderBuffer;
|
||||
GLuint StencilRenderBuffer;
|
||||
bool UseStencil;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
|
Loading…
x
Reference in New Issue
Block a user