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

Pages: [1]
1
Graphics / Re: sf::Image::setPixel Crashing the application
« on: November 13, 2015, 05:17:05 pm »
Thanks! this
image.setPixel(600, 600, sf::Color::White);
was the thing crashing, just changing the <= to < has done it.

and...
texture.update(image);
it will change the texture because its on the main loop, so it will be called every frame...
but is there's any alternatives to this function?

2
Graphics / Re: sf::Image::setPixel Crashing the application
« on: November 13, 2015, 05:06:31 pm »
If its not <= its going to loop forever, i just want it to draw a line inside the boundaries of the window (600 pixels high)

3
Graphics / sf::Image::setPixel Crashing the application
« on: November 13, 2015, 04:56:52 pm »
(first of all, sorry for my bad english, its not my native language)

Hi!

I'm using SFML v2.3, Mingw32 v4.7.1 (Code::Blocks default) and Windows 10.

I'm trying to make an application to test the sf::Image class and render single pixels, but everytime i try to do a simple loop using sf::Image::setPixel it crashes...

#include <SFML/Graphics.hpp>
#include <iostream>

int loopCount = 0;

const int Largura = 800;
const int Altura = 600;

int main()
{
    //Setup Window
    sf::RenderWindow window(sf::VideoMode(Largura, Altura), "yay");
    window.setVerticalSyncEnabled(true);

    // create an empty 800x600 texture
    sf::Texture texture;
    if (!texture.create(800, 600))
    {
        std::cout << "Fail to create the texture";
    }

    // create an black image
    sf::Image image;
    image.create(800, 600, sf::Color::Black);

    // Set the texture to be the image and create the Sprite to render
    texture.update(image);
    sf::Sprite sprite;
    sprite.setTexture(texture);

    //the loop that is crashing the program
    //it should create a diagonal line of white pixels
    for(int i=0; i<=600; i++){
    image.setPixel(i, i, sf::Color::White);
    }

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

        //The actual Rendering
        window.clear();
        texture.update(image);
        window.draw(sprite);
        window.display();
    }

    return 0;

}
 

What am i doing wrong? I am not suposed to manipulate pixels like that?

Pages: [1]
anything