View Full Version : Drawing tons of points
04-02-2012, 07:11 PM
Hi, I'm making a simple ray tracer for a project and am trying to figure out the most efficient way to draw to every pixel on the screen. I'm currently using a 500x500 window and even before the ray tracing, just drawing black to every pixel using glBegin(GL_POINTS) is bringing the FPS down to about 5. Is there a better way that lets me specify the color for every pixel?
04-02-2012, 08:27 PM
If all you're using OpenGL to do is draw points you calculate on the CPU to the screen, there are far better ways to do that. Pretty much any GUI API will have faster ways of getting that done.
04-02-2012, 08:49 PM
Ya, I know, unfortunately opengl is required for the assignment :(
04-03-2012, 04:06 AM
Use a texture instead and transfer the rendered pixels using glTexSubImage2D.
And transfer at least line by line instead of individual pixels
04-03-2012, 02:49 PM
Thanks, that's exactly what I was looking for. Although it didn't help as much as I thought it would, only got around a 1 fps increase.
04-03-2012, 03:50 PM
Can you show us the code of your render function?
Are you sure that the slow part is openGl?
Transfer a mem buffer on a texture and draw a quad with that texture shouldn't take more than 2 ms (500 fps) on dx9 hardware.
04-03-2012, 05:18 PM
glBegin( GL_QUADS );
Right now, drawing using a texture is running at ~320fps. Using the commented out code to draw all the points runs at ~310.
04-04-2012, 03:11 AM
only got around a 1 fps increase
Beware, this metric is misleading.
It could mean you went from 1 fps to 2 fps which is a great improvement (500ms spared).
It could mean you went from 200 to 201 which is totally insignificant (0.03 milliseconds difference).
04-04-2012, 05:22 AM
The storage format also has an effect
Are you sure that you have created a floating point texture?
Because if you haven't, the driver will convert it which waste a little CPU time.
04-04-2012, 11:59 PM
mmm ok, thanks for everything guys, it appears I'm just a tard. I was running the project in debug mode, once I switched to release the fps shot up to about 1600.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.