I have some students doing a project on volume rendering. I am trying to devise the most basic possible example to get them started. What I want to do is have a window and set each pixel in the window independently, based on raycasts through the underlying volume dataset. This could easily be done with Windows API functions, for example. But we want to use OpenGL.
Two ideas I've had:
Or, slightly more complex...
So my question is twofold: is there a better method than these options? and can someone point me to the relevant OpenGL functions to accomplish these methods?
The first option, pixel by pixel will be really slow! I would suggest you to create a RGB buffer with the same size as the window and use glDrawPixels to draw it.
EDIT:
unsigned char * buffer = new unsigned char [width * height * 3];
glRasterPos(0,0);
glDrawPixels(width,height,GL_RGB,GL_UNSIGNED_BYTE,buffer);
delete [] buffer;
Take a look into one of these ray casting examples, and pick one that suits your need :
http://www.daimi.au.dk/~trier/?page_id=98
http://cumbia.informatik.uni-stuttgart.de/ger/research/fields/current/spvolren/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With