Results 1 to 3 of 3

Thread: How to write own GluUnProject()

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2008
    Posts
    3

    How to write own GluUnProject()

    good day,

    ive been trying to implement my own version of gluUnproject()

    the window size is 250*250;

    for the sake of my test im trying to find the obj position of window cords 125,125,0.

    so i pass those values to gluUnproject and it returns:
    X: 0 Y: 0 Z : 3.9999999433755855

    passing the same values to my version i get these values:

    X: 0 Y: 0 Z: 1.8999999320507073


    ive checked my inversion method and its returning the correct values.

    is there nething obvious that ive missed out ??

    and does any one know of any source code examples of other people doing their own implementation ??

    Thanks for your time.

    vec4* Matrix::UnProjection(double x,double y,double z,Matrix model,Matrix proj,Matrix view)
    {
    vec4* newPos = new vec4();
    vec4* cords = new vec4();

    Matrix m;

    Matrix inverseProjection = m.Inverse(m.multiplyTwoMatrix(model,proj));

    cords->x = 2*(x-view[0])/view[2] - 1;

    cords->y = 2*(y-view[1])/view[3] - 1;

    cords->z = 2*(z)-1;

    cords->w = 1;

    newPos = m.MultiplyVectorMatrix(inverseProjection,cords);

    return newPos;
    }

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649

    Re: How to write own GluUnProject()

    Quote Originally Posted by YKingY
    does any one know of any source code examples of other people doing their own implementation ??
    Check the source in Mesa3D.

  3. #3
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: How to write own GluUnProject()


Similar Threads

  1. gluUnProject
    By schailan in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-31-2002, 10:40 PM
  2. gluUnProject
    By guju in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 06-06-2002, 12:51 AM
  3. gluUnProject help!!!
    By Neo3D3D in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-06-2002, 08:37 AM
  4. gluUnproject()
    By Epidemi in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-10-2000, 11:08 PM
  5. gluUnProject?
    By CyBBe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-10-2000, 04:58 PM

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