Resolve conflict between default cube map and 2D textures in texture map.

TRAC #11625 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Andrew Lewycky git-svn-id: https://angleproject.googlecode.com/svn/trunk@106 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 4a35ef2d
......@@ -499,16 +499,9 @@ void Context::bindElementArrayBuffer(unsigned int buffer)
void Context::bindTexture2D(GLuint texture)
{
if (!getTexture(texture) || texture == 0)
if (!getTexture(texture) && texture != 0)
{
if (texture != 0)
{
mTextureMap[texture] = new Texture2D();
}
else // Special case: 0 refers to different initial textures based on the target
{
mTextureMap[0] = mTexture2DZero;
}
mTextureMap[texture] = new Texture2D();
}
texture2D = texture;
......@@ -518,16 +511,9 @@ void Context::bindTexture2D(GLuint texture)
void Context::bindTextureCubeMap(GLuint texture)
{
if (!getTexture(texture) || texture == 0)
if (!getTexture(texture) && texture != 0)
{
if (texture != 0)
{
mTextureMap[texture] = new TextureCubeMap();
}
else // Special case: 0 refers to different initial textures based on the target
{
mTextureMap[0] = mTextureCubeMapZero;
}
mTextureMap[texture] = new TextureCubeMap();
}
textureCubeMap = texture;
......@@ -641,6 +627,8 @@ Program *Context::getProgram(unsigned int handle)
Texture *Context::getTexture(unsigned int handle)
{
if (handle == 0) return NULL;
TextureMap::iterator texture = mTextureMap.find(handle);
if (texture == mTextureMap.end())
......@@ -775,7 +763,19 @@ TextureCubeMap *Context::getTextureCubeMap()
Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type)
{
return getTexture(samplerTexture[type][sampler]);
GLuint texid = samplerTexture[type][sampler];
if (texid == 0)
{
switch (type)
{
default: UNREACHABLE();
case SAMPLER_2D: return mTexture2DZero;
case SAMPLER_CUBE: return mTextureCubeMapZero;
}
}
return getTexture(texid);
}
Framebuffer *Context::getFramebuffer()
......
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