Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-10-30
4
Medium Priority
?
244 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 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

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 …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 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