Commit 6238406c authored by nadro's avatar nadro

- Improve OpenGL calls cache (This may be unstable revision, require more...

- Improve OpenGL calls cache (This may be unstable revision, require more tests). Cache will be improved further in close future.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4404 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 5b282f8f
......@@ -809,7 +809,7 @@ namespace video
/** \param texture Pointer to texture to use.
\param destPos Upper left 2d destination position where the
image will be drawn. */
virtual void draw2DImage(const video::ITexture* texture,
virtual void draw2DImage(video::ITexture* texture,
const core::position2d<s32>& destPos) =0;
//! Draws a 2d image using a color
......@@ -828,7 +828,7 @@ namespace video
will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image.*/
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
......@@ -852,7 +852,7 @@ namespace video
255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */
virtual void draw2DImageBatch(const video::ITexture* texture,
virtual void draw2DImageBatch(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects,
const core::array<s32>& indices,
......@@ -877,7 +877,7 @@ namespace video
255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */
virtual void draw2DImageBatch(const video::ITexture* texture,
virtual void draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0,
......@@ -894,7 +894,7 @@ namespace video
the corners of the destRect
\param useAlphaChannelOfTexture True if alpha channel will be
blended. */
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
......
......@@ -1003,7 +1003,7 @@ void CD3D8Driver::draw2D3DVertexPrimitiveList(const void* vertices,
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CD3D8Driver::draw2DImage(const video::ITexture* texture,
void CD3D8Driver::draw2DImage(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
......@@ -1137,7 +1137,7 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
}
void CD3D8Driver::draw2DImage(const video::ITexture* texture,
void CD3D8Driver::draw2DImage(video::ITexture* texture,
const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect,
......
......@@ -79,12 +79,12 @@ namespace video
E_INDEX_TYPE iType);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
//! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
......
......@@ -1567,7 +1567,7 @@ void CD3D9Driver::draw2D3DVertexPrimitiveList(const void* vertices,
}
void CD3D9Driver::draw2DImage(const video::ITexture* texture,
void CD3D9Driver::draw2DImage(video::ITexture* texture,
const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect,
......@@ -1639,7 +1639,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
}
void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture,
void CD3D9Driver::draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect,
......@@ -1787,7 +1787,7 @@ void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture,
//! draws a 2d image, using a color and the alpha channel of the texture if
//! desired. The image is drawn at pos and clipped against clipRect (if != 0).
void CD3D9Driver::draw2DImage(const video::ITexture* texture,
void CD3D9Driver::draw2DImage(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
......
......@@ -161,17 +161,17 @@ namespace video
E_INDEX_TYPE iType);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
//! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
//! Draws a set of 2d images, using a color and the alpha channel of the texture.
virtual void draw2DImageBatch(const video::ITexture* texture,
virtual void draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0,
......
......@@ -152,7 +152,7 @@ void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos,
frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
}
const video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber);
video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber);
if (!tex)
return;
......
......@@ -714,7 +714,7 @@ void CNullDriver::draw3DBox(const core::aabbox3d<f32>& box, SColor color)
//! draws an 2d image
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos)
void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos)
{
if (!texture)
return;
......@@ -730,7 +730,7 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::positi
//! in one line. All drawings are clipped against clipRect (if != 0).
//! The subtextures are defined by the array of sourceRects and are chosen
//! by the indices given.
void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
void CNullDriver::draw2DImageBatch(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects,
const core::array<s32>& indices,
......@@ -751,7 +751,7 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
//! draws a set of 2d images, using a color and the alpha channel of the
//! texture if desired.
void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
void CNullDriver::draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect,
......@@ -769,7 +769,7 @@ void CNullDriver::draw2DImageBatch(const video::ITexture* texture,
//! Draws a part of the texture into the rectangle.
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
void CNullDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture)
{
......@@ -781,7 +781,7 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s
//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
......
......@@ -141,7 +141,7 @@ namespace video
SColor color = SColor(255,255,255,255));
//! draws an 2d image
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos);
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos);
//! draws a set of 2d images, using a color and the alpha
/** channel of the texture if desired. The images are drawn
......@@ -160,7 +160,7 @@ namespace video
Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of the texture is
used to draw the image. */
virtual void draw2DImageBatch(const video::ITexture* texture,
virtual void draw2DImageBatch(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects,
const core::array<s32>& indices,
......@@ -185,7 +185,7 @@ namespace video
255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */
virtual void draw2DImageBatch(const video::ITexture* texture,
virtual void draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect=0,
......@@ -193,12 +193,12 @@ namespace video
bool useAlphaChannelOfTexture=false);
//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
//! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
......
This diff is collapsed.
......@@ -151,7 +151,7 @@ namespace video
//! draws a set of 2d images, using a color and the alpha channel of the
//! texture if desired.
void draw2DImageBatch(const video::ITexture* texture,
void draw2DImageBatch(video::ITexture* texture,
const core::array<core::position2d<s32> >& positions,
const core::array<core::rect<s32> >& sourceRects,
const core::rect<s32>* clipRect,
......@@ -159,7 +159,7 @@ namespace video
bool useAlphaChannelOfTexture);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
......@@ -179,7 +179,7 @@ namespace video
Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of the texture is
used to draw the image. */
virtual void draw2DImage(const video::ITexture* texture,
virtual void draw2DImage(video::ITexture* texture,
const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects,
const core::array<s32>& indices,
......@@ -188,7 +188,7 @@ namespace video
bool useAlphaChannelOfTexture=false);
//! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
......@@ -303,7 +303,7 @@ namespace video
//! sets the current Texture
//! Returns whether setting was a success or not.
bool setActiveTexture(u32 stage, const video::ITexture* texture);
bool setActiveTexture(u32 stage, video::ITexture* texture);
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
//! Returns whether disabling was successful or not.
......@@ -405,6 +405,12 @@ namespace video
//! Get ZBuffer bits.
GLenum getZBufferBits() const;
//! Set the gl matrix mode, if not set already
void setGlMatrixMode(GLenum mode);
//! Set active texture, if not set already
void setGlActiveTexture(GLenum texture);
//! Get Cg context
#ifdef _IRR_COMPILE_WITH_CG_
const CGcontext& getCgContext();
......@@ -429,9 +435,6 @@ namespace video
inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
//! Set GL pipeline to desired texture wrap modes of the material
void setWrapMode(const SMaterial& material);
//! get native wrap mode value
GLint getTextureWrapMode(const u8 clamp);
......@@ -458,9 +461,6 @@ namespace video
void renderArray(const void* indexList, u32 primitiveCount,
scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! Set the gl matrix mode, if not set already
void setMatrixMode(GLenum mode);
core::stringw Name;
core::matrix4 Matrices[ETS_COUNT];
core::array<u8> ColorBuffer;
......@@ -484,7 +484,7 @@ namespace video
core::array<video::IRenderTarget> MRTargets;
class STextureStageCache
{
const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES];
ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES];
public:
STextureStageCache()
{
......@@ -499,7 +499,7 @@ namespace video
clear();
}
void set(u32 stage, const ITexture* tex)
void set(u32 stage, ITexture* tex)
{
if (stage<MATERIAL_MAX_TEXTURES)
{
......@@ -512,7 +512,7 @@ namespace video
}
}
const ITexture* operator[](int stage) const
ITexture* operator[](int stage) const
{
if ((u32)stage<MATERIAL_MAX_TEXTURES)
return CurrentTexture[stage];
......@@ -520,7 +520,7 @@ namespace video
return 0;
}
void remove(const ITexture* tex)
void remove(ITexture* tex)
{
for (s32 i = MATERIAL_MAX_TEXTURES-1; i>= 0; --i)
{
......@@ -561,8 +561,6 @@ namespace video
core::matrix4 TextureFlipMatrix;
GLenum CurrentMatrixMode;
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
......@@ -571,8 +569,16 @@ namespace video
SIrrlichtCreationParameters Params;
bool IsDepthTestEnabled;
bool IsTexture2DEnabled;
bool DepthMask;
GLenum CurrentMatrixMode;
GLenum CurrentActiveTexture;
s8 CacheLODBias[MATERIAL_MAX_TEXTURES];
//! All the lights that have been requested; a hardware limited
//! number of them will be used at once.
struct RequestedLight
......
......@@ -269,7 +269,7 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
......@@ -297,14 +297,14 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR);
#else
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
#endif
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
}
}
};
......@@ -625,7 +625,7 @@ public:
{
// lightmap
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
......@@ -679,7 +679,7 @@ public:
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f);
#endif
}
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
}
}
}
......@@ -688,14 +688,14 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.f );
#else
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f );
#endif
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
......@@ -724,7 +724,7 @@ public:
// detail map on second layer
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
......@@ -744,9 +744,9 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
}
}
};
......@@ -806,7 +806,7 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
......@@ -830,14 +830,14 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
}
}
};
......@@ -876,7 +876,7 @@ public:
#endif
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
......@@ -907,14 +907,14 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->setGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->setGlActiveTexture(GL_TEXTURE0_ARB);
}
glDisable(GL_BLEND);
}
......
......@@ -25,7 +25,8 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mi
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0), MipmapLegacyMode(true),
IsRenderTarget(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
ReadOnlyLock(false), KeepImage(true),
WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), Bilinear(true), Trilinear(false), Anisotropic(0), MipMapStatus(true), CacheStatus(false)
{
#ifdef _DEBUG
setDebugName("COpenGLTexture");
......@@ -62,7 +63,8 @@ COpenGLTexture::COpenGLTexture(const io::path& name, COpenGLDriver* driver)
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0), HasMipMaps(true),
MipmapLegacyMode(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
ReadOnlyLock(false), KeepImage(true),
WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), Bilinear(true), Trilinear(false), Anisotropic(0), MipMapStatus(true), CacheStatus(false)
{
#ifdef _DEBUG
setDebugName("COpenGLTexture");
......@@ -656,6 +658,78 @@ void COpenGLTexture::unbindRTT()
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
}
//! Cache methods.
u8 COpenGLTexture::getTextureWrapU() const
{
return WrapU;
}
void COpenGLTexture::setTextureWrapU(u8 value)
{
WrapU = value;
}
u8 COpenGLTexture::getTextureWrapV() const
{
return WrapV;
}
void COpenGLTexture::setTextureWrapV(u8 value)
{
WrapV = value;
}
bool COpenGLTexture::getBilinearFilter() const
{
return Bilinear;
}
void COpenGLTexture::setBilinearFilter(bool value)
{
Bilinear = value;
}
bool COpenGLTexture::getTrilinearFilter() const
{
return Trilinear;
}
void COpenGLTexture::setTrilinearFilter(bool value)
{
Trilinear = value;
}
u8 COpenGLTexture::getAnisotropicFilter() const
{
return Anisotropic;
}
void COpenGLTexture::setAnisotropicFilter(u8 value)
{
Anisotropic = value;
}
bool COpenGLTexture::getMipMapsStatus() const
{
return MipMapStatus;
}
void COpenGLTexture::setMipMapsStatus(bool value)
{
MipMapStatus = value;
}
bool COpenGLTexture::getCacheStatus() const
{
return CacheStatus;
}
void COpenGLTexture::setCacheStatus(bool value)
{
CacheStatus = value;
}
/* FBO Textures */
......
......@@ -103,6 +103,29 @@ public:
//! sets whether this texture is intended to be used as a render target.
void setIsRenderTarget(bool isTarget);
//! Cache methods.
u8 getTextureWrapU() const;
void setTextureWrapU(u8 value);
u8 getTextureWrapV() const;
void setTextureWrapV(u8 value);
bool getBilinearFilter() const;
void setBilinearFilter(bool value);
bool getTrilinearFilter() const;
void setTrilinearFilter(bool value);
u8 getAnisotropicFilter() const;
void setAnisotropicFilter(u8 value);
bool getMipMapsStatus() const;
void setMipMapsStatus(bool value);
bool getCacheStatus() const;
void setCacheStatus(bool value);
protected:
//! protected constructor with basic setup, no GL texture name created, for derived classes
......@@ -143,6 +166,14 @@ protected:
bool AutomaticMipmapUpdate;
bool ReadOnlyLock;
bool KeepImage;
u8 WrapU;
u8 WrapV;
bool Bilinear;
bool Trilinear;
u8 Anisotropic;
bool MipMapStatus;
bool CacheStatus;
};
//! OpenGL FBO texture.
......
......@@ -792,7 +792,7 @@ const core::dimension2d<u32>& CSoftwareDriver::getCurrentRenderTargetSize() cons
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CSoftwareDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
void CSoftwareDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
......
......@@ -65,7 +65,7 @@ namespace video
const core::vector3df& end, SColor color = SColor(255,255,255,255));
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
......
......@@ -2188,7 +2188,7 @@ void CBurningVideoDriver::lightVertex ( s4DVertex *dest, u32 vertexargb )
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
void CBurningVideoDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
......@@ -2227,7 +2227,7 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core
//! Draws a part of the texture into the rectangle.
void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
void CBurningVideoDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture)
{
......
......@@ -85,12 +85,12 @@ namespace video
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
//! Draws a part of the texture into the rectangle.
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment