Made setViewTransform behave the same way as the rest of setView* API.
This commit is contained in:
parent
6582276e3e
commit
eb8ab50281
4 changed files with 158 additions and 152 deletions
|
@ -172,6 +172,17 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::destroyVertexShader(vsh);
|
||||
bgfx::destroyFragmentShader(fsh);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
||||
|
||||
float view[16];
|
||||
float proj[16];
|
||||
mtxLookAt(view, eye, at);
|
||||
mtxProj(proj, 60.0f, 16.0f/9.0f, 0.1f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
while (!processEvents(width, height, debug, reset) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
|
@ -194,17 +205,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering simple static mesh.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
||||
|
||||
float view[16];
|
||||
float proj[16];
|
||||
mtxLookAt(view, eye, at);
|
||||
mtxProj(proj, 60.0f, 16.0f/9.0f, 0.1f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
float time = (float)(bx::getHPCounter()/double(bx::getHPFrequency() ) );
|
||||
|
||||
// Submit 11x11 cubes.
|
||||
|
|
|
@ -1290,13 +1290,13 @@ namespace bgfx
|
|||
void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx.m_submit->setViewTransform(_id, _view, _proj, _other);
|
||||
s_ctx.setViewTransform(_id, _view, _proj, _other);
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx.m_submit->setViewTransformMask(_viewMask, _view, _proj, _other);
|
||||
s_ctx.setViewTransformMask(_viewMask, _view, _proj, _other);
|
||||
}
|
||||
|
||||
void setState(uint64_t _state)
|
||||
|
|
90
src/bgfx_p.h
90
src/bgfx_p.h
|
@ -984,47 +984,6 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
if (BGFX_CONFIG_MAX_VIEWS > _other)
|
||||
{
|
||||
m_other[_id] = _other;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_other[_id] = _id;
|
||||
}
|
||||
|
||||
if (NULL != _view)
|
||||
{
|
||||
memcpy(m_view[_id].val, _view, sizeof(Matrix4) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_view[_id].setIdentity();
|
||||
}
|
||||
|
||||
if (NULL != _proj)
|
||||
{
|
||||
memcpy(m_proj[_id].val, _proj, sizeof(Matrix4) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_view[_id].setIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
id += ntz;
|
||||
|
||||
setViewTransform( (uint8_t)id, _view, _proj, _other);
|
||||
}
|
||||
}
|
||||
|
||||
void setState(uint64_t _state)
|
||||
{
|
||||
uint8_t blend = ( (_state&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT)&0xff;
|
||||
|
@ -2289,6 +2248,47 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
if (BGFX_CONFIG_MAX_VIEWS > _other)
|
||||
{
|
||||
m_other[_id] = _other;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_other[_id] = _id;
|
||||
}
|
||||
|
||||
if (NULL != _view)
|
||||
{
|
||||
memcpy(m_view[_id].val, _view, sizeof(Matrix4) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_view[_id].setIdentity();
|
||||
}
|
||||
|
||||
if (NULL != _proj)
|
||||
{
|
||||
memcpy(m_proj[_id].val, _proj, sizeof(Matrix4) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_view[_id].setIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other)
|
||||
{
|
||||
for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) )
|
||||
{
|
||||
viewMask >>= ntz;
|
||||
id += ntz;
|
||||
|
||||
setViewTransform( (uint8_t)id, _view, _proj, _other);
|
||||
}
|
||||
}
|
||||
|
||||
void dumpViewStats()
|
||||
{
|
||||
#if 0 // BGFX_CONFIG_DEBUG
|
||||
|
@ -2373,6 +2373,9 @@ namespace bgfx
|
|||
memcpy(m_submit->m_rt, m_rt, sizeof(m_rt) );
|
||||
memcpy(m_submit->m_clear, m_clear, sizeof(m_clear) );
|
||||
memcpy(m_submit->m_rect, m_rect, sizeof(m_rect) );
|
||||
memcpy(m_submit->m_view, m_view, sizeof(m_view) );
|
||||
memcpy(m_submit->m_proj, m_proj, sizeof(m_proj) );
|
||||
memcpy(m_submit->m_other, m_other, sizeof(m_other) );
|
||||
m_submit->finish();
|
||||
|
||||
dumpViewStats();
|
||||
|
@ -3031,9 +3034,12 @@ namespace bgfx
|
|||
RenderTargetHandle m_rt[BGFX_CONFIG_MAX_VIEWS];
|
||||
Clear m_clear[BGFX_CONFIG_MAX_VIEWS];
|
||||
Rect m_rect[BGFX_CONFIG_MAX_VIEWS];
|
||||
Uniform m_uniform[BGFX_CONFIG_MAX_UNIFORMS];
|
||||
Matrix4 m_view[BGFX_CONFIG_MAX_VIEWS];
|
||||
Matrix4 m_proj[BGFX_CONFIG_MAX_VIEWS];
|
||||
uint8_t m_other[BGFX_CONFIG_MAX_VIEWS];
|
||||
uint16_t m_seq[BGFX_CONFIG_MAX_VIEWS];
|
||||
uint16_t m_seqMask[BGFX_CONFIG_MAX_VIEWS];
|
||||
Uniform m_uniform[BGFX_CONFIG_MAX_UNIFORMS];
|
||||
|
||||
Resolution m_resolution;
|
||||
uint32_t m_frames;
|
||||
|
|
Reference in a new issue