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