• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2013 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 #include "angle_gl.h"
13 #include <string>
14 #include <math.h>
15 
16 namespace gl
17 {
18 
19 int VariableComponentCount(GLenum type);
20 GLenum VariableComponentType(GLenum type);
21 size_t VariableComponentSize(GLenum type);
22 size_t VariableInternalSize(GLenum type);
23 size_t VariableExternalSize(GLenum type);
24 GLenum VariableBoolVectorType(GLenum type);
25 int VariableRowCount(GLenum type);
26 int VariableColumnCount(GLenum type);
27 bool IsSampler(GLenum type);
28 bool IsMatrixType(GLenum type);
29 GLenum TransposeMatrixType(GLenum type);
30 int VariableRegisterCount(GLenum type);
31 int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
32 int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
33 int VariableSortOrder(GLenum type);
34 
35 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
36 
37 bool IsCubemapTextureTarget(GLenum target);
38 
39 bool IsTriangleMode(GLenum drawMode);
40 
41 // [OpenGL ES 3.0.2] Section 2.3.1 page 14
42 // Data Conversion For State-Setting Commands
43 // Floating-point values are rounded to the nearest integer, instead of truncated, as done by static_cast.
iround(GLfloat value)44 template <typename outT> outT iround(GLfloat value) { return static_cast<outT>(value > 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); }
uiround(GLfloat value)45 template <typename outT> outT uiround(GLfloat value) { return static_cast<outT>(value + 0.5f); }
46 
47 }
48 
49 std::string getTempPath();
50 void writeFile(const char* path, const void* data, size_t size);
51 
52 #endif  // LIBGLESV2_UTILITIES_H
53