Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Splitting Pyramid Problem

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    9

    Splitting Pyramid Problem

    Good for now: Click image for larger version. 

Name:	oknow.jpg 
Views:	68 
Size:	20.9 KB 
ID:	934
    Bad. One of the faces reappears down the middle: Click image for larger version. 

Name:	badlater.jpg 
Views:	76 
Size:	21.4 KB 
ID:	933

    I've have a pyramid on screen. I'm able to rotate it by 5 degrees on the y-axis, but at certain points one of the faces will appear straight down the middle, and will continue to increase in size until it reaches the original face size, which at that point if you continue to go in the same direction (using the left/right arrow keys) the pyramid will then rotate in the opposite direction. I am incrementing and decrementing the angle with:

    Code :
    if ( key == GLUT_KEY_LEFT )
    	{
    		rStepAngle += 0.10f;
    	}
     
    	else if ( key == GLUT_KEY_RIGHT )
    	{
    		rStepAngle -= 0.10f;
    	}
            ...

    Another question I have is, how do I make each face a solid color. I attempted to do this by:

    Code :
    VertexData data[ 12 ] = {
    		{ { 255,   0,   0, 255 }, { -0.5f, 0.0f,  0.5f } },	// front
    		{ { 255,   0,   0, 255 }, {  0.5f, 0.0f,  0.5f } },
    		{ { 255,   0,   0, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ {   0, 255,   0, 255 }, {  0.5f, 0.0f,  0.5f } },	// right
    		{ {   0, 255,   0, 255 }, {  0.5f, 0.0f, -0.5f } },
    		{ {   0, 255,   0, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ {   0,   0, 255, 255 }, {  0.5f, 0.0f, -0.5f } },	// back
    		{ {   0,   0, 255, 255 }, { -0.5f, 0.0f, -0.5f } },
    		{ {   0,   0, 255, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ { 255, 255,   0, 255 }, { -0.5f, 0.0f, -0.5f } },	// left
    		{ { 255, 255,   0, 255 }, { -0.5f, 0.0f,  0.5f } },
    		{ { 255, 255,   0, 255 }, {  0.0f, 0.5f,  0.0f } }
    	};
     
    glVertexAttribPointer( vColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof( VertexData ), BUFFER_OFFSET( 0 ) );

    Sticking that in the buffer, but the shader does gouraud and it's like the color for the vertices is random.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    9
    I was able to figure out the problem. A beginner mistake: I had not culled the back face.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •