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

Pages: 1 2 [3] 4 5 ... 10
31
Window / Re: Best Game Loop for an Input Manager
« on: January 19, 2013, 07:53:23 pm »
You only keep track of the last event that was processed, so for isKeyPressed to return true, that would have to be last event processed, which is.. unlikely.

I wouldn't expect a function named isKeyPressed to use events.

32
SFML projects / Re: Game Development Design articles
« on: January 19, 2013, 07:44:26 pm »
It's not exactly an implementation, but Game Programming Patterns does a pretty good job of illustrating the component pattern with a realistic example using C++ code.

33
General / Re: What is wrong with this code?
« on: January 15, 2013, 04:50:59 am »
1.6 Shape::Rectangle Documentation

Note what the third and fourth parameter are.


34
Window / Re: Help with mouse clicks?
« on: January 13, 2013, 12:12:37 am »

35
Feature requests / Re: sf::Sprite::FlipX/Y
« on: January 12, 2013, 01:37:53 am »
Quote
That really made things SIMPLE as SFML is supposed to be and I think that made the Sprite class so freaking sexy.

void flipX(sf::Sprite & s )
{
    auto rect= s.getTextureRect() ;

    rect.left += rect.width ;
    rect.width = -rect.width ;

    s.setTextureRect(rect) ;
}

void flipY(sf::Sprite& s)
{
    auto rect = s.getTextureRect() ;

    rect.top += rect.height ;
    rect.height = -rect.height ;

    s.setTextureRect(rect) ;
}

There.  It's all sexy again.

36
Graphics / Re: Controlling Game Speed on Different Computers
« on: January 11, 2013, 06:35:34 am »
There is a lot of information about this out in internet lands.  I would suggest using google as it has little to do with SFML.

37
Graphics / Re: "Internal OpenGL call" help
« on: January 10, 2013, 06:52:02 pm »
Quote
what do I put in it to de-allocate the textures and sprites so I don't cause memory leaks?
You may want to read a basic C++ book and also do a search for RAII, and read the documentation for SFML.

int main()
{
    // ...

    {
        sf::Texture t ;
        t.loadFromFile(/**/) ;     // resource is loaded.
        // ...
    }                                        // resource is freed.

    {
         sf::Texture * t = new sf::Texture ;
         t->loadFromFile( /**/ ) ;   // resource is loaded.
         // ...
         delete t ;                          // resource is freed.
    }

    {
         std::unique_ptr<sf::Texture> t = new sf::Texture ;
         t->loadFromFile( /**/ ) ;     // resource is loaded.
         // ...
    }                                             // resource is freed.
}

[Edit:  Oops.  Missed the cpp tag somehow.]

38
General / Re: Strangest sf::sleep bug
« on: January 10, 2013, 09:07:48 am »
I believe it has to do with the granularity of sf::sleep on your system.  (Mine behaves in a similar way.)

On my system, the granularity of sleep is about 14ms.  1/60 is about 16ms, so depending on the timing sleeping for 1/60 of a second can sleep for ~2 ~2/60 seconds, which leads to an average of a little over 30 fps.   If I sleep for 1/120 of a second, I get a little over 60 fps, and as expected, if I sleep for 1/240th of a second, I also get a little over 60 fps.


39
Graphics / Re: Can't Create sf::Text Object
« on: January 07, 2013, 12:12:34 am »
Quote
So I guess my graphics card only supports OpenGL 1.1 and windows says that my driver for it is up to date.

I'd go to the manufacturer's website and update.  Windows is notorious for not updating card drivers.  I believe the "Microsoft" in "ATI Radeon HD 3200 Graphics (Microsoft Corperation - WDDM v1.1)" may indicate you're using a Microsoft driver and not one from the manufacturer.  So, did Microsoft misspell "corporation" or did you?   :)

40
#include <SFML/Graphics.hpp>

template <typename T>
void setSize(T& obj, float width, float height )
{
    obj.setSize( sf::Vector2f( width, height ) ) ;
}

// Or use a typedef to lessen the visible impact
typedef sf::Vector2f v2f ;

int main()
{
    sf::RectangleShape rect ;
    setSize(rect, 100.0f, 200.0f) ;

    rect.setSize(v2f(100.0f, 200.0f)) ;
}

41
Graphics / Re: Switching in between backgrounds
« on: January 06, 2013, 06:36:03 pm »
Why are backgroundNum and randBackgroundNum members of BackgroundManager?

Why is createBackground static?

Why are you using an init function instead of initializing things in the constructor?

Why are you using a unique_pointer+dynamic memory instead of an actual Background object?

Why does switchBackground block the entire program for 5 seconds while it repeatedly draws the same sprite to the window (which is probably enough for the O/S to flag your program as unresponsive if you're on Windows?)






42
Graphics / Re: Texture size when drawing
« on: January 05, 2013, 11:57:30 am »
    /// \brief Construct a new window
    ///
    /// This constructor creates the window with the size and pixel
    /// depth defined in \a mode.

It's not exactly crystal clear.

43
Graphics / Re: Question About GL States
« on: January 01, 2013, 11:26:20 pm »
Try this:

#include <SFML/Graphics.hpp>

int main() {

        //Render window
    sf::RenderWindow  window( sf::VideoMode( 800, 600, 32 ), "GL States Issue" );

        //Multisampler textures
        sf::Texture prime1Tex;
        sf::Texture prime2Tex;
        sf::Texture prime3Tex;
        prime1Tex.loadFromFile("prime1.png");
        prime2Tex.loadFromFile("prime2.png");
        prime3Tex.loadFromFile("prime3.png");

    prime1Tex.setRepeated(true) ;
    prime2Tex.setRepeated(true) ;
    prime3Tex.setRepeated(true) ;

    prime1Tex.setSmooth(true) ;
    prime2Tex.setSmooth(true) ;
    prime3Tex.setSmooth(true) ;

        //Mutlisample shader - Samples from 3 repeating prime textures to significantly reduce tiling patterns
        sf::Shader multisamplerShader;
        multisamplerShader.loadFromFile("multisampler.sfx", sf::Shader::Fragment);

    multisamplerShader.setParameter("prime1Tex", prime1Tex);//sf::Shader::CurrentTexture);
    multisamplerShader.setParameter("prime2Tex", prime2Tex);
    multisamplerShader.setParameter("prime3Tex", prime3Tex);

    multisamplerShader.setParameter("screenSize", sf::Vector2f(800,600)) ;

        //Random extra sprite to draw
    sf::Sprite proj;
        sf::Texture projTex;
        projTex.loadFromFile("randomsprite.png");
        proj.setTexture(projTex);

        //Vertex array storing tile data.
        sf::VertexArray tileDetails;
        tileDetails.setPrimitiveType(sf::Triangles);
        tileDetails.append(sf::Vertex(sf::Vector2f(20.0f, 20.0f), sf::Vector2f(20.0f,20.0f)));
        tileDetails.append(sf::Vertex(sf::Vector2f(20.0f, 500.0f), sf::Vector2f(20.0f,500.0f)));
        tileDetails.append(sf::Vertex(sf::Vector2f(500.0f, 500.0f), sf::Vector2f(500.0f,500.0f)));

        bool run = true;
        while(run)
        {
                window.clear(sf::Color::Cyan);

        window.draw(proj);
                window.draw(tileDetails, &multisamplerShader);
       
                window.display();
               
                sf::Event Event ;      
                while (window.pollEvent(Event))
                {
                        if ((Event.type == sf::Event::KeyPressed && (Event.key.code == sf::Keyboard::Escape)))  {run = false; }
                }
        }
}

With the shader changed to:
uniform sampler2D prime1Tex;
uniform sampler2D prime2Tex;
uniform sampler2D prime3Tex;

uniform vec2 screenSize ;

void main()
{
        // normalized screen coordinates.
        vec2 pixelPos = gl_FragCoord.xy / screenSize ;
               
        //Get the pixel data from each texture
        vec4 prime1Fragment = texture2D(prime1Tex, pixelPos);
        vec4 prime2Fragment = texture2D(prime2Tex, pixelPos);
        vec4 prime3Fragment = texture2D(prime3Tex, pixelPos);
       
        //Combine them together
        vec4 finalFragment = prime1Fragment * 0.33 + prime2Fragment * 0.33 + prime3Fragment * 0.33;    
        finalFragment.a = 1.0;
               
        gl_FragColor = finalFragment;
}

The texture coordinates in gl_TextCoord in a fragment shader are normalized.   I think the "correct" way to do this would probably involve a vertex shader, but the results looked reasonable to me.

44
General discussions / Re: SFML 2 and Qt5 on Windows
« on: December 30, 2012, 01:13:04 pm »
And, from the link you posted...

Quote
On the other hand if your application requires full desktop OpenGL, then it’s simply a matter of configuring Qt with “-opengl desktop” and you get the same behavior as before.

45
Graphics / Re: sf::Text not appearing on the screen
« on: December 30, 2012, 04:51:55 am »
I don't see where you associate your text with a font.

Pages: 1 2 [3] 4 5 ... 10
anything