====codigo========
/*
* GLUT Shapes Demo
*
* Written by Nigel Stewart November 2003
*
* This program is test harness for the sphere, cone
* and torus shapes in GLUT.
*
* Spinning wireframe and smooth shaded shapes are
* displayed until the ESC or q key is pressed. The
* number of geometry stacks and slices can be adjusted
* using the + and - keys.
*/
#include<windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
static int slices = 16;
static int stacks = 16;
/* GLUT callback Handlers */
static void display(void)
{
glClearColor(0,0,0,1);//pantalla color negro
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Dibujando ejes
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);//Rojo Eje X
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(2.0f, 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);//verde Eje Y
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 2.0f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f);//azul Eje Z
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 2.0f);
glEnd();
glColor3f(0.0f, 0.0f, 1.0f); //dibujos en color gris
//Dibujando el objeto
for (GLint i=0; i<10; i++) {
glPushMatrix();
glRotatef(i * 360 / 10, 0.0f, 1.0f, 0.0f);
glTranslatef(0.3f, 0.0f, 0.0f);
glutSolidSphere(0.1, 30, 30);
//glutWireTeapot(0.25);
glPopMatrix();
}
glColor3f(1.0f, 0.0f, 0.0f); //dibujos en color gris
//Dibujando el objeto
for (GLint i=0; i<10; i++) {
glPushMatrix();
glRotatef(i * 360 / 10, 0.0f, 1.0f, 0.0f);
glTranslatef(0.7f, 0.0f, 0.0f);
glTranslatef(0.0f, 1.0f, 0.0f);
//glutWireTeapot(0.25);
glutWireCube(0.2);
glutSolidCube(0.2);
//glColor3b(1.0f, 0.0f, 0.0f);
glPopMatrix();
}
glColor3f(0.0f, 1.0f, 0.0f); //dibujos en color verde
//Dibujando el objeto
for (GLint i=0; i<10; i++) {
glPushMatrix();
glRotatef(i * 360 / 10, 0.0f, 1.0f, 0.0f);
glTranslatef(0.8f, 0.0f, 1.0f);
glTranslatef(0.0f, 2.0f, 0.0f);
//glutWireTeapot(0.25);
glutWireCube(0.2);
glutSolidCube(0.2);
glPopMatrix();
}
//glutWireTeapot(0.5);
glutSwapBuffers();
}
// Funcion que actua sobre la Pantalla
void reshape(int width, int height){
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0,1,1.0,128.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(2.5,3.5,2.0,0.0,0.0,0.0,0.0,1.0,0.0);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(20,20);
glutInitWindowSize(500,500);
glutCreateWindow("Transformaciones OpenGL");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return EXIT_SUCCESS;
}
0 comentarios:
Publicar un comentario