Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - Toby

Pages: [1] 2
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.

2
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 19, 2017, 12:44:41 am »
I had placed ImGui::NewFrame(); prior to my ImGui::Render() in my render loop, but if I place it in my constructor where it runs once it seems to work fine. So I guess that's that. Or well, actually, now I noticed my test sprite isn't showing up anymore and unlike the demo I can't double click to collapse the window. Interesting.. Anyways regarding dependencies, I am sure that SFML is functioning as intended since I've tried drawing a sprite before and it worked fine.

It's almost as if it is working, but at the same time now. :P Ah well, it is getting late. I'll have to try it more tomorrow.

This is my current mess  for the record http://pastebin.com/fz9WcvLc I commented out ImGui::Render() intentionally but when it is active it renders over everything instead of working in tandem with SFML. (I see my sprite flicker for a split second when the program starts and then it is gone)

Seems to work with sf::CircleShape but not with sf::Sprite. Odd.

3
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 19, 2017, 12:16:01 am »
My final issue seems to be that I can't interact with my own windows. They are completely static.

Code: [Select]
sf::Event event;
while (_window.pollEvent(event))
{
ImGui::SFML::ProcessEvent(event); ///IMGUI

if (event.type == sf::Event::Closed)
_window.close();
}

My event handling loop is very straight forward and just like the demo. However I can't interact with the window at all. Which is very strange. They do render at least.

Edit:

Actually seem to be related to the update function. Since commenting out the event update part for ImGui still lets me move the windows around etc in the demo code.

4
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:57:45 pm »
Oh I had to call ImGui::Newframe prior to rendering. It works now! Strange that their code didn't have to do that.

5
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:52:56 pm »
My only problem now is that while the demo code works I can't seem to use it the same way as they do it:

Code: [Select]
#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();
}

I try and replicate this structure but in my game class and it crashes and says something about an assertion failing relating go g.Initialized so I assume it is my usage of ImGui::SFML::Init that fails. In that example code they just pass in a window but when I look at the function it is supposed to take a window and an sf::Texture* fontTexture, but I'm unsure if that is why it crashes since then it should crash in the demo code too?

Edit:
When I try and use the
Code: [Select]
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.

6
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:26:00 pm »
That solved it! Thank you so much! Adding opengl32.lib did the trick. I've been stuck all day trying to fix this. You have no idea how happy I am right now.

7
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:04:18 pm »
I suspect I have to include opengl since my link errors all mention gl commands. But I find it odd that I would have to do that since SFML already uses OpenGL. How would I link OpenGL so that imgui works with it? Since intellisense itself has no problem with the imgui and imgui-sfml commands. They all seem to work, it only breaks when I try to compile.

8
General / Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 03:53:28 pm »
I've been trying to get ImGui to work with SFML for several hours now. There is a binding made for SFML, or two rather: https://github.com/eliasdaler/imgui-sfml which is based on https://github.com/Mischa-Alff/imgui-backends
I'm using the former and I can't for the life of me get it to work. I've tried using both of them to no avail. The first one gives me linker errors and the second one gives me an error about how something isn't a member of a class. I can provide the detailed errors if needed but I'm starting to think that they are not compatible with either VS2017 (which wouldn't make sense) or that they are outdated and no longer compatible with SFML.
Considering they are just simple cpp and h files it shouldn't be this hard to get them to compile.

Has anyone gotten ImGui to work with SFML? Some help would be appreciated.

Edit:

Code: [Select]
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

Figured I might as well post the linker error I get when I try and use the SFML binding from  https://github.com/eliasdaler/imgui-sfml trying to compile his sample code.

9
Graphics / Re: Create sprites immediately in a certain spot
« on: March 23, 2015, 12:54:28 pm »
I'm pretty sure I solved it now anyway. I added a capture timer, you have to stay in the zone for at least a second to capture it, so when they spawn in they won't be in the zone long enough to capture it.

10
Graphics / Re: Create sprites immediately in a certain spot
« on: March 23, 2015, 12:16:16 pm »
It's a damn mystery, that's what it is. Kind of hard to show more code since I would have to dump so much in here. But it doesn't make sense since the zone only checks for active soldiers and they are only made active after their position has been set. Which means that the soldier is in position in the enemy capture zone before they are active, so how they still manage to trigger the player's zone is beyond me.

But I'll keep digging around and rewriting the code for the zone checking again.

11
Graphics / Re: Create sprites immediately in a certain spot
« on: March 23, 2015, 11:04:15 am »
But the thing is, unless SFML makes my code multi threaded, there is no way for the capture check to occur while the sprite is being made. Evertyhing is done in sequence. Actually, doesn't SFML make multiple threads? Sure looks like it in the output window when the program closes.

12
Graphics / Re: Create sprites immediately in a certain spot
« on: March 23, 2015, 12:44:58 am »
Thanks for the replies. I'll have to look into it tomorrow. Getting pretty late here. Hopefully I don't have to resort to plan B.

13
Graphics / Re: Create sprites immediately in a certain spot
« on: March 23, 2015, 12:36:13 am »
I thought so too. But it is apparently enough to trigger the capture zone. Because for a split second the zone says that there are enemies in the zone just as they spawn on the other side of the screen and then you lose the game. And my capture zone is set to ignore things that have their isActive bool set to false.
Ah well, I guess I'll just have to rewrite the code for the capture zone tomorrow and hope for the best, since you can't initialize sprites to be in the right spot as they are created it seems.

Unless I create the Sprite in a temporary variable, move it and then set it equal to the Sprite that the soldier actually uses or something.

14
Graphics / Re: Create sprites immediately in a certain spot
« on: March 22, 2015, 11:59:25 pm »
The problem is that it still seems to be created at 0, 0 before the set position line is performed. So for a split second all enemies are inside the player zone, "capturing" it.

Code: [Select]
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

This is from inside the soldier constructor. I only activate it after it is made. For whatever reason this was fine but not anymore. But unless I show all of my code I won't solve it this way. Which is why I'm looking for a way to initialize the sprite at the right position right away. Like I do with certain variables in the constructor.

Code: [Select]
Soldier::Soldier(Side Faction, sf::Vector2f initialPos) : moveSpeed(100), HP(100), bBoxSize(14, 28)
{
//Constructor code
}

movespeed is a float value that is set to 100 just as it is created, instead of being assigned a junk value and then made equal to 100. Is there no way to do that with the sprite position?

15
Graphics / Create sprites immediately in a certain spot
« on: March 22, 2015, 11:48:07 pm »
I've been trying for hours to fix this issue that is driving me mad. I have two zones that can be captured with soldiers in my game. My problem is that when reinforcements are created for the enemy faction, for one tick, the soldiers are at 0, 0. Which is covered by the player's capture zone, this causes the zone to think that there are more enemies than friendlies in the zone during that tick, thus triggering a game over state.

I've tried and tried to make sure that the enemies are created on the spot, but it doesn't seem to be possible, I actually have to create the sprite at 0, 0 and THEN move it to the place it should be. I tried to solve this by having an isActive flag on the soldiers, which are only set to true after I've set their position. This worked initially but since then I had to revert some code that I changed attempting to fix the problem. But once I discovered that I could do it by having the isActive bool I reverted those changes. And suddenly that solution no longer works. It is really hard to explain but my question is just if it is possible to initialize an object to spawn at a certain position right from the get go, instead of being created at 0, 0 and then moved.

Some help would be greatly appreciated.

Pages: [1] 2