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 some warnings #235

Merged
merged 1 commit into from
Feb 20, 2023
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
14 changes: 9 additions & 5 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct WindowContext {
lastCursor = ImGuiMouseCursor_COUNT;

joystickId = getConnectedJoystickId();
for (int i = 0; i < sf::Joystick::ButtonCount; ++i) {
for (int i = 0; i < static_cast<int>(sf::Joystick::ButtonCount); ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an SFML/SFML bug we ought to fix. We shouldn't use a signed int for a count like this. But that's outside the scope of this PR.

joystickMapping[i] = ImGuiKey_None;
}

Expand Down Expand Up @@ -535,6 +535,8 @@ ImGuiKey keycodeToImGuiKey(sf::Keyboard::Key code) {
return ImGuiKey_F11;
case sf::Keyboard::F12:
return ImGuiKey_F12;
default:
break;
}
return ImGuiKey_None;
}
Expand All @@ -553,6 +555,8 @@ ImGuiKey keycodeToImGuiMod(sf::Keyboard::Key code) {
case sf::Keyboard::LSystem:
case sf::Keyboard::RSystem:
return ImGuiKey_ModSuper;
default:
break;
}
return ImGuiKey_None;
}
Expand Down Expand Up @@ -585,8 +589,8 @@ void ProcessEvent(const sf::Event& event) {
case sf::Event::TouchBegan: // fall-through
case sf::Event::TouchEnded: {
s_currWindowCtx->mouseMoved = false;
int button = event.touch.finger;
if (event.type == sf::Event::TouchBegan && button >= 0 && button < 3) {
unsigned int button = event.touch.finger;
if (event.type == sf::Event::TouchBegan && button < 3) {
s_currWindowCtx->touchDown[event.touch.finger] = true;
}
} break;
Expand Down Expand Up @@ -1164,7 +1168,7 @@ void RenderDrawLists(ImDrawData* draw_data) {
}

ImGuiIO& io = ImGui::GetIO();
assert(io.Fonts->TexID != (ImTextureID)NULL); // You forgot to create and set font texture
assert(io.Fonts->TexID != (ImTextureID) nullptr); // You forgot to create and set font texture
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need to do that cast to ImTextureID? Maybe that's out of scope of this PR though.

Copy link
Contributor

@eliasdaler eliasdaler Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this cast was needed to calm down some other compiler warnings :)
(Well, I found this.)


// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates !=
// framebuffer coordinates)
Expand Down Expand Up @@ -1321,7 +1325,7 @@ void initDefaultJoystickMapping() {
}

void updateJoystickButtonState(ImGuiIO& io) {
for (int i = 0; i < sf::Joystick::ButtonCount; ++i) {
for (int i = 0; i < static_cast<int>(sf::Joystick::ButtonCount); ++i) {
ImGuiKey key = s_currWindowCtx->joystickMapping[i];
if (key != ImGuiKey_None) {
bool isPressed = sf::Joystick::isButtonPressed(s_currWindowCtx->joystickId, i);
Expand Down