glMatrixMode(GL_PROJECTION)
とはどう違いglMatrixMode(GL_MODELVIEW)
ますか?
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
#define KEY_ESCAPE 27
void display();
void keyboard(unsigned char,int,int);
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH );
glutInitWindowSize(600,400);
glutCreateWindow("Opengl Test");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
void display() {
float x,y,z;
int i;
x=0;
y=-0.8;
z=0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,1,0);
glBegin(GL_POINTS);
for(i=0;i<98;i++) {
glVertex3f(x,y,z);
x=x+0.01;
}
glEnd();
glutSwapBuffers();
}
void keyboard(unsigned char key, int mousePositionX, int mousePositionY) {
switch ( key ) {
case KEY_ESCAPE:
exit ( 0 );
break;
default:
break;
}
}
例 2:
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
#define KEY_ESCAPE 27
void display();
void keyboard(unsigned char,int,int);
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH );
glutInitWindowSize(600,400);
glutCreateWindow("Opengl Test");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
void display() {
float x,y,z;
int i;
x=0;
y=-0.8;
z=0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,1,0);
glBegin(GL_POINTS);
for(i=0;i<98;i++) {
glVertex3f(x,y,z);
x=x+0.01;
}
glEnd();
glutSwapBuffers();
}
void keyboard(unsigned char key, int mousePositionX, int mousePositionY) {
switch ( key ) {
case KEY_ESCAPE:
exit ( 0 );
break;
default:
break;
}
}
両方のコードで、同じ結果が得られました。誰でもこれらglMatrixMode(GL_MODELVIEW)
との違いを示すことができますglMatrixMode(GL_PROJECTION)
か?