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) ...@@ -499,16 +499,9 @@ void Context::bindElementArrayBuffer(unsigned int buffer)
void Context::bindTexture2D(GLuint texture) void Context::bindTexture2D(GLuint texture)
{ {
if (!getTexture(texture) || texture == 0) if (!getTexture(texture) && texture != 0)
{ {
if (texture != 0) mTextureMap[texture] = new Texture2D();
{
mTextureMap[texture] = new Texture2D();
}
else // Special case: 0 refers to different initial textures based on the target
{
mTextureMap[0] = mTexture2DZero;
}
} }
texture2D = texture; texture2D = texture;
...@@ -518,16 +511,9 @@ void Context::bindTexture2D(GLuint texture) ...@@ -518,16 +511,9 @@ void Context::bindTexture2D(GLuint texture)
void Context::bindTextureCubeMap(GLuint texture) void Context::bindTextureCubeMap(GLuint texture)
{ {
if (!getTexture(texture) || texture == 0) if (!getTexture(texture) && texture != 0)
{ {
if (texture != 0) mTextureMap[texture] = new TextureCubeMap();
{
mTextureMap[texture] = new TextureCubeMap();
}
else // Special case: 0 refers to different initial textures based on the target
{
mTextureMap[0] = mTextureCubeMapZero;
}
} }
textureCubeMap = texture; textureCubeMap = texture;
...@@ -641,6 +627,8 @@ Program *Context::getProgram(unsigned int handle) ...@@ -641,6 +627,8 @@ Program *Context::getProgram(unsigned int handle)
Texture *Context::getTexture(unsigned int handle) Texture *Context::getTexture(unsigned int handle)
{ {
if (handle == 0) return NULL;
TextureMap::iterator texture = mTextureMap.find(handle); TextureMap::iterator texture = mTextureMap.find(handle);
if (texture == mTextureMap.end()) if (texture == mTextureMap.end())
...@@ -775,7 +763,19 @@ TextureCubeMap *Context::getTextureCubeMap() ...@@ -775,7 +763,19 @@ TextureCubeMap *Context::getTextureCubeMap()
Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type) 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() 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