Merge branch 'master' of cane:bkaradzic/bgfx

This commit is contained in:
Branimir Karadžić 2015-06-02 23:29:37 -07:00
commit 8155b139f6
4 changed files with 59 additions and 10 deletions

View file

@ -89,10 +89,10 @@ struct Keyboard
return state;
}
static void decodeKeyState(uint32_t _state, uint8_t& _modifiers, bool& _down)
static bool decodeKeyState(uint32_t _state, uint8_t& _modifiers)
{
_modifiers = (_state>>16)&0xff;
_down = 0 != ( (_state>>8)&0xff);
return 0 != ( (_state>> 8)&0xff);
}
void setKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down)
@ -101,6 +101,14 @@ struct Keyboard
m_once[_key] = false;
}
bool getKeyState(entry::Key::Enum _key, uint8_t* _modifiers)
{
uint8_t modifiers;
_modifiers = NULL == _modifiers ? &modifiers : _modifiers;
return decodeKeyState(m_key[_key], *_modifiers);
}
void pushChar(uint8_t _len, const uint8_t _char[4])
{
for (uint32_t len = m_ring.reserve(4)
@ -196,8 +204,7 @@ struct Input
for (const InputBinding* binding = _bindings; binding->m_key != entry::Key::None; ++binding)
{
uint8_t modifiers;
bool down;
Keyboard::decodeKeyState(m_keyboard.m_key[binding->m_key], modifiers, down);
bool down = Keyboard::decodeKeyState(m_keyboard.m_key[binding->m_key], modifiers);
if (binding->m_flags == 1)
{
@ -302,6 +309,11 @@ void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down)
s_input->m_keyboard.setKeyState(_key, _modifiers, _down);
}
bool inputGetKeyState(entry::Key::Enum _key, uint8_t* _modifiers)
{
return s_input->m_keyboard.getKeyState(_key, _modifiers);
}
void inputChar(uint8_t _len, const uint8_t _char[4])
{
s_input->m_keyboard.pushChar(_len, _char);

View file

@ -39,6 +39,9 @@ void inputProcess();
///
void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down);
///
bool inputGetKeyState(entry::Key::Enum _key, uint8_t* _modifiers = NULL);
/// Adds single UTF-8 encoded character into input buffer.
void inputChar(uint8_t _len, const uint8_t _char[4]);

View file

@ -61,6 +61,11 @@ struct OcornutImguiContext
uint32_t vtx_offset = 0;
for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
{
if (0 == pcmd->vtx_count)
{
continue;
}
bgfx::setState(0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_ALPHA_WRITE
@ -105,6 +110,11 @@ struct OcornutImguiContext
io.IniFilename = NULL;
// io.PixelCenterOffset = bgfx::RendererType::Direct3D9 == bgfx::getRendererType() ? -0.5f : 0.0f;
for (uint32_t ii = 0; ii < ImGuiKey_COUNT; ++ii)
{
io.KeyMap[ii] = ImGuiKey_(ii);
}
const bgfx::Memory* vsmem;
const bgfx::Memory* fsmem;
@ -182,6 +192,26 @@ struct OcornutImguiContext
io.MousePos = ImVec2((float)_mx, (float)_my);
io.MouseDown[0] = 0 != (_button & IMGUI_MBUT_LEFT);
#if 0
io.KeysDown[ImGuiKey_Tab] = inputGetKeyState(entry::Key::Tab);
io.KeysDown[ImGuiKey_LeftArrow] = inputGetKeyState(entry::Key::Left);
io.KeysDown[ImGuiKey_RightArrow] = inputGetKeyState(entry::Key::Right);
io.KeysDown[ImGuiKey_UpArrow] = inputGetKeyState(entry::Key::Up);
io.KeysDown[ImGuiKey_DownArrow] = inputGetKeyState(entry::Key::Down);
io.KeysDown[ImGuiKey_Home] = inputGetKeyState(entry::Key::Home);
io.KeysDown[ImGuiKey_End] = inputGetKeyState(entry::Key::End);
io.KeysDown[ImGuiKey_Delete] = inputGetKeyState(entry::Key::Delete);
io.KeysDown[ImGuiKey_Backspace] = inputGetKeyState(entry::Key::Backspace);
io.KeysDown[ImGuiKey_Enter] = inputGetKeyState(entry::Key::Return);
io.KeysDown[ImGuiKey_Escape] = inputGetKeyState(entry::Key::Esc);
io.KeysDown[ImGuiKey_A] = inputGetKeyState(entry::Key::KeyA);
io.KeysDown[ImGuiKey_C] = inputGetKeyState(entry::Key::KeyC);
io.KeysDown[ImGuiKey_V] = inputGetKeyState(entry::Key::KeyV);
io.KeysDown[ImGuiKey_X] = inputGetKeyState(entry::Key::KeyX);
io.KeysDown[ImGuiKey_Y] = inputGetKeyState(entry::Key::KeyY);
io.KeysDown[ImGuiKey_Z] = inputGetKeyState(entry::Key::KeyZ);
#endif // 0
ImGui::NewFrame();
//ImGui::ShowTestWindow(); //Debug only.

View file

@ -510,8 +510,8 @@ int main(int _argc, const char* _argv[])
for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
{
Index3 index;
index.m_texcoord = 0;
index.m_normal = 0;
index.m_texcoord = -1;
index.m_normal = -1;
index.m_vertexIndex = -1;
char* vertex = argv[edge+1];
@ -528,8 +528,12 @@ int main(int _argc, const char* _argv[])
index.m_normal = (nn < 0) ? nn+numNormals : nn-1;
}
const int tex = atoi(texcoord);
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
// https://en.wikipedia.org/wiki/Wavefront_.obj_file#Vertex_Normal_Indices_Without_Texture_Coordinate_Indices
if(*texcoord != '\0')
{
const int tex = atoi(texcoord);
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
}
}
const int pos = atoi(vertex);
@ -716,8 +720,8 @@ int main(int _argc, const char* _argv[])
bool hasTexcoord;
{
Index3Map::const_iterator it = indexMap.begin();
hasNormal = 0 != it->second.m_normal;
hasTexcoord = 0 != it->second.m_texcoord;
hasNormal = -1 != it->second.m_normal;
hasTexcoord = -1 != it->second.m_texcoord;
if (!hasTexcoord
&& texcoords.size() == positions.size() )