glReadPixels()不使用纹理

时间:2013-07-07 07:37:48

标签: opengl textures glu glreadpixels

我一直在用C ++和OpenGL中的某些代码来解决对象选择问题。代码完美无缺,直到我引入纹理,现在我看不到任何反应。

以下是代码:

void MouseFunc(int x, int y)
{

    glutSetWindow(id) //I have several subwindows
    glDisable(GL_LIGHTING);
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_TEXTURE_2D);

    glDrawBuffer(GL_BACK);

    //code that draws a single colored figure

    unsigned char pixel[3];
    GLint viewport[4];
    glGetIntergv(GL_VIEWPORT, viewport);

    glReadBuffer(GL_BACK);
    glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);

    //code for comparison between read and stored colors

    glEnable(GL_LIGHTING);
    gLEnable(GL_COLOR_MATERIAL);
    glEnable(GL_TEXtURE_2D);
}

0 个答案:

没有答案