dark-hammer / include / engine / gl / gfx-types-gl.h

/***********************************************************************************
 * Copyright (c) 2012, Sepehr Taghdisian
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation 
 *   and/or other materials provided with the distribution.
 *
 ***********************************************************************************/

#ifndef GFX_TYPES_GL_H_
#define GFX_TYPES_GL_H_

#include "core/types.h"

#if defined(_MSVC_)
#pragma warning(disable: 663)
#endif

/* api specific flag differences */
#define GFX_BMP2D_EXTRAFLAG GFX_BMP2D_FLIPY

/* compressed formats
 * http://www.opengl.org/registry/specs/EXT/texture_compression_rgtc.txt
 * http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt
 * http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt
 * */
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C

#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E

#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F

#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC

#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE

/**************************************************************************
 * ENUMS
 */

enum gfx_blend_mode
{
    GFX_BLEND_ZERO              = 0, /*GL_ZERO*/
    GFX_BLEND_ONE               = 1, /*GL_ONE*/
    GFX_BLEND_SRC_COLOR         = 0x0300, /*GL_SRC_COLOR*/
    GFX_BLEND_INV_SRC_COLOR     = 0x0301, /*GL_ONE_MINUS_SRC_COLOR*/
    GFX_BLEND_SRC_ALPHA         = 0x0302, /*GL_SRC_ALPHA*/
    GFX_BLEND_INV_SRC_ALPHA     = 0x0303, /*GL_ONE_MINUS_SRC_ALPHA*/
    GFX_BLEND_DEST_ALPHA        = 0x0304, /*GL_DST_ALPHA*/
    GFX_BLEND_INV_DEST_ALPHA    = 0x0305, /*GL_ONE_MINUS_DST_ALPHA*/
    GFX_BLEND_DEST_COLOR        = 0x0306, /*GL_DST_COLOR*/
    GFX_BLEND_INV_DEST_COLOR    = 0x0307, /*GL_ONE_MINUS_DST_COLOR*/
    GFX_BLEND_SRC_ALPHA_SAT     = 0x0308, /*GL_SRC_ALPHA_SATURATE*/
    GFX_BLEND_CONSTANT_COLOR    = 0x8001, /*GL_CONSTANT_COLOR*/
    GFX_BLEND_INV_CONSTANT_COLOR= 0x8001, /*GL_ONE_MINUS_CONSTANT_COLOR*/
    GFX_BLEND_SRC1_COLOR        = 0x88F9, /*GL_SRC1_COLOR*/
    GFX_BLEND_INV_SRC1_COLOR    = 0x88FA, /*GL_ONE_MINUS_SRC1_COLOR*/
    GFX_BLEND_SRC1_ALPHA        = 0x8589, /*GL_SOURCE1_ALPHA*/
    GFX_BLEND_INV_SRC1_ALPHA    = 0x88FB, /*GL_ONE_MINUS_SRC1_ALPHA*/
    GFX_BLEND_UNKNOWN           = 0xff
};

enum gfx_blend_op
{
    GFX_BLENDOP_ADD            = 0x8006, /*GL_FUNC_ADD*/
    GFX_BLENDOP_SUBTRACT       = 0x800A, /*GL_FUNC_SUBTRACT*/
    GFX_BLENDOP_REV_SUBTRACT   = 0x800B, /*GL_FUNC_REVERSE_SUBTRACT*/
    GFX_BLENDOP_MIN            = 0x8007, /*GL_MIN*/
    GFX_BLENDOP_MAX            = 0x8008, /*GL_MAX*/
    GFX_BLENDOP_UNKNOWN        = 0xff
};

enum gfx_clear_flag
{
    GFX_CLEAR_DEPTH = 0x00000100,  /*GL_CLEAR_DEPTH_BIT*/
    GFX_CLEAR_STENCIL = 0x00000400, /*GL_CLEAR_STENCIL_BIT*/
    GFX_CLEAR_COLOR = 0x00004000 /*GL_CLEAR_COLOR_BIT*/
};

enum gfx_cmp_func
{
	GFX_CMP_OFF = 0,
    GFX_CMP_NEVER = 0x0200, /*GL_NEVER*/
    GFX_CMP_LESS = 0x0201, /*GL_LESS*/
    GFX_CMP_EQUAL = 0x0202, /*GL_EQUAL*/
    GFX_CMP_LESSEQUAL = 0x0203, /*GL_LEQUAL*/
    GFX_CMP_GREATER = 0x0203, /*GL_GREATER*/
    GFX_CMP_NOTEQUAL = 0x0205, /*GL_NOTEQUAL*/
    GFX_CMP_GREATEREQUAL = 0x0206, /*GL_GEQUAL*/
    GFX_CMP_ALWAYS = 0x0207, /*GL_ALWAYS*/
    GFX_CMP_UNKNOWN = 0xff
};

enum gfx_cull_mode
{
    GFX_CULL_NONE = 0,
    GFX_CULL_FRONT = 0x0404, /*GL_FRONT​*/
    GFX_CULL_BACK = 0x0405, /*GL_BACK*/
    GFX_CULL_UNKNOWN = 0xff
};

enum gfx_fill_mode
{
    GFX_FILL_WIREFRAME = 0x1B01, /*GL_LINE*/
    GFX_FILL_SOLID = 0x1B02, /*GL_FILL*/
    GFX_FILL_UNKNOWN = 0xff
};

enum gfx_filter_mode
{
    GFX_FILTER_UNKNOWN = 0,
    GFX_FILTER_NEAREST = 0x2600, /*GL_NEAREST*/
    GFX_FILTER_LINEAR = 0x2601 /*GL_LINEAR*/
};

enum gfx_stencil_op
{
    GFX_STENCILOP_KEEP = 0x1E00, /*GL_KEEP*/
    GFX_STENCILOP_ZERO = 0, /*GL_ZERO*/
    GFX_STENCILOP_REPLACE = 0x1E01, /*GL_REPLACE*/
    GFX_STENCILOP_INCR_SAT = 0x1E02, /*GL_INCR*/
    GFX_STENCILOP_DECR_SAT = 0x1E03, /*GL_DECR*/
    GFX_STENCILOP_INVERT = 0x150A, /*GL_INVERT*/
    GFX_STENCILOP_INCR = 0x8507, /*GL_INCR_WRAP*/
    GFX_STENCILOP_DECR = 0x8508, /*GL_DECR_WRAP*/
    GFX_STENCILOP_UNKNOWN = 0xff
};

enum gfx_address_mode
{
    GFX_ADDRESS_UNKNOWN = 0,
    GFX_ADDRESS_WRAP = 0x2901, /*GL_REPEAT*/
    GFX_ADDRESS_MIRROR = 0x8370, /*GL_MIRRORED_REPEAT*/
    GFX_ADDRESS_CLAMP = 0x812F, /*GL_CLAMP_TO_EDGE*/
    GFX_ADDRESS_BORDER = 0x812D /*GL_CLAMP_TO_BORDER*/
};

enum gfx_map_mode
{
    GFX_MAP_READ = 0x0001, /*GL_MAP_READ_BIT*/
    GFX_MAP_WRITE = 0x0002, /*GL_MAP_WRITE_BIT*/
    GFX_MAP_READ_WRITE = 0x0003, /*(GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)*/
    GFX_MAP_WRITE_DISCARD = 0x000A, /*(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)*/
    GFX_MAP_WRITE_DISCARDRANGE = 0x0006, /*(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT)*/
};

enum gfx_mem_hint
{
    GFX_MEMHINT_STATIC = 0x88E4, /*GL_STATIC_DRAW*/
    GFX_MEMHINT_DYNAMIC = 0x88E8, /*GL_DYNAMIC_DRAW*/
    GFX_MEMHINT_READ = 0x88E9 /*GL_DYNAMIC_READ*/
};

enum gfx_input_element_fmt
{
	GFX_INPUTELEMENT_FMT_FLOAT = 0x1406, /* GL_FLOAT */
	GFX_INPUTELEMENT_FMT_UINT = 0x1405, /* GL_UNSIGNED_INT */
	GFX_INPUTELEMENT_FMT_INT = 0x1404 /* GL_INT */
};

enum gfx_buffer_type
{
    GFX_BUFFER_VERTEX = 0x8892, /*GL_ARRAY_BUFFER*/
    GFX_BUFFER_INDEX = 0x8893, /*GL_ELEMENT_ARRAY_BUFFER*/
    GFX_BUFFER_SHADERSTORAGE = 0x90D2, /*GL_SHADER_STORAGE_BUFFER*/
    GFX_BUFFER_SHADERTEXTURE = 0x8C2A, /*GL_TEXTURE_BUFFER*/
    GFX_BUFFER_STREAMOUT = 0x8C8E, /*GL_TRANSFORM_FEEDBACK_BUFFER*/
    GFX_BUFFER_CONSTANT = 0x8A11 /*GL_UNIFORM_BUFFER*/
};

enum gfx_constant_type
{
	GFX_CONSTANT_UNKNOWN = 0,
	GFX_CONSTANT_FLOAT = 0x1406, /*GL_FLOAT*/
	GFX_CONSTANT_FLOAT2 = 0x8B50, /*GL_FLOAT_VEC2*/
	GFX_CONSTANT_FLOAT3 = 0x8B51, /*GL_FLOAT_VEC3*/
	GFX_CONSTANT_FLOAT4 = 0x8B52, /*GL_FLOAT_VEC4*/
	GFX_CONSTANT_INT = 0x1404, /*GL_INT*/
	GFX_CONSTANT_INT2 = 0x8B53, /*GL_INT_VEC2*/
	GFX_CONSTANT_INT3 = 0x8B54, /*GL_INT_VEC3*/
	GFX_CONSTANT_INT4 = 0x8B55, /*GL_INT_VEC4*/
	GFX_CONSTANT_UINT = 0x1405, /*GL_UNSIGNED_INT*/
	GFX_CONSTANT_MAT4x3 = 0x8B68, /*GL_FLOAT_MAT3x4*/
	GFX_CONSTANT_MAT4x4 = 0x8B5C, /*GL_FLOAT_MAT*/
    GFX_CONSTANT_STRUCT /* not existed in GL (have to assign manually) */
};

enum gfx_format
{
	GFX_FORMAT_UNKNOWN = 0,
	GFX_FORMAT_BC1 = GL_COMPRESSED_RGB_S3TC_DXT1_EXT,	/* DXTC1 (RGB) */
    GFX_FORMAT_BC1_SRGB = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
    GFX_FORMAT_BC2 = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, /* DXTC3 (RGBA) */
    GFX_FORMAT_BC2_SRGB = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
    GFX_FORMAT_BC3 = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, /* DXTC5 (RGBA) */
    GFX_FORMAT_BC3_SRGB = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
    GFX_FORMAT_BC4 = GL_COMPRESSED_RED_RGTC1_EXT, /* TC-RED */
    GFX_FORMAT_BC4_SNORM = GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
    GFX_FORMAT_BC5 = GL_COMPRESSED_RED_GREEN_RGTC2_EXT, /* TC-RG */
    GFX_FORMAT_BC5_SNORM = GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
    GFX_FORMAT_RGBA_UNORM = 0x1908, /*GL_RGBA*/ /* 32bit */
    GFX_FORMAT_RGBA_UNORM_SRGB = 0x8C43, /*GL_SRGB8_ALPHA8*/ /* 32bit */
    GFX_FORMAT_RGB_UNORM = 0x8C41, /*GL_SRGB8*/ /* 24bit */
    GFX_FORMAT_R32G32B32A32_FLOAT = 0x8814, /*GL_RGBA32F,*/
    GFX_FORMAT_R32G32B32A32_UINT = 0x8D7C, /*GL_RGBA8UI,*/
    GFX_FORMAT_R32G32B32A32_SINT = 0x8D8E, /*GL_RGBA8I,*/
    GFX_FORMAT_R32G32B32_FLOAT = 0x8815, /*GL_RGB32F,*/
    GFX_FORMAT_R32G32B32_UINT = 0x8D71, /*GL_RGB32UI,*/
    GFX_FORMAT_R32G32B32_SINT = 0x8D83, /*GL_RGB32I,*/
    GFX_FORMAT_R16G16B16A16_FLOAT = 0x881A, /*GL_RGBA16F,*/
    GFX_FORMAT_R16G16B16A16_UNORM = 0x805B, /*GL_RGBA16,*/
    GFX_FORMAT_R16G16B16A16_UINT = 0x8D76, /*GL_RGBA16UI,*/
    GFX_FORMAT_R16G16B16A16_SINT = 0x8D88, /*GL_RGBA16I,*/
    GFX_FORMAT_R16G16B16A16_SNORM = 0x8F9B, /*GL_RGBA16_SNORM,*/
    GFX_FORMAT_R32G32_FLOAT = 0x8230, /*GL_RG32F,*/
    GFX_FORMAT_R32G32_UINT = 0x823C, /*GL_RG32UI,*/
    GFX_FORMAT_R32G32_SINT = 0x823B, /*GL_RG32I,*/
    GFX_FORMAT_R10G10B10A2_UNORM = 0x8059, /*GL_RGB10_A2,*/
    GFX_FORMAT_R10G10B10A2_UINT = 0x906F, /*GL_RGB10_A2UI,*/
    GFX_FORMAT_R11G11B10_FLOAT =  0x8C3A, /*GL_R11F_G11F_B10F,*/
    GFX_FORMAT_R16G16_FLOAT = 0x822F, /*GL_RG16F,*/
    GFX_FORMAT_R16G16_UNORM = 0x822C, /*GL_RG16,*/
    GFX_FORMAT_R16G16_UINT = 0x823A, /*GL_RG16UI,*/
    GFX_FORMAT_R16G16_SNORM = 0x8F99, /*GL_RG16_SNORM,*/
    GFX_FORMAT_R16G16_SINT = 0x8239, /*GL_RG16I,*/
    GFX_FORMAT_R32_FLOAT = 0x822E, /*GL_R32F,*/
    GFX_FORMAT_R32_UINT = 0x8236, /*GL_R32UI,*/
    GFX_FORMAT_R32_SINT = 0x8235, /*GL_R32I,*/
    GFX_FORMAT_R8G8_UNORM = 0x822B, /*GL_RG8,*/
    GFX_FORMAT_R8G8_UINT = 0x8238, /*GL_RG8UI,*/
    GFX_FORMAT_R8G8_SNORM = 0x8F95, /*GL_RG8_SNORM,*/
    GFX_FORMAT_R8G8_SINT = 0x8237, /*GL_RG8I,*/
    GFX_FORMAT_R16_FLOAT = 0x822D, /*GL_R16F,*/
    GFX_FORMAT_R16_UNORM = 0x822A, /*GL_R16,*/
    GFX_FORMAT_R16_UINT = 0x8234, /*GL_R16UI,*/
    GFX_FORMAT_R16_SNORM = 0x8F98, /*GL_R16_SNORM,*/
    GFX_FORMAT_R16_SINT = 0x8233, /*GL_R16I,*/
    GFX_FORMAT_R8_UNORM = 0x8229, /*GL_R8,*/
    GFX_FORMAT_R8_UINT = 0x8232, /*GL_R8UI,*/
    GFX_FORMAT_R8_SNORM = 0x8F94, /*GL_R8_SNORM,*/
    GFX_FORMAT_R8_SINT = 0x8231, /*GL_R8I*/
    GFX_FORMAT_DEPTH24_STENCIL8 = 0x88F0, /*GL_DEPTH24_STENCIL8*/
	GFX_FORMAT_DEPTH32 = 0x81A7, /*GL_DEPTH_COMPONENT32*/
	GFX_FORMAT_DEPTH16 = 0x81A5 /*GL_DEPTH_COMPONENT16​​*/
};

enum gfx_texture_type
{
	GFX_TEXTURE_1D = 0x0DE0, /*GL_TEXTURE_1D*/
	GFX_TEXTURE_2D = 0x0DE1, /*GL_TEXTURE_2D*/
	GFX_TEXTURE_3D = 0x806F, /*GL_TEXTURE_3D*/
	GFX_TEXTURE_CUBE = 0x8513, /*GL_TEXTURE_CUBE_MAP*/
	GFX_TEXTURE_1D_ARRAY = 0x8C18, /*GL_TEXTURE_1D_ARRAY*/
	GFX_TEXTURE_2D_ARRAY = 0x8C1A, /*GL_TEXTURE_2D_ARRAY*/
	GFX_TEXTURE_CUBE_ARRAY = 0x9009 /*GL_TEXTURE_CUBE_MAP_ARRAY*/
};

enum gfx_primitive_type
{
    GFX_PRIMITIVE_POINTLIST = 0x0000, /*GL_POINTS*/
    GFX_PRIMITIVE_LINELIST = 0x0001, /*GL_LINES*/
    GFX_PRIMITIVE_LINESTRIP = 0x0003, /*GL_LINE_STRIP*/
    GFX_PRIMITIVE_TRIANGLELIST = 0x0004, /*GL_TRIANGLES*/
    GFX_PRIMITIVE_TRIANGLESTRIP = 0x0005, /*GL_TRIANGLE_STRIP*/
    GFX_PRIMITIVE_LINELIST_ADJ = 0x000A, /*GL_LINES_ADJACENCY*/
    GFX_PRIMITIVE_LINESTRIP_ADJ = 0x000B, /*GL_LINE_STRIP_ADJACENCY*/
    GFX_PRIMITIVE_TRIANGLELIST_ADJ = 0x000C, /*GL_TRIANGLES_ADJACENCY*/
    GFX_PRIMITIVE_TRIANGLESTRIP_ADJ = 0x000D /*GL_TRIANGLE_STRIP_ADJACENCY*/
};

enum gfx_index_type
{
    GFX_INDEX_UNKNOWN = 0,
	GFX_INDEX_UINT32 = 0x1405, /*GL_UNSIGNED_INT*/
	GFX_INDEX_UINT16 = 0x1403, /*GL_UNSIGNED_SHORT*/
};

#endif /* GFX_TYPES_GL_H_ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.