Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

trying to rotate this triangle so that i can tell its 3d

Posted on 2003-10-30
4
Medium Priority
?
245 Views
Last Modified: 2010-04-07
hmmm this is got me stumped. as far as i know this is right (obviously not tho) i cant seem to get the viewport or camera to shift back and the shape to rotate. Anyone care to shed any light on this problem?
0
Comment
Question by:rholding2000
2 Comments
 

Author Comment

by:rholding2000
ID: 9649981
sorry forgot to post the code

#include <windows.h>                                    
#include <glut.h>
#include <gl\gl.h>                                          

GLfloat      rtri;

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);                                                
      glRotatef(rtri,0.0f,1.0f,0.0f);            
      glTranslatef(0.0f,0.0f,20.0f);
      glColor3f(1.0f,0.0f,0.0f);                              
      glVertex3f( 0.0f, 1.0f, 0.0f);
      glColor3f(0.0f,1.0f,0.0f);                              
      glVertex3f(-1.0f,-1.0f, 1.0f);
      glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);                              // Right Of Triangle (Front)
            glColor3f(1.0f,0.0f,0.0f);                                    // Red
            glVertex3f( 0.0f, 1.0f, 0.0f);                              // Top Of Triangle (Right)
            glColor3f(0.0f,0.0f,1.0f);                                    // Blue
            glVertex3f( 1.0f,-1.0f, 1.0f);                              // Left Of Triangle (Right)
            glColor3f(0.0f,1.0f,0.0f);                                    // Green
            glVertex3f( 1.0f,-1.0f, -1.0f);                              // Right Of Triangle (Right)
            glColor3f(1.0f,0.0f,0.0f);                                    // Red
            glVertex3f( 0.0f, 1.0f, 0.0f);                              // Top Of Triangle (Back)
            glColor3f(0.0f,1.0f,0.0f);                                    // Green
            glVertex3f( 1.0f,-1.0f, -1.0f);                              // Left Of Triangle (Back)
            glColor3f(0.0f,0.0f,1.0f);                                    // Blue
            glVertex3f(-1.0f,-1.0f, -1.0f);                              // Right Of Triangle (Back)
            glColor3f(1.0f,0.0f,0.0f);                                    // Red
            glVertex3f( 0.0f, 1.0f, 0.0f);                              // Top Of Triangle (Left)
            glColor3f(0.0f,0.0f,1.0f);                                    // Blue
            glVertex3f(-1.0f,-1.0f,-1.0f);                              // Left Of Triangle (Left)
            glColor3f(0.0f,1.0f,0.0f);                                    // Green
            glVertex3f(-1.0f,-1.0f, 1.0f);                              // Right Of Triangle (Left)
      glEnd();// Reset The Current Modelview Matrix
      glFlush();
      rtri+=0.2f;      


}


void main(int argc, char **argv)
{

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("GLUT Initialisation Tutorial");
glutDisplayFunc(renderScene);
glutMainLoop();

}
0
 
LVL 1

Accepted Solution

by:
jadecc earned 400 total points
ID: 9727532
Hi,

  I know this is an older post but if you haven't figured this out by now, try moving the glRotatef and glTranslatef before the glBegin() statement. I think that will take care of the rotation problem.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question