1
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 19, 2017, 12:50:59 pm »
Thanks, I think that was the last of my issues. Now I can finally get to work.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
sf::Event event;
while (_window.pollEvent(event))
{
ImGui::SFML::ProcessEvent(event); ///IMGUI
if (event.type == sf::Event::Closed)
_window.close();
}
#include "imgui.h"
#include "imgui-SFML.h"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/CircleShape.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
//ImGui::ShowTestWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::Render();
window.display();
}
ImGui::SFML::Shutdown();
}
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
ImGui::Render();
window.display();
It crashes. I use the ImGui::SFML::Init(window); in my game class constructor, ImGui::SFML::ProcessEvent(event); in my process event function and ImGui::SFML::Update(window, deltaClock.restart()); in my update function and finally the ImGui::Begin etc in my render loop. So I'm unsure as to what I'm doing differently.
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::Render(void)" (?Render@ImGui@@YAXXZ) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::ShowTestWindow(bool *)" (?ShowTestWindow@ImGui@@YAXPEA_N@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "bool __cdecl ImGui::Begin(char const *,bool *,int)" (?Begin@ImGui@@YA_NPEBDPEA_NH@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::End(void)" (?End@ImGui@@YAXXZ) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "bool __cdecl ImGui::Button(char const *,struct ImVec2 const &)" (?Button@ImGui@@YA_NPEBDAEBUImVec2@@@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::SFML::Init(class sf::RenderTarget &,class sf::Texture *)" (?Init@SFML@ImGui@@YAXAEAVRenderTarget@sf@@PEAVTexture@4@@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::SFML::ProcessEvent(class sf::Event const &)" (?ProcessEvent@SFML@ImGui@@YAXAEBVEvent@sf@@@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::SFML::Update(class sf::RenderWindow &,class sf::Time)" (?Update@SFML@ImGui@@YAXAEAVRenderWindow@sf@@VTime@4@@Z) referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::SFML::Shutdown(void)" (?Shutdown@SFML@ImGui@@YAXXZ) referenced in function main
SSprite.setPosition(initialPos); //Move the Soldier into an initial position
isActive = true; //IMPORTANT: We set the active bool to true AFTER we move the actor into place
Soldier::Soldier(Side Faction, sf::Vector2f initialPos) : moveSpeed(100), HP(100), bBoxSize(14, 28)
{
//Constructor code
}