PDA

View Full Version : clearing a point



blaze157
04-28-2014, 08:03 PM
I am making a particle physics thing were sand falls from the top of the screen and collects on the bottom.
the sand is being drawn using GL_POINTS.
since the whole screen is a lot of points to draw (1920x1080) and the sand does not move much i would only like to render the point when it moves.
to do this i tried removing glClear( GL_COLOR_BUFFER_BIT ); and drawing over the old pixels after i move them with a black pixel but it doesn't work.
the sand leaves streaks like its not being cleared and the streaks flicker like it cant decide weather or not to put color or black so its flipping back and forth or something.:confused:
is there a way to do this or do i need to just clear the whole screen.

Brokenmind
04-29-2014, 01:19 AM
and drawing over the old pixels after i move them with a black pixel but it doesn't work.

This sounds like you draw over the old pixel after you move them, which is the same coordinate as the new pixel. The flickering you see might have the same origin, so you should test whether you really overdraw the old position instead of the new one.

As for the question whether particle physics should be drawn using another approach, I unfortunately cannot help you.

Cornix
04-29-2014, 02:12 AM
Just quoting the "Common Mistakes"-Page:

The buffers should always be cleared. On much older hardware, there was a technique to get away without clearing the scene, but on even semi-recent hardware, this will actually make things slower. So always do the clear.
Source: https://www.opengl.org/wiki/Common_Mistakes#Swap_Buffers

blaze157
04-29-2014, 01:15 PM
This sounds like you draw over the old pixel after you move them, which is the same coordinate as the new pixel. The flickering you see might have the same origin
that makes sense, i guess i was thinking about my 2D field of particles and i forgot that openGL can be layered and you can have 2 points in the same place

well its no big deal ill just clear the whole screen. thank you