plik


Open GL Super Bible:Interactive Graphics To access the contents, click the chapter and section titles. Open GL Super Bible (Publisher: Macmillan Computer Publishing) Author(s): Waite group Press ISBN: 1571690735 Publication Date: 08/01/96   Previous Table of Contents Next gluPickMatrix Purpose Defines a picking region that can be used to identify user selections. Include File <glu.h> Syntax void gluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4]); Description This function creates a matrix that will define a smaller viewing volume based on screen coordinates for the purpose of selection. By using the mouse coordinates with this function in selection mode, you can determine which of your objects are under or near the mouse cursor. The matrix created is multiplied by the current projection matrix. Typically you should call glLoadIdentity before calling this function, then multiply the perspective matrix that you used to create the viewing volume in the first place. If you are using gluPickMatrix to pick NURBS surfaces, you must turn off the NURBS property GLU_AUTO_LOAD_MATRIX before using this function. Parameters x,y GLdouble: The center of the picking region in window coordinates. width,height GLdouble: The width and height of the desired picking region in window coordinates. viewport GLint[4]: The current viewport. You can get the current viewport by calling glGetIntegerv with GL_VIEWPORT. Returns None. Example The following code is from the PLANETS example program. It uses this function to create a new clipping volume that will cover an area of the window only 2 pixels by 2 pixels, centered on the mouse cursor. This is used to select the object that is directly underneath the mouse cursor. // Hit counter and viewport storage GLint hits, viewport[4]; // Set up selection buffer glSelectBuffer(BUFFER_LENGTH, selectBuff); // Get the viewport glGetIntegerv(GL_VIEWPORT, viewport); // Switch to projection and save the matrix glMatrixMode(GL_PROJECTION); glPushMatrix(); // Change render mode glRenderMode(GL_SELECT); // Establish new clipping volume to be unit cube around // mouse cursor point (xPos, yPos) and extending two pixels // in the vertical and horizontal direction glLoadIdentity(); gluPickMatrix(xPos, yPos, 2,2, viewport); // Apply perspective matrix gluPerspective(45.0f, fAspect, 1.0, 425.0); // Draw the scene RenderScene(); // Collect the hits hits = glRenderMode(GL_RENDER); // If a single hit occurred, display the info. if(hits == 1) ProcessPlanet(selectBuff[3]); // Restore the projection matrix glMatrixMode(GL_PROJECTION); glPopMatrix(); // Go back to modelview for normal rendering glMatrixMode(GL_MODELVIEW); See Also glGet, glLoadIdentity, glMultMatrix, glRenderMode, gluPerspective Previous Table of Contents Next   Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.

Wyszukiwarka

Podobne podstrony:
6 rozB 617 635
617 (2)
demo cgi 616
616 (2)
613 616
613 617
613 616
617 Dywersyfikacja
Vzduchovka Slavia 617 R
616 618
617 621

więcej podobnych podstron