Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for imgui 1.91.5 (clean some deprecated API calls) #305

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 6 additions & 32 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,36 +586,10 @@ void SetJoystickRTriggerThreshold(float threshold) {

void SetJoystickMapping(int key, unsigned int joystickButton) {
assert(s_currWindowCtx);
// This function now expects ImGuiKey_* values.
// For partial backwards compatibility, also expect some ImGuiNavInput_* values.
ChrisThrasher marked this conversation as resolved.
Show resolved Hide resolved
ImGuiKey finalKey{};
switch (key) {
case ImGuiNavInput_Activate:
finalKey = ImGuiKey_GamepadFaceDown;
break;
case ImGuiNavInput_Cancel:
finalKey = ImGuiKey_GamepadFaceRight;
break;
case ImGuiNavInput_Input:
finalKey = ImGuiKey_GamepadFaceUp;
break;
case ImGuiNavInput_Menu:
finalKey = ImGuiKey_GamepadFaceLeft;
break;
case ImGuiNavInput_FocusPrev:
case ImGuiNavInput_TweakSlow:
finalKey = ImGuiKey_GamepadL1;
break;
case ImGuiNavInput_FocusNext:
case ImGuiNavInput_TweakFast:
finalKey = ImGuiKey_GamepadR1;
break;
default:
assert(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END);
finalKey = static_cast<ImGuiKey>(key);
}
assert(key >= ImGuiKey_NamedKey_BEGIN);
assert(key < ImGuiKey_NamedKey_END);
assert(joystickButton < sf::Joystick::ButtonCount);
s_currWindowCtx->joystickMapping[joystickButton] = finalKey;
s_currWindowCtx->joystickMapping[joystickButton] = static_cast<ImGuiKey>(key);
}

void SetDPadXAxis(sf::Joystick::Axis dPadXAxis, bool inverted) {
Expand Down Expand Up @@ -920,11 +894,11 @@ void RenderDrawLists(ImDrawData* draw_data) {
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert),
(const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
(const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert),
(const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
(const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, uv)));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert),
(const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
(const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, col)));

for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
Expand Down