【发布时间】:2015-12-05 01:31:59
【问题描述】:
我使用freeglut创建windows,代码如下:
int window1, window2;
GLfloat cube[] = {
//cube point
}
init2()
{
//init shaders...
//init vertex arrays with cube points...
}
void display2()
{
glutSetWindow(window2);
glViewport(0, 0, WIDTH, HEIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_DEPTH_TEST);
mul.use();
glm::mat4 view;
view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(camera.Zoom, (GLfloat)WIDTH / (GLfloat)HEIGHT, 0.1f, 100.0f);
mul.setUniform("view", view);
mul.setUniform("projection", projection);
glBindVertexArray(box_vao2);
glDrawArrays(GL_QUADS, 0, 24);
glBindVertexArray(0);
glUseProgram(0);
glutSwapBuffers();
}
openwin2()
{
window2 = glutCreateWindow("win2");
init2();
glutDisplayFunc(display2);
glutReshapeFunc(reshape2);
glutIdleFunc(idle2);
}
void mouse(int button, int state, int x, int y)
{
//do something and...
openwin2();
}
int main(int argc, char **argv)
{
//glutinit...
window1 = glutCreateWindow("window1");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutIdleFunc(idle);
glutMainLoop();
//...
}
所以,当我第一次点击打开window2时,它可以显示我用vao绘制的立方体,但是如果我关闭它并重新打开它,窗口什么也不做,为什么?
是关于 vao 的吗?
【问题讨论】:
-
关于what VAO的一些东西?您的代码中没有任何内容涉及 VAO。
-
修改问题,我用一个vao来存储立方体点,用glDrawArrays来绘制。
-
对不起,我尽量让它最小化,但我还是错过了一些东西。
-
如果你有 Intel gfx 卡,它可能与这个 What is the proper OpenGL initialisation on Intel HD 3000? 有关,这仍然是一个悬而未决的问题......
标签: c++ opengl graphics freeglut