Results 1 to 7 of 7

Thread: glUnProject??

  1. #1
    Member Newbie
    Join Date
    Feb 2004
    Location
    Bangladesh
    Posts
    41

    glUnProject??

    Hi!
    I'm new in OpenGL.
    I badly need some easy code of using glUnproject. How does it work ? How to make button in openGL using glUnproject? Is there any better way to make interface or button in opebGL?
    Please please help me

  2. #2
    Member Contributor
    Join Date
    Aug 2001
    Posts
    62

    Re: glUnProject??

    Code :
            GLint Viewport[4];
    	GLdouble ModelMatrix[16];
    	GLdouble ProjMatrix[16];
    	float z1;
    	double winX = 10;
    	double winY = 10;
     	double newX;
    	double newY;
    	double newZ;
     
    	glMatrixMode(GL_MODELVIEW);
    	glPushMatrix();
    	glLoadIdentity();
    	glGetDoublev(GL_MODELVIEW_MATRIX,ModelMatrix);
    	glGetDoublev(GL_PROJECTION_MATRIX,ProjMatrix);
    	glGetIntegerv(GL_VIEWPORT,Viewport);
    	glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z1);
    	gluUnProject(winX,winY,z1,ModelMatrix,ProjMatrix,Viewport,&newX,&newY,&newZ);
            glPopMatrix();

    [This message has been edited by no-one (edited 07-11-2002).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: glUnProject??

    Mishuk,

    If you are looking for ways to create a 2D GUI 'on top' of your 3D drawings, don't use gluUnproject, but setup a glOrtho projection after drawing the 3D stuff and render in 2D (possibly without depth-writing & testing to prevent 3D geometry obscuring the GUI).

    HTH

    Jean-Marc.

  4. #4
    Member Newbie
    Join Date
    Feb 2004
    Location
    Bangladesh
    Posts
    41

    Re: glUnProject??

    To design 2D GUI how to implement it without
    glUnProject? Can you give me some hints?

  5. #5
    Member Contributor
    Join Date
    Aug 2001
    Posts
    62

    Re: glUnProject??

    something like this?

    Code :
     
    glMatrixMode(GL_PROJECTION);
    	glPushMatrix();
    	glLoadIdentity();
          glDisable(GL_DEPTH_TEST);
    // set the top left to 0,0 and the bottom right to 800 by 600
    	glOrtho(0,800,600,0,1.0,-1.0);
     
          DrawGuiStuff();
     
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    [This message has been edited by no-one (edited 07-14-2002).]

  6. #6
    Member Newbie
    Join Date
    Feb 2004
    Location
    Bangladesh
    Posts
    41

    Re: glUnProject??

    Thank you.
    But in this case how can i implement mouse coordinate to associate with the GUI without glUnProject? Is it possible to implement it without glUnProject?

    Moreover i saw some code about Selection and picking. Is is usual technique to make GUI?

    thanks

  7. #7
    Member Contributor
    Join Date
    Aug 2001
    Posts
    62

    Re: glUnProject??

    >Is it possible to implement it without glUnProject?

    yes, if you set the projection and viewport the same size, then yes, the mouse coordinates will be in natural window coordinates, or in relation to the desktop in which case you'll have to adjust them by getting the windows position and adjust accordingly.

    >
    Moreover i saw some code about Selection and picking. Is is usual technique to make GUI?
    <

    it depends, OpenGL picking has the possibility of HW acceleration, though both are quite feasible, its really up to which you prefer, though selection without GL can get fairly complicated if your not used to it.

Similar Threads

  1. About glUnProject!
    By imported_davie in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-17-2010, 08:12 AM
  2. Yupp, more help on glUnProject needed.
    By mums in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-11-2004, 12:32 PM
  3. which z-values for glUnProject()?
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-15-2003, 12:59 AM
  4. glUnProject Problems
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-29-2001, 06:40 PM
  5. glUnProject...?
    By CyBBe in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-29-2000, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean