lunes, 27 de febrero de 2012

CUBO 2D


CODIGO DE CUBO EN 2D
#include <GL/glut.h>


void myinit(void)
{
      glClearColor(1.0, 1.0, 1.0, 1.0);
      glColor3f(1.0, 0.0, 0.0); 
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0.0, 500.0, 0.0, 500.0);
      glMatrixMode(GL_MODELVIEW);
}




void display( void )
{


    typedef GLfloat point2[2];     


    point2 verticesc[8]={{150.0,150.0},{350.0,150.0},{350.0,350.0},{150.0,350.0},{250.0,250.0},{400.0,250.0},{400.0,450.0},{250.0,450.0}};




    glClear(GL_COLOR_BUFFER_BIT);


glBegin(GL_LINES);
glVertex2fv(verticesc[0]);
glVertex2fv(verticesc[1]);
glVertex2fv(verticesc[1]);
glVertex2fv(verticesc[2]);
glVertex2fv(verticesc[2]);
glVertex2fv(verticesc[3]);
glVertex2fv(verticesc[3]);
glVertex2fv(verticesc[0]);
glVertex2fv(verticesc[0]);
glVertex2fv(verticesc[4]);
glVertex2fv(verticesc[4]);
glVertex2fv(verticesc[5]);
glVertex2fv(verticesc[5]);
glVertex2fv(verticesc[6]);
glVertex2fv(verticesc[6]);
glVertex2fv(verticesc[7]);
glVertex2fv(verticesc[7]);
glVertex2fv(verticesc[3]);
glVertex2fv(verticesc[7]);
glVertex2fv(verticesc[4]);
glVertex2fv(verticesc[6]);
glVertex2fv(verticesc[2]);
glVertex2fv(verticesc[5]);
glVertex2fv(verticesc[1]);
glEnd();

     glFlush(); 
 }

//http://lapalabradelmanko.wordpress.com/2010/09/22/dibujar-funcion-seno-en-opengl/


void main(int argc, char** argv)
{
    //glutInit(&amp;argc,argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
    glutInitWindowSize(500,500); 
    glutInitWindowPosition(0,0); 
    glutCreateWindow("Cubo");
    glutDisplayFunc(display); 




    myinit();




    glutMainLoop();
}

No hay comentarios:

Publicar un comentario