Solved

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

Posted on 2003-10-30
4
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

734 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