| 1 |
#pragma once |
| 2 |
|
| 3 |
#ifndef DOXYGEN_GENERATING_OUTPUT |
| 4 |
#define NCINE_INCLUDE_OPENGL |
| 5 |
#include "../../../CommonHeaders.h" |
| 6 |
#endif |
| 7 |
|
| 8 |
#include "../../../../Main.h" |
| 9 |
#include "../RhiTypes.h" |
| 10 |
|
| 11 |
namespace nCine::RHI::GL |
| 12 |
{ |
| 13 |
/** |
| 14 |
@brief Translates backend-neutral pixel formats into OpenGL formats |
| 15 |
|
| 16 |
Translation table of the OpenGL backend: maps each logical @ref PixelFormat (plus a BGR/BGRA |
| 17 |
channel-order flag) to the OpenGL internal format, external format and pixel data type consumed |
| 18 |
by the texture upload calls, and verifies device support for the compressed families. This is |
| 19 |
the only place the OpenGL texture-format constants live; pipeline code only ever names a |
| 20 |
@ref PixelFormat. |
| 21 |
*/ |
| 22 |
struct GLTextureFormat |
| 23 |
{ |
| 24 |
/** |
| 25 |
* @brief Resolves a pixel format into its OpenGL internal format, external format and data type |
| 26 |
* |
| 27 |
* @param format Backend-neutral pixel format |
| 28 |
* @param bgr Whether the external channel order is BGR/BGRA instead of RGB/RGBA |
| 29 |
* @param internalFormat Receives the sized OpenGL internal format |
| 30 |
* @param externalFormat Receives the external OpenGL format |
| 31 |
* @param dataType Receives the OpenGL pixel data type |
| 32 |
*/ |
| 33 |
static void Resolve(PixelFormat format, bool bgr, GLint& internalFormat, GLenum& externalFormat, GLenum& dataType); |
| 34 |
|
| 35 |
/** @brief Verifies that the device supports the given pixel format, aborting if it does not */ |
| 36 |
static void CheckSupport(PixelFormat format); |
| 37 |
|
| 38 |
/** |
| 39 |
* @brief Returns `true` if the internal format is one of the unsized (ES 2.0 style) ones |
| 40 |
* |
| 41 |
* Immutable storage is defined for sized internal formats only, so a format that answers `true` here |
| 42 |
* has to be allocated per level even where @ref GLTexture::SupportsImmutableStorage() holds. Such a |
| 43 |
* format is not color-renderable either, so it cannot back a render target. |
| 44 |
*/ |
| 45 |
static bool IsUnsizedInternalFormat(GLint internalFormat); |
| 46 |
}; |
| 47 |
} |