Home | History | Annotate | Download | only in common
      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 <GLES3/gl3.h>
     13 #include <GLES3/gl3ext.h>
     14 #include <GLES2/gl2.h>
     15 #include <GLES2/gl2ext.h>
     16 
     17 #include <string>
     18 #include <math.h>
     19 
     20 namespace gl
     21 {
     22 
     23 int UniformComponentCount(GLenum type);
     24 GLenum UniformComponentType(GLenum type);
     25 size_t UniformComponentSize(GLenum type);
     26 size_t UniformInternalSize(GLenum type);
     27 size_t UniformExternalSize(GLenum type);
     28 GLenum UniformBoolVectorType(GLenum type);
     29 int VariableRowCount(GLenum type);
     30 int VariableColumnCount(GLenum type);
     31 bool IsSampler(GLenum type);
     32 bool IsMatrixType(GLenum type);
     33 GLenum TransposeMatrixType(GLenum type);
     34 int AttributeRegisterCount(GLenum type);
     35 int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
     36 int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
     37 
     38 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
     39 
     40 bool IsCubemapTextureTarget(GLenum target);
     41 bool IsInternalTextureTarget(GLenum target, GLuint clientVersion);
     42 
     43 bool IsTriangleMode(GLenum drawMode);
     44 
     45 // [OpenGL ES 3.0.2] Section 2.3.1 page 14
     46 // Data Conversion For State-Setting Commands
     47 // Floating-point values are rounded to the nearest integer, instead of truncated, as done by static_cast.
     48 template <typename outT> outT iround(GLfloat value) { return static_cast<outT>(value > 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); }
     49 template <typename outT> outT uiround(GLfloat value) { return static_cast<outT>(value + 0.5f); }
     50 
     51 }
     52 
     53 std::string getTempPath();
     54 void writeFile(const char* path, const void* data, size_t size);
     55 
     56 #endif  // LIBGLESV2_UTILITIES_H
     57