mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Cleanup.
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex = 0, uint32_t _numVertices = UINT32_MAX);
|
||||
}
|
||||
|
||||
struct PosColorVertex
|
||||
{
|
||||
float m_x;
|
||||
@@ -15,17 +20,25 @@ struct PosColorVertex
|
||||
|
||||
static void init()
|
||||
{
|
||||
ms_decl
|
||||
ms_decl0
|
||||
.begin()
|
||||
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
|
||||
.skip(4)
|
||||
.end();
|
||||
|
||||
ms_decl1
|
||||
.begin()
|
||||
.skip(12)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.end();
|
||||
};
|
||||
|
||||
static bgfx::VertexDecl ms_decl;
|
||||
static bgfx::VertexDecl ms_decl0;
|
||||
static bgfx::VertexDecl ms_decl1;
|
||||
};
|
||||
|
||||
bgfx::VertexDecl PosColorVertex::ms_decl;
|
||||
bgfx::VertexDecl PosColorVertex::ms_decl0;
|
||||
bgfx::VertexDecl PosColorVertex::ms_decl1;
|
||||
|
||||
static PosColorVertex s_cubeVertices[] =
|
||||
{
|
||||
@@ -102,10 +115,16 @@ class ExampleCubes : public entry::AppI
|
||||
PosColorVertex::init();
|
||||
|
||||
// Create static vertex buffer.
|
||||
m_vbh = bgfx::createVertexBuffer(
|
||||
m_vbh0 = bgfx::createVertexBuffer(
|
||||
// Static data can be passed with bgfx::makeRef
|
||||
bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
|
||||
, PosColorVertex::ms_decl
|
||||
, PosColorVertex::ms_decl0
|
||||
);
|
||||
|
||||
m_vbh1 = bgfx::createVertexBuffer(
|
||||
// Static data can be passed with bgfx::makeRef
|
||||
bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
|
||||
, PosColorVertex::ms_decl1
|
||||
);
|
||||
|
||||
// Create static index buffer.
|
||||
@@ -124,7 +143,8 @@ class ExampleCubes : public entry::AppI
|
||||
{
|
||||
// Cleanup.
|
||||
bgfx::destroyIndexBuffer(m_ibh);
|
||||
bgfx::destroyVertexBuffer(m_vbh);
|
||||
bgfx::destroyVertexBuffer(m_vbh0);
|
||||
bgfx::destroyVertexBuffer(m_vbh1);
|
||||
bgfx::destroyProgram(m_program);
|
||||
|
||||
// Shutdown bgfx.
|
||||
@@ -201,7 +221,8 @@ class ExampleCubes : public entry::AppI
|
||||
bgfx::setTransform(mtx);
|
||||
|
||||
// Set vertex and index buffer.
|
||||
bgfx::setVertexBuffer(m_vbh);
|
||||
bgfx::setVertexBuffer(0, m_vbh0);
|
||||
bgfx::setVertexBuffer(1, m_vbh1);
|
||||
bgfx::setIndexBuffer(m_ibh);
|
||||
|
||||
// Set render states.
|
||||
@@ -229,7 +250,8 @@ class ExampleCubes : public entry::AppI
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
bgfx::VertexBufferHandle m_vbh;
|
||||
bgfx::VertexBufferHandle m_vbh0;
|
||||
bgfx::VertexBufferHandle m_vbh1;
|
||||
bgfx::IndexBufferHandle m_ibh;
|
||||
bgfx::ProgramHandle m_program;
|
||||
int64_t m_timeOffset;
|
||||
|
||||
@@ -2636,7 +2636,7 @@ namespace bgfx
|
||||
g_caps.limits.maxTextures = BGFX_CONFIG_MAX_TEXTURES;
|
||||
g_caps.limits.maxTextureSamplers = BGFX_CONFIG_MAX_TEXTURE_SAMPLERS;
|
||||
g_caps.limits.maxVertexDecls = BGFX_CONFIG_MAX_VERTEX_DECLS;
|
||||
g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS;
|
||||
g_caps.limits.maxVertexStreams = 1;
|
||||
g_caps.limits.maxIndexBuffers = BGFX_CONFIG_MAX_INDEX_BUFFERS;
|
||||
g_caps.limits.maxVertexBuffers = BGFX_CONFIG_MAX_VERTEX_BUFFERS;
|
||||
g_caps.limits.maxDynamicIndexBuffers = BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS;
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
#endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_VERTEX_STREAMS
|
||||
# define BGFX_CONFIG_MAX_VERTEX_STREAMS 1
|
||||
# define BGFX_CONFIG_MAX_VERTEX_STREAMS 4
|
||||
#endif // BGFX_CONFIG_MAX_VERTEX_STREAMS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS
|
||||
|
||||
@@ -661,6 +661,7 @@ namespace bgfx { namespace d3d9
|
||||
BX_TRACE("Max fragment shader 3.0 instr. slots: %d", m_caps.MaxPixelShader30InstructionSlots);
|
||||
BX_TRACE("Num simultaneous render targets: %d", m_caps.NumSimultaneousRTs);
|
||||
BX_TRACE("Max vertex index: %d", m_caps.MaxVertexIndex);
|
||||
BX_TRACE("Max streams: %d", m_caps.MaxStreams);
|
||||
|
||||
g_caps.supported |= ( 0
|
||||
| BGFX_CAPS_TEXTURE_3D
|
||||
@@ -674,12 +675,14 @@ namespace bgfx { namespace d3d9
|
||||
| BGFX_CAPS_TEXTURE_READ_BACK
|
||||
| (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0)
|
||||
);
|
||||
g_caps.limits.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
|
||||
|
||||
m_caps.NumSimultaneousRTs = uint8_t(bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
|
||||
m_caps.NumSimultaneousRTs = bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
|
||||
m_caps.MaxStreams = bx::uint32_min(m_caps.MaxStreams, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
m_caps.MaxAnisotropy = bx::uint32_max(m_caps.MaxAnisotropy, 1);
|
||||
|
||||
g_caps.limits.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
|
||||
g_caps.limits.maxFBAttachments = uint8_t(m_caps.NumSimultaneousRTs);
|
||||
|
||||
m_caps.MaxAnisotropy = bx::uint32_max(m_caps.MaxAnisotropy, 1);
|
||||
g_caps.limits.maxVertexStreams = uint8_t(m_caps.MaxStreams);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user