Fix active texture handling.

TRAC #14429 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@488 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ce864420
...@@ -207,8 +207,6 @@ Context::~Context() ...@@ -207,8 +207,6 @@ Context::~Context()
mState.arrayBuffer.set(NULL); mState.arrayBuffer.set(NULL);
mState.elementArrayBuffer.set(NULL); mState.elementArrayBuffer.set(NULL);
mState.texture2D.set(NULL);
mState.textureCubeMap.set(NULL);
mState.renderbuffer.set(NULL); mState.renderbuffer.set(NULL);
mTexture2DZero.set(NULL); mTexture2DZero.set(NULL);
...@@ -968,18 +966,14 @@ void Context::bindTexture2D(GLuint texture) ...@@ -968,18 +966,14 @@ void Context::bindTexture2D(GLuint texture)
{ {
mResourceManager->checkTextureAllocation(texture, SAMPLER_2D); mResourceManager->checkTextureAllocation(texture, SAMPLER_2D);
mState.texture2D.set(getTexture(texture)); mState.samplerTexture[SAMPLER_2D][mState.activeSampler].set(getTexture(texture));
mState.samplerTexture[SAMPLER_2D][mState.activeSampler].set(mState.texture2D.get());
} }
void Context::bindTextureCubeMap(GLuint texture) void Context::bindTextureCubeMap(GLuint texture)
{ {
mResourceManager->checkTextureAllocation(texture, SAMPLER_CUBE); mResourceManager->checkTextureAllocation(texture, SAMPLER_CUBE);
mState.textureCubeMap.set(getTexture(texture)); mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].set(getTexture(texture));
mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].set(mState.textureCubeMap.get());
} }
void Context::bindReadFramebuffer(GLuint framebuffer) void Context::bindReadFramebuffer(GLuint framebuffer)
...@@ -1088,29 +1082,19 @@ Program *Context::getCurrentProgram() ...@@ -1088,29 +1082,19 @@ Program *Context::getCurrentProgram()
Texture2D *Context::getTexture2D() Texture2D *Context::getTexture2D()
{ {
if (mState.texture2D.id() == 0) // Special case: 0 refers to different initial textures based on the target return static_cast<Texture2D*>(getSamplerTexture(mState.activeSampler, SAMPLER_2D));
{
return mTexture2DZero.get();
}
return static_cast<Texture2D*>(mState.texture2D.get());
} }
TextureCubeMap *Context::getTextureCubeMap() TextureCubeMap *Context::getTextureCubeMap()
{ {
if (mState.textureCubeMap.id() == 0) // Special case: 0 refers to different initial textures based on the target return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, SAMPLER_CUBE));
{
return mTextureCubeMapZero.get();
}
return static_cast<TextureCubeMap*>(mState.textureCubeMap.get());
} }
Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type) Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type)
{ {
GLuint texid = mState.samplerTexture[type][sampler].id(); GLuint texid = mState.samplerTexture[type][sampler].id();
if (texid == 0) if (texid == 0) // Special case: 0 refers to different initial textures based on the target
{ {
switch (type) switch (type)
{ {
......
...@@ -181,8 +181,6 @@ struct State ...@@ -181,8 +181,6 @@ struct State
int activeSampler; // Active texture unit selector - GL_TEXTURE0 int activeSampler; // Active texture unit selector - GL_TEXTURE0
BindingPointer<Buffer> arrayBuffer; BindingPointer<Buffer> arrayBuffer;
BindingPointer<Buffer> elementArrayBuffer; BindingPointer<Buffer> elementArrayBuffer;
BindingPointer<Texture> texture2D;
BindingPointer<Texture> textureCubeMap;
GLuint readFramebuffer; GLuint readFramebuffer;
GLuint drawFramebuffer; GLuint drawFramebuffer;
BindingPointer<Renderbuffer> renderbuffer; BindingPointer<Renderbuffer> renderbuffer;
......
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