PDA

View Full Version : Draw a room



phuongmaruko
12-06-2010, 02:42 AM
Hi all!
I'm trying to draw a room in opengl. I've searched and another topic I found on this forum told me that I should try to use GL_QUADS.
I've try :

glBegin(GL_QUADS);
/* Floor */
glColor3f(0.0,0.0,1.0);
glVertex3f(-1,-1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,-1,1);
glVertex3f(-1,-1,1);

/* Ceiling */
glVertex3f(-1,1,-1);
glVertex3f(1,1,-1);
glVertex3f(1,1,1);
glVertex3f(-1,1,1);

/* Walls */
//wall1
glVertex3f(-1,-1,1);
glVertex3f(1,-1,1);
glVertex3f(1,1,1);
glVertex3f(-1,1,1);

//wall2
glVertex3f(-1,-1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,1,-1);
glVertex3f(-1,1,-1);

//wall3
glVertex3f(1,1,1);
glVertex3f(1,-1,1);
glVertex3f(1,-1,-1);
glVertex3f(1,1,-1);

//wall4
glVertex3f(-1,1,1);
glVertex3f(-1,-1,1);
glVertex3f(-1,-1,-1);
glVertex3f(-1,1,-1);

glEnd();

However, just the floor and wall3 appeared on my screen. Anyone can help me!

randall
12-06-2010, 03:52 AM
Do you have culling enabled? If yes try to disable it: glDisable(GL_CULL_FACE);

ugluk
12-06-2010, 04:23 AM
There's a NeHe FPS tutorial, try that if you want a room. Also, there are plenty of Cube tutorials both on NeHe and elsewhere. Randall is right though, that probably you've enabled GL_CULL_FACE. Just leave it disabled.

phuongmaruko
12-06-2010, 07:59 AM
Yeah it worked. thanks a lot!

phuongmaruko
12-07-2010, 10:41 AM
according to codecolony.de site, I used texture to cover my room. my texture just could cover exterior sides of the room, hence standing in the room, i couldn't see the texture on walls. Which parameter can help me to set texture for not exterior but inner sides of my room?