miércoles, 26 de febrero de 2014

Figures predesigned of OpenGL(glut)


Código Fuente:
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif
#include <stdlib.h>
#include <iostream>


using namespace std;

void display()
{
cerr << "display() \n";
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();


glPushMatrix();
glTranslatef(-0.8,0.8,0.0);
glColor3f(1,0,1);
glScalef(0.8,0.8,0.8);
glRotatef(45,0,1,1);
glutWireSphere(0.2,15,15);
glPopMatrix();


glPushMatrix();
glTranslatef(-0.4,0.8,0.0);
glColor3f(1,1,0);
glScalef(0.8,0.8,0.8);
glRotatef(90,1,0,1);
glutWireCone(0.2,0.5,10,10);
glPopMatrix();


glPushMatrix();
glTranslatef(0,0.8,0.0);
glColor3f(0,1,1);
glScalef(0.8,0.8,0.8);
glRotatef(60,0,1,1);
glutWireCube(0.2);
glPopMatrix();

glPushMatrix();
glTranslatef(-0.8,0.2,0.0);
glColor3f(0,0,1);
glScalef(0.8,0.8,0.8);
glRotatef(60,0,1,1);
glutWireTorus(0.1,0.1,10,10);
glPopMatrix();



glPushMatrix();
glTranslatef(-0.5,0.2,0.0);
glColor3f(1,1,1);
glScalef(0.2,0.2,0.2);
glRotatef(30,0,1,1);
glutWireOctahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(-0.1,0.2,0.0);
glColor3f(0,0,1);
glScalef(0.1,0.1,0.1);
glRotatef(30,0,1,1);
glutWireDodecahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(0.3,0.2,0.0);
glColor3f(1,0,0);
glScalef(0.2,0.2,0.2);
glRotatef(60,0,1,1);
glutWireIcosahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(0.7,0.2,0.0);
glColor3f(0,1,1);
glScalef(0.2,0.2,0.2);
glRotatef(60,0,1,1);
glutWireOctahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(0.5,0.75,0.0);
glColor3f(1,1,0);
glScalef(0.8,0.8,0.8);
glRotatef(60,0,1,1);
glutSolidTeapot(0.2);
glPopMatrix();


glFlush();
}


int main(int argc, char *argv[])
{
  cerr << "main () \n";
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  glutInitWindowSize(550,450);
  glutCreateWindow("");
  glutDisplayFunc(display);
  glutMainLoop();
}

No hay comentarios:

Publicar un comentario