Thread: What am i missing or doing wrong?

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    1

    Question What am i missing or doing wrong?

    ok, im just trying to open an opengl window and make a triangle appear. this code is based on a tutorial i found. what am i missing or doing wrong?

    Code:
    #include <GL\glut.h>
    
    
    void Display(void)
    {
    	glClear(GL_COLOR_BUFFER_BIT);
    	glLoadIdentity();
    	glBegin(GL_POLYGON);
    		glColor3f(0.0,0.0,0.0);
    		glVertex3f(-0.5,-0.5,-3.0);
    		glColor3f(1.0,0.0,0.0);
    		glVertex3f(0.5,-0.5,-3.0);
    		glColor3f(0.0,0.0,1.0);
    		glVertex3f(0.5,0.5,-3.0);
    	glEnd();
    	glFlush();			
    }
    
    void Reshape(int x, int y)
    {
    	if (y == 0 || x == 0) return;  
    	glMatrixMode(GL_PROJECTION);  
    	glLoadIdentity();
    	gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
    	glMatrixMode(GL_MODELVIEW);
    	glViewport(0,0,x,y);  
    }
    
    int main (int argc, char **argv)
    {
    	
    	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_SINGLE);
    	glutInitWindowSize(300,300);
    	glutCreateWindow("Intro");
    	glClearColor(0.0,0.0,0.0,0.0);
    	glutDisplayFunc(Display);
    	glutReshapeFunc(Reshape);
    	glutMainLoop();
    	return 0;
    }

  2. #2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong?
    By Hussain Hani in forum C++ Programming
    Replies: 3
    Last Post: 07-10-2009, 01:38 AM
  2. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM
  3. Help with a Class
    By maloy in forum C++ Programming
    Replies: 12
    Last Post: 09-27-2002, 08:41 PM
  4. Help!!!!!!!! What Am I Doing Wrong????
    By Cnote in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2002, 10:09 PM
  5. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM