Moves non-D3D-specific utility functions to the gl namespace.

TRAC #12043 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@225 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 713914b5
......@@ -52,19 +52,19 @@ void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
void Framebuffer::detachTexture(GLuint texture)
{
if (mColorbufferHandle == texture && es2dx::IsTextureTarget(mColorbufferType))
if (mColorbufferHandle == texture && IsTextureTarget(mColorbufferType))
{
mColorbufferType = GL_NONE;
mColorbufferHandle = 0;
}
if (mDepthbufferHandle == texture && es2dx::IsTextureTarget(mDepthbufferType))
if (mDepthbufferHandle == texture && IsTextureTarget(mDepthbufferType))
{
mDepthbufferType = GL_NONE;
mDepthbufferHandle = 0;
}
if (mStencilbufferHandle == texture && es2dx::IsTextureTarget(mStencilbufferType))
if (mStencilbufferHandle == texture && IsTextureTarget(mStencilbufferType))
{
mStencilbufferType = GL_NONE;
mStencilbufferHandle = 0;
......
......@@ -1371,7 +1371,7 @@ void TextureCubeMap::generateMipmaps()
Colorbuffer *TextureCubeMap::getColorbuffer(GLenum target)
{
if (!es2dx::IsCubemapTextureTarget(target))
if (!IsCubemapTextureTarget(target))
{
return error(GL_INVALID_OPERATION, (Colorbuffer *)NULL);
}
......@@ -1388,7 +1388,7 @@ Colorbuffer *TextureCubeMap::getColorbuffer(GLenum target)
IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)
{
ASSERT(es2dx::IsCubemapTextureTarget(target));
ASSERT(IsCubemapTextureTarget(target));
needRenderTarget();
......@@ -1401,7 +1401,7 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)
Texture::TextureColorbufferProxy::TextureColorbufferProxy(Texture *texture, GLenum target)
: Colorbuffer(NULL), mTexture(texture), mTarget(target)
{
ASSERT(target == GL_TEXTURE_2D || es2dx::IsCubemapTextureTarget(target));
ASSERT(target == GL_TEXTURE_2D || IsCubemapTextureTarget(target));
latchTextureInfo();
}
......
......@@ -730,7 +730,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
try
{
if (!es2dx::IsTextureTarget(target))
if (!gl::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -763,7 +763,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
try
{
if (!es2dx::IsTextureTarget(target))
if (!gl::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -871,7 +871,7 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
texture->copyImage(level, internalformat, x, y, width, height, source);
}
else if (es2dx::IsCubemapTextureTarget(target))
else if (gl::IsCubemapTextureTarget(target))
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
......@@ -902,7 +902,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
try
{
if (!es2dx::IsTextureTarget(target))
if (!gl::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -939,7 +939,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
texture->copySubImage(level, xoffset, yoffset, x, y, width, height, source);
}
else if (es2dx::IsCubemapTextureTarget(target))
else if (gl::IsCubemapTextureTarget(target))
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
......@@ -2269,7 +2269,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
{
attachmentObjectType = attachmentType;
}
else if (es2dx::IsTextureTarget(attachmentType))
else if (gl::IsTextureTarget(attachmentType))
{
attachmentObjectType = GL_TEXTURE;
}
......@@ -2303,7 +2303,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
if (attachmentObjectType == GL_TEXTURE)
{
if (es2dx::IsCubemapTextureTarget(attachmentType))
if (gl::IsCubemapTextureTarget(attachmentType))
{
*params = attachmentType;
}
......@@ -4125,7 +4125,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
try
{
if (!es2dx::IsTextureTarget(target))
if (!gl::IsTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
......@@ -4140,7 +4140,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
return error(GL_INVALID_VALUE);
}
if (!es2dx::CheckTextureFormatType(format, type))
if (!gl::CheckTextureFormatType(format, type))
{
return error(GL_INVALID_ENUM);
}
......@@ -4165,7 +4165,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
texture->subImage(level, xoffset, yoffset, width, height, format, type, context->unpackAlignment, pixels);
}
else if (es2dx::IsCubemapTextureTarget(target))
else if (gl::IsCubemapTextureTarget(target))
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
......
......@@ -178,6 +178,47 @@ int ComputePixelSize(GLenum format, GLenum type)
return 0;
}
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)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
switch (format)
{
case GL_RGBA:
case GL_RGB:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
return true;
default:
return false;
}
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
return (format == GL_RGBA);
case GL_UNSIGNED_SHORT_5_6_5:
return (format == GL_RGB);
default:
return false;
}
}
}
namespace es2dx
......@@ -522,47 +563,6 @@ bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount,
return true;
}
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)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
switch (format)
{
case GL_RGBA:
case GL_RGB:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
return true;
default:
return false;
}
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
return (format == GL_RGBA);
case GL_UNSIGNED_SHORT_5_6_5:
return (format == GL_RGB);
default:
return false;
}
}
D3DFORMAT ConvertRenderbufferFormat(GLenum format)
{
switch (format)
......
......@@ -27,6 +27,9 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig
int ComputePixelSize(GLenum format, GLenum type);
GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment);
bool IsCubemapTextureTarget(GLenum target);
bool IsTextureTarget(GLenum target);
bool CheckTextureFormatType(GLenum format, GLenum type);
}
......@@ -51,9 +54,6 @@ unsigned int GetDepthSize(D3DFORMAT depthFormat);
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