jueves, 28 de febrero de 2013

1er. Figura en OpenGL

Figura en dibujo




Figura



Codigo

// triangulo.cpp : Defines the entry point for the console application.
#include <GL/glut.h>
typedef float point3[3];
/* initial triangle */
/* initial     x      y    */
point3 v[]={{0.0, 0.00,-3.0}, {0.0, 0.0,3.0}, {6.0, 0.0,-3.0}, {3.0, 6.0,3.0}};
int n;
void display(void)
{
 glClear(GL_COLOR_BUFFER_BIT);
 glBegin(GL_TRIANGLES);
 glVertex2fv(v[0]);
 glVertex2fv(v[1]);
 glVertex2fv(v[2]);
 glVertex2fv(v[1]);
 glVertex2fv(v[2]);
 glVertex2fv(v[3]);
  glVertex2fv(v[3]);
 glVertex2fv(v[2]);
 glVertex2fv(v[0]);
  glVertex2fv(v[0]);
 glVertex2fv(v[1]);
 glVertex2fv(v[3]);
 glEnd();
 glFlush();
}
void myinit()
{
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -6.0, 8.0, 8.0,-10.0);
 glMatrixMode(GL_MODELVIEW);
 glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glColor3f(0.9, 0.0, 0.9);
}
void
main(int argc, char **argv)
{
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
 glutInitWindowSize(500, 500);
 glutCreateWindow("3D Gasket");
 glutDisplayFunc(display);
 myinit();
 glutMainLoop();

}

No hay comentarios:

Publicar un comentario