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

Pages: [1]
1
General / Re: Implement Timestep and Gravity
« on: April 18, 2013, 04:36:03 am »
To make your movement less choppy, look into http://en.wikipedia.org/wiki/Delta_timing

2
General / Re: Compiling / Linking SFML 2.0 VS2012
« on: November 17, 2012, 04:22:46 pm »
Right; which is what I'd expect as well.

Turns out I was also linking to a dynamic build of SFML-GUI, and I forgot that was a dynamic link; so it still relied on the SFML dlls even though I linked SFML as a static build ;).

Works fine now, just forgot I was linking to that other project..

3
General / Re: Compiling / Linking SFML 2.0 VS2012
« on: November 17, 2012, 04:10:05 pm »
sfml-graphics-2.dll

Is the first one that the program states and then ends. However, I imagine that it is also missing the system, window and main dlls as I link to all of those.

I've tried running it from both the file explorer and the IDE.

4
General / Compiling / Linking SFML 2.0 VS2012
« on: November 17, 2012, 04:00:41 pm »
Hi,

I've been trying to link SFML 2.0 statically to my VS2012 Professional project now for a while, yet keep on running into the same issue.

I began by downloading the latest tarball of the nightly build for SFML 2.0. Through the VS2012 command prompt, I ran the following cmake command, to generate the configuration file for nmake:
Code: [Select]
c:\sfml2>cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=FALSE -D STATIC_STD_LIBS=TRUE -D SFML_STATIC=TRUE c:/sfml2

I'm sure some of the flags there are not needed for static compilation anyways, but that's not the case.
After the configuration file is generated, I run nmake, and the static -s libs are produced as expected. I then add these to my C++ project, link to the appropriate -s and -s-d for the Release/Debug builds respectively, and my project compiles.

However, when I try and run my program, it complains about the DLLs not being in the runtime folder...
I have defined the SFML_STATIC macro in my project properties, am linking to the right libraries, have the appropriate include files. I've tried cleaning my project and rebuilding many times, even changing the Code Generation Runtime Library settings.

I even had a friend compile the source on his computer, and I still receive the same error (same VS 2011 compiler).

I could link just fine to the dynamic libraries..
Any help would be greatly appreciated!
Thanks.

5
I can confirm it does work on Professional as I am a student as well and have compiled 2.0 RC just fine, but I do find it odd that it wouldn't work on Express 2012.

Like Mario said, I thought it was the same compiler and linker for both versions and only the IDE was different.. Guess not..

6
Graphics / Re: Drawing Text
« on: October 29, 2012, 01:04:30 am »
Somehow didn't catch that I omitted setting the color in the second snip..

Thanks, works now!

7
Graphics / Re: Drawing Text
« on: October 28, 2012, 10:39:23 pm »
void Render::createWindow(unsigned int w, unsigned int h, string title) {
        //Create new rendering window
        width = w;
        height = h;

        window.create(sf::VideoMode(width, height, 32), title, sf::Style::Close);
        window.setFramerateLimit(60);
        font.loadFromFile("resources/arial.ttf");
}

void Render::render() {
        //Render
        window.clear(sf::Color::White);
        sf::Text text;
        text.setString("Hello");
        text.setFont(font);
        text.setCharacterSize(50.f);
        text.setPosition(10.f, 10.f);
        window.draw(text);
        window.display();
}
 

And my main game loop:
Render::createWindow(800, 600, "Caption");

        while(Render::window.isOpen()) {
                currentTime = clock->restart().asSeconds();
                fps = 1.f / currentTime;

                //Event polling
                sf::Event event;
                while (Render::window.pollEvent(event)) {
                        if(event.type == sf::Event::Closed) {
                                Render::window.close();
                        }
                }

                lastTime = currentTime;

                Render::render();
        }
 

Thanks again.

8
Graphics / Re: Drawing Text
« on: October 28, 2012, 04:17:21 pm »
I do clear the window every frame as my last two code exerts show ;).

9
Graphics / Re: Drawing Text
« on: October 28, 2012, 04:09:04 pm »
Thanks for that.

However, I now use the following code, yet it still only displays a white screen:
        window.clear(sf::Color::White);
        sf::Text text;
        text.setString("Hello");
        text.setFont(font);
        text.setCharacterSize(50.f);
        window.draw(text);
        window.display();
 

(I have also tried setting the position of the font to see if that was it; alas it wasn't)

After loading the font in the game's beginning:
font.loadFromFile("resources/arial.ttf");
 

The font face loads fine as no warnings are displayed in the game's console.

10
Graphics / Drawing Text [Solved]
« on: October 28, 2012, 03:27:18 pm »
I'm relatively new to SFML and I've been going through the 2.0 documentation for the past couple of days. That being said, I've been trying to unsuccessfully render text to my renderWindow, which I create as follows:

        window.create(sf::VideoMode(width, height, 32), title, sf::Style::Close);
        window.setFramerateLimit(60);
 

This works fine as a window is rendered.

Then, for debug purposes I attempt to draw text while the window is open with:
        window.clear(sf::Color::White);
        sf::Text text;
        text.setString("TTT");
        text.setCharacterSize(12);
        text.setColor(sf::Color::Black);
        text.setPosition(10, 10);
        window.draw(text);
        window.display();
 

The code compiles fine, however I just get a white window with no text. I have successfully linked to the graphics and window package for SFML 2.0.

Thanks in advance.

11
General / Re: Framerate Issues
« on: May 03, 2012, 12:59:43 am »
Thanks! That proved to work just fine!

12
General / Re: Framerate Issues
« on: April 30, 2012, 11:31:54 pm »
 for (unsigned int i = 0; i < 3702; i++)

3702 tiles are not a trivial task to draw and this for every frame.
I'm not sure if you're moving your tiles inbetween. If you don't, I'd suggest you render all your tiles onto a sf::RenderTexture and then just extract that texture. With that you only have to make once those 3702 draw calls and afterwards just draw the extracted texture with one call.

The other way would be to use sf::VertexArray and map your tile textures onto the vertices. With that you'll also only have to make one draw call and you'll gain much performance.

Thanks for the reply. It did turn out it was a bad idea to render all those in every step. The FPS is hovering around 60 now. However, now I have a slight question with regard to rendering on the texture. Would it be done like this:

                tileData[i]->rect.setSize(sf::Vector2f(16, 16));
                tileData[i]->rect.setOutlineThickness(1);
                tileData[i]->rect.setOutlineColor(sf::Color::Black);
                tileData[i]->rect.setPosition(sf::Vector2f(tileData[i]->x, tileData[i]->y));

                //Reset texture
                worldTexture.draw(tileData[i]->rect);
 

And then in the Render::render() script execute:
worldTexture.display();
 

?
I'm not terribly familiar with the sf::RenderTexture class and the SFML 2.0 documentation isn't exactly thorough in how to address this (at least not in the documentation I've had access to).

13
General / Re: Framerate Issues
« on: April 29, 2012, 06:53:26 pm »
Thanks for the replies.

I forgot to reset the clock after the end of the game loop, which I now do.
Further, I fixed the FPS calculation, yet now my FPS is hovering around 1.7648.

void Render::render() {
        if(!Game::closing && Render::window.isOpen()) {
                window.clear();

                //Draw all terrain
                Terrain::render();

                if(Control::renderCursor) {
                        window.draw(Control::rect);
                }
                window.display();
        }
}
 

That is the only drawing code present. Terrain::render() simply loops through all block instances:

void Terrain::render() {
        //Render whole terrain
        int slot = 0;
        int line = 0;

        for (unsigned int i = 0; i < 3702; i++) {
                tileData[i].draw(slot*16,line*16);
               
                //Counter
                slot++;

                //Reset row count
                if (slot == 64) {
                        slot = 0;
                        line++;
                }
        }
}
 


With this being defined as block::draw(int xx, int yy) :

void block::draw(int xx, int yy) {
        //Draw this block

        if(!Game::closing) {
                sf::RectangleShape rect;
                rect.setSize(sf::Vector2f(16, 16));

                if(type) {
                        rect.setFillColor(sf::Color::Black);
                } else {
                        rect.setFillColor(sf::Color::White);
                        /*
                        sf::Text text;
                        text.setString(tileNumber);
                        text.setCharacterSize(12);
                        text.setPosition(xx, yy);
                        text.setColor(sf::Color::Black);
                        Render::window.draw(text);
                        */

                }

                rect.setOutlineThickness(1);
                rect.setOutlineColor(sf::Color::Black);
                rect.setPosition(sf::Vector2f(xx, yy));

                Render::window.draw(rect);
        }
}
 

And yes, I do realize that I shouldn't be defining the rect parameters in a draw event (redundant+unnecessary).

I also thought that when you set the FPS limit with SFML, it would auto sleep and I wouldn't need to call the Sleep() function manually, however that is obviously not the case here.

Thanks again.

14
General / Framerate Issues
« on: April 29, 2012, 03:05:48 am »
Hello,

When I make a new window, I define it as follows (I am using SFML 2.0):
void Render::createWindow(unsigned int w, unsigned int h) {
        //Constructor
        width = w;
        height = h;
        window.create(sf::VideoMode(width, height), "Smart Traffic Simulation", sf::Style::Close);

        window.setVerticalSyncEnabled(true); //Tried leaving it to default false as well
        window.setFramerateLimit(60);
}
 

window being a static member of Render:: defined elsewhere in the render.cpp file.

The above function should limit the framerate to about 60 with auto Sleep() function calls, give or take Window's 16ms discrepancies. However, when I measure framerate in the Game's main loop:

float fps = 1000.f / (float)Clock.getElapsedTime().asSeconds();
 
Clock being defined as: sf::Clock Clock;

I get very high numbers, sub 1000. Further, 25% of my CPU is used, and the application window (SFML generated one) lags incredibly (not c++ console however).

Is this a slight bug in SFML 2.0? I have an Intel Quad-Core CPU.

Thanks.

Pages: [1]