Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Very basic volume rendering using OpenGL functions (for teaching purposes) [closed]

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:

  1. Use glut to create a window.
  2. Manually set each pixel in the window using some OpenGL function.

Or, slightly more complex...

  1. Use glut to create a window.
  2. Create an off-screen texture the same size as the window.
  3. Set each pixel individually in the texture, based on the results of raycasting.
  4. Flip the texture to the window contents.

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?

like image 857
Dave Avatar asked Apr 08 '11 13:04

Dave


2 Answers

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;
like image 173
tibur Avatar answered Sep 19 '22 01:09

tibur


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/

like image 24
BЈовић Avatar answered Sep 21 '22 01:09

BЈовић