/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the name of
* Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include <stdio.h>
#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,2.0F,2.0F,0.0F };
GLfloat mat_shininess[] = { 50.0F };
GLfloat lmodel_ambient[] = { 0.2F,0.2F,0.2F,1.0F };
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glLightfv(GL_LIGHT0,GL_AMBIENT,couleurGrisMoyen());
glLightfv(GL_LIGHT0,GL_DIFFUSE,couleurBlanc());
glLightfv(GL_LIGHT0,GL_SPECULAR,couleurBlanc());
glLightfv(GL_LIGHT0,GL_POSITION,position);
glMaterialfv(GL_FRONT,GL_AMBIENT,couleurGrisFonce());
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurGrisClair());
glMaterialfv(GL_FRONT,GL_SPECULAR,couleurBlanc());
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glClearAccum(0.0,0.0,0.0,0.0);
}
#define ACSIZE 16
GLfloat dx[ACSIZE],dy[ACSIZE];
GLfloat jitter3[3][2] = {
{0.5F,0.5F},
{1.35899e-05F,0.230369F},
{0.000189185F,0.766878F},
};
GLfloat jitter11[11][2] = {
{0.5F,0.5F},{0.406537F,0.135858F},
{0.860325F,0.968558F},{0.680141F,0.232877F},
{0.775694F,0.584871F},{0.963354F,0.309056F},
{0.593493F,0.864072F},{0.224334F,0.415055F},
{0.0366643F,0.690884F},{0.139685F,0.0313988F},
{0.319861F,0.767097F},
};
GLfloat jitter16[16][2] = {
{0.4375F,0.4375F},{0.1875F,0.5625F},
{0.9375F,1.1875F},{0.4375F,0.9375F-1.0F},
{0.6875F,0.5625F},{0.1875F,0.0625F},
{0.6875F,0.3125F},{0.1875F,0.3125F},
{0.4375F,0.1875F},{0.9375F-1.0F,0.4375F},
{0.6875F,0.8125F},{0.4375F,0.6875F},
{0.6875F,0.0625F},{0.9375F,0.9375F},
{1.1875F,0.8125F},{0.9375F,0.6875F},
};
GLfloat jitter29[29][2] = {
{0.5F,0.5F},{0.498126F,0.141363F},
{0.217276F,0.651732F},{0.439503F,0.954859F},
{0.734171F,0.836294F},{0.912454F,0.79952F},
{0.406153F,0.671156F},{0.0163892F,0.631994F},
{0.298064F,0.843476F},{0.312025F,0.0990405F},
{0.98135F,0.965697F},{0.841999F,0.272378F},
{0.559348F,0.32727F},{0.809331F,0.638901F},
{0.632583F,0.994471F},{0.00588314F,0.146344F},
{0.713365F,0.437896F},{0.185173F,0.246584F},
{0.901735F,0.474544F},{0.366423F,0.296698F},
{0.687032F,0.188184F},{0.313256F,0.472999F},
{0.543195F,0.800044F},{0.629329F,0.631599F},
{0.818263F,0.0439354F},{0.163978F,0.00621497F},
{0.109533F,0.812811F},{0.131325F,0.471624F},
{0.0196755F,0.331813F},
};
GLfloat jitter90[90][2] = {
{0.5F,0.5F},{0.784289F,0.417355F},
{0.608691F,0.678948F},{0.546538F,0.976002F},
{0.972245F,0.270498F},{0.765121F,0.189392F},
{0.513193F,0.743827F},{0.123709F,0.874866F},
{0.991334F,0.745136F},{0.56342F,0.0925047F},
{0.662226F,0.143317F},{0.444563F,0.928535F},
{0.248017F,0.981655F},{0.100115F,0.771923F},
{0.593937F,0.559383F},{0.392095F,0.225932F},
{0.428776F,0.812094F},{0.510615F,0.633584F},
{0.836431F,0.00343328F},{0.494037F,0.391771F},
{0.617448F,0.792324F},{0.688599F,0.48914F},
{0.530421F,0.859206F},{0.0742278F,0.665344F},
{0.979388F,0.626835F},{0.183806F,0.479216F},
{0.151222F,0.0803998F},{0.476489F,0.157863F},
{0.792675F,0.653531F},{0.0990416F,0.267284F},
{0.776667F,0.303894F},{0.312904F,0.296018F},
{0.288777F,0.691008F},{0.460097F,0.0436075F},
{0.594323F,0.440751F},{0.876296F,0.472043F},
{0.0442623F,0.0693901F},{0.355476F,0.00442787F},
{0.391763F,0.361327F},{0.406994F,0.696053F},
{0.708393F,0.724992F},{0.925807F,0.933103F},
{0.850618F,0.11774F},{0.867486F,0.233677F},
{0.208805F,0.285484F},{0.572129F,0.211505F},
{0.172931F,0.180455F},{0.327574F,0.598031F},
{0.685187F,0.372379F},{0.23375F,0.878555F},
{0.960657F,0.409561F},{0.371005F,0.113866F},
{0.29471F,0.496941F},{0.748611F,0.0735321F},
{0.878643F,0.34504F},{0.210987F,0.778228F},
{0.692961F,0.606194F},{0.82152F,0.8893F},
{0.0982095F,0.563104F},{0.214514F,0.581197F},
{0.734262F,0.956545F},{0.881377F,0.583548F},
{0.0560485F,0.174277F},{0.0729515F,0.458003F},
{0.719604F,0.840564F},{0.325388F,0.7883F},
{0.26136F,0.0848927F},{0.393754F,0.467505F},
{0.425361F,0.577672F},{0.648594F,0.0248658F},
{0.983843F,0.521048F},{0.272936F,0.395127F},
{0.177695F,0.675733F},{0.89175F,0.700901F},
{0.632301F,0.908259F},{0.782859F,0.53611F},
{0.0141421F,0.855548F},{0.0437116F,0.351866F},
{0.939604F,0.0450863F},{0.0320883F,0.962943F},
{0.341155F,0.895317F},{0.952087F,0.158387F},
{0.908415F,0.820054F},{0.481435F,0.281195F},
{0.675525F,0.25699F},{0.585273F,0.324454F},
{0.156488F,0.376783F},{0.140434F,0.977416F},
{0.808155F,0.77305F},{0.282973F,0.188937F},
};
void loaddxdy(void) {
long i;
for (i = 0; i < ACSIZE; i++) {
dx[i] = jitter16[i][0]*10/glutGet(GLUT_WINDOW_WIDTH);
dy[i] = jitter16[i][1]*10/glutGet(GLUT_WINDOW_HEIGHT); }
}
void display(void) {
int i;
glPushMatrix() ;
manipulateurSouris();
manipulateurClavier();
glClear(GL_ACCUM_BUFFER_BIT);
loaddxdy();
for (i = 0; i < (ACSIZE); i++) {
printf("Passe %d\n",i);
glPushMatrix();
glTranslatef(dx[i],dy[i],0.0);
glRotatef(45.0,1.0,1.0,1.0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glutSolidTeapot(2.0);
glPopMatrix();
glAccum(GL_ACCUM,1.0/(ACSIZE)); }
printf("Travail final\n");
glAccum(GL_RETURN,1.0);
printf("Termine\n");
glPopMatrix() ;
glFlush();
glutSwapBuffers() ;
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(300,300);
glutInitWindowPosition(50,50);
glutCreateWindow("Utilisation de du Tampon Accumulation : Antialiasing");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-3.0,3.0,-3.0,3.0,-100.0,100.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(keyBasique);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}