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 =========================================================================*/
23 #ifndef vtkgluPickMatrix_h
24 #define vtkgluPickMatrix_h
25 
26 #include "vtkOpenGL.h" // Needed for GLfloat and GLdouble.
27 
28 // This function was copied from Mesa and sets up the pick matrix
29 inline void vtkgluPickMatrix( GLdouble x, GLdouble y,
30  GLdouble width, GLdouble height,
31  int *origin, int *size )
32 {
33  GLfloat m[16];
34  GLfloat sx, sy;
35  GLfloat tx, ty;
36 
37  sx = size[0] / width;
38  sy = size[1] / height;
39  tx = (size[0] + 2.0 * (origin[0] - x)) / width;
40  ty = (size[1] + 2.0 * (origin[1] - y)) / height;
41 
42 #define M(row,col) m[col*4+row]
43  M(0,0) = sx; M(0,1) = 0.0; M(0,2) = 0.0; M(0,3) = tx;
44  M(1,0) = 0.0; M(1,1) = sy; M(1,2) = 0.0; M(1,3) = ty;
45  M(2,0) = 0.0; M(2,1) = 0.0; M(2,2) = 1.0; M(2,3) = 0.0;
46  M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0;
47 #undef M
48 
49  glMultMatrixf( m );
50 }
51 
52 #endif
53 // VTK-HeaderTest-Exclude: vtkgluPickMatrix.h
void vtkgluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, int *origin, int *size)
#define M(row, col)