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

Pages: [1]
1
General / Detecting Memory Leaks
« on: December 25, 2010, 04:56:18 pm »
When you click on the titlebar with the mouse the OS don't let you draw anything on the window. So you program is in pause. When you stop moving the window, the program continue.
If your program was in pause for 3 second, GetFrameTime() will give you more than 3 second... That's normal.

If you don't want to use getFrameTime() you can use a fixed framerate

2
General / Cross-platform solution to disabling console output window
« on: December 19, 2010, 05:40:10 pm »
Do you compile in debug or release?

To redirect the console output to a file.. You can do something like that:
Code: [Select]
int main()
{


std::ofstream error_file; //File
std::streambuf *cout_buffer = std::cout.rdbuf() ; //Initial buffer of cout
error_file.open("log erreur.txt", std::ofstream::out); //Open file
std::cout.rdbuf( error_file.rdbuf() ); //Change the cout buffer


    //Code here

// Stop using the file
std::cout.rdbuf( cout_buffer );
error_file.close();


    return 0;
}

3
Graphics / Bug with local sf::Image declarations?
« on: December 18, 2010, 07:43:03 pm »
The address can be used again... If the texture is not the same.

Normally you declare your image before the loop so he don't have problem.

4
Graphics / Drawing variables
« on: December 14, 2010, 06:21:21 pm »
You can display text on the screen with sf::String (sf::Text in SFML 2.0)

I suggest you to read the tuto:
http://www.sfml-dev.org/tutorials/1.6/graphics-fonts-fr.php

To display variable like a float it's the same thing but you have to convert your number into string before.

For this he have more than one method.
You can read that : How to convert a numeric type to a string?

Laurent also give an example of a converter somewhere on the forum...

[Edit] I find it :
Code: [Select]
namespace Converter
{
    template <typename T>
    std::string ToString(const T& i)
    {
        std::ostringstream stream;
        stream << i;
        return stream.str();
    }

    template <typename T>
    T FromString(const std::string& str)
    {
        std::istringstream stream(str);
        T tmp;
        stream >> tmp;
       
        return tmp;
    }
}

5
Graphics / Drawing variables
« on: December 14, 2010, 05:39:51 pm »
In the console or on a sf::RenderWindow?

6
System / Odd behaviour of thread
« on: December 13, 2010, 03:08:23 pm »
Quote
void CreateThread()
{
    TestThread thread;
    thread.Launch();
}

thread is destroy at the end of the CreateThread function so he don't have enough time to start.

If you do :
Code: [Select]
void CreateThread()
{
    TestThread *thread = new TestThread();
    thread->Launch();
}

It suppose to work but how you will delete the thread?

7
Window / Event Polling not working
« on: December 08, 2010, 01:10:53 am »
I think your problem is normal...
Quote
This event system is good enough for reacting to events like window closing, or a single key press. But if you want to handle, for example, the continous motion of a character when you press an arrow key, then you will soon see that there is a problem : there will be a delay between each movement, the delay defined by the operating system when you keep on pressing a key.


For your utilization you have to use sf::Input

An example:
Code: [Select]
   while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

        if (App.GetInput().IsKeyDown(sf::Key::Left))
        {
            //do something
        }
        if (App.GetInput().IsKeyDown(sf::Key::S))
        {
            //Do something else
        }


You can also look in the tutorial : Handling events

8
Window / Event Polling not working
« on: December 07, 2010, 11:40:26 pm »
When you said you have to wait before the program detect your key again... You pressed the button,release,pressed,release etc... or you keep the button pressed?

9
Window / [MAC OS X-SFML2] No mouse moved events while pressing mouse
« on: December 03, 2010, 10:54:52 pm »
For me it's working... I just need to add this
Code: [Select]
#include <stdio.h>

Edit: I just see the title of the subject... I'm not working with MAC.
But the code is working on Linux and Windows

10
Window / Handling input in a state based approach
« on: December 02, 2010, 10:41:14 pm »
You have to use constant pointer or reference with sf::Input...
Code: [Select]
sf::Input* Input =  &App.GetInput() ; // Not correct
const sf::Input* Input =  &App.GetInput() ; //Correct
//or
sf::Input& Input = App.GetInput(); //Not correct
const sf::Input& Input = App.GetInput(); //Correct

Maybe it's not the problem but here :
Code: [Select]
stateManager::stateLoop(sf::Input& input)
You have to pass a constant reference:
Code: [Select]
stateManager::stateLoop(const sf::Input& input)

11
General / Need help with This constuctor
« on: December 02, 2010, 03:40:19 pm »
Do you really have a enum TileType inside your Tile class?
Code: [Select]

class Tile : public sf::Sprite
{
    public:
        enum TileType
        {
            Type1, Type2
        };

Someone know if he have a difference between
Code: [Select]
Tile(const enum TileType type, int x, int y);
//and
Tile(const TileType type, int x, int y);

It's just to remember this type is a enum?

12
General / Vector Not Allocating
« on: December 02, 2010, 03:55:07 am »
Hi,

I think this will be better :
Code: [Select]
while( ! filein.eof() )  

Pages: [1]