28 #ifndef BERSERK_GLDEFS_HPP 
   29 #define BERSERK_GLDEFS_HPP 
   38     #define BRK_GL_CATCH_ERR() \ 
   39         do { GLDefs::CatchErrors(); } while (false); 
   41     #define BRK_GL_CATCH_ERR() 
   65         while ((error = glGetError()) != GL_NO_ERROR) {
 
   83                 return BRK_TEXT(
"Invalid enum passed");
 
   84             case GL_INVALID_VALUE:
 
   85                 return BRK_TEXT(
"Invalid value passed");
 
   86             case GL_INVALID_OPERATION:
 
   87                 return BRK_TEXT(
"Set of state for a command is not legal for the parameters given to command");
 
   88             case GL_OUT_OF_MEMORY:
 
   90             case GL_INVALID_FRAMEBUFFER_OPERATION:
 
   91                 return BRK_TEXT(
"Invalid framebuffer operation");
 
   93                 return BRK_TEXT(
"Something else, refer to documentation");
 
   98         switch (bufferUsage) {
 
  100                 return GL_DYNAMIC_DRAW;
 
  102                 return GL_STATIC_DRAW;
 
  112                 return GL_VERTEX_SHADER;
 
  114                 return GL_FRAGMENT_SHADER;
 
  124                 return GL_UNSIGNED_INT;
 
  126                 return GL_UNSIGNED_SHORT;
 
  187                 BRK_ERROR(
"Unsupported RHIVertexElementType");
 
  208                 return GL_RG16_SNORM;
 
  212                 return GL_RGB8_SNORM;
 
  214                 return GL_RGB16_SNORM;
 
  218                 return GL_RGBA8_SNORM;
 
  224                 return GL_SRGB8_ALPHA8;
 
  242                 return GL_DEPTH_COMPONENT32F;
 
  244                 return GL_DEPTH32F_STENCIL8;
 
  246                 return GL_DEPTH24_STENCIL8;
 
  248                 BRK_ERROR(
"Unsupported RHITextureFormat");
 
  302                 return GL_DEPTH_COMPONENT;
 
  305                 return GL_DEPTH_STENCIL;
 
  307                 BRK_ERROR(
"Unsupported RHITextureFormat");
 
  320                 return GL_UNSIGNED_BYTE;
 
  329                 return GL_UNSIGNED_SHORT;
 
  338                 return GL_HALF_FLOAT;
 
  346                 return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
 
  348                 return GL_UNSIGNED_INT_24_8;
 
  350                 BRK_ERROR(
"Unsupported RHITextureFormat");
 
  356         auto id = 
static_cast<uint32>(face);
 
  363         static const GLenum targets[] = {
 
  364                 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
 
  365                 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
 
  366                 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
 
  367                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
 
  368                 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
 
  369                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};
 
  377                 return GL_NEAREST_MIPMAP_NEAREST;
 
  379                 return GL_LINEAR_MIPMAP_NEAREST;
 
  381                 return GL_NEAREST_MIPMAP_LINEAR;
 
  383                 return GL_LINEAR_MIPMAP_LINEAR;
 
  389                 BRK_ERROR(
"Unsupported RHISamplerMinFilter");
 
  401                 BRK_ERROR(
"Unsupported RHISamplerMagFilter");
 
  411                 return GL_CLAMP_TO_BORDER;
 
  413                 return GL_CLAMP_TO_EDGE;
 
  415                 return GL_MIRRORED_REPEAT;
 
  417                 return GL_MIRROR_CLAMP_TO_EDGE;
 
  419                 BRK_ERROR(
"Unsupported RHISamplerRepeatMode");
 
  427                 return {0.0f, 0.0f, 0.0f, 1.0f};
 
  429                 return {1.0f, 1.0f, 1.0f, 1.0f};
 
  431                 BRK_ERROR(
"Unsupported RHISamplerBorderColor");
 
  445                 BRK_ERROR(
"Unsupported RHIPrimitivesType");
 
  473                 return GL_FRONT_AND_BACK;
 
  475                 BRK_ERROR(
"Unsupported RHIPolygonCullMode");
 
  487                 BRK_ERROR(
"Unsupported RHIPolygonFrontFace");
 
  511                 BRK_ERROR(
"Unsupported RHICompareFunction");
 
  525                 return GL_ONE_MINUS_SRC_COLOR;
 
  529                 return GL_ONE_MINUS_DST_COLOR;
 
  533                 return GL_ONE_MINUS_SRC_ALPHA;
 
  537                 return GL_ONE_MINUS_DST_ALPHA;
 
  549                 return GL_FUNC_SUBTRACT;
 
  551                 return GL_FUNC_REVERSE_SUBTRACT;
 
  557                 BRK_ERROR(
"Unsupported RHIBlendOperation");
 
  580             case GL_UNSIGNED_INT:
 
  582             case GL_UNSIGNED_INT_VEC2:
 
  584             case GL_UNSIGNED_INT_VEC3:
 
  586             case GL_UNSIGNED_INT_VEC4:
 
  623             case GL_SAMPLER_2D_ARRAY:
 
  627             case GL_SAMPLER_CUBE:
 
  630                 BRK_ERROR(
"Unsupported RHIShaderParamType");
 
  654                 BRK_ERROR(
"Unsupported RHIVertexElementType");
 
  662                 return sizeof(float) * 1;
 
  664                 return sizeof(float) * 2;
 
  666                 return sizeof(float) * 3;
 
  668                 return sizeof(float) * 4;
 
  670                 return sizeof(
int32) * 1;
 
  672                 return sizeof(
int32) * 2;
 
  674                 return sizeof(
int32) * 3;
 
  676                 return sizeof(
int32) * 4;
 
  677             case GL_UNSIGNED_INT:
 
  678                 return sizeof(
uint32) * 1;
 
  679             case GL_UNSIGNED_INT_VEC2:
 
  680                 return sizeof(
uint32) * 2;
 
  681             case GL_UNSIGNED_INT_VEC3:
 
  682                 return sizeof(
uint32) * 3;
 
  683             case GL_UNSIGNED_INT_VEC4:
 
  684                 return sizeof(
uint32) * 4;
 
  686                 return sizeof(
uint32) * 1;
 
  688                 return sizeof(
uint32) * 2;
 
  690                 return sizeof(
uint32) * 3;
 
  692                 return sizeof(
uint32) * 4;
 
  694                 return sizeof(float) * 2 * 2;
 
  696                 return sizeof(float) * 3 * 3;
 
  698                 return sizeof(float) * 4 * 4;
 
  701             case GL_SAMPLER_CUBE:
 
#define BRK_NS_END
Definition: Config.hpp:48
 
#define BRK_TEXT(text)
Definition: Config.hpp:53
 
std::int32_t int32
Definition: Typedefs.hpp:43
 
std::uint32_t uint32
Definition: Typedefs.hpp:44
 
std::uint16_t uint16
Definition: Typedefs.hpp:41
 
GL mapping of RHI definitions.
Definition: GLDefs.hpp:60
 
static GLint GetSamplerRepeatMode(RHISamplerRepeatMode mode)
Definition: GLDefs.hpp:406
 
static GLenum GetPolygonCullMode(RHIPolygonCullMode mode)
Definition: GLDefs.hpp:464
 
static GLenum GetIndexType(RHIIndexType type)
Definition: GLDefs.hpp:121
 
static GLint GetSamplerMagFilter(RHISamplerMagFilter filter)
Definition: GLDefs.hpp:394
 
static const char * GetErrorDescription(GLenum error)
Definition: GLDefs.hpp:80
 
static GLenum GetBufferUsage(RHIBufferUsage bufferUsage)
Definition: GLDefs.hpp:97
 
static GLenum GetShaderType(RHIShaderType type)
Definition: GLDefs.hpp:109
 
static RHIShaderParamType GetShaderParam(GLenum type)
Definition: GLDefs.hpp:619
 
static GLenum GetTextureDataBaseFormat(RHITextureFormat format)
Definition: GLDefs.hpp:271
 
static bool IsMatrixType(GLenum type)
Definition: GLDefs.hpp:608
 
static bool NeedClearBefore(RHIRenderTargetOption option)
Definition: GLDefs.hpp:70
 
static GLenum GetStencilOp(RHIOperation operation)
Definition: GLDefs.hpp:707
 
static GLenum GetCompareFunc(RHICompareFunction function)
Definition: GLDefs.hpp:492
 
static GLenum GetBlendFactor(RHIBlendFactor factor)
Definition: GLDefs.hpp:516
 
static GLint GetSamplerMinFilter(RHISamplerMinFilter filter)
Definition: GLDefs.hpp:374
 
static GLenum GetPolygonFrontFace(RHIPolygonFrontFace frontFace)
Definition: GLDefs.hpp:480
 
static GLenum GetIndexSize(RHIIndexType type)
Definition: GLDefs.hpp:133
 
static GLenum GetTextureDataType(RHITextureFormat format)
Definition: GLDefs.hpp:312
 
static GLenum GetTextureCubeFaceTarget(RHITextureCubemapFace face)
Definition: GLDefs.hpp:355
 
static GLenum GetPolygonMode(RHIPolygonMode mode)
Definition: GLDefs.hpp:450
 
static GLenum GetBlendOperation(RHIBlendOperation operation)
Definition: GLDefs.hpp:544
 
static RHIVertexElementType GetElementType(GLenum type)
Definition: GLDefs.hpp:635
 
static void CatchErrors()
Definition: GLDefs.hpp:62
 
static GLenum GetPrimitivesType(RHIPrimitivesType type)
Definition: GLDefs.hpp:436
 
static Vec4f GetBorderColor(RHISamplerBorderColor color)
Definition: GLDefs.hpp:424
 
static RHIShaderDataType GetShaderDataParam(GLenum type)
Definition: GLDefs.hpp:562
 
static GLenum GetTextureInternalFormat(RHITextureFormat format)
Definition: GLDefs.hpp:191
 
static void GetVertexElementType(RHIVertexElementType type, GLenum &baseType, uint32 &count)
Definition: GLDefs.hpp:144
 
static bool IsSuitableForDepthStencil(RHITextureFormat format, bool &depth, bool &stencil)
Definition: GLDefs.hpp:253
 
static int32 GetShaderDataSize(GLenum type)
Definition: GLDefs.hpp:659
 
Generic vector class for an N dimensional space base on type T.
Definition: TVecN.hpp:55
 
#define BRK_ERROR(message)
Definition: Logger.hpp:148
 
RHITextureCubemapFace
Definition: RHIDefs.hpp:177
 
RHIShaderParamType
Definition: RHIDefs.hpp:106
 
RHIShaderDataType
Definition: RHIDefs.hpp:83
 
RHITextureFormat
Definition: RHIDefs.hpp:135
 
RHIIndexType
Definition: RHIDefs.hpp:57
 
RHIBufferUsage
Definition: RHIDefs.hpp:50
 
RHIPolygonFrontFace
Definition: RHIDefs.hpp:241
 
RHIBlendOperation
Definition: RHIDefs.hpp:289
 
RHIRenderTargetOption
Definition: RHIDefs.hpp:302
 
RHIShaderType
Definition: RHIDefs.hpp:122
 
RHIOperation
Definition: RHIDefs.hpp:257
 
RHIPolygonMode
Definition: RHIDefs.hpp:227
 
RHISamplerBorderColor
Definition: RHIDefs.hpp:214
 
RHICompareFunction
Definition: RHIDefs.hpp:246
 
RHIVertexElementType
Definition: RHIDefs.hpp:71
 
RHIPolygonCullMode
Definition: RHIDefs.hpp:233
 
RHISamplerMagFilter
Definition: RHIDefs.hpp:186
 
RHISamplerMinFilter
Definition: RHIDefs.hpp:191
 
RHISamplerRepeatMode
Definition: RHIDefs.hpp:206
 
RHIBlendFactor
Definition: RHIDefs.hpp:266
 
RHIPrimitivesType
Definition: RHIDefs.hpp:220
 
Definition: GLDevice.cpp:46
 
static const uint32 MAX_TEXTURE_CUBE_FACES
Definition: RHIDefs.hpp:335