OpenGL Würfel zeichnen



  • Hallo,

    ich habe eine Frage:

    Ich zeichne einen Würfel mit:

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
    	glLoadIdentity();									// Reset The Current Modelview Matrix
    
    	glTranslatef(0.0f,0.0f,-7.0f);						// Move into The Screen 7.0
    
    	glRotatef(rquad,0.0f,1.0f,0.0f);					// Rotate The Quad On The X axis ( NEW )
    
    	glBegin(GL_QUADS);									// Draw A Quad
    		glColor3f(0.0f,1.0f,0.0f);						
    		glVertex3f( 1.0f, 1.0f,-1.0f);					
    		glVertex3f(-1.0f, 1.0f,-1.0f);					
    		glVertex3f(-1.0f, 1.0f, 1.0f);					
    		glVertex3f( 1.0f, 1.0f, 1.0f);					
    
    		glColor3f(1.0f,0.5f,0.0f);						
    		glVertex3f( 1.0f,-1.0f, 1.0f);					
    		glVertex3f(-1.0f,-1.0f, 1.0f);					
    		glVertex3f(-1.0f,-1.0f,-1.0f);					
    		glVertex3f( 1.0f,-1.0f,-1.0f);
    
    		glColor3f(1.0f,0.0f,0.0f);						
    		glVertex3f( 1.0f, 1.0f, 1.0f);					
    		glVertex3f(-1.0f, 1.0f, 1.0f);					
    		glVertex3f(-1.0f,-1.0f, 1.0f);					
    		glVertex3f( 1.0f,-1.0f, 1.0f);					
    
    		glColor3f(1.0f,1.0f,0.0f);						
    		glVertex3f( 1.0f,-1.0f,-1.0f);				
    		glVertex3f(-1.0f,-1.0f,-1.0f);					
    		glVertex3f(-1.0f, 1.0f,-1.0f);					
    		glVertex3f( 1.0f, 1.0f,-1.0f);					
    
    		glColor3f(0.0f,0.0f,1.0f);						
    		glVertex3f(-1.0f, 1.0f, 1.0f);					
    		glVertex3f(-1.0f, 1.0f,-1.0f);					
    		glVertex3f(-1.0f,-1.0f,-1.0f);					
    		glVertex3f(-1.0f,-1.0f, 1.0f);					
    
    		glColor3f(1.0f,0.0f,1.0f);						
    		glVertex3f( 1.0f, 1.0f,-1.0f);					
    		glVertex3f( 1.0f, 1.0f, 1.0f);					
    		glVertex3f( 1.0f,-1.0f, 1.0f);					
    		glVertex3f( 1.0f,-1.0f,-1.0f);					
    	glEnd();
    

    Dieser Würfel wird mit der einer der Flächen nach vorne gezeichnet.
    Wie müsste man den Code abändern, damit der Würfel mit einer der Kanten nach vorne gezeichnet wird?



  • rquad muss hier

    glRotatef(rquad,0.0f,1.0f,0.0f);

    einen anderen wert haben (+/- 45 IMO)



  • Arrrgh ... Danke 😃


Log in to reply