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