部屋の下部に青いクワッドを描画しようとしています。
これは私が使用しようとしてきたコードですが、クワッドはなく、緑色のクリア カラーのみです。
#include <iostream>
#include <vector>
#include <cmath>
#include <GL/glu.h>
#include <GL/freeglut.h>
bool keystates[256];
bool speckeystates[256];
// manage key events
void keys(unsigned char key, int x, int y) {
keystates[key]=true;
}
void keyup(unsigned char key, int x, int y) {
keystates[key]=false;
}
void skeys(int key, int x, int y) {
speckeystates[key]=true;
}
void skeyup(int key, int x, int y) {
speckeystates[key]=false;
}
void draw(void) {
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt(0,0,0,640,480,640,0,1,0); // from near-top-left to far-bottom-right, floor should be visible
glBegin(GL_QUADS);
glColor3ub(15,15,255); // visible blue color
glVertex3i(0,480,0); // draw quad across bottom
glVertex3i(640,480,0);
glVertex3i(640,480,640);
glVertex3i(0,480,640);
glEnd();
glFlush(); // flush drawing
glutSwapBuffers(); // swap the buffers
glutPostRedisplay();
}
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(0,0);
glutCreateWindow("Window!"); // init window stuff
glutDisplayFunc(draw); // our frame/draw event
glutKeyboardFunc(keys);
glutKeyboardUpFunc(keyup);
glutSpecialFunc(skeys);
glutSpecialUpFunc(skeyup); // init key event stuff
glEnable(GL_DEPTH_TEST); // init opengl stuff
glClearColor(0.2f,0.3f,0.2f,1.0f);
gluPerspective(45.0,640/480,0,640); // x: 0-640 y: 0-480 z: 0-640
glDepthFunc(GL_LEQUAL);
glutMainLoop(); // begin the loop
}