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

Pages: [1]
1
Graphics / Re: sf::Text Garbled When Objects are Drawn Underneath
« on: December 05, 2012, 05:32:44 am »
Hey .. thanks! Updating the drivers to the new Catalyst beta release of 12.11 worked for me.

What a strange bug ... talk about frustrating!

2
Graphics / [SOLVED]sf::Text Garbled When Objects are Drawn Underneath
« on: December 05, 2012, 05:07:11 am »
So, I looked around but couldn't find a similar thread. This may be an issue with my hardware...

OS: Windows 7
GPU: Radeon HD 5800
Static version of SFML 2.0

Description: So, as you can see from the code, I draw two Rectangle objects at 0,0. Then, I try and layer a sf::Text object on top ... this makes the text completely garbled. If I only draw ONE of those RectangleShapes, the text shows up fine, so this is only an issue when two or more RectangleShapes are drawn at this location.

You should be able to paste this code right into a main file with just the SFML library as a header.
sf::RectangleShape back;
sf::RectangleShape front;
sf::Font font;

int main()
{
        sf::RenderWindow window(sf::VideoMode(1600, 900), "Tile Game"); //Set up the main Window
        font.loadFromFile("arial.ttf");
        while(window.isOpen()){

                back.setFillColor(sf::Color::Blue);
                back.setPosition(0, 0);
                back.setSize(sf::Vector2f(400,400));
                window.draw(back); //draw one large Rectangle

                front.setFillColor(sf::Color::Red);
                front.setPosition(0, 0);
                front.setSize(sf::Vector2f(200,200));
                window.draw(front); //draw a smaller rectangle

                sf::Text text("test", font, 25);

                window.draw(text); //draw some text

                window.display();
        }
    return 0;
}
 

Notice, if you comment out one of the window.draw() from a Rectangle, the font shows up. Please see the attachment for a picture of what the font is showing up as on my screen.

[attachment deleted by admin]

3
Graphics / Re: sf::Texture out of scope?
« on: November 28, 2012, 04:09:48 am »
Exploiter, I had an example at the top. Here's another shot at being more thorough:

EDIT: More code...

This is from Player class. units is a vector of all units a player will have.
void Player::PlayerInit(){
        Unit newUnit("Alien.png");
        units.push_back(newUnit);
}
 

Unit::Unit(string FP){
        filePath = "images/" + FP;
        if (!localTexture.loadFromFile(filePath)){
                return;}
}
 

void Unit::displaySprite(sf::RenderWindow& window){
        localSprite.setPosition(xLoc, yLoc);
        localSprite.setTexture(localTexture);
        window.draw(localSprite);
}
 

Both snippets are from the class "Unit.cpp" I know that I am using the correct class instances because xLoc and yLoc are being set correctly in another function.

Now, let me be clear - the above works, but only the FIRST time I create a new "Unit" instance. When I create more units, the picture is just ... gone. I call loadFromFile on localTexture, it does not fail, which is why it seems like something is stopping me from accessing the same resource   :-\

I am trying my best to follow the guidelines ... minimal and complete.

4
Graphics / Re: sf::Texture out of scope?
« on: November 27, 2012, 04:53:39 am »
I tinkered a little more and it looks more like I cannot use multiple class instances with the same texture ... is there a limit on accessing a resource?

5
Graphics / sf::Texture out of scope?
« on: November 22, 2012, 06:11:46 am »
Hi All,

Running into a problem with my texture, and I believe it's because the texture is going out of scope when I try and draw the sprite in another function. How do you generally get around this, as I'm sure most would want to initialize the sprite and its properties before using it later.

Here is the "initializer":
void Unit::setImage(string unitFP){
        if (!localTexture.loadFromFile(unitFP)){
                return;}
        localSprite.setTexture(localTexture); }
 

And here is the code that will determine where to draw the sprite:
void Unit::displaySprite(sf::RenderWindow& window){
        localSprite.setPosition(xLoc, yLoc);
        window.draw(localSprite); }
 

The instance is what I expect it to be, since xLoc and yLoc are set correctly, but the texture is lost and instead only a white quad is shown.

Can anyone lend a hand with their own personal ideas as to how to solve this problem? Thanks!!!

NOTE: I have declared localSprite and localTexture in the header file.

6
Graphics / Re: Help with creating a derived shape class
« on: July 05, 2012, 04:37:52 am »
I guess I could do that, although I still wish to know why I can't create my own class based on sf::shape ... in SFML 2.0 documentation it seems like they encourage the use of the ability to write your own derived shape class.

Thanks for the idea though! It will do unless I can figure out the answer to my initial question.

7
Graphics / Help with creating a derived shape class
« on: July 05, 2012, 01:15:26 am »
Hi all,

I'm trying to create my own derived shape class in order to make it easier to create hexagons. However, I'm having some trouble with the abstract class sf::Shape. Right now I have:

class Hexagon : public sf::Shape {
public:
        Hexagon(){}
        virtual ~Hexagon();
        virtual int getPointCount() {
                return 6;}
        virtual sf::Vector2f getPoint(unsigned int *index){
                //logic I haven't figured out yet, but I don't think it should matter...
        }
};

Hexagon *newhex;

newhex = new Hexagon();

Problem is, the last line is giving me two errors:

newhex error: This declaration has no storage class or type identifier
Hexagon() error: object of abstract class type "Hexagon" is not allowed.

The Hexagon() error is really confusing since I am using the abstract base sf::Shape and so Hexagon() should no longer be an abstract class. This is my first attempt at abstract base classes so I apologize if I'm doing something wrong that is very obvious.

Thanks for any help!

Pages: [1]
anything