Added topology flip for tristrip.
This commit is contained in:
parent
a167dcda12
commit
bc456cdbc9
@ -327,6 +327,7 @@ namespace bgfx
|
||||
enum Enum
|
||||
{
|
||||
TriListFlipWinding, //!< Flip winding order of triangle list.
|
||||
TriStripFlipWinding, //!< Flip winding order of trinagle strip.
|
||||
TriListToLineList, //!< Convert triangle list to line list.
|
||||
TriStripToTriList, //!< Convert triangle strip to triangle list.
|
||||
LineStripToLineList, //!< Convert line strip to line list.
|
||||
|
@ -248,6 +248,7 @@ typedef enum bgfx_topology
|
||||
typedef enum bgfx_topology_convert
|
||||
{
|
||||
BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING,
|
||||
BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING,
|
||||
BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST,
|
||||
BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST,
|
||||
BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST,
|
||||
|
@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(69)
|
||||
#define BGFX_API_VERSION UINT32_C(70)
|
||||
|
||||
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.
|
||||
|
@ -37,6 +37,37 @@ namespace bgfx
|
||||
return _numIndices;
|
||||
}
|
||||
|
||||
inline bool isEven(uint32_t _num)
|
||||
{
|
||||
return 0 == (_num & 1);
|
||||
}
|
||||
|
||||
template<typename IndexT>
|
||||
static uint32_t topologyConvertTriStripFlipWinding(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
||||
{
|
||||
const uint32_t numIndices = isEven(_numIndices) ? _numIndices + 1 : _numIndices;
|
||||
|
||||
if (NULL != _dst)
|
||||
{
|
||||
return numIndices;
|
||||
}
|
||||
|
||||
IndexT* dst = (IndexT*)_dst;
|
||||
IndexT* end = &dst[_dstSize/sizeof(IndexT)];
|
||||
|
||||
if (isEven(_numIndices) )
|
||||
{
|
||||
*dst++ = _indices[_numIndices-1];
|
||||
}
|
||||
|
||||
for (uint32_t ii = 1; ii <= _numIndices && dst < end; ++ii)
|
||||
{
|
||||
*dst++ = _indices[_numIndices - ii];
|
||||
}
|
||||
|
||||
return numIndices;
|
||||
}
|
||||
|
||||
template<typename IndexT, typename SortT>
|
||||
static uint32_t topologyConvertTriListToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices, IndexT* _temp, SortT* _tempSort)
|
||||
{
|
||||
@ -195,6 +226,14 @@ namespace bgfx
|
||||
|
||||
return topologyConvertTriListFlipWinding(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
||||
|
||||
case TopologyConvert::TriStripFlipWinding:
|
||||
if (_index32)
|
||||
{
|
||||
return topologyConvertTriStripFlipWinding(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
||||
}
|
||||
|
||||
return topologyConvertTriStripFlipWinding(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
||||
|
||||
case TopologyConvert::TriListToLineList:
|
||||
if (NULL == _allocator)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user