1 // 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. 5 // 6 7 // utilities.h: Conversion functions and other utility routines. 8 9 #ifndef LIBGLESV2_UTILITIES_H 10 #define LIBGLESV2_UTILITIES_H 11 12 #define GL_APICALL 13 #include <GLES2/gl2.h> 14 #include <GLES2/gl2ext.h> 15 #include <d3d9.h> 16 17 namespace gl 18 { 19 20 struct Color; 21 22 int UniformComponentCount(GLenum type); 23 GLenum UniformComponentType(GLenum type); 24 size_t UniformTypeSize(GLenum type); 25 int VariableRowCount(GLenum type); 26 int VariableColumnCount(GLenum type); 27 28 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); 29 30 int ComputePixelSize(GLenum format, GLenum type); 31 GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment); 32 GLsizei ComputeCompressedPitch(GLsizei width, GLenum format); 33 GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format); 34 bool IsCompressed(GLenum format); 35 bool IsCubemapTextureTarget(GLenum target); 36 bool IsTextureTarget(GLenum target); 37 bool CheckTextureFormatType(GLenum format, GLenum type); 38 39 bool IsColorRenderable(GLenum internalformat); 40 bool IsDepthRenderable(GLenum internalformat); 41 bool IsStencilRenderable(GLenum internalformat); 42 43 } 44 45 namespace es2dx 46 { 47 48 D3DCMPFUNC ConvertComparison(GLenum comparison); 49 D3DCOLOR ConvertColor(gl::Color color); 50 D3DBLEND ConvertBlendFunc(GLenum blend); 51 D3DBLENDOP ConvertBlendOp(GLenum blendOp); 52 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp); 53 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap); 54 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace); 55 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha); 56 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter); 57 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter); 58 unsigned int GetAlphaSize(D3DFORMAT colorFormat); 59 unsigned int GetRedSize(D3DFORMAT colorFormat); 60 unsigned int GetGreenSize(D3DFORMAT colorFormat); 61 unsigned int GetBlueSize(D3DFORMAT colorFormat); 62 unsigned int GetDepthSize(D3DFORMAT depthFormat); 63 unsigned int GetStencilSize(D3DFORMAT stencilFormat); 64 bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, 65 D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount); 66 D3DFORMAT ConvertRenderbufferFormat(GLenum format); 67 D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples); 68 GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type); 69 70 } 71 72 namespace dx2es 73 { 74 75 GLenum ConvertBackBufferFormat(D3DFORMAT format); 76 GLenum ConvertDepthStencilFormat(D3DFORMAT format); 77 78 } 79 80 #endif // LIBGLESV2_UTILITIES_H 81