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

Pages: [1]
1
Graphics / Re: Weird flickering shapes.
« on: August 15, 2015, 03:44:48 pm »
You will still have to wait quite some time until you got the trillion triangles. Like, years?

I'm not in a hurry. :)

No seriously it was mostly academic curiosity. I don't need to draw a trillion triangles. But with rendertexture I could if I wanted and it wouldn't use more ram than 1 triangle (or thereabouts). At least not proportionally more.

2
Graphics / Re: Weird flickering shapes.
« on: August 15, 2015, 03:26:03 pm »
Got it to work now with rendertexture. Thanks!

Gotta have those trillion trinagles...

3
Graphics / Re: Weird flickering shapes.
« on: August 15, 2015, 03:08:26 pm »

Thanks both. It seems my attention slipped when reading the tutorial. :)

Out of curiosity, how would you go about just adding to a previous frame without the need to remember all the objects? I.e. draw a trillion random triangles. That's more than you can keep in ram but perfectly doable if you just draw on the same surface. Do you draw them to an Image or something?

4
Graphics / Weird flickering shapes.
« on: August 15, 2015, 02:48:41 pm »
I'm getting some curious screen flickering. Below is the code. I'm just drawing a triangle at a random point on the screen every second. The idea is to keep what has been drawn previously and just draw another triangle. I'm don't clear the screen between redraws and reuse the shape object. I assume this is a valid approach.

Here's an album with the first few frames the code generates. Pictures are in order of appearance. It's curious that every odd frame has the first triangle in it. But every even frame don't have the first triangle. Why doesn't all frames have the first triangle in it?

http://imgur.com/a/nd5xW


#include "stdafx.h"
#include <Windows.h>
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1024, 576), "SFML works!");
    sf::Vector2u windowSize = window.getSize();

    sf::CircleShape triangle(50, 3);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {          
            if (event.type == sf::Event::Closed ||
                event.type == event.KeyPressed && event.key.code == sf::Keyboard::Escape)
            {
                window.close();            
            }
        }

        int posX = rand() % windowSize.x;
        int posY = rand() % windowSize.y;

        triangle.setPosition(posX,posY);

        int r = rand() % 255;
        int g = rand() % 255;
        int b = rand() % 255;

        triangle.setFillColor(sf::Color::Color(r, g, b));

        window.draw(triangle);
        window.display();

        Sleep(1000);
    }

    return 0;
}
 

Pages: [1]
anything