projects
/
opengl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix on Mojave
[opengl.git]
/
assignment1.cpp
diff --git
a/assignment1.cpp
b/assignment1.cpp
index b3049f0583f956317d1b38e07ec0914aae1acb1f..887ffb0d9a2444a8dacce433606dca42b2aeed75 100644
(file)
--- a/
assignment1.cpp
+++ b/
assignment1.cpp
@@
-17,6
+17,8
@@
using namespace std;
GLuint* vaos;
GLuint* progIds;
GLuint* vaos;
GLuint* progIds;
+bool hasDrawn = false;
+
void display() {
glClear(GL_COLOR_BUFFER_BIT);
for (int i = 0; i < 2; i++) {
void display() {
glClear(GL_COLOR_BUFFER_BIT);
for (int i = 0; i < 2; i++) {
@@
-25,6
+27,10
@@
void display() {
glDrawArrays(GL_TRIANGLES, 0, 3);
}
glutSwapBuffers();
glDrawArrays(GL_TRIANGLES, 0, 3);
}
glutSwapBuffers();
+ if (!hasDrawn) {
+ glutPostRedisplay();
+ hasDrawn = true;
+ }
}
void attachShader(GLuint progId, const char* filePath, GLenum type) {
}
void attachShader(GLuint progId, const char* filePath, GLenum type) {
@@
-38,7
+44,8
@@
void attachShader(GLuint progId, const char* filePath, GLenum type) {
ifstream file(filePath);
stringstream buffer;
buffer << file.rdbuf();
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);
glShaderSource(shader, 1, (const GLchar**)&contents, NULL);
glCompileShader(shader);
@@
-155,17
+162,23
@@
void init() {
validateProgram(progId2);
}
validateProgram(progId2);
}
+void keyboard(unsigned char key, int x, int y) {
+ glutPostRedisplay();
+}
+
int main(int argc, char** argv) {
glutInit(&argc, argv);
int main(int argc, char** argv) {
glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_
DOUB
LE|GLUT_RGB|GLUT_3_2_CORE_PROFILE);
+ glutInitDisplayMode(GLUT_
STENCIL|GLUT_SING
LE|GLUT_RGB|GLUT_3_2_CORE_PROFILE);
glutInitWindowSize(800, 600);
glutInitWindowSize(800, 600);
- glutCreateWindow("Hello Triangle");
+
int win =
glutCreateWindow("Hello Triangle");
glutDisplayFunc(display);
glewInit();
init();
glutDisplayFunc(display);
glewInit();
init();
+ glutKeyboardFunc(keyboard);
+
glutMainLoop();
return 0;
glutMainLoop();
return 0;