/*
* (c) Copyright 1993, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
/*
* teapots.c
* This program demonstrates lots of material properties.
* A single light source illuminates the objects.
*/
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleCouleurs.h"
#include "ModuleManipulateur.h"
#include "ModuleMenus.h"
#include "ModuleReshape.h"
void myinit(void) {
GLfloat position[] = { 0.0F,3.0F,3.0F,0.0F };
GLfloat local_view[] = { 0.0F };
glLightfv(GL_LIGHT0,GL_AMBIENT,couleurNoir());
glLightfv(GL_LIGHT0,GL_DIFFUSE,couleurBlanc());
glLightfv(GL_LIGHT0,GL_SPECULAR,couleurBlanc());
glLightfv(GL_LIGHT0,GL_POSITION,position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,couleurGrisFonce());
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER,local_view);
glFrontFace (GL_CW);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void renderTeapot (GLfloat x,GLfloat y,GLfloat ambr,GLfloat ambg,GLfloat ambb,GLfloat difr,GLfloat difg,GLfloat difb,GLfloat specr,GLfloat specg,GLfloat specb,GLfloat shine) {
float mat[4];
glPushMatrix();
glTranslatef(x-8.0F,y-9.0F,0.0);
mat[0] = ambr;
mat[1] = ambg;
mat[2] = ambb;
mat[3] = 1.0;
glMaterialfv(GL_FRONT,GL_AMBIENT,mat);
mat[0] = difr;
mat[1] = difg;
mat[2] = difb;
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat);
mat[0] = specr;
mat[1] = specg;
mat[2] = specb;
glMaterialfv(GL_FRONT,GL_SPECULAR,mat);
glMaterialf(GL_FRONT,GL_SHININESS,shine*128.0F);
glutSolidTeapot(1.0);
glPopMatrix();
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
renderTeapot(2.0F,17.0F,0.0215F,0.1745F,0.0215F,0.07568F,0.61424F,0.07568F,0.633F,0.727811F,0.633F,0.6F);
renderTeapot(2.0F,14.0F,0.135F,0.2225F,0.1575F,0.54F,0.89F,0.63F,0.316228F,0.316228F,0.316228F,0.1F);
renderTeapot(2.0F,11.0F,0.05375F,0.05F,0.06625F,0.18275F,0.17F,0.22525F,0.332741F,0.328634F,0.346435F,0.3F);
renderTeapot(2.0F,8.0F,0.25F,0.20725F,0.20725F,1.0F,0.829F,0.829F,0.296648F,0.296648F,0.296648F,0.088F);
renderTeapot(2.0F,5.0F,0.1745F,0.01175F,0.01175F,0.61424F,0.04136F,0.04136F,0.727811F,0.626959F,0.626959F,0.6F);
renderTeapot(2.0F,2.0F,0.1F,0.18725F,0.1745F,0.396F,0.74151F,0.69102F,0.297254F,0.30829F,0.306678F,0.1F);
renderTeapot(6.0F,17.0F,0.329412F,0.223529F,0.027451F,0.780392F,0.568627F,0.113725F,0.992157F,0.941176F,0.807843F,0.21794872F);
renderTeapot(6.0F,14.0F,0.2125F,0.1275F,0.054F,0.714F,0.4284F,0.18144F,0.393548F,0.271906F,0.166721F,0.2F);
renderTeapot(6.0F,11.0F,0.25F,0.25F,0.25F,0.4F,0.4F,0.4F,0.774597F,0.774597F,0.774597F,0.6F);
renderTeapot(6.0F,8.0F,0.19125F,0.0735F,0.0225F,0.7038F,0.27048F,0.0828F,0.256777F,0.137622F,0.086014F,0.1F);
renderTeapot(6.0F,5.0F,0.24725F,0.1995F,0.0745F,0.75164F,0.60648F,0.22648F,0.628281F,0.555802F,0.366065F,0.4F);
renderTeapot(6.0F,2.0F,0.19225F,0.19225F,0.19225F,0.50754F,0.50754F,0.50754F,0.508273F,0.508273F,0.508273F,0.4F);
renderTeapot(10.0F,17.0F,0.0F,0.0F,0.0F,0.01F,0.01F,0.01F,0.50F,0.50F,0.50F,.25F);
renderTeapot(10.0F,14.0F,0.0F,0.1F,0.06F,0.0F,0.50980392F,0.50980392F,0.50196078F,0.50196078F,0.50196078F,.25F);
renderTeapot(10.0F,11.0F,0.0F,0.0F,0.0F,0.1F,0.35F,0.1F,0.45F,0.55F,0.45F,.25F);
renderTeapot(10.0F,8.0F,0.0F,0.0F,0.0F,0.5F,0.0F,0.0F,0.7F,0.6F,0.6F,.25F);
renderTeapot(10.0F,5.0F,0.0F,0.0F,0.0F,0.55F,0.55F,0.55F,0.70F,0.70F,0.70F,.25F);
renderTeapot(10.0F,2.0F,0.0F,0.0F,0.0F,0.5F,0.5F,0.0F,0.60F,0.60F,0.50F,.25F);
renderTeapot(14.0F,17.0F,0.02F,0.02F,0.02F,0.01F,0.01F,0.01F,0.4F,0.4F,0.4F,.078125F);
renderTeapot(14.0F,14.0F,0.0F,0.05F,0.05F,0.4F,0.5F,0.5F,0.04F,0.7F,0.7F,.078125F);
renderTeapot(14.0F,11.0F,0.0F,0.05F,0.0F,0.4F,0.5F,0.4F,0.04F,0.7F,0.04F,.078125F);
renderTeapot(14.0F,8.0F,0.05F,0.0F,0.0F,0.5F,0.4F,0.4F,0.7F,0.04F,0.04F,.078125F);
renderTeapot(14.0F,5.0F,0.05F,0.05F,0.05F,0.5F,0.5F,0.5F,0.7F,0.7F,0.7F,.078125F);
renderTeapot(14.0F,2.0F,0.05F,0.05F,0.0F,0.5F,0.5F,0.4F,0.7F,0.7F,0.04F,.078125F);
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(300,360);
glutInitWindowPosition(50,50);
glutCreateWindow("Teapots");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-8.0,8.0,-8.0,8.0,-1000.0,1000.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(keyBasique);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}