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

Pages: [1]
1
Graphics / Re: [Solved] Drawing a 2D Pixel matrix
« on: January 28, 2013, 09:51:40 pm »
Quote
Can you be a little more descriptive?  Works fine for me.

Before posting this I checked the forum looking for posts with problems like mine, but I couldn't find any. Just after posting it I found some people that were having issues drawing sprites combined with other objects on computers using ATI cards. They solved it updating the Graphic drivers.
I updated my drivers and tachaaaaan it works now.

I'm sorry.

Quote
Here's a bit a nicer code (as long as your compiler supports std::vector::data()):

Oh, thanks! I didn't think about it.

And once again, sorry. I think updating your graphic drivers is the first think you do when something doesn't work.

2
Graphics / Re: Drawing a 2D Pixel matrix
« on: January 28, 2013, 09:04:56 pm »
Hi, it's me again.

My previous problem was solved, but I continued my project, I found another problem and I can't find any solution.

The question is, I want to draw my pixel matrix and then over this drawing I want to draw some objects (sprites). But that doens't seem to work.
I made another minimal example to show what I mean:

int main() {
        const int H = 500;
        const int W = 1000;

        sf::RenderTexture RT;
        RT.create(W, H);

        sf::RenderWindow window(sf::VideoMode(W, H, 32), "Test");

        //Creates the sf::Vertex matrix
        sf::Vertex **pixMat = new sf::Vertex*[H];
        for (int i=0;i<H;++i)
                pixMat[i] = new sf::Vertex[W];

        //Fills the matrix with blue pixels
        for (int i=0;i<H;++i) {
                for (int j=0;j<W;++j)
                        pixMat[i][j] = sf::Vertex(sf::Vector2f(j+.5f, i+.5f), sf::Color::Blue);
        }

        //Loads the texture and creates the sf::Sprite we want to draw
        sf::Texture tex;
        tex.loadFromFile("pleasedosomequickdrawonpaint.png");
        sf::Sprite whatever(tex);
        whatever.setPosition(W/2, H/2);

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

                //Draws the pixel matrix
                for (int i=0;i<H;++i)
                        RT.draw(pixMat[i], W, sf::Points);

                //THIS IS WHAT DOESNT WORK
                RT.draw(whatever);

                //And finally draws the RenderTexture to the RenderWindow
                RT.display();
                window.draw(sf::Sprite(RT.getTexture()));
                window.display();
        }
}

The drawn sprite is not shown correctly. But I tried to change the sf::Sprite for something else, like a sf::RectangleShape, and it works. The problem seems to be the Sprite.

Thank you very much.

3
Graphics / Re: Drawing a 2D Pixel matrix
« on: January 27, 2013, 06:38:50 pm »
Oh waw, I was expecting everything but this to be the problem. Thank you very much man, i guess it's time to finish my game!

4
Graphics / [Solved] Drawing a 2D Pixel matrix
« on: January 27, 2013, 01:31:44 am »
(Im so bad at English, I will try my best)

A little bit of context:
I'm new to using graphic libraries. I have never used any libraries appart from the STL ones before. I started with SFML a couple of days ago, I managed to have a Tic-Tac-Toe game and a Four-in-a-line working. Now I'm planning to program something similar to the classic "Tanks" game. When I was thinking on a way to set up the collision detection functions between the tank and the terrain I realized I need a way to treat and handle the pixels of an image or a texture one by one. I red the tutorials and the documentation and I found the sf::Vertex and the possibility of drawing an array of these vertex.

I didn't consider the option of using the .setPixel and .getPixel from the sf::Image because I find them a little bit weird. What if my data is stored on a texture or on a sprite?

So in order to get used to this structure I made this minimal program, which basicly creates an array of pixels, draws a blue rectangle on it and then draws it to the window.

And here comes the problem. The program works fine but on the output, appart from the blue rectangle and the white blackground I get some weird black lines that cross the image from top to bottom, like when your computer crashes or your monitor falls of the table.

Can someone tell me what did I do wrong or why I'm getting this black lines?

Thank you.

Pages: [1]