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.


Topics - Chunker120

Pages: [1]
1
General / Unresolved GLEW references when building SFGUI
« on: August 01, 2014, 07:18:52 am »
Hey, I downloaded glew, built SFML myself, tested it, and now tried to install SFGUI but I've been struggling a lot. After building with cmake, it generated the proper files, see here:



And I opened up SFGUI.sln and tried ALL_BUILD. Everything works fine, however I'm getting errors, and all of them are glew related.



What can I do? Here's my cmake configuration:




Any help would be appreciated. I'm on windows 8.1 x64, built SFML myself, nothing is precompiled

2
Graphics / What is faster: using a sprite or some shapes?
« on: September 26, 2013, 07:40:45 am »
I'm working on a GUI system, and I want to add a button for example, and the button looks like a rectangle with 3 lines on it. It can be either made as a sprite or some shapes. Which one would be optimal to use?

3
General / SFML inheritance and sf::Drawable
« on: September 14, 2013, 09:08:24 pm »
I have 3 simple classes.

class Element : public sf::Drawable
{
     private:
                ....

    public:
         virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {}
};

class Button : public gui::Button
{
    public:
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
        {
              switch(type)
                {
                        case ButtonType::TextOnly:
                                if(displayBody)
                                        target.draw(body);

                                target.draw(text);
                                break;

                        case ButtonType::IconOnly:
                                if(displayBody)
                                        target.draw(body);

                                target.draw(icon);
                                break;

                        case ButtonType::IconText:
                                if(displayBody)
                                        target.draw(body);

                                target.draw(text);
                                target.draw(icon);
                                break;
                }
        }
};

class UserInterface : public sf::Drawable
        {
                private:
                        std::map<std::string, Element> components;

                public:
                        UserInterface();

                        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
                        void add(std::string name, Element element);

                        std::map<std::string, Element> getList() { return components; }
                        std::vector<Element> etc;
        };

and this is the draw function in UserInterface:
void gui::UserInterface::draw(sf::RenderTarget& target, sf::RenderStates states) const
        {
                for (auto && iter : components)
                {
                        target.draw(iter.second);
                }
        }

What this should do is simple, it creates a container class called UserInterface, to which you can add any class that inherits from Element. Every class that inherits from the base class Element has a different overriden draw() function.

The problem is, this doesn't work. It successfully adds new classes to the container, however the draw() function doesn't work. It should be as simple as:

Button button(etc);
UserInterface UI;

UI.add(button);

...

window.draw(UI);

4
General / Getting random lines rendered in VertexArray - SFML bug?
« on: June 24, 2013, 05:40:07 pm »
I'm making a game in SFML 2.0 (I built the source myself) with Visual Studio 2012. I made a map system with vertexArrays, and it works nicely, everything is perfect in the game except a detail.

When walking around the map, I see some lines being displayed randomly for a very short amount of time, in random places, like a stuttering graphical bug. My friend said he also experienced this with his game so it made me think it's a SFML bug rather than a coding bug. Here's a screenshot bellow, you can see the line, it randomly appeared when I took the picture. Also in this picture I zoomed in the in-game camera.

5
I have a big game written in SFML, and a problem that has been occuring is that the game takes a while to show up on the windows taskbar, and if I do the following steps, I can't switch windows anymore, it's like a constant window lag, even though the game runs at 65 FPS:
step1: Open the game, icon shows up after 8 seconds
step2: click on another windows icon on the start bar
step 3: click on the game icon again
step4: Now I can't click another icon again, I can alt+tab out of the game, though it will sometimes crash and call abort()

I'm not sure what code to show because I'm not sure what can cause this. It's been happening for a while but I thought it was just my computer (it isn't)

Additional details

  • I built SFML myself, I didn't mix up debug and release.
  • I'm using Windows 7 32-bit, AMD Athlon 64 processor 3000+
  • I'm using Visual Studio 2012 as the IDE
  • It could possibly be an operating system error, a friend of mine that is using windows 8 has said that the game has no problem with switching windows, but a friend that uses the exact same version of windows like me has reported this issue.
  • I am using a thread.
  • The sf::RenderWindow is not global

Again, I'm sorry about no code, it's a general question, and I don't really know which part of the code to show, I have about 20 files of game engine, and no idea what could be causing this. However, my speculations are that the thread is causing this. I am using a sf::Thread to load resources during a loading screen, and I don't terminate it.

6
General / Can't figure out how to work with std::thread and SFML
« on: May 30, 2013, 07:14:13 pm »
In a previous thread I asked for some help and was told to use std::thread.

I basically declared a function:

void initialize(sf::RenderWindow &winMain);

...

int main()
{
    sf::RenderWindow winMain;
    std::thread loadingThread(initialize, winMain);
 
     ...
 
     loadingThread.join();
}

But it doesn't work. I just want it to run a thread with a function that needs my renderwindow passed as a paramater to it. The error:

Error   1   error C2661: 'std::thread::thread' : no overloaded function takes 2 arguments

What could I be doing wrong? I'm just confused. I'm sorry I couldn't show the full source code, but it would just confuse you further.

If something is fundamentally wrong, please tell me, how would I make a thread that uses a function declared in the same file which has a pointer paramater?

7
Let's say I have a class called Game, and a public method that looks like this:

void Game::initialize(sf::RenderWindow &winMain);

How would I go about creating a thread that uses this function? I tried these but it didn't work:

sf::Thread loadingThread(&Game::loadWorld, &myGame, winMain);
sf::Thread loadingThread(std::bind(&Game::loadWorld, winMain), &myGame);

8
I am making a game, and I noticed that it has some weird issues. For example, when I switch to the game window I can't switch to another window, almost as if it's stuck (The game is running smooth though). And sometimes, when using ALT+TAB to switch betwen windows, the game crashes and says abort() was called.

In another linux thread I heard that using a global sf::RenderWindow is very bad, and I wanted to fix it however I have been using this as a design choice for a while. Here's how my code is currently structured:

I declare a render window in main.cpp and wherever I need it I just call extern MyWindow and use the render window rather than using it as a function argument, mostly because it looks cleaner.

Is there a simpler way to fix this flaw? Is it the real cause of my problem?

9
General / SFML how to handle large spritesheets?
« on: May 18, 2013, 03:00:56 pm »
I am working on a basic game with NPCs, and each NPC has a resolution of 120x1030, it holds all animations in a single file. Each animation has 4 frames and I just add them under each other.

The problem is, I have noticed some small performance drops (Got a pretty weak computer) when trying to use sprites with the spritesheet (I have a sf::IntRect set up, so it only displays a portion of the sprite).

Is the small performance drop because of the large spritesheets? If so, can I do anything to optimize it? (Putting them outside the spritesheet is not an option because I need a lot of different humans)

10
General / How to flip sprite horizontal?
« on: May 12, 2013, 04:44:07 pm »
I have an animation in a top-down perspective, but I want the sprite to get flipped horizontal if the player faces east. The sprite class doesn't by default have any methods that would help me achieve that, so how would I go around flipping a sprite horizontally?

11
I've built SFML myself using the latest snapshot, everything works fine, however I noticed that there's no longer a convertCoords option, and instead there are some mapCoordinatesToPixels method and another one, every source tells me to use convertcoords which no longer exists, the tutorials should really be updated but what I'm really here for is to find out how to actually convert coords in the latest snapshot?

All I want is to render a camera and a sprite, and I don't want the sprite to move with the camera. Here's my code:

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow winMain(sf::VideoMode(500, 500, 32), "Title");
        sf::View camera = winMain.getDefaultView();
        sf::Event mainEvent;

        sf::Texture logo_tex;
        logo_tex.loadFromFile("textlogo.png");
        sf::Sprite logo_spr(logo_tex);
        logo_spr.setPosition(350, 350);

        winMain.setView(camera);

        while(winMain.isOpen())
        {
                winMain.mapPixelToCoords(logo_spr.getPosition());

                while(winMain.pollEvent(mainEvent))
                {
                        if(mainEvent.type == sf::Event::Closed)
                                winMain.close();

                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) camera.move(1, 0);
                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) camera.move(-1, 0);
                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) camera.move(0, -1);
                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) camera.move(0, 1);
                }

                winMain.clear();
                winMain.draw(logo_spr);
                winMain.display();
        }
}

However I'm getting an error when trying to convert the coords, it tells me the paramater is vector2f and not vector2i.

Any ideas?

12
General / How to calculate FPS in SFML 2.0?
« on: October 07, 2012, 03:21:47 pm »
This is a question that's been bugging me for ages. When I try to measure time I get weird numbers such as 12e10 or something similar.

Can anyone explain how FPS is calculated in SFML 2.0?

Pages: [1]