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

Pages: [1]
1
I made this http://en.sfml-dev.org/forums/index.php?topic=9624 post with the same problem, and i have found some new things to add to this very peculiar bug.

I (almost (see Case 3)) only get the bug when drawing 2 Shapes, not with 1. The 2 Shapes yields the same result as one Shape with the setOutlineThickness(2.0f);.

If you have several Sprites with the same texture, only the first of one type of texture will not work. Thus if you try to draw 3 Sprites with Texture 1 (and some RectangleShapes or whatnot to get the bug) they will not work, but after that you can draw a Sprite with another Texture and after you have drawn that one you can draw the first Texture!

It's hard to explain in text so here is the code used and some images:
#include "stdafx.h"
#include <SFML/Graphics.hpp>

using namespace sf;

int main(){

        RenderWindow window(VideoMode(150, 140, 32), "SFML", Style::Default);
        window.setFramerateLimit(4);

        CircleShape fooShape(20.0f, 30);
        CircleShape barShape(25.0f, 30);
        fooShape.setPosition(10.0f, 10.0f);
        barShape.setPosition(70.0f, 20.0f);

        Texture aTexture1;
        aTexture1.loadFromFile("texture1.png");
        Texture aTexture2;
        aTexture2.loadFromFile("texture2.png");

        Sprite sprite1;
        sprite1.setTexture(aTexture1);
        sprite1.setPosition(15.0f, 100.0f);
        Sprite sprite2;
        sprite2.setTexture(aTexture1);
        sprite2.setPosition(40.0f, 100.0f);
        Sprite sprite3;
        sprite3.setTexture(aTexture1);
        sprite3.setPosition(65.0f, 100.0f);
        Sprite sprite4;
        sprite4.setTexture(aTexture2);
        sprite4.setPosition(90.0f, 100.0f);
        Sprite sprite5;
        sprite5.setTexture(aTexture1);
        sprite5.setPosition(115.0f, 100.0f);
        Sprite sprite6;
        sprite6.setTexture(aTexture1);
        sprite6.setPosition(40.0f, 50.0f);

        bool drawFoo = false;
        bool drawBar = false;
        bool drawOtherSprites = true;
        bool drawTexture2 = true;
        bool drawMiddle = false;

        while(window.isOpen()){
                Event Event;
                while(window.pollEvent(Event)){
                        if(Event.type == Event.KeyPressed){
                                if(Event.key.code == Keyboard::U){/*Choose if drawing first shape*/
                                        if(drawFoo) drawFoo = false;
                                        else        drawFoo = true;
                                }else if(Event.key.code == Keyboard::I){/*Choose if drawing second shape*/
                                        if(drawBar) drawBar = false;
                                        else        drawBar = true;
                                }else if(Event.key.code == Keyboard::O){/*Choose if drawing other sprites than the first and the middle-Sprite*/
                                        if(drawOtherSprites)    drawOtherSprites = false;
                                        else                    drawOtherSprites = true;
                                }else if(Event.key.code == Keyboard::P){/*Choose if drawing Sprite with texture2*/
                                        if(drawTexture2)        drawTexture2 = false;
                                        else                    drawTexture2 = true;
                                }else if(Event.key.code == Keyboard::L){/*Choose if drawing texture1 Sprite between drawing of shapes*/
                                        if(drawMiddle)  drawMiddle = false;
                                        else            drawMiddle = true;
                                }
                        }
                }      
                window.clear(Color(200, 100, 40));
                if(drawFoo)
                        window.draw(fooShape);
                if(drawMiddle)
                        window.draw(sprite6);
                if(drawBar)
                        window.draw(barShape);

                window.draw(sprite1);
                if(drawOtherSprites){
                        window.draw(sprite2);
                        window.draw(sprite3);
                        if(drawTexture2)
                                window.draw(sprite4);
                        window.draw(sprite5);
                }
                window.display();
        }
        return EXIT_SUCCESS;
}
(I'm using Visual C++ 2010 Express, a XFX Radeon 5750 graphics card and i updated to the latest SFML 2.0 build today)

Case 1.

All Sprites.                        Only the first few are affected. When not drawing second textured sprite, all are affected.


Case 2.
I also noticed a difference when i have transparency in my Textures:

Exactly the same as before but with transparency instead of white background.

As seen the partially transparent Textures will not draw anything at all instead of a white box.


Case 3.
Also, when drawing only the first Sprite, it will be affected by the bug after one of the Shapes have been set to not drawing, furthermore if i then start drawing the other Sprites it will take exactly 1 frame to update and show all the Textures correctly:

Bug.                                 Still Bug.                           This will show for exactly one frame and then revert to this.

This is the reason of window.setFramerateLimit(4); in the code, because it will not be noticeable with a framerate of 60 or even 10.


Case 4.
As you said in the posts before, after a Shape has been drawn, the Sprites after that one will not work, in my case, after 2 shapes, and if i draw one Sprite of texture1.png, between those two Shapes, everything will render normally, except if i remove the middle Sprite and then draw it again, it will produce something like in Case 3.

This is way too much info, but if any one can get something out of this I'm happy to help!

2
Graphics / Re: Sprite not showing when Shape are being drawn, SFML 2.0
« on: November 07, 2012, 01:30:49 am »
Appears to be the same issue as http://en.sfml-dev.org/forums/index.php?topic=9561.0

Yes I saw that post but i only read the first page, it seems they discovered the problem with Sprite aswell, sorry for making the post, will report my new findings in that thread instead.

3
Graphics / Re: Sprite not showing when Shape are being drawn, SFML 2.0
« on: November 06, 2012, 08:05:45 pm »
What build of SFML are you using? How old is it, because I notice the case is not correct.

window.SetFramerateLimit(1);

is now:

window.setFramerateLimit(1);

...and many other things. So I guess you are using an old version?

Correct, I was using an old version of SFML 2.0 and have now updated my library and changed the code accordingly, but the program behaves exactly the same...

Did you try my code, and if so, is it working like it should?

4
Graphics / Sprite not showing when Shape are being drawn, SFML 2.0
« on: November 06, 2012, 04:21:21 pm »
I have a Texture which i load to a Sprite and i have 2 Shapes (In the attached code CircleShape but RectangleShape will result in the same error) and when i draw those 2 the sprite will show only the first frame. After the first frame the sprite will not be drawn any more. If i draw only one, the sprite will be drawn. If i draw two Shapes and then remove one of them to only draw one of them, the Sprite will not draw.

The code has some basic movement on the sprite and control of drawing the 2 Shapes or not to demonstrate the dissapearance of the sprite. Frameratelimit is set to 1 to show the first frame clearly. There is need for a "texture.png" to draw the sprite:
#include "stdafx.h"
#include <SFML/Graphics.hpp>

using namespace sf;

int main(){

    RenderWindow window(VideoMode(1400, 800, 32), "SFML FTW", Style::Default);
    window.setFramerateLimit(1);

    CircleShape fooShape(150.0f, 50);
    CircleShape barShape(50.0f, 30);
    fooShape.setPosition(100.0f, 100.0f);
    barShape.setPosition(0.0f, 0.0f);
   
    Texture aTexture;
    aTexture.loadFromFile("texture.png");
    Sprite aSprite;
    aSprite.setTexture(aTexture);
    aSprite.setPosition(1000.0f, 600.0f);

    bool drawFoo = false;
    bool drawBar = false;

    while(window.isOpen()){
        Event Event;
        while(window.pollEvent(Event)){
            if(Event.type == Event.KeyPressed){
                if(Event.key.code == Keyboard::A){
                    aSprite.move(-20.0f, 0.0f);
                }else if(Event.key.code == Keyboard::D){
                    aSprite.move(20.0f, 0.0f);      
                }else if(Event.key.code == Keyboard::W){
                    aSprite.move(0.0f, -20.0f);    
                }else if(Event.key.code == Keyboard::S){
                    aSprite.move(0.0f, 20.0f);      
                }else if(Event.key.code == Keyboard::O){
                    if(drawFoo) drawFoo = false;
                    else        drawFoo = true;
                }else if(Event.key.code == Keyboard::P){
                    if(drawBar) drawBar = false;
                    else        drawBar = true;
                }
            }
        }      
        window.clear(Color(200, 100, 40));
        if(drawFoo)
            window.draw(fooShape);
        if(drawBar)
            window.draw(barShape);
        window.draw(aSprite);
        window.display();
    }
    return EXIT_SUCCESS;
}

I'm using SFML 2.0, Visual C++ 2010 Express and my graphics card is a XFX Radeon 5750

EDIT: Updated the code according to the new build of SFML 2.0

Pages: [1]
anything