[gameprogrammer] glut problems
- From: "Yasser Gonzalez" <yassergs@xxxxxxxxxxxxxxx>
- To: "gameprogrammer@xxxxxxxxxxxxx" <gameprogrammer@xxxxxxxxxxxxx>
- Date: Fri, 20 Apr 2007 10:22:40 +0200
Some body colud tell me what happends with this code. I don't see the
triangle on the screen:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <gl/glut.h>
void init(GLvoid)
{
glClearColor(1.0f,0.0f,1.0f,0.0f);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
}
void reshape(int w,int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80.0f,(float)w/(float)h,1.0f,5000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-6.5f);
glBegin(GL_TRIANGLES);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glutSwapBuffers();
}
void idle(void)
{
display();
}
void keyPressed(unsigned char k, int x,int y)
{
switch(k)
{
case 27:
exit(0);
break;
}
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(5,5);
glutInitWindowSize(400,400);
glutCreateWindow("Ejemplo 2 de GLUT");
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
init();
glutDisplayFunc(display);
glutIdleFunc(idle);
glutKeyboardFunc(keyPressed);
glutMainLoop();
return 1;
}
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: glut problems
- From: Bob Kozdemba
Other related posts:
- » [gameprogrammer] glut problems
- » [gameprogrammer] Re: glut problems
- [gameprogrammer] Re: glut problems
- From: Bob Kozdemba