Cocos2d-x  4.0.0
Static Public Member Functions | List of all members
UtilsGL Class Reference

Convert backend enum class to corresponding opengl defined value. More...

Static Public Member Functions

static GLenum toGLAttributeType (VertexFormat vertexFormat)
 Convert attribute enum classs type to GLenum type.
 
static GLsizei getGLAttributeSize (VertexFormat vertexFormat)
 Convert attribute component count to GLsizei.
 
static GLsizei getGLDataTypeSize (GLenum size)
 Get opengl data type size in bytes.
 
static GLint toGLMagFilter (SamplerFilter magFilter)
 Convert magnification filter to GLint.
 
static GLint toGLMinFilter (SamplerFilter minFilter, bool hasMipmaps, bool isPow2)
 Convert minifying filter to GLint.
 
static GLint toGLAddressMode (SamplerAddressMode addressMode, bool isPow2)
 Convert wrap parameter for texture coordinate to GLint.
 
static void toGLTypes (PixelFormat textureFormat, GLint &internalFormat, GLuint &format, GLenum &type, bool &isCompressed)
 Get textrue parameters from texture pixle format.
 
static GLenum toGLComareFunction (CompareFunction compareFunction)
 Convert compare function to GLenum.
 
static GLenum toGLStencilOperation (StencilOperation stencilOperation)
 Convert stencil operation to GLenum.
 
static GLenum toGLBlendOperation (BlendOperation blendOperation)
 Convert blend operation to GLenum.
 
static GLenum toGLBlendFactor (BlendFactor blendFactor)
 Convert blend factor to GLenum.
 
static GLenum toGLFrontFace (Winding winding)
 Convert winding value to GLenum.
 
static GLenum toGLPrimitiveType (PrimitiveType primitiveType)
 Convert primitive type to GLenum.
 
static GLenum toGLIndexType (IndexFormat indexType)
 Convert index type to GLenum.
 
static GLenum toGLCullMode (CullMode mode)
 Convert cull mode to GLenum.
 

Detailed Description

Convert backend enum class to corresponding opengl defined value.

Member Function Documentation

static GLenum toGLAttributeType ( VertexFormat  vertexFormat)
static

Convert attribute enum classs type to GLenum type.

i.e. convert VertexFormat::FLOAT4 to GL_FLOAT.

Parameters
vertexFormatSpecifies the attribute data type to convert.
Returns
Attribute type.
static GLsizei getGLAttributeSize ( VertexFormat  vertexFormat)
static

Convert attribute component count to GLsizei.

i.e. convert VertexFormat::FLOAT4 to 4.

Parameters
vertexFormatSpecifies the attribute type.
Returns
Attribute component counts.
static GLsizei getGLDataTypeSize ( GLenum  size)
static

Get opengl data type size in bytes.

i.e. GL_FLOAT_VEC4 data type size is sizeof(GLfloat) * 4.

Parameters
sizeSpecifies the data type.
Returns
Data type size in bytes.
static GLint toGLMagFilter ( SamplerFilter  magFilter)
static

Convert magnification filter to GLint.

i.e. convert SamplerFilter::LINEAR to GL_LINEAR.

Parameters
magFilterSpecifies the magnification filter to convert.
Returns
Magnification filter.
static GLint toGLMinFilter ( SamplerFilter  minFilter,
bool  hasMipmaps,
bool  isPow2 
)
static

Convert minifying filter to GLint.

i.e. convert SamplerFilter::LINEAR to GL_LINEAR. If mipmaps is enabled and texture width and height are not power of two, then if minFilter is SamplerFilter::LINEAR, GL_LINEAR is returned, otherwise return GL_NEAREST.

Parameters
minFilterSpecifies minifying filter.
hasMipmapsSpecifies whether mipmap is enabled.
isPow2Specifies if texture width and height are power of two.
Returns
Minifying filter
static GLint toGLAddressMode ( SamplerAddressMode  addressMode,
bool  isPow2 
)
static

Convert wrap parameter for texture coordinate to GLint.

i.e. convert SamplerAddressMode::REPEAT to GL_REPEAT. If texture width and height are not power of 2, then GL_CLAMP_TO_EDGE is returned.

Parameters
addressModeSpecifies wrapping mode.
isPow2Specifies if texture width and height are power of two.
Returns
Wrap mode.
static void toGLTypes ( PixelFormat  textureFormat,
GLint &  internalFormat,
GLuint &  format,
GLenum &  type,
bool &  isCompressed 
)
static

Get textrue parameters from texture pixle format.

Parameters
intextureFormat Specifies texture pixel format.
outinternalFormat Specifies the internal format of the texture.
outformat Specifies the format of the texel data.
outtype Specifies the data type of the texel data.
outisCompressed Specifies if the texel data is compressed.
static GLenum toGLComareFunction ( CompareFunction  compareFunction)
static

Convert compare function to GLenum.

i.e. convert CompareFunction::NEVER to GL_NEVER.

Parameters
compareFunctionSpecifies the compare function to convert.
Returns
Compare function.
static GLenum toGLStencilOperation ( StencilOperation  stencilOperation)
static

Convert stencil operation to GLenum.

i.e. convert StencilOperation::KEEP to GL_KEEP.

Parameters
stencilOperationSpecifies stencil operation.
Returns
Stencil operation.
static GLenum toGLBlendOperation ( BlendOperation  blendOperation)
static

Convert blend operation to GLenum.

i.e. convert BlendOperation::ADD to GL_FUNC_ADD.

Parameters
blendOperationSpecifies blend function to convert.
Returns
Blend operation.
static GLenum toGLBlendFactor ( BlendFactor  blendFactor)
static

Convert blend factor to GLenum.

i.e. convert BlendFactor::ZERO to GL_ZERO.

Parameters
blendFactorSpecifies the blend factor to convert.
Returns
Blend factor.
static GLenum toGLFrontFace ( Winding  winding)
static

Convert winding value to GLenum.

i.e. convert Winding::CLOCK_WISE to GL_CW.

Parameters
windingSpecifies the winding value to convert.
Returns
Winding mode.
static GLenum toGLPrimitiveType ( PrimitiveType  primitiveType)
static

Convert primitive type to GLenum.

i.e. convert PrimitiveType::TRIANGLE to GL_TRIANGLES.

Parameters
primitiveTypeSpecifies the kind of primitives to convert.
Returns
Primitive type.
static GLenum toGLIndexType ( IndexFormat  indexType)
static

Convert index type to GLenum.

i.e. convert IndexFormat::U_INT to GL_UNSIGNED_INT.

Parameters
indexTypeSpecifies the index type to convert.
Returns
Index type.
static GLenum toGLCullMode ( CullMode  mode)
static

Convert cull mode to GLenum.

i.e. convert CullMode::BACK to GL_BACK.

Parameters
modeSpecifies the cull mode to convert.
Returns
Cull mode.

The documentation for this class was generated from the following file: