Commit 17bc727e authored by hybrid's avatar hybrid

Add mirror texture wrap modes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2870 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0f8a4a75
Changes in 1.7 Changes in 1.7
- windows show now active/inactive state - Add mirror texture wrap modes
- windows show now active/inactive state
- remove unneed drop/grab calls found by manik_sheeri - remove unneed drop/grab calls found by manik_sheeri
- fix rounding problem in IGUIElements which have EGUIA_SCALE alignments. - fix rounding problem in IGUIElements which have EGUIA_SCALE alignments.
- MessageBox supports now automatic resizing and images. - MessageBox supports now automatic resizing and images.
Deprecated EGDS_MESSAGE_BOX_WIDTH and EGDS_MESSAGE_BOX_HEIGHT Deprecated EGDS_MESSAGE_BOX_WIDTH and EGDS_MESSAGE_BOX_HEIGHT
- Let maya-cam animator react on a setTarget call to the camera which happened outside it's own control - Let maya-cam animator react on a setTarget call to the camera which happened outside it's own control
- New contextmenue features: - New contextmenue features:
automatic checking for checked flag. automatic checking for checked flag.
close handling now customizable close handling now customizable
serialization can handle incomplete xml's serialization can handle incomplete xml's
setEventParent now in public interface setEventParent now in public interface
New function findItemWithCommandId New function findItemWithCommandId
New function insertItem New function insertItem
- irrArray: Fixed issues with push_front and reallocation - irrArray: Fixed issues with push_front and reallocation
Changed behavior for set_pointer and clear, when free_when_destroyed is false Changed behavior for set_pointer and clear, when free_when_destroyed is false
- NPK (Nebula device archive) reader added, it's an uncompressed PAK-like format - NPK (Nebula device archive) reader added, it's an uncompressed PAK-like format
...@@ -36,7 +38,7 @@ Changes in 1.7 ...@@ -36,7 +38,7 @@ Changes in 1.7
- Sphere node now properly chooses a good tesselation based on the parameters - Sphere node now properly chooses a good tesselation based on the parameters
- Active camera not regsitered twice anymore - Active camera not registered twice anymore
- Parallax/normal map shader rotation bug under OpenGL fixed - Parallax/normal map shader rotation bug under OpenGL fixed
......
...@@ -26,14 +26,23 @@ namespace video ...@@ -26,14 +26,23 @@ namespace video
//! Texture is clamped to the border pixel (if exists) //! Texture is clamped to the border pixel (if exists)
ETC_CLAMP_TO_BORDER, ETC_CLAMP_TO_BORDER,
//! Texture is alternatingly mirrored (0..1..0..1..0..) //! Texture is alternatingly mirrored (0..1..0..1..0..)
ETC_MIRROR ETC_MIRROR,
//! Texture is mirrored once and then clamped (0..1..0)
ETC_MIRROR_CLAMP,
//! Texture is mirrored once and then clamped to edge
ETC_MIRROR_CLAMP_TO_EDGE,
//! Texture is mirrored once and then clamped to border
ETC_MIRROR_CLAMP_TO_BORDER
}; };
static const char* const aTextureClampNames[] = { static const char* const aTextureClampNames[] = {
"texture_clamp_repeat", "texture_clamp_repeat",
"texture_clamp_clamp", "texture_clamp_clamp",
"texture_clamp_clamp_to_edge", "texture_clamp_clamp_to_edge",
"texture_clamp_clamp_to_border", "texture_clamp_clamp_to_border",
"texture_clamp_mirror", 0}; "texture_clamp_mirror",
"texture_clamp_mirror_clamp",
"texture_clamp_mirror_clamp_to_edge",
"texture_clamp_mirror_clamp_to_border", 0};
//! Struct for holding material parameters which exist per texture layer //! Struct for holding material parameters which exist per texture layer
class SMaterialLayer class SMaterialLayer
......
...@@ -1536,17 +1536,31 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1536,17 +1536,31 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
switch (material.TextureLayer[st].TextureWrap) switch (material.TextureLayer[st].TextureWrap)
{ {
case ETC_REPEAT: case ETC_REPEAT:
mode=D3DTADDRESS_WRAP; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_WRAP)
mode=D3DTADDRESS_WRAP;
break; break;
case ETC_CLAMP: case ETC_CLAMP:
case ETC_CLAMP_TO_EDGE: case ETC_CLAMP_TO_EDGE:
mode=D3DTADDRESS_CLAMP; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_CLAMP)
mode=D3DTADDRESS_CLAMP;
break; break;
case ETC_MIRROR: case ETC_MIRROR:
mode=D3DTADDRESS_MIRROR; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_MIRROR)
mode=D3DTADDRESS_MIRROR;
break; break;
case ETC_CLAMP_TO_BORDER: case ETC_CLAMP_TO_BORDER:
mode=D3DTADDRESS_BORDER; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
mode=D3DTADDRESS_BORDER;
else
mode=D3DTADDRESS_CLAMP;
break;
case ETC_MIRROR_CLAMP:
case ETC_MIRROR_CLAMP_TO_EDGE:
case ETC_MIRROR_CLAMP_TO_BORDER:
if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_MIRRORONCE)
mode=D3DTADDRESS_MIRRORONCE;
else
mode=D3DTADDRESS_CLAMP;
break; break;
} }
......
...@@ -2137,17 +2137,31 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -2137,17 +2137,31 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
switch (material.TextureLayer[st].TextureWrap) switch (material.TextureLayer[st].TextureWrap)
{ {
case ETC_REPEAT: case ETC_REPEAT:
mode=D3DTADDRESS_WRAP; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_WRAP)
mode=D3DTADDRESS_WRAP;
break; break;
case ETC_CLAMP: case ETC_CLAMP:
case ETC_CLAMP_TO_EDGE: case ETC_CLAMP_TO_EDGE:
mode=D3DTADDRESS_CLAMP; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_CLAMP)
mode=D3DTADDRESS_CLAMP;
break; break;
case ETC_MIRROR: case ETC_MIRROR:
mode=D3DTADDRESS_MIRROR; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_MIRROR)
mode=D3DTADDRESS_MIRROR;
break; break;
case ETC_CLAMP_TO_BORDER: case ETC_CLAMP_TO_BORDER:
mode=D3DTADDRESS_BORDER; if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
mode=D3DTADDRESS_BORDER;
else
mode=D3DTADDRESS_CLAMP;
break;
case ETC_MIRROR_CLAMP:
case ETC_MIRROR_CLAMP_TO_EDGE:
case ETC_MIRROR_CLAMP_TO_BORDER:
if (Caps.TextureAddressCaps & D3DPTADDRESSCAPS_MIRRORONCE)
mode=D3DTADDRESS_MIRRORONCE;
else
mode=D3DTADDRESS_CLAMP;
break; break;
} }
......
...@@ -2165,6 +2165,40 @@ void COpenGLDriver::setWrapMode(const SMaterial& material) ...@@ -2165,6 +2165,40 @@ void COpenGLDriver::setWrapMode(const SMaterial& material)
#endif #endif
mode=GL_REPEAT; mode=GL_REPEAT;
break; break;
case ETC_MIRROR_CLAMP:
#ifdef GL_EXT_texture_mirror_clamp
if (FeatureAvailable[IRR_EXT_texture_mirror_clamp])
mode=GL_MIRROR_CLAMP_EXT;
else
#endif
#if defined(GL_ATI_texture_mirror_once)
if (FeatureAvailable[IRR_ATI_texture_mirror_once])
mode=GL_MIRROR_CLAMP_ATI;
else
#endif
mode=GL_CLAMP;
break;
case ETC_MIRROR_CLAMP_TO_EDGE:
#ifdef GL_EXT_texture_mirror_clamp
if (FeatureAvailable[IRR_EXT_texture_mirror_clamp])
mode=GL_MIRROR_CLAMP_TO_EDGE_EXT;
else
#endif
#if defined(GL_ATI_texture_mirror_once)
if (FeatureAvailable[IRR_ATI_texture_mirror_once])
mode=GL_MIRROR_CLAMP_TO_EDGE_ATI;
else
#endif
mode=GL_CLAMP;
break;
case ETC_MIRROR_CLAMP_TO_BORDER:
#ifdef GL_EXT_texture_mirror_clamp
if (FeatureAvailable[IRR_EXT_texture_mirror_clamp])
mode=GL_MIRROR_CLAMP_TO_BORDER_EXT;
else
#endif
mode=GL_CLAMP;
break;
} }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode);
......
...@@ -965,12 +965,30 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, ...@@ -965,12 +965,30 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex,
break; break;
case ETC_CLAMP: case ETC_CLAMP:
case ETC_CLAMP_TO_EDGE: case ETC_CLAMP_TO_EDGE:
case ETC_CLAMP_TO_BORDER:
dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f ); dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f );
dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f ); dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f );
break; break;
case ETC_MIRROR:
dest->Tex[t].x = M[0] * srcT.x + M[4] * srcT.y + M[8];
if (core::fract(dest->Tex[t].x)>0.5f)
dest->Tex[t].x=1.f-dest->Tex[t].x;
dest->Tex[t].y = M[1] * srcT.x + M[5] * srcT.y + M[9];
if (core::fract(dest->Tex[t].y)>0.5f)
dest->Tex[t].y=1.f-dest->Tex[t].y;
break;
case ETC_MIRROR_CLAMP:
case ETC_MIRROR_CLAMP_TO_EDGE:
case ETC_MIRROR_CLAMP_TO_BORDER:
dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f );
if (core::fract(dest->Tex[t].x)>0.5f)
dest->Tex[t].x=1.f-dest->Tex[t].x;
dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f );
if (core::fract(dest->Tex[t].y)>0.5f)
dest->Tex[t].y=1.f-dest->Tex[t].y;
break;
} }
} }
} }
#endif #endif
......
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