954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

OpenGl cube help

[IMG]http://img690.imageshack.us/img690/7592/12946613.jpg[/IMG]

why is there a hole in my cube when I rotate it like this?

colors:
front side is red
back side is white
left side is blue
right side is green
top side is yellow
bottom is teal

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

Could have something to do with depth.

Lets see some source code and then I'll be able to help you out more.

sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99
 

this the code of my opengl cube, depth test is enabled

private void Display()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glLoadIdentity();
          
            Gl.glRotated(_xAngle, 1, 0, 0);
            Gl.glRotated(_yAngle, 0, 1, 0);
            Gl.glRotated(_zAngle, 0, 0, 1);
           
            Gl.glBegin(Gl.GL_QUADS);
            //front
            Gl.glColor3d(1,0,0);
            Gl.glVertex3d(0.75,0.75,-0.75);
            Gl.glVertex3d(-0.75, 0.75, -0.75);
            Gl.glVertex3d(-0.75, -0.75, -0.75);
            Gl.glVertex3d(0.75, -0.75, -0.75);
            //right
            Gl.glColor3d(0, 1, 0);
            Gl.glVertex3d(0.75, 0.75, 0.75);
            Gl.glVertex3d(0.75, 0.75, -0.75);
            Gl.glVertex3d(0.75, -0.75, -0.75);
            Gl.glVertex3d(0.75, -0.75, 0.75);
            //left
            Gl.glColor3d(0, 0, 1);
            Gl.glVertex3d(-0.75, 0.75, 0.75);
            Gl.glVertex3d(-0.75, 0.75, -0.75);
            Gl.glVertex3d(-0.75, -0.75, -0.75);
            Gl.glVertex3d(-0.75, -0.75, 0.75);
            //back
            Gl.glColor3d(1, 1, 1);
            Gl.glVertex3d(-0.75, 0.75, 0.75);
            Gl.glVertex3d(0.75, 0.75, 0.75);
            Gl.glVertex3d(0.75, -0.75, 0.75);
            Gl.glVertex3d(-0.75, -0.75, 0.75);
            //top
            Gl.glColor3d(1, 1, 0);
            Gl.glVertex3d(0.75, 0.75, 0.75);
            Gl.glVertex3d(-0.75, 0.75, 0.75);
            Gl.glVertex3d(-0.75, 0.75, -0.75);
            Gl.glVertex3d(0.75, 0.75, -0.75);
            //bottom
            Gl.glColor3d(0, 1, 1);
            Gl.glVertex3d(0.75, -0.75, -0.75);
            Gl.glVertex3d(-0.75, -0.75, -0.75);
            Gl.glVertex3d(-0.75, -0.75, 0.75);
            Gl.glVertex3d(0.75, -0.75, 0.75);
            Gl.glEnd();

            Gl.glFlush();
            Glut.glutSwapBuffers();
        }
daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

I'm thinking that there is some kind of wall, like a limit.

is there a way to increase the space or do I really have to make it smaller?

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

Move the camera back by translating (0,0,-10) units in matrix mode projection.

I know the basics of setting up OpenGL stuff but it looks like you are using java where I know it in C++.

sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99
 

it looks like java but I'm really using C#, Taoframework OpenGL and FreeGlut.

Does matrixmode - projection mean that I'm moving the camera?

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

Yeah any translations/rotations done in projection modifies the camera and in modelview you are moving the objects.

sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99
 

I see, thanks :)

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: