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 - mos

Pages: [1] 2
2
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 19, 2017, 12:29:06 am »
I feel like you're still missing some dependencies as I am having none of the issues you are. Check the dependency table here: http://www.sfml-dev.org/tutorials/2.4/start-vc.php (only use "-s" if using SFML_STATIC). Make sure you have the correct ones for Debug and Release.

3
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 19, 2017, 12:00:36 am »
Equally weird is that your demo code works fine for me and adding ImGui::NewFrame makes the whole screen black.

4
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:32:59 pm »
You're welcome. Glad I could help.

5
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 11:18:59 pm »
You should have opengl32.lib in "Additional Dependencies" under Linker -> Input for Debug and Release. If you have that, then maybe you're missing a component. When I had linking issues with SFML, I installed "Windows Universal CRT SDK" in the Visual Studio Installer (can be found under Compilers, build tools, and runtimes) to make them go away.

So check if you have the right dependencies and components.

6
General / Re: Using ImGui with SFML (Visual Studio 2017)
« on: March 18, 2017, 08:59:48 pm »
Using this one: https://github.com/eliasdaler/imgui-sfml. It is quite easy to setup.
  • Right click your project -> Properties
  • Change Configuration on top to All Configurations
  • Go to C/C++ -> General -> Additional Include Directories
  • Add the imgui (https://github.com/ocornut/imgui) folder path in there
  • Open up imconfig-SFML.h and imconfig.h. Add the contents of imconfig-SFML.h inside imconfig.h in their proper positions in the top of the file (#include with the other includes, defines with the other defines, etc...).
  • Add the following files to your project: imgui.cpp, imgui_draw.cpp, imgui-SFML.cpp

Try out this test program:

#include <imgui.h>
#include <imgui-sfml\imgui-SFML.h>

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(640, 480), "");
        window.setVerticalSyncEnabled(true);
        ImGui::SFML::Init(window);

        sf::Color bgColor;

        float color[3] = { 0.f, 0.f, 0.f };

        // let's use char array as buffer, see next part
        // for instructions on using std::string with ImGui
        char windowTitle[255] = "ImGui + SFML = <3";

        window.setTitle(windowTitle);
        window.resetGLStates(); // call it if you only draw ImGui. Otherwise not needed.
        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::Begin("Sample window"); // begin window

                                                         // Background color edit
                if (ImGui::ColorEdit3("Background color", color))
                {
                        // this code gets called if color value changes, so
                        // the background color is upgraded automatically!
                        bgColor.r = static_cast<sf::Uint8>(color[0] * 255.f);
                        bgColor.g = static_cast<sf::Uint8>(color[1] * 255.f);
                        bgColor.b = static_cast<sf::Uint8>(color[2] * 255.f);
                }

                // Window title text edit
                ImGui::InputText("Window title", windowTitle, 500);

                if (ImGui::Button("Update window title"))
                {
                        // this code gets if user clicks on the button
                        // yes, you could have written if(ImGui::InputText(...))
                        // but I do this to show how buttons work :)
                        window.setTitle(windowTitle);
                }
                ImGui::End(); // end window

                window.clear(bgColor); // fill background with color
                ImGui::Render();
                window.display();
        }

        ImGui::SFML::Shutdown();
}

I am using Visual Studio 2017 as well and it works great without any errors. All the instructions take from here: https://eliasdaler.github.io/using-imgui-with-sfml-pt1/. I had to change the following two lines in the test program:

#include "imgui.h"
#include "imgui-sfml.h"

to this:

#include <imgui.h>
#include <imgui-sfml\imgui-SFML.h>

to make it work. Though if you want to stay to the original then you just include the imgui-SFML directory as well. Hope this helps!

EDIT: If  the problem still persists, the link mentions to try linking OpenGL to your project.

7
I tried it with this one: http://www.sfml-dev.org/artifacts/by-branch/master/windows-vc14-32.zip and I still get the same results.

I'm not using a joystick though and have no code to handle it (unless SFML does so automatically).

8
SFML v 2.4.2. I am using it on Visual C++ 14 (2015) - 32-bit.

9
General / Game runs very laggy on my computer (Noticeable CPU spikes)
« on: March 17, 2017, 11:31:25 pm »
When I look at the monitor in Visual Studio, I see the CPU usage spiking from 1%-7% constantly. So I think some of my code is bad or I'm not doing the timing correct. I followed this tutorial:

http://gafferongames.com/game-physics/fix-your-timestep/

This is what it looks like:

https://gfycat.com/SoftLikableDairycow

As you can see, it seems like it is skipping some draw calls. I tried setting the FramerateLimit to 60, 120, and unlimited but get the same results. I tried turning on VSync but get worse performance.

My specs are: Windows 10 64-bit, nVidia 970, i7-4790k

You can download the visual studio project here (Run using x86): https://www.dropbox.com/s/o9uqarh4q3p8uap/RPGWorld.zip?dl=0

Or you can look at the code here: https://gist.github.com/anonymous/2af3c35d568324fb0a6ce8039ef42a64 The relevant code is most likely in Game.cpp where I do the timing in the function update() and Player.cpp where I do the movement.

Another thing to note is that I let someone else try the project and it ran smoothly for them. He was using a Linux machine but same graphics card. Is it Windows related? Any help would be appreciated.

10
General / Re: Multiple tile layers
« on: September 19, 2016, 12:22:47 am »
Thank you both. This was really helpful. Going to try and get a working version.

11
General / Re: Multiple tile layers
« on: September 18, 2016, 04:23:03 am »
I've never done bitshifting before so I'm sure what the tileentry is supposed to be. If I go by the vertex array tutorial linked, would that be tileNumber? If so, not sure what   tileentry = 1 + 20 * 256 = 5121 would mean as the number of tiles don't go that high.

I was going to use the Tiled map editor eventually, but I wanted to know how to do it first on my own. As for your alternative method, I agree. I really don't want to use another array to do this.

Thanks for the reply!

12
General / Multiple tile layers
« on: September 17, 2016, 08:26:50 pm »
Hello, I followed this tutorial: http://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php and was able to draw a simple map. However, I can't figure out how to add a tile on top of another tile.

My tile sheet looks like this:



As you can see, some have a background while the others have a transparent one. If I draw the transparent background tiles next to one that isn't, it looks out of place:



So I wanted to draw another tile underneath it; like grass or sand. Do I have to make 2 arrays? I read my array from a XML file:

<?xml version="1.0" encoding="UTF-8"?>

<Level>
        <!-- Location of tile sheet -->
        <Tileset>Resources/Tiles/medieval.png</Tileset>

        <!-- Number of rows and columns on sheet -->
        <SheetRows>7</SheetRows>
        <SheetColumns>18</SheetColumns>
       
        <!-- Size of the world -->
        <WorldWidth>16</WorldWidth>
        <WorldHeight>10</WorldHeight>
       
        <!-- Offsets -->
        <TopOffset>0</TopOffset>
        <BottomOffset>32</BottomOffset>
        <LeftOffset>0</LeftOffset>
        <RightOffset>32</RightOffset>

        <!-- Tiles from sheet -->
        <Map>
                <Row>75  4   75  1   1   1   0   0   1   0   0   0   0   0   0   0</Row>
                <Row>0   4   75  1   0   0   0   0   0   0   44  0   1   57  0   0</Row>
                <Row>0   4   0   75  0   0   0   1   1   0   4   0   0   0   0   0</Row>
                <Row>0   40  24  72  0   0   0   0   0   0   4   0   0   0   0   0</Row>
                <Row>0   0   0   1   0   0   0   0   0   57  4   0   1   0   0   0</Row>
                <Row>0   0   0   0   0   0   0   1   1   0   4   0   0   0   0   0</Row>
                <Row>0   0   0   0   0   0   0   0   0   0   4   0   0   0   0   0</Row>
                <Row>0   0   0   1   0   0   57  0   0   0   4   0   1   0   0   0</Row>
                <Row>0   0   0   1   0   0   57  0   0   0   4   0   1   0   0   0</Row>
                <Row>0   0   0   0   0   0   0   1   1   0   4   0   0   0   0   0</Row>
        </Map>
</Level>
 

Here's my TileMap.cpp code: https://gist.github.com/anonymous/f9ddbf24f684d0552d7fee31f4063155

What's the best way to achieve multiple layers? Any help would be appreciated!

13
General / Re: How do I setup SFML on VS 2015?
« on: September 17, 2016, 08:17:22 pm »
I mean that the C++ thingy doesn't show for me, whatever I do.

For that option to appear, you have to add at least one .cpp file in your solution. At least, it was like that for me.

14
General / FPS Stutter (Windows 10)
« on: September 05, 2016, 04:41:18 am »
Hello, I am having trouble making my game run smooth. It only runs smoothly when I don't limit the framerate. So like this:

window.setFramerateLimit(0);
window.setVerticalSyncEnabled(false);

I change any one of those then you can see some jitter. If I set the framelimit to 60 or turn vync on and display the FPS, you can see it jumping around from 20-65 and sometimes to the thousands.

With the help of jagoly in irc, we were able to implement a fixed timestep and it the stutter less noticeable. However, it is still there on my machine at least. jagoly tested it on his machine and it ran smooth for him no matter if the fps was limited or not.

Why is it not like that on mine? I'm running Windows 10 64bit with a Nvidia GTX 970. Vsync works in other applications just fine for me. Here's my code:

Game.h: https://gist.github.com/anonymous/eccb8b49d41581dcb4062d0a917aac15
Game.cpp: https://gist.github.com/anonymous/92fc02ad0e1aff55deb9682244c1f6c1
Player.h: https://gist.github.com/anonymous/40e2bf3bc4f2d812db34f2e10b8afa12
Player.cpp: https://gist.github.com/anonymous/655f2fd6f7debedfe21974ef89f97af9

Whole project if you want to run it: https://dl.dropboxusercontent.com/u/735021/FPStutter.zip

Any help would be appreciated. Thank you!

15
General / Re: Spritesheet movement update
« on: September 05, 2016, 03:37:17 am »
Thank you very much! I was able to make it walk smoothly.

Pages: [1] 2
anything