MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / initTestTexture

Function initTestTexture

Source/3rdParty/bgfx/src/renderer_gl.cpp:1613–1671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1611 }
1612
1613 GLenum initTestTexture(TextureFormat::Enum _format, bool _srgb, bool _mipmaps, bool _array, GLsizei _dim)
1614 {
1615 const TextureFormatInfo& tfi = s_textureFormat[_format];
1616 GLenum internalFmt = _srgb
1617 ? tfi.m_internalFmtSrgb
1618 : tfi.m_internalFmt
1619 ;
1620 GLenum fmt = _srgb
1621 ? tfi.m_fmtSrgb
1622 : tfi.m_fmt
1623 ;
1624
1625 GLsizei bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(_format) );
1626 GLsizei size = (_dim*_dim*bpp)/8;
1627 void* data = NULL;
1628
1629 if (bimg::isDepth(bimg::TextureFormat::Enum(_format) ) )
1630 {
1631 _srgb = false;
1632 _mipmaps = false;
1633 _array = false;
1634 }
1635 else
1636 {
1637 data = bx::alignPtr(BX_STACK_ALLOC(size+16), 0, 16);
1638 }
1639
1640 flushGlError();
1641 GLenum err = 0;
1642
1643 const GLenum target = _array
1644 ? GL_TEXTURE_2D_ARRAY
1645 : GL_TEXTURE_2D
1646 ;
1647
1648 if (bimg::isCompressed(bimg::TextureFormat::Enum(_format) ) )
1649 {
1650 for (uint32_t ii = 0, dim = _dim; ii < (_mipmaps ? 5u : 1u) && 0 == err; ++ii, dim >>= 1)
1651 {
1652 dim = bx::uint32_max(1, dim);
1653 uint32_t block = bx::uint32_max(4, dim);
1654 size = (block*block*bpp)/8;
1655 compressedTexImage(target, ii, internalFmt, dim, dim, 0, 0, size, data);
1656 err |= getGlError();
1657 }
1658 }
1659 else
1660 {
1661 for (uint32_t ii = 0, dim = _dim; ii < (_mipmaps ? 5u : 1u) && 0 == err; ++ii, dim >>= 1)
1662 {
1663 dim = bx::uint32_max(1, dim);
1664 size = (dim*dim*bpp)/8;
1665 texImage(target, 0, ii, internalFmt, dim, dim, 0, 0, fmt, tfi.m_type, data);
1666 err |= getGlError();
1667 }
1668 }
1669
1670 return err;

Callers 2

isTextureFormatValidFunction · 0.85
isFramebufferFormatValidFunction · 0.85

Calls 8

getBitsPerPixelFunction · 0.85
isDepthFunction · 0.85
flushGlErrorFunction · 0.85
isCompressedFunction · 0.85
compressedTexImageFunction · 0.85
getGlErrorFunction · 0.85
texImageFunction · 0.85
EnumEnum · 0.70

Tested by

no test coverage detected