GLuint* vaos;
GLuint* progIds;
+bool hasDrawn = false;
+
void display() {
glClear(GL_COLOR_BUFFER_BIT);
for (int i = 0; i < 2; i++) {
glDrawArrays(GL_TRIANGLES, 0, 3);
}
glutSwapBuffers();
+ if (!hasDrawn) {
+ glutPostRedisplay();
+ hasDrawn = true;
+ }
}
void attachShader(GLuint progId, const char* filePath, GLenum type) {
ifstream file(filePath);
stringstream buffer;
buffer << file.rdbuf();
- const char* contents = buffer.str().c_str();
+ string str = buffer.str();
+ const char* contents = str.c_str();
glShaderSource(shader, 1, (const GLchar**)&contents, NULL);
glCompileShader(shader);
validateProgram(progId2);
}
+void keyboard(unsigned char key, int x, int y) {
+ glutPostRedisplay();
+}
+
int main(int argc, char** argv) {
glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_3_2_CORE_PROFILE);
+ glutInitDisplayMode(GLUT_STENCIL|GLUT_SINGLE|GLUT_RGB|GLUT_3_2_CORE_PROFILE);
glutInitWindowSize(800, 600);
- glutCreateWindow("Hello Triangle");
+ int win = glutCreateWindow("Hello Triangle");
glutDisplayFunc(display);
glewInit();
init();
+ glutKeyboardFunc(keyboard);
+
glutMainLoop();
return 0;