Updated MRT examples to use MRT clear API.
This commit is contained in:
parent
d3af45bd56
commit
889af211fe
@ -143,10 +143,6 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBott
|
|||||||
|
|
||||||
int _main_(int /*_argc*/, char** /*_argv*/)
|
int _main_(int /*_argc*/, char** /*_argv*/)
|
||||||
{
|
{
|
||||||
// Create vertex stream declaration.
|
|
||||||
PosColorVertex::init();
|
|
||||||
PosColorTexCoord0Vertex::init();
|
|
||||||
|
|
||||||
uint32_t width = 1280;
|
uint32_t width = 1280;
|
||||||
uint32_t height = 720;
|
uint32_t height = 720;
|
||||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||||
@ -155,6 +151,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
bgfx::init();
|
bgfx::init();
|
||||||
bgfx::reset(width, height, reset);
|
bgfx::reset(width, height, reset);
|
||||||
|
|
||||||
|
// Create vertex stream declaration.
|
||||||
|
PosColorVertex::init();
|
||||||
|
PosColorTexCoord0Vertex::init();
|
||||||
|
|
||||||
// Enable debug text.
|
// Enable debug text.
|
||||||
bgfx::setDebug(debug);
|
bgfx::setDebug(debug);
|
||||||
|
|
||||||
@ -306,11 +306,25 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
|
|
||||||
bgfx::setViewTransform(0, view, proj);
|
bgfx::setViewTransform(0, view, proj);
|
||||||
|
|
||||||
bgfx::setViewClearMask(0x3
|
// Set clear color palette for index 0
|
||||||
|
bgfx::setClearColor(0, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
// Set clear color palette for index 1
|
||||||
|
bgfx::setClearColor(1, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
bgfx::setViewClear(0
|
||||||
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
||||||
, 0x00000000
|
, 1.0f // Depth
|
||||||
, 1.0f
|
, 0 // Stencil
|
||||||
, 0
|
, 0 // FB texture 0, color palette 0
|
||||||
|
, 1 == mode ? 1 : 0 // FB texture 1, color palette 1
|
||||||
|
);
|
||||||
|
|
||||||
|
bgfx::setViewClear(1
|
||||||
|
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
||||||
|
, 1.0f // Depth
|
||||||
|
, 0 // Stencil
|
||||||
|
, 0 // Color palette 0
|
||||||
);
|
);
|
||||||
|
|
||||||
bgfx::FrameBufferHandle invalid = BGFX_INVALID_HANDLE;
|
bgfx::FrameBufferHandle invalid = BGFX_INVALID_HANDLE;
|
||||||
|
@ -232,19 +232,26 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
// Enable debug text.
|
// Enable debug text.
|
||||||
bgfx::setDebug(debug);
|
bgfx::setDebug(debug);
|
||||||
|
|
||||||
// Set view 0 clear state.
|
// Set clear color palette for index 0
|
||||||
|
bgfx::setClearColor(0, UINT32_C(0x00000000) );
|
||||||
|
|
||||||
|
// Set clear color palette for index 1
|
||||||
|
bgfx::setClearColor(1, UINT32_C(0x303030ff) );
|
||||||
|
|
||||||
|
// Set geometry pass view clear state.
|
||||||
bgfx::setViewClear(RENDER_PASS_GEOMETRY_ID
|
bgfx::setViewClear(RENDER_PASS_GEOMETRY_ID
|
||||||
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
||||||
, 0x303030ff
|
|
||||||
, 1.0f
|
, 1.0f
|
||||||
, 0
|
, 0
|
||||||
|
, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Set light pass view clear state.
|
||||||
bgfx::setViewClear(RENDER_PASS_LIGHT_ID
|
bgfx::setViewClear(RENDER_PASS_LIGHT_ID
|
||||||
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
||||||
, 0
|
|
||||||
, 1.0f
|
, 1.0f
|
||||||
, 0
|
, 0
|
||||||
|
, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create vertex stream declaration.
|
// Create vertex stream declaration.
|
||||||
@ -439,7 +446,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
|
|
||||||
// Setup views
|
// Setup views
|
||||||
float vp[16];
|
float vp[16];
|
||||||
float invvp[16];
|
float invMvp[16];
|
||||||
{
|
{
|
||||||
bgfx::setViewRectMask(0
|
bgfx::setViewRectMask(0
|
||||||
| RENDER_PASS_GEOMETRY_BIT
|
| RENDER_PASS_GEOMETRY_BIT
|
||||||
@ -459,7 +466,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
bgfx::setViewTransform(RENDER_PASS_GEOMETRY_ID, view, proj);
|
bgfx::setViewTransform(RENDER_PASS_GEOMETRY_ID, view, proj);
|
||||||
|
|
||||||
bx::mtxMul(vp, view, proj);
|
bx::mtxMul(vp, view, proj);
|
||||||
bx::mtxInverse(invvp, vp);
|
bx::mtxInverse(invMvp, vp);
|
||||||
|
|
||||||
bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
|
bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
|
||||||
bgfx::setViewTransformMask(0
|
bgfx::setViewTransformMask(0
|
||||||
@ -644,7 +651,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
// Draw light.
|
// Draw light.
|
||||||
bgfx::setUniform(u_lightPosRadius, &lightPosRadius);
|
bgfx::setUniform(u_lightPosRadius, &lightPosRadius);
|
||||||
bgfx::setUniform(u_lightRgbInnerR, lightRgbInnerR);
|
bgfx::setUniform(u_lightRgbInnerR, lightRgbInnerR);
|
||||||
bgfx::setUniform(u_mtx, invvp);
|
bgfx::setUniform(u_mtx, invMvp);
|
||||||
const uint16_t scissorHeight = uint16_t(y1-y0);
|
const uint16_t scissorHeight = uint16_t(y1-y0);
|
||||||
bgfx::setScissor(uint16_t(x0), height-scissorHeight-uint16_t(y0), uint16_t(x1-x0), scissorHeight);
|
bgfx::setScissor(uint16_t(x0), height-scissorHeight-uint16_t(y0), uint16_t(x1-x0), scissorHeight);
|
||||||
bgfx::setTexture(0, s_normal, gbuffer, 1);
|
bgfx::setTexture(0, s_normal, gbuffer, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user