I need a little help, just getting started.

Started by davidbiii, February 13, 2011, 21:07:12

Previous topic - Next topic

davidbiii

I am just getting started with LJGL. 
I am struggling to pull all the pieces together.

I am hoping I can ask questions here on the forum.
I will be fine when I get rolling

Here is my first questions....

I am trying to draw a four triangles that meet at a point.
Like a pyramid on its side, with out a bottom.

When I draw it and then move around it, the sides will sometimes disappear.
It seems like I have to be facing it from the right direction to see it.

It seems like the surface is only seen from one direction
Can some explain,  I am sure it is something stupid.

Here is the code segment

        GL11.glBegin(GL11.GL_TRIANGLES);
         
        GL11.glNormal3f( 0.0f, 0.0f, 1.0f);
        GL11.glVertex3f(size, size,  size);   
        GL11.glVertex3f( size, -size,  size);          
        GL11.glVertex3f( 2 * size,  0,  0);   

        GL11.glNormal3f( 0.0f, 0.0f, 1.0f);
        GL11.glVertex3f(size, size,  -size);   
        GL11.glVertex3f( size, -size,  -size);        
        GL11.glVertex3f( 2 * size,  0,  0);   

        GL11.glNormal3f( 0.0f, 0.0f, 1.0f);
        GL11.glVertex3f(size, size,  +size);
        GL11.glVertex3f( size, size,  -size);
        GL11.glVertex3f( 2 * size,  0,  0);   
       
        GL11.glNormal3f( 0.0f, 0.0f, 1.0f);       
        GL11.glVertex3f( size, -size,  -size);
        GL11.glVertex3f(size, -size,  +size);
   
        GL11.glVertex3f( 2 * size,  0,  0);
             
       
        GL11.glEnd();

   








princec

When you move "behind" a triangle, the default behaviour in OpenGL is to "cull" it from the scene, that is, not draw it. To draw both the front and back of a triangle you need to use glCullFace().

Cas :)