VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkgluPickMatrix.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00022 #ifndef vtkgluPickMatrix_h 00023 #define vtkgluPickMatrix_h 00024 00025 #include "vtkOpenGL.h" // Needed for GLfloat and GLdouble. 00026 00027 // This function was copied from Mesa and sets up the pick matrix 00028 inline void vtkgluPickMatrix( GLdouble x, GLdouble y, 00029 GLdouble width, GLdouble height, 00030 int *origin, int *size ) 00031 { 00032 GLfloat m[16]; 00033 GLfloat sx, sy; 00034 GLfloat tx, ty; 00035 00036 sx = size[0] / width; 00037 sy = size[1] / height; 00038 tx = (size[0] + 2.0 * (origin[0] - x)) / width; 00039 ty = (size[1] + 2.0 * (origin[1] - y)) / height; 00040 00041 #define M(row,col) m[col*4+row] 00042 M(0,0) = sx; M(0,1) = 0.0; M(0,2) = 0.0; M(0,3) = tx; 00043 M(1,0) = 0.0; M(1,1) = sy; M(1,2) = 0.0; M(1,3) = ty; 00044 M(2,0) = 0.0; M(2,1) = 0.0; M(2,2) = 1.0; M(2,3) = 0.0; 00045 M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0; 00046 #undef M 00047 00048 glMultMatrixf( m ); 00049 } 00050 00051 #endif 00052 // VTK-HeaderTest-Exclude: vtkgluPickMatrix.h