以下是我的小opengl程序,只是绘制一个三角形。有一个小故障,当我添加glClear()函数时,RAM每秒略微增加大约10K。为什么会这样?
int screenwidth=537, screenheight=716;
GLFWwindow* window;
if (!glfwInit()) return -1;
window = glfwCreateWindow(screenwidth, screenheight, "Test", NULL, NULL);
if(!window){glfwTerminate(); return -1;}
glfwMakeContextCurrent(window);
//Setting up the OpenGL Context
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, screenwidth, screenheight, 0, 0, 1);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(1,0.9176f,0.1259f,1);
//The rendering loop
while (!glfwWindowShouldClose(window)){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex2f(0, 0);
glVertex2f(.5f, .5f);
glVertex2f(0, .5f);
glEnd();
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS){
glfwSetWindowShouldClose(window, GL_TRUE);
}
glfwSwapBuffers(window);
glfwPollEvents();
}