Archived

This topic is now archived and is closed to further replies.

loopguru

Win32 / Raytracing Question / Advice

Recommended Posts

First off let me say that that Radeon ad is damn annoying... Second let me preface the question by describing my application. I have a "main" application that spawns an openGL rendering window. Everything regarding this window is contained in a class I defined - call it COGLwin. It has its own message handler (and of course its own rendering context). The ultimate purpose of COGLwin is to use openGL as a means to do volume rendering via raycasting. Nevermind the details of volume rendering. The only thing is that it operates very similar to raytracing. As such I would like, as other raytracers do, render the scene scanline by scanline. My question is this: Say during the raycasting (raytracing) procedure I get a WM_PAINT message (e.g. minimize then maximize again) and a portion of what I have already rendered gets invalidated. Since volume rendering can be computationally intensive, I clearly do not want to render the entire scene again. An option is to store my progress (i.e. the pixels I''ve rendered already) in some buffer and, when I need to repaint, simply dump that buffer to the window. I''d prefer not to do this though because: (a) the datasets that need to be rendered can be huge and minimizing memory-usage is vital (must avoid paging the dataset if possible) ; (b) writing to the buffer is just more overhead. Can anyone offer a better suggestion? Or does Windoze somehow "implicitly" perform this refresh for us? Thanks. Sorry for the length of the post... ks ______ ______ /\_____\ /\_____\ ____ \ \__/_/_ \ \__/_/ /\___\ /\ \_____\ /\ \___\ /\ \___\ \ \/ / / / \ \/ / / \ \/ / / \/_/\/ / \/_/_/ \/_/_/ \/_/ S(k)

Share this post


Link to post
Share on other sites
Well actually the whole point of the WM_PAINT message was so that windows didn''t have to store the graphics for your window whenever it got overwritten or minimized/maximized.

Generally with raytracing the overhead of writing to the buffer and updating the scene is neglible compared to the cost of doing the actual raytracing. Also, unless you are not planning on allowing the user to save the images you will need to store the image anyhow. I recommend you just store a buffer of the size your image is going to be.

However, if you are *really* worried about memory usage, here is an alternate solution. Only keep a buffer for the current scanline and write the pixels into that buffer. Now, when the end of that scanline is reached, open an image file on your hard drive and add that scanline on. This way you only have to keep one scanline in memory at any one time, and whenever windows requests a repaint, just open the image file and read the info straight from it. You could take this to the extreme and save to hard drive every pixel, but that sounds like overkill to me.

Share this post


Link to post
Share on other sites