Allow other attachment points for glFramebufferTexture2D

TRAC #12040 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@194 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0bbb031d
...@@ -52,12 +52,23 @@ void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer) ...@@ -52,12 +52,23 @@ void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
void Framebuffer::detachTexture(GLuint texture) void Framebuffer::detachTexture(GLuint texture)
{ {
if (mColorbufferHandle == texture if (mColorbufferHandle == texture && es2dx::IsTextureTarget(mColorbufferType))
&& (mColorbufferType == GL_TEXTURE_2D || es2dx::IsCubemapTextureTarget(mColorbufferType)))
{ {
mColorbufferType = GL_NONE; mColorbufferType = GL_NONE;
mColorbufferHandle = 0; mColorbufferHandle = 0;
} }
if (mDepthbufferHandle == texture && es2dx::IsTextureTarget(mDepthbufferType))
{
mDepthbufferType = GL_NONE;
mDepthbufferHandle = 0;
}
if (mStencilbufferHandle == texture && es2dx::IsTextureTarget(mStencilbufferType))
{
mStencilbufferType = GL_NONE;
mStencilbufferHandle = 0;
}
} }
void Framebuffer::detachRenderbuffer(GLuint renderbuffer) void Framebuffer::detachRenderbuffer(GLuint renderbuffer)
......
...@@ -730,7 +730,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna ...@@ -730,7 +730,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
try try
{ {
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target)) if (!es2dx::IsTextureTarget(target))
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -763,7 +763,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -763,7 +763,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
try try
{ {
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target)) if (!es2dx::IsTextureTarget(target))
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -902,7 +902,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL ...@@ -902,7 +902,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
try try
{ {
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target)) if (!es2dx::IsTextureTarget(target))
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -1627,6 +1627,8 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t ...@@ -1627,6 +1627,8 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
switch (attachment) switch (attachment)
{ {
case GL_COLOR_ATTACHMENT0: case GL_COLOR_ATTACHMENT0:
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -1687,7 +1689,12 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t ...@@ -1687,7 +1689,12 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
framebuffer->setColorbuffer(textarget, texture); switch (attachment)
{
case GL_COLOR_ATTACHMENT0: framebuffer->setColorbuffer(textarget, texture); break;
case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
}
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -2267,7 +2274,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac ...@@ -2267,7 +2274,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
{ {
attachmentObjectType = attachmentType; attachmentObjectType = attachmentType;
} }
else if (attachmentType == GL_TEXTURE_2D || es2dx::IsCubemapTextureTarget(attachmentType)) else if (es2dx::IsTextureTarget(attachmentType))
{ {
attachmentObjectType = GL_TEXTURE; attachmentObjectType = GL_TEXTURE;
} }
...@@ -4125,7 +4132,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -4125,7 +4132,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
try try
{ {
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target)) if (!es2dx::IsTextureTarget(target))
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
......
...@@ -438,6 +438,11 @@ bool IsCubemapTextureTarget(GLenum target) ...@@ -438,6 +438,11 @@ bool IsCubemapTextureTarget(GLenum target)
return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
} }
bool IsTextureTarget(GLenum target)
{
return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
}
// Verify that format/type are one of the combinations from table 3.4. // Verify that format/type are one of the combinations from table 3.4.
bool CheckTextureFormatType(GLenum format, GLenum type) bool CheckTextureFormatType(GLenum format, GLenum type)
{ {
......
...@@ -46,6 +46,7 @@ unsigned int GetStencilSize(D3DFORMAT stencilFormat); ...@@ -46,6 +46,7 @@ unsigned int GetStencilSize(D3DFORMAT stencilFormat);
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount, bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount,
D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount); D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount);
bool IsCubemapTextureTarget(GLenum target); bool IsCubemapTextureTarget(GLenum target);
bool IsTextureTarget(GLenum target);
bool CheckTextureFormatType(GLenum format, GLenum type); bool CheckTextureFormatType(GLenum format, GLenum type);
D3DFORMAT ConvertRenderbufferFormat(GLenum format); D3DFORMAT ConvertRenderbufferFormat(GLenum format);
......
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