Made setViewTransform behave the same way as the rest of setView* API.
This commit is contained in:
parent
6582276e3e
commit
eb8ab50281
@ -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.
|
||||
|
194
makefile
194
makefile
@ -1,97 +1,97 @@
|
||||
#
|
||||
# Copyright 2011-2013 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
all:
|
||||
premake4 --file=premake/premake4.lua vs2008
|
||||
premake4 --file=premake/premake4.lua vs2010
|
||||
premake4 --file=premake/premake4.lua --gcc=nacl gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=nacl-arm gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=pnacl gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=mingw gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=linux gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=emscripten gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=osx gmake
|
||||
premake4 --file=premake/premake4.lua xcode4
|
||||
make -s --no-print-directory -C src
|
||||
|
||||
linux-debug32:
|
||||
make -R -C .build/projects/gmake-linux config=debug32
|
||||
linux-release32:
|
||||
make -R -C .build/projects/gmake-linux config=release32
|
||||
linux-debug64:
|
||||
make -R -C .build/projects/gmake-linux config=debug64
|
||||
linux-release64:
|
||||
make -R -C .build/projects/gmake-linux config=release64
|
||||
linux: linux-debug32 linux-release32 linux-debug64 linux-release64
|
||||
|
||||
mingw-debug32:
|
||||
make -R -C .build/projects/gmake-mingw config=debug32
|
||||
mingw-release32:
|
||||
make -R -C .build/projects/gmake-mingw config=release32
|
||||
mingw-debug64:
|
||||
make -R -C .build/projects/gmake-mingw config=debug64
|
||||
mingw-release64:
|
||||
make -R -C .build/projects/gmake-mingw config=release64
|
||||
mingw: mingw-debug32 mingw-release32 mingw-debug64 mingw-release64
|
||||
|
||||
vs2008-debug32:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Debug|Win32"
|
||||
vs2008-release32:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Release|Win32"
|
||||
vs2008-debug64:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Debug|x64"
|
||||
vs2008-release64:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Release|x64"
|
||||
vs2008: vs2008-debug32 vs2008-release32 vs2008-debug64 vs2008-release64
|
||||
|
||||
nacl-debug32:
|
||||
make -R -C .build/projects/gmake-nacl config=debug32
|
||||
nacl-release32:
|
||||
make -R -C .build/projects/gmake-nacl config=release32
|
||||
nacl-debug64:
|
||||
make -R -C .build/projects/gmake-nacl config=debug64
|
||||
nacl-release64:
|
||||
make -R -C .build/projects/gmake-nacl config=release64
|
||||
nacl: nacl-debug32 nacl-release32 nacl-debug64 nacl-release64
|
||||
|
||||
nacl-arm-debug32:
|
||||
make -R -C .build/projects/gmake-nacl-arm config=debug32
|
||||
nacl-arm-release32:
|
||||
make -R -C .build/projects/gmake-nacl-arm config=release32
|
||||
nacl-arm: nacl-arm-debug32 nacl-arm-release32
|
||||
|
||||
pnacl-debug:
|
||||
make -R -C .build/projects/gmake-pnacl config=debug64
|
||||
pnacl-release:
|
||||
make -R -C .build/projects/gmake-pnacl config=release64
|
||||
pnacl: pnacl-debug pnacl-release
|
||||
|
||||
osx-debug32:
|
||||
make -C .build/projects/gmake-osx config=debug32
|
||||
osx-release32:
|
||||
make -C .build/projects/gmake-osx config=release32
|
||||
osx-debug64:
|
||||
make -C .build/projects/gmake-osx config=debug64
|
||||
osx-release64:
|
||||
make -C .build/projects/gmake-osx config=release64
|
||||
osx: osx-debug32 osx-release32 osx-debug64 osx-release64
|
||||
|
||||
rebuild-shaders:
|
||||
make -C examples/01-cubes rebuild
|
||||
make -C examples/02-metaballs rebuild
|
||||
make -C examples/03-raymarch rebuild
|
||||
make -C examples/04-mesh rebuild
|
||||
make -C examples/05-instancing rebuild
|
||||
make -C examples/06-bump rebuild
|
||||
make -C examples/07-callback rebuild
|
||||
make -C examples/08-update rebuild
|
||||
|
||||
docs:
|
||||
markdown README.md > .build/docs/readme.html
|
||||
|
||||
clean:
|
||||
@echo Cleaning...
|
||||
-rm -r .build
|
||||
-rm -r .debug
|
||||
#
|
||||
# Copyright 2011-2013 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
all:
|
||||
premake4 --file=premake/premake4.lua vs2008
|
||||
premake4 --file=premake/premake4.lua vs2010
|
||||
premake4 --file=premake/premake4.lua --gcc=nacl gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=nacl-arm gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=pnacl gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=mingw gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=linux gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=emscripten gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=osx gmake
|
||||
premake4 --file=premake/premake4.lua xcode4
|
||||
make -s --no-print-directory -C src
|
||||
|
||||
linux-debug32:
|
||||
make -R -C .build/projects/gmake-linux config=debug32
|
||||
linux-release32:
|
||||
make -R -C .build/projects/gmake-linux config=release32
|
||||
linux-debug64:
|
||||
make -R -C .build/projects/gmake-linux config=debug64
|
||||
linux-release64:
|
||||
make -R -C .build/projects/gmake-linux config=release64
|
||||
linux: linux-debug32 linux-release32 linux-debug64 linux-release64
|
||||
|
||||
mingw-debug32:
|
||||
make -R -C .build/projects/gmake-mingw config=debug32
|
||||
mingw-release32:
|
||||
make -R -C .build/projects/gmake-mingw config=release32
|
||||
mingw-debug64:
|
||||
make -R -C .build/projects/gmake-mingw config=debug64
|
||||
mingw-release64:
|
||||
make -R -C .build/projects/gmake-mingw config=release64
|
||||
mingw: mingw-debug32 mingw-release32 mingw-debug64 mingw-release64
|
||||
|
||||
vs2008-debug32:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Debug|Win32"
|
||||
vs2008-release32:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Release|Win32"
|
||||
vs2008-debug64:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Debug|x64"
|
||||
vs2008-release64:
|
||||
devenv .build/projects/vs2008/bgfx.sln /Build "Release|x64"
|
||||
vs2008: vs2008-debug32 vs2008-release32 vs2008-debug64 vs2008-release64
|
||||
|
||||
nacl-debug32:
|
||||
make -R -C .build/projects/gmake-nacl config=debug32
|
||||
nacl-release32:
|
||||
make -R -C .build/projects/gmake-nacl config=release32
|
||||
nacl-debug64:
|
||||
make -R -C .build/projects/gmake-nacl config=debug64
|
||||
nacl-release64:
|
||||
make -R -C .build/projects/gmake-nacl config=release64
|
||||
nacl: nacl-debug32 nacl-release32 nacl-debug64 nacl-release64
|
||||
|
||||
nacl-arm-debug32:
|
||||
make -R -C .build/projects/gmake-nacl-arm config=debug32
|
||||
nacl-arm-release32:
|
||||
make -R -C .build/projects/gmake-nacl-arm config=release32
|
||||
nacl-arm: nacl-arm-debug32 nacl-arm-release32
|
||||
|
||||
pnacl-debug:
|
||||
make -R -C .build/projects/gmake-pnacl config=debug64
|
||||
pnacl-release:
|
||||
make -R -C .build/projects/gmake-pnacl config=release64
|
||||
pnacl: pnacl-debug pnacl-release
|
||||
|
||||
osx-debug32:
|
||||
make -C .build/projects/gmake-osx config=debug32
|
||||
osx-release32:
|
||||
make -C .build/projects/gmake-osx config=release32
|
||||
osx-debug64:
|
||||
make -C .build/projects/gmake-osx config=debug64
|
||||
osx-release64:
|
||||
make -C .build/projects/gmake-osx config=release64
|
||||
osx: osx-debug32 osx-release32 osx-debug64 osx-release64
|
||||
|
||||
rebuild-shaders:
|
||||
make -C examples/01-cubes rebuild
|
||||
make -C examples/02-metaballs rebuild
|
||||
make -C examples/03-raymarch rebuild
|
||||
make -C examples/04-mesh rebuild
|
||||
make -C examples/05-instancing rebuild
|
||||
make -C examples/06-bump rebuild
|
||||
make -C examples/07-callback rebuild
|
||||
make -C examples/08-update rebuild
|
||||
|
||||
docs:
|
||||
markdown README.md > .build/docs/readme.html
|
||||
|
||||
clean:
|
||||
@echo Cleaning...
|
||||
-rm -r .build
|
||||
-rm -r .debug
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user