Skip to main content
GameDev.net gamedev.net
🔒 Locked

Ray Tracer

Started by lc_gta Jan 4, 2002 at 10:23 AM 6 replies 400+ views
Original Post
lc_gta
lc_gta
Ok, i''m rewriting a ray tracer that i wrote about a year ago for a class project. In my original implementation i was going more for functionality than performance so its not that fast at the moment. My question is what''s the best way for me to plot the pixels. Currently i have a set_pixel function that''s uses the following glBegin(GL_POINTS); glVertex2i(x,y); glEnd(); Is this a legitimate solution, or is there a faster way? I realize that plotting pixels probably isn''t opengl''s strong suit but i''d like to find the most efficient solution. All suggestions welcome thanks
DeathWish
DeathWish
Don''t call glBegin()...glEnd() each time - just call glBegin(), then plot all the pixels you''ll need to plot, then call glEnd().
lc_gta
lc_gta
i figured looping through an array would be better than doing each one individually, but is

glBegin(GL_POINTS);
/*loop through pixel array*/
glEnd();

going to be faster than using glDrawPixels or will they be about the same?
kamrann
kamrann
Unless yours is an extremely basic ray-tracer, then the pixel plotting shouldn''t be at all important, since 99% of the time should be spent in ray-object intersection testing, and pixel plotting time will be insignificant in comparison.

Cameron
lc_gta
lc_gta
i realize that the pixel plotting is very insignificant in the whole scheme of things. I''m pretty sure that my ray-polygon intersection routine is my slowest component, but i''ve got the algorithms and optimization techniques for the ray intersections and such already, i''m just trying to squeeze all the performance i can out of it.

thanks for all the replies so far
Brannon
Brannon
If you have an array of points, then maybe try using glVertexPointer/glDrawArrays to send all of the vertex data in one function call. If that works like I am thinking, then it would at least eliminate the function call overhead of calling glVertex for each point.


-Brannon
-Brannon
Absolution
Absolution
Hmm, what I might do is fill up a back buffer array of GLubytes with the pixel RGBs, use glTexSubImage2D to copy these values to a texture, and then blit this texture to an orthogonally projected quad the same size as your screen. :/ Probably faster than calling all of those vertex and color function calls and definitely leaves a lot of room for optimization tricks. Anyway, I use this when I want to display video on a quad or whenever I need to change a texture.

Abs

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.