@ -40,156 +40,471 @@ class Renderbuffer {
Renderbuffer & operator = ( Renderbuffer & & other ) = delete ;
public :
/** @{ @name Internal renderbuffer formats */
# ifndef MAGNUM_TARGET_GLES2
/**
* @ copybrief AbstractTexture : : Components
* @ brief Internal format
*
* Like AbstractTexture : : Components , without three - component RGB .
* @ requires_gles30 ( no extension providing this functionality )
* @ see @ ref Texture : : setData ( ) " setData() "
* @ todo RGB , RGB8 ES only ( ES3 + @ es_extension { OES , rgb8_rgba8 } )
*/
enum class Components {
Red , RedGreen , RGBA
} ;
enum class InternalFormat : GLenum {
# ifndef MAGNUM_TARGET_GLES
/**
* Red component , normalized unsigned , size implementation - dependent .
* @ deprecated Prefer to use the exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::R8 " .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gl Use exactly specified format in OpenGL ES instead .
*/
Red = GL_RED ,
# endif
/**
* @ copybrief AbstractTexture : : ComponentType
*
* Like AbstractTexture : : ComponentType , without normalized signed
* types .
* @ requires_gles30 ( no extension providing this functionality )
*/
enum class ComponentType {
UnsignedByte , Byte , UnsignedShort , Short , UnsignedInt , Int , Half ,
Float , NormalizedUnsignedByte
/**
* Red component , normalized unsigned byte .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gles30 % Extension @ es_extension { EXT , texture_rg }
*/
# ifndef MAGNUM_TARGET_GLES2
R8 = GL_R8 ,
# else
R8 = GL_R8_EXT ,
# endif
# ifndef MAGNUM_TARGET_GLES
, NormalizedUnsignedShort
/**
* Red and green component , normalized unsigned , size
* implementation - dependent .
* @ deprecated Prefer to use the exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::RG8 " .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gl Use exactly specified format in OpenGL ES instead .
*/
RG = GL_RG ,
# endif
} ;
# endif
/**
* @ copybrief AbstractTexture : : Format
*
* Like AbstractTexture : : Format without
* AbstractTexture : : Format : : RGB9Intensity5 , three - component and
* compressed formats , but with added separate stencil index .
*/
enum class Format : GLenum {
/**
* Red and green component , each normalized unsigned byte .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gles30 % Extension @ es_extension { EXT , texture_rg }
*/
# ifndef MAGNUM_TARGET_GLES2
Red = GL_RED , RedGreen = GL_RG ,
RG8 = GL_RG8 ,
# else
RG8 = GL_RG8_EXT ,
# endif
# ifndef MAGNUM_TARGET_GLES
/**
* RGBA , normalized unsigned , size implementation - dependent .
* @ deprecated Prefer to use the exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::RGBA8 " .
* @ requires_gl Use exactly specified format in OpenGL ES 2.0
* instead .
*/
RGBA = GL_RGBA ,
# endif
/**
* RGBA , each component normalized unsigned byte .
* @ requires_gles30 % Extension @ es_extension { ARM , rgba8 } or
* @ es_extension { OES , required_internalformat } and @ es_extension { OES , rgb8_rgba8 }
*/
# ifndef MAGNUM_TARGET_GLES2
RGBA8 = GL_RGBA8 ,
# else
RGBA8 = GL_RGBA8_OES ,
# endif
# ifndef MAGNUM_TARGET_GLES
BGRA = GL_BGRA ,
/**
* Red component , normalized unsigned short .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gl Only byte - sized normalized formats are available
* in OpenGL ES .
*/
R16 = GL_R16 ,
/**
* Red and green component , each normalized unsigned short .
* @ requires_gl30 % Extension @ extension { ARB , texture_rg }
* @ requires_gl Only byte - sized normalized formats are available
* in OpenGL ES .
*/
RG16 = GL_RG16 ,
/**
* RGB , each component normalized unsigned short .
* @ requires_gl Only byte - sized normalized formats are available
* in OpenGL ES .
*/
RGB16 = GL_RGB16 ,
/**
* RGBA , each component normalized unsigned short .
* @ requires_gl Only byte - sized normalized formats are available
* in OpenGL ES .
*/
RGBA16 = GL_RGBA16 ,
# endif
# ifndef MAGNUM_TARGET_GLES2
SRGBA = GL_SRGB8_ALPHA8 , RGB10Alpha2 = GL_RGB10_A2 ,
RGB10AlphaUnsigned2 = GL_RGB10_A2UI ,
/**
* Red component , non - normalized unsigned byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R8UI = GL_R8UI ,
/**
* Red and green component , each non - normalized unsigned byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG8UI = GL_RG8UI ,
/**
* RGBA , each component non - normalized unsigned byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA8UI = GL_RGBA8UI ,
/**
* Red component , non - normalized signed byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R8I = GL_R8I ,
/**
* Red and green component , each non - normalized signed byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG8I = GL_RG8I ,
/**
* RGBA , each component non - normalized signed byte .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA8I = GL_RGBA8I ,
/**
* Red component , non - normalized unsigned short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R16UI = GL_R16UI ,
/**
* Red and green component , each non - normalized unsigned short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG16UI = GL_RG16UI ,
/**
* RGBA , each component non - normalized unsigned short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA16UI = GL_RGBA16UI ,
/**
* Red component , non - normalized signed short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R16I = GL_R16I ,
/**
* Red and green component , each non - normalized signed short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG16I = GL_RG16I ,
/**
* RGBA , each component non - normalized signed short .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA16I = GL_RGBA16I ,
/**
* Red component , non - normalized unsigned int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R32UI = GL_R32UI ,
/**
* Red and green component , each non - normalized unsigned int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG32UI = GL_RG32UI ,
/**
* RGBA , each component non - normalized unsigned int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA32UI = GL_RGBA32UI ,
/**
* Red component , non - normalized signed int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
R32I = GL_R32I ,
/**
* Red and green component , each non - normalized signed int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RG32I = GL_RG32I ,
/**
* RGBA , each component non - normalized signed int .
* @ requires_gl30 % Extension @ extension { EXT , texture_integer }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGBA32I = GL_RGBA32I ,
# endif
RGB5Alpha1 = GL_RGB5_A1 ,
RGBA4 = GL_RGBA4 ,
# ifndef MAGNUM_TARGET_GLES
/**
* Red component , half float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
R16F = GL_R16F ,
/**
* Red and green component , each half float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
RG16F = GL_RG16F ,
/**
* RGBA , each component half float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
RGBA16F = GL_RGBA16F ,
/**
* Red component , float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
R32F = GL_R32F ,
/**
* Red and green component , each float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
RG32F = GL_RG32F ,
/**
* RGBA , each component float .
* @ requires_gl30 % Extension @ extension { ARB , texture_float }
* @ requires_gl Only ( non ) normalized integral formats are
* available in OpenGL ES .
*/
RGBA32F = GL_RGBA32F ,
# endif
# ifndef MAGNUM_TARGET_GLES2
RFloat11GFloat11BFloat10 = GL_R11F_G11F_B10F ,
/**
* RGBA , normalized unsigned , each RGB component 10 bit , alpha 2 bit .
* @ requires_gles30 Usable only as internal texture format in OpenGL
* ES 2.0 , see @ ref Magnum : : AbstractTexture : : InternalFormat " InternalFormat::RGB10A2 " .
*/
RGB10A2 = GL_RGB10_A2 ,
/**
* RGBA , non - normalized unsigned , each RGB component 10 bit , alpha 2 bit .
* @ requires_gl33 % Extension @ extension { ARB , texture_rgb10_a2ui }
* @ requires_gles30 Only normalized integral formats are available
* in OpenGL ES 2.0 .
*/
RGB10A2UI = GL_RGB10_A2UI ,
# endif
/** RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. */
RGB5A1 = GL_RGB5_A1 ,
/** RGBA, normalized unsigned, each component 4bit. */
RGBA4 = GL_RGBA4 ,
# ifndef MAGNUM_TARGET_GLES
/**
* RGB , float , red and green 11 bit , blue 10 bit .
* @ requires_gl30 % Extension @ extension { EXT , packed_float }
* @ requires_gl Usable only as internal texture format in OpenGL
* ES , see @ ref Magnum : : AbstractTexture : : InternalFormat " InternalFormat::R11FG11FB10F " .
*/
R11FG11FB10F = GL_R11F_G11F_B10F ,
# endif
/* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is
GL_ARB_ES2_compatibility */
# if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT)
/** RGB, normalized unsigned, red and blue 5bit, green 6bit. */
RGB565 = GL_RGB565 ,
# endif
# ifndef MAGNUM_TARGET_GLES
/**
* Depth component , at least 16 bit .
*
* Prefer to use the exactly specified version of this format , in
* this case e . g . ` Format : : % Depth16 ` .
* @ requires_gl Use exactly specified format < tt > Format : : % Depth16 < / tt > instead .
* sRGBA , each component normalized unsigned byte .
* @ requires_gles30 % Extension @ es_extension { EXT , sRGB }
*/
Depth = GL_DEPTH_COMPONENT ,
# ifndef MAGNUM_TARGET_GLES2
SRGB8Alpha8 = GL_SRGB8_ALPHA8 ,
# else
SRGB8Alpha8 = GL_SRGB8_ALPHA8_EXT ,
# endif
DepthStencil = GL_DEPTH_STENCIL ,
# ifndef MAGNUM_TARGET_GLES
/**
* Depth component , size implementation - dependent .
* @ todo is this allowed in core ?
* @ deprecated Prefer to use exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::DepthComponent16 " .
* @ requires_gl Use exactly specified format in OpenGL ES instead .
*/
DepthComponent = GL_DEPTH_COMPONENT ,
# endif
Depth16 = GL_DEPTH_COMPONENT16 ,
/** Depth component, 16bit. */
DepthComponent16 = GL_DEPTH_COMPONENT16 ,
/**
* Depth component , 24 bit .
* @ requires_gles30 % Extension @ es_extension { OES , depth24 }
*/
# ifndef MAGNUM_TARGET_GLES2
DepthComponent24 = GL_DEPTH_COMPONENT24 ,
# else
DepthComponent24 = GL_DEPTH_COMPONENT24_OES ,
# endif
/**
* Depth component , 32 bit .
* @ requires_es_extension % Extension @ es_extension { OES , depth32 }
*/
# ifndef MAGNUM_TARGET_GLES
Depth24 = GL_DEPTH_COMPONENT24 ,
DepthFloat = GL_DEPTH_COMPONENT32F ,
DepthComponent32 = GL_DEPTH_COMPONENT32 ,
# else
DepthComponent32 = GL_DEPTH_COMPONENT32_OES ,
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* Stencil index ( unspecified size ) .
*
* Prefer to use the exactly specified version of this format , in
* this case e . g . ` Format : : % Stencil8 ` .
* @ requires_gl Use exactly specified format < tt > Format : : % Stencil8 < / tt > instead .
* Depth component , 32 bit float .
* @ requires_gl30 % Extension @ extension { ARB , depth_buffer_float }
* @ requires_gles30 Only integral depth textures are available in
* OpenGL ES 2.0 .
*/
Stencil = GL_STENCIL_INDEX ,
DepthComponent32F = GL_DEPTH_COMPONENT32F ,
# endif
# ifndef MAGNUM_TARGET_GLES
/**
* Stencil index , size implementation - dependent .
* @ deprecated Prefer to use exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::StencilIndex8 " .
* @ requires_gl Use exactly specified format in OpenGL ES instead .
*/
StencilIndex = GL_STENCIL_INDEX ,
# endif
/**
* 1 - bit stencil index .
*
* @ requires_gl Use < tt > Format : : % Stencil8 < / tt > instead .
* @ requires_es_extension % Extension @ es_extension { OES , stencil1 }
*/
Stencil1 = GL_STENCIL_INDEX1 ,
# ifndef MAGNUM_TARGET_GLES
StencilIndex1 = GL_STENCIL_INDEX1 ,
# else
StencilIndex1 = GL_STENCIL_INDEX1_OES ,
# endif
/**
* 4 - bit stencil index .
*
* @ requires_gl Use < tt > Format : : % Stencil8 < / tt > instead .
* @ requires_es_extension % Extension @ es_extension { OES , stencil4 }
*/
Stencil4 = GL_STENCIL_INDEX4 ,
# ifndef MAGNUM_TARGET_GLES
StencilIndex4 = GL_STENCIL_INDEX4 ,
# else
StencilIndex4 = GL_STENCIL_INDEX4_OES ,
# endif
/** 8-bit stencil index. */
Stencil8 = GL_STENCIL_INDEX8
StencilIndex 8 = GL_STENCIL_INDEX8 ,
# ifndef MAGNUM_TARGET_GLES
,
/**
* 16 - bit stencil index .
*
* @ requires_gl Use < tt > Format : : % Stencil8 < / tt > instead .
* @ requires_gl At most 8 bit stencil index is available in OpenGL
* ES .
*/
Stencil16 = GL_STENCIL_INDEX1 ,
StencilIndex 16 = GL_STENCIL_INDEX16 ,
Depth24Stencil8 = GL_DEPTH24_STENCIL8 ,
DepthFloatStencil8 = GL_DEPTH32F_STENCIL8
/**
* Depth and stencil component , size implementation - dependent .
* @ deprecated Prefer to use exactly specified version of this
* format , e . g . @ ref Magnum : : Renderbuffer : : InternalFormat " InternalFormat::Depth24Stencil8 " .
* @ requires_gl Use exactly specified format in OpenGL ES instead .
*/
DepthStencil = GL_DEPTH_STENCIL ,
# endif
} ;
/** @copydoc AbstractTexture::InternalFormat */
class MAGNUM_EXPORT InternalFormat {
public :
# ifndef MAGNUM_TARGET_GLES2
/** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components, AbstractTexture::ComponentType) */
InternalFormat ( Components components , ComponentType type ) ;
# endif
/** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Format) */
inline constexpr InternalFormat ( Format format ) : internalFormat ( static_cast < GLenum > ( format ) ) { }
/**
* @ brief OpenGL internal format ID
*
* @ todoc Remove workaround when Doxygen supports \ @ copydoc for conversion operators
*/
inline constexpr operator GLenum ( ) const { return internalFormat ; }
private :
GLenum internalFormat ;
} ;
/**
* 24 bit depth and 8 bit stencil component .
* @ requires_gl30 % Extension @ extension { EXT , packed_depth_stencil }
* @ requires_gles30 % Extension @ es_extension { OES , packed_depth_stencil }
*/
# ifdef MAGNUM_TARGET_GLES2
Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES ,
# else
Depth24Stencil8 = GL_DEPTH24_STENCIL8 ,
/*@}*/
/**
* 32 bit float depth component and 8 bit stencil component .
* @ requires_gl30 % Extension @ extension { ARB , depth_buffer_float }
* @ requires_gles30 Only integral depth textures are available in
* OpenGL ES 2.0 .
*/
Depth32FStencil8 = GL_DEPTH32F_STENCIL8 ,
# endif
} ;
/**
* @ brief Constructor
@ -232,30 +547,13 @@ class Renderbuffer {
*/
inline void setStorage ( InternalFormat internalFormat , const Vector2i & size ) {
bind ( ) ;
glRenderbufferStorage ( GL_RENDERBUFFER , internalFormat , size . x ( ) , size . y ( ) ) ;
glRenderbufferStorage ( GL_RENDERBUFFER , GLenum ( internalFormat ) , size . x ( ) , size . y ( ) ) ;
}
private :
GLuint renderbuffer ;
} ;
# ifndef MAGNUM_TARGET_GLES2
/** @relates Renderbuffer
@ brief Convertor of component count and data type to InternalFormat
@ requires_gles30 ( no extension providing this functionality )
*/
inline Renderbuffer : : InternalFormat operator | ( Renderbuffer : : Components components , Renderbuffer : : ComponentType type ) {
return Renderbuffer : : InternalFormat ( components , type ) ;
}
/** @relates Renderbuffer
* @ overload
*/
inline Renderbuffer : : InternalFormat operator | ( Renderbuffer : : ComponentType type , Renderbuffer : : Components components ) {
return Renderbuffer : : InternalFormat ( components , type ) ;
}
# endif
}
# endif