VTK
vtkgluPickMatrix.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkgluPickMatrix.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
22 #ifndef vtkgluPickMatrix_h
23 #define vtkgluPickMatrix_h
24 
25 #include "vtkOpenGL.h" // Needed for GLfloat and GLdouble.
26 
27 // This function was copied from Mesa and sets up the pick matrix
28 inline void vtkgluPickMatrix( GLdouble x, GLdouble y,
29  GLdouble width, GLdouble height,
30  int *origin, int *size )
31 {
32  GLfloat m[16];
33  GLfloat sx, sy;
34  GLfloat tx, ty;
35 
36  sx = size[0] / width;
37  sy = size[1] / height;
38  tx = (size[0] + 2.0 * (origin[0] - x)) / width;
39  ty = (size[1] + 2.0 * (origin[1] - y)) / height;
40 
41 #define M(row,col) m[col*4+row]
42  M(0,0) = sx; M(0,1) = 0.0; M(0,2) = 0.0; M(0,3) = tx;
43  M(1,0) = 0.0; M(1,1) = sy; M(1,2) = 0.0; M(1,3) = ty;
44  M(2,0) = 0.0; M(2,1) = 0.0; M(2,2) = 1.0; M(2,3) = 0.0;
45  M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0;
46 #undef M
47 
48  glMultMatrixf( m );
49 }
50 
51 #endif
52 // VTK-HeaderTest-Exclude: vtkgluPickMatrix.h
void vtkgluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, int *origin, int *size)
#define M(row, col)