문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top