Solved

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

Posted on 2003-10-30
4
238 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
4 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 100 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
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 gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now