Sorry for the delay. I actually change all the handle from class to int 3 weeks ago. But I wanted to use it, to make sure it is the right decision. It is a big change. Also I had a really bad bug when I was doing example 13 stencil, took like a week to solve it.
I have committed my changes and I have merged the develop branch from
https://github.com/KrautApps/cerberus.
Since we are now passing an int, the C++ code does casting magically! Here is a C++ code for destroying vertex buffer:
C++:
void _bgfx_destroy_vertex_buffer( uint16_t _handle )
{
bgfx_destroy_vertex_buffer( *(bgfx_vertex_buffer_handle_t *)&_handle ); // <-- from uint16_t to a bgfx_vertex_buffer_handle_t struct
}
I tried using int as handle on 2 examples, example 12 lod and example 13 stencil.
Here is a screenshot of example 12 lod:

And here are two screenshots of example 13 stencil:

Notes and problems:
1. 32-bit int array of size 2 for 64-bit int is causing headache. For example, example 9 hdr I need to create an if statement like this:
Cerberus:
If (BGFX_CAPS_TEXTURE_BLIT[1]|BGFX_CAPS_TEXTURE_READ_BACK[1]) = (supported[1] & (BGFX_CAPS_TEXTURE_BLIT[1]|BGFX_CAPS_TEXTURE_READ_BACK[1]) ) Then
It works but not readable at all! And will probably cause problem down later on.
Also in example 13 stencil there is a table of render states:
C++:
static RenderState s_renderStates[RenderState::Count] =
{
{ // StencilReflection_CraftStencil
BGFX_STATE_WRITE_RGB
| BGFX_STATE_WRITE_Z
| BGFX_STATE_DEPTH_TEST_LESS
| BGFX_STATE_MSAA
, UINT32_MAX
, BGFX_STENCIL_TEST_ALWAYS // pass always
| BGFX_STENCIL_FUNC_REF(1) // value = 1
| BGFX_STENCIL_FUNC_RMASK(0xff)
| BGFX_STENCIL_OP_FAIL_S_REPLACE
| BGFX_STENCIL_OP_FAIL_Z_REPLACE
| BGFX_STENCIL_OP_PASS_Z_REPLACE // store the value
, BGFX_STENCIL_NONE
},
...
Currently I just hard coded these render states:
Cerberus:
rs = s_renderStates[ RENDER_STATE_STENCIL_REFLECTION_CRAFT_STENCIL ]
rs.m_state[0] = $01000040
rs.m_state[1] = $00000017
rs.m_blendFactorRgba = $ffffffff
rs.m_fstencil = $2228ff01
rs.m_bstencil = $00000000
...
I am not sure how to solve this problem.
2. In example 13 stencil, bgfxFrame is not called at the end:
C++:
// Setup view rect and transform for all used views.
setViewRectMask(s_viewMask, 0, 0, uint16_t(m_viewState.m_width), uint16_t(m_viewState.m_height) );
setViewTransformMask(s_viewMask, m_viewState.m_view, m_viewState.m_proj);
s_viewMask = 0;
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
//reset clear values on used views
clearViewMask(s_clearMask, BGFX_CLEAR_NONE, m_clearValues);
s_clearMask = 0;
return true;
}
In Cerberus, I called bgfxFrame() in glfw bgfx target. This is so that Mojo 1 program does not need to call bgfxFrame.
3. Currently Mojo 1 uses bgfx dynamic create buffer. But after doing some of the example, I think I may need to use bgfx transient buffer. I am not sure what is the difference. I need to look into it.