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)
void Framebuffer::detachTexture(GLuint texture)
{
if (mColorbufferHandle == texture
&& (mColorbufferType == GL_TEXTURE_2D || es2dx::IsCubemapTextureTarget(mColorbufferType)))
if (mColorbufferHandle == texture && es2dx::IsTextureTarget(mColorbufferType))
{
mColorbufferType = GL_NONE;
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)
......
......@@ -730,7 +730,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
try
{
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target))
if (!es2dx::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -763,7 +763,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
try
{
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target))
if (!es2dx::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -902,7 +902,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
try
{
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target))
if (!es2dx::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -1627,6 +1627,8 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
switch (attachment)
{
case GL_COLOR_ATTACHMENT0:
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
break;
default:
return error(GL_INVALID_ENUM);
......@@ -1687,7 +1689,12 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
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&)
......@@ -2263,11 +2270,11 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
}
GLenum attachmentObjectType; // Type category
if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
{
attachmentObjectType = attachmentType;
}
else if (attachmentType == GL_TEXTURE_2D || es2dx::IsCubemapTextureTarget(attachmentType))
else if (es2dx::IsTextureTarget(attachmentType))
{
attachmentObjectType = GL_TEXTURE;
}
......@@ -4125,7 +4132,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
try
{
if (target != GL_TEXTURE_2D && !es2dx::IsCubemapTextureTarget(target))
if (!es2dx::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......
......@@ -438,6 +438,11 @@ bool IsCubemapTextureTarget(GLenum target)
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.
bool CheckTextureFormatType(GLenum format, GLenum type)
{
......
......@@ -46,6 +46,7 @@ unsigned int GetStencilSize(D3DFORMAT stencilFormat);
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount,
D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount);
bool IsCubemapTextureTarget(GLenum target);
bool IsTextureTarget(GLenum target);
bool CheckTextureFormatType(GLenum format, GLenum type);
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