0

Optirun を使用しない限り、このコードが機能する理由がわかりません。

//Initialize GLUT and OpenGL
void ViewPort::startVideo(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(XWIN, YWIN);
glutCreateWindow("Titolo");
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_TEXTURE_CUBE_MAP);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

//OpenGL INFO
printf("GL_VERSION:   %s\n", glGetString(GL_VERSION));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
printf("GL_VENDOR:  %s\n", glGetString(GL_VENDOR));
shadow = new ShadowMap(256 * SHADOW_QUALITY, 256 * SHADOW_QUALITY);
}

/*...*/

ShadowMap::ShadowMap(int w, int h) {
this->h = h;
this->w = w;

shadowShader = new Shader("./basicShader.vs", "./shadowShader.fs");

// Create the cube map
glGenTextures(1, &shadowCubeID);
glBindTexture(GL_TEXTURE_CUBE_MAP, shadowCubeID);

if (int err = glGetError())
    cerr << "glDebug: " << gluErrorString(err) << " shadow map" << endl;

for (unsigned int i = 0; i < 6; i++) {
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_DEPTH_COMPONENT, w, w, 0,
    GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    if (int err = glGetError())
        cerr << "glDebug: " << gluErrorString(err) << " shadow map" << endl;
}

//now i render to the shadowFBO
glGenFramebuffers(1, &shadowFBO);
glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO);

//disable read and write from color buffer
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,     GL_TEXTURE_CUBE_MAP_POSITIVE_X,
        shadowCubeID, 0);

errorCheckFBO();

glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
}

キューブマップの六面体全員をglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, ...)で作成するとエラー(操作無効)となります。

プログラムが次の場合に出力される OpenGL 情報:

GL_VERSION:   3.0 Mesa 10.1.3
GL_RENDERER: Mesa DRI Intel(R) Haswell Mobile 
GL_VENDOR:  Intel Open Source Technology Center

うまくいかないとき:

GL_VERSION:   2.1 Mesa 10.1.3
GL_RENDERER: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits)
GL_VENDOR:  VMware, Inc.

どうすれば問題を回避できますか? (私の英語でごめんなさい)

4

1 に答える 1