0

This is a really simple question.

Where can I call gluUnproject? Do I need a current openGL context of some kind?

I looked up the function here, but that isn't telling me if there's any kind of precondition.

I want to do this:

    GLdouble near[3];

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    eq::Matrix4f projection;
    getView()->getProjection(projection);
    GLdouble *projMatrix = Matrix4d(projection).array;
    glMultMatrixd(projMatrix);

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity();
    eq::Matrix4f camera;
    getView()->getCamera(camera);
    GLdouble *modelMatrix = Matrix4d(camera).array;
    glMultMatrixd(modelMatrix);

    const PixelViewport pvp = event.context.pvp;
    int viewport[4] = {pvp.x, pvp.y, pvp.w, pvp.h};

    // SCREEN HEIGHT NOT CONTEXT HEIGHT
    const int y = (int)getWindow()->getPixelViewport().h - event.pointerButtonPress.y;

    gluUnProject(
                             event.pointerButtonPress.x,
                             y,
                             0.0,
                             modelMatrix,
                             projMatrix,
                             viewport,
                             &near[0], 
                             &near[1], 
                             &near[2] 
                             );

    near[2] = 1.0f;
    GLdouble far[3] = {near[0],near[1], -1.0f};

On my server node instead of having to pass it to my render nodes, and have them return the result. The server doesn't have an openGL context. Can I still call gluUnproject?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Stephen Furlani
  • 6,794
  • 4
  • 31
  • 60

2 Answers2

2

gluUnProject is not part of OpenGL. It's part of GLU. Technically you can use all of the GLU functions which don't access OpenGL without having a context at all. gluUnProject is such a function.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

Mesa's implementation doesn't seem to require a current context.

genpfault
  • 51,148
  • 11
  • 85
  • 139