i trying create 3d room. doing creating 3d cube , trying changing camera position inside cube appears room. when make coordinate vertices 3 instead of 1 works 1 doesn't work. why did happen?
my code cube :
glbegin(gl_quads); // draw cube using quads glvertex3f(1.0f, 1.0f, -1.0f); // top right of quad (top) glvertex3f(-1.0f, 1.0f, -1.0f); // top left of quad (top) glvertex3f(-1.0f, 1.0f, 1.0f); // bottom left of quad (top) glvertex3f(1.0f, 1.0f, 1.0f); // bottom right of quad (top) glvertex3f(1.0f, -1.0f, 1.0f); // top right of quad (bottom) glvertex3f(-1.0f, -1.0f, 1.0f); // top left of quad (bottom) glvertex3f(-1.0f, -1.0f, -1.0f); // bottom left of quad (bottom) glvertex3f(1.0f, -1.0f, -1.0f); // bottom right of quad (bottom) glvertex3f(1.0f, 1.0f, 1.0f); // top right of quad (front) glvertex3f(-1.0f, 1.0f, 1.0f); // top left of quad (front) glvertex3f(-1.0f, -1.0f, 1.0f); // bottom left of quad (front) glvertex3f(1.0f, -1.0f, 1.0f); // bottom right of quad (front) glvertex3f(1.0f, -1.0f, -1.0f); // top right of quad (back) glvertex3f(-1.0f, -1.0f, -1.0f); // top left of quad (back) glvertex3f(-1.0f, 1.0f, -1.0f); // bottom left of quad (back) glvertex3f(1.0f, 1.0f, -1.0f); // bottom right of quad (back) glvertex3f(-1.0f, 1.0f, 1.0f); // top right of quad (left) glvertex3f(-1.0f, 1.0f, -1.0f); // top left of quad (left) glvertex3f(-1.0f, -1.0f, -1.0f); // bottom left of quad (left) glvertex3f(-1.0f, -1.0f, 1.0f); // bottom right of quad (left) glvertex3f(1.0f, 1.0f, -1.0f); // top right of quad (right) glvertex3f(1.0f, 1.0f, 1.0f); // top left of quad (right) glvertex3f(1.0f, -1.0f, 1.0f); // bottom left of quad (right) glvertex3f(1.0f, -1.0f, -1.0f); // bottom right of quad (right) glend();
and using glulookat(0.0,0.0,0.0,0.0,0.0,-1.0,0.0,1.0,0.0);
i'm assuming you're using perspective projection , near plane greater one. lead following scenario geometry behind near plane , gets clipped:
simply reduce near plane 0.1
example. make sure not make small while far plane big, or you'll lose depth precision , hit "z fighting" issues.