Rendering/vtkgluPickMatrix.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00022 #ifndef vtkgluPickMatrix_h
00023 #define vtkgluPickMatrix_h
00024 
00025 #ifndef VTK_IMPLEMENT_MESA_CXX
00026 # if defined(__APPLE__) && (defined(VTK_USE_CARBON) || defined(VTK_USE_COCOA))
00027 #  include <OpenGL/gl.h>
00028 # else
00029 #  include <GL/gl.h>
00030 # endif
00031 #endif
00032 
00033 
00034 inline void vtkgluPickMatrix( GLdouble x, GLdouble y,
00035                               GLdouble width, GLdouble height,
00036                               int *origin, int *size )
00037 {
00038   GLfloat m[16];
00039   GLfloat sx, sy;
00040   GLfloat tx, ty;
00041   
00042   sx = size[0] / width;
00043   sy = size[1] / height;
00044   tx = (size[0] + 2.0 * (origin[0] - x)) / width;
00045   ty = (size[1] + 2.0 * (origin[1] - y)) / height;
00046 
00047 #define M(row,col)  m[col*4+row]
00048    M(0,0) = sx;   M(0,1) = 0.0;  M(0,2) = 0.0;  M(0,3) = tx;
00049    M(1,0) = 0.0;  M(1,1) = sy;   M(1,2) = 0.0;  M(1,3) = ty;
00050    M(2,0) = 0.0;  M(2,1) = 0.0;  M(2,2) = 1.0;  M(2,3) = 0.0;
00051    M(3,0) = 0.0;  M(3,1) = 0.0;  M(3,2) = 0.0;  M(3,3) = 1.0;
00052 #undef M
00053 
00054    glMultMatrixf( m );
00055 }
00056 
00057 #endif