2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // utilities.h: Conversion functions and other utility routines.
9 #ifndef LIBGLESV2_UTILITIES_H
10 #define LIBGLESV2_UTILITIES_H
13 #include <GLES2/gl2.h>
14 #include <GLES2/gl2ext.h>
24 int UniformComponentCount(GLenum type);
25 GLenum UniformComponentType(GLenum type);
26 size_t UniformTypeSize(GLenum type);
27 int VariableRowCount(GLenum type);
28 int VariableColumnCount(GLenum type);
30 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
32 int ComputePixelSize(GLenum format, GLenum type);
33 GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment);
34 GLsizei ComputeCompressedPitch(GLsizei width, GLenum format);
35 GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);
36 bool IsCompressed(GLenum format);
37 bool IsCubemapTextureTarget(GLenum target);
38 bool IsTextureTarget(GLenum target);
39 bool CheckTextureFormatType(GLenum format, GLenum type);
41 bool IsColorRenderable(GLenum internalformat);
42 bool IsDepthRenderable(GLenum internalformat);
43 bool IsStencilRenderable(GLenum internalformat);
50 D3DCMPFUNC ConvertComparison(GLenum comparison);
51 D3DCOLOR ConvertColor(gl::Color color);
52 D3DBLEND ConvertBlendFunc(GLenum blend);
53 D3DBLENDOP ConvertBlendOp(GLenum blendOp);
54 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
55 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
56 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace);
57 D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
58 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
59 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter);
60 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter);
61 bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,
62 D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount);
63 D3DFORMAT ConvertRenderbufferFormat(GLenum format);
64 D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples);
70 GLuint GetAlphaSize(D3DFORMAT colorFormat);
71 GLuint GetRedSize(D3DFORMAT colorFormat);
72 GLuint GetGreenSize(D3DFORMAT colorFormat);
73 GLuint GetBlueSize(D3DFORMAT colorFormat);
74 GLuint GetDepthSize(D3DFORMAT depthFormat);
75 GLuint GetStencilSize(D3DFORMAT stencilFormat);
77 GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
79 GLenum ConvertBackBufferFormat(D3DFORMAT format);
80 GLenum ConvertDepthStencilFormat(D3DFORMAT format);
84 std::string getTempPath();
85 void writeFile(const char* path, const void* data, size_t size);
87 #endif // LIBGLESV2_UTILITIES_H