This project is a bgfx renderer backend for cocos2d-x v4.
- This project is not complete and still has many problems.
- This project is not fully tested.
- This project only supports desktop platforms now.
You are welcome to contribute!
To use this project, you have to modify bgfx and cocos2d-x.
- Modify shaderc
in bgfx.
- Remove
main
function inshaderc.cpp
. - Replace implementation of
g_allocator
andTinyStlAllocator
with#include "../../src/bgfx_p.h"
inshaderc_spirv.cpp
. - Compile it as static library and link to your program.
- Remove following files from the project of cocos2d-x.
- All files in
renderer/backend/metal
andrenderer/backend/opengl
renderer/CCRenderer.cpp
renderer/backend/ProgramCache.cpp
renderer/backend/ProgramState.cpp
2d/CCSprite.cpp
math/Mat4.cpp
platform/desktop/CCGLViewImpl-desktop.cpp
- Change your shaders into bgfx format.
- Add gl_Position.xy = applyVP(gl_Position.xy);
to your vertex shader to apply viewport.
- Add bgfx/include
bimg/include
bx/include
to your include path.
- Link libraries from bgfx except dear-imgui
and example-common
.
- Program will write a
.hlsl
file when compile HLSL shaders. - Not work properly when window size changes.
Texture2DBX::getBytes
/TextureCubeBX::getBytes
may not work properly.CommandBufferBX::captureScreen
may not work properly.CommandBufferBX::applyRenderPassDescriptor
may not work properly.CommandBufferBX::setLineWidth
is not supported.