Les modules utilisés
dans les exemples GLUt
Un fichier zip de l'ensemble des modules
ModuleFont.h: Gestion des polices de caractères
/*
* Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc.
*/
/*
* font.c
*
* Draws some text in a bitmapped font. Uses glBitmap()
* and other pixel routines. Also demonstrates use of
* display lists.
*/
/* Modifie par: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
#ifndef MODULEFONT
#define MODULEFONT
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
enum {
CENTER = 0,
RIGHT,
LEFT } ;
enum {
REGULAR8x13 = 1,
REGULAR6x10,
SYMBOL,
DESSIN } ;
void lineOutput(int xi,int yi,int xf,int yf) ;
void simpleBitmapOutput(char *format,...) ;
void simpleBitmapOutput(int fonte,char *format,...) ;
void simpleBitmapOutput(int depth,int fonte,char *format,...) ;
void placeFontCursor(float x,float y,float z) ;
void deplacementCursor(float x,float y,float z) ;
void setFont(void *font,int alignement) ;
void setAlignement(int a);
void bitmapStringOutput(char *format,...) ;
void bitmapStringOutput(GLfloat x,GLfloat y,GLfloat z,char *format,...) ;
void bitmapOutput(void *font,char *format,...) ;
void bitmapOutput(GLfloat x,GLfloat y,GLfloat z,void *font,char *format,...) ;
void setBold(int b) ;
void setAntialiased(int a) ;
void setEcartementCaracteres(float e) ;
int getBold(void) ;
int getAntialiased(void) ;
float getEcartementCaracteres(void) ;
void strokeOutput(GLfloat x,GLfloat y,float fact,char *format,...) ;
#endif
ModuleFont.cpp: Gestion des polices de caractères
/*
* Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc.
*/
/*
* font.c
*
* Draws some text in a bitmapped font. Uses glBitmap()
* and other pixel routines. Also demonstrates use of
* display lists.
*/
/* Modifie par: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleFont.h"
static GLubyte dessin[256][13] = {
/* */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ! */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* " */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* # */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* $ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* % */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* & */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ' */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ( */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ) */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* * */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* + */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* , */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* - */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* . */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* / */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 0 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 1 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 2 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 3 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 4 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 5 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 6 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 7 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 8 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 9 */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* : */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ; */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* < */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* = */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* > */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ? */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* @ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* A */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* B */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* C */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* D */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* E */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* F */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0xFE,0x04,0x08},
/* G */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* H */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* I */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* J */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* K */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* L */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* M */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* N */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* O */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* P */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* Q */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* R */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* S */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* T */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00},
/* U */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* V */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* W */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* X */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* Y */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* Z */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* [ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* \ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ] */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ^ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* _ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ` */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* a */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* b */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* c */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* d */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* e */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* f */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x20,0x7F,0x20,0x10},
/* g */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* h */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* i */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* j */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* k */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* l */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* m */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* n */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* o */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* p */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* q */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* r */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* s */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* t */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00},
/* u */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* v */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* w */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* x */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* y */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* z */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* { */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* | */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* } */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ~ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
static GLubyte symbol[256][13] = {
/* */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ! */ {0x00,0x10,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00},
/* " */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x28,0x28,0x00,0x00},
/* # */ {0x00,0x00,0x00,0x48,0xfc,0x48,0x48,0xfc,0x48,0x00,0x00,0x00,0x00},
/* $ */ {0x00,0x28,0x7c,0xaa,0x2a,0x2a,0x5c,0xa8,0xa8,0xaa,0x7c,0x28,0x00},
/* % */ {0x00,0x0c,0x12,0x92,0x4c,0x20,0x10,0x08,0x64,0x92,0x90,0x60,0x00},
/* & */ {0x00,0x76,0x88,0x94,0x92,0x60,0x20,0x20,0x40,0x40,0x30,0x00,0x00},
/* ' */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x18,0x00,0x00},
/* ( */ {0x00,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x00},
/* ) */ {0x00,0x10,0x08,0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x00},
/* * */ {0x00,0x00,0x10,0x54,0x38,0xfe,0x38,0x54,0x10,0x00,0x00,0x00,0x00},
/* + */ {0x00,0x00,0x10,0x10,0x10,0xfe,0x10,0x10,0x10,0x00,0x00,0x00,0x00},
/* , */ {0x30,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* - */ {0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* . */ {0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* / */ {0x00,0x80,0x80,0x40,0x20,0x20,0x10,0x08,0x08,0x04,0x02,0x02,0x00},
/* 0 */ {0x00,0x38,0x44,0x82,0xc2,0xa2,0x92,0x8a,0x86,0x82,0x44,0x38,0x00},
/* 1 */ {0x00,0xfe,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0x50,0x30,0x10,0x00},
/* 2 */ {0x00,0xfe,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x02,0x82,0x7c,0x00},
/* 3 */ {0x00,0x7c,0x82,0x02,0x02,0x02,0x7c,0x02,0x02,0x02,0x82,0x7c,0x00},
/* 4 */ {0x04,0x04,0x04,0x04,0x04,0xfe,0x44,0x24,0x24,0x14,0x0c,0x04,0x00},
/* 5 */ {0x00,0x7c,0x82,0x02,0x02,0x02,0xfc,0x80,0x80,0x80,0x80,0xfe,0x00},
/* 6 */ {0x00,0x7c,0x82,0x82,0x82,0x82,0xfc,0x80,0x80,0x80,0x82,0x7e,0x00},
/* 7 */ {0x00,0x40,0x40,0x40,0x40,0x20,0x10,0x08,0x04,0x02,0x02,0xfe,0x00},
/* 8 */ {0x00,0x7c,0x82,0x82,0x82,0x82,0x7c,0x82,0x82,0x82,0x82,0x7c,0x00},
/* 9 */ {0x00,0x7c,0x82,0x02,0x02,0x02,0x7e,0x82,0x82,0x82,0x82,0x7c,0x00},
/* : */ {0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00},
/* ; */ {0x30,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00},
/* < */ {0x00,0x04,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x04,0x00},
/* = */ {0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00,0x00},
/* > */ {0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x80,0x00},
/* ? */ {0x00,0x10,0x00,0x10,0x10,0x08,0x04,0x02,0x02,0x82,0x82,0x7c,0x00},
/* @ */ {0x00,0x3e,0x40,0x9c,0xa2,0xa2,0x9a,0x82,0x7c,0x00,0x00,0x00,0x00},
/* A */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0x66,0x3c,0x18},
/* B */{0x00,0x00,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* C */{0x00,0x00,0x7e,0xe7,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe7,0x7e},
/* D */{0x00,0x00,0xfc,0xce,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc7,0xce,0xfc},
/* E */{0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xc0,0xff},
/* F */{0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xff},
/* G */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xcf,0xc0,0xc0,0xc0,0xc0,0xe7,0x7e},
/* H */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0xc3,0xc3},
/* I */{0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e},
/* J */{0x00,0x00,0x7c,0xee,0xc6,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06},
/* K */{0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xe0,0xf0,0xd8,0xcc,0xc6,0xc3},
/* L */{0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
/* M */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xdb,0xff,0xff,0xe7,0xc3},
/* N */{0x00,0x00,0xc7,0xc7,0xcf,0xcf,0xdf,0xdb,0xfb,0xf3,0xf3,0xe3,0xe3},
/* O */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e},
/* P */{0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* Q */{0x00,0x00,0x3f,0x6e,0xdf,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c},
/* R */{0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* S */{0x00,0x00,0x7e,0xe7,0x03,0x03,0x07,0x7e,0xe0,0xc0,0xc0,0xe7,0x7e},
/* T */{0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff},
/* U */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3},
/* V */{0x00,0x00,0x18,0x3c,0x3c,0x66,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3},
/* W */{0x00,0x00,0xc3,0xe7,0xff,0xff,0xdb,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3},
/* X */{0x00,0x00,0xc3,0x66,0x66,0x3c,0x3c,0x18,0x3c,0x3c,0x66,0x66,0xc3},
/* Y */{0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x3c,0x66,0x66,0xc3},
/* Z */{0x00,0x00,0xff,0xc0,0xc0,0x60,0x30,0x7e,0x0c,0x06,0x03,0x03,0xff},
/* [ */ {0x00,0x00,0x1c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1c,0x00},
/* \ */ {0x00,0x02,0x02,0x04,0x08,0x08,0x10,0x20,0x20,0x40,0x80,0x80,0x00},
/* ] */ {0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00},
/* ^ */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x44,0x28,0x10,0x00},
/* _ */ {0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ` */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x18,0x18,0x00,0x00},
/* a */ {0x00,0x72,0x8a,0x84,0x84,0x8a,0x4a,0x30,0x00,0x00,0x00,0x00,0x00},
/* b */ {0x80,0x9c,0xa2,0x42,0x42,0x44,0x58,0x64,0x22,0x22,0x1c,0x00,0x00},
/* c */ {0x00,0x8c,0x48,0x48,0x30,0x30,0x30,0x28,0x28,0x44,0xc4,0x00,0x00},
/* d */ {0x00,0x70,0x88,0x88,0x88,0x88,0x50,0x20,0x40,0x48,0x30,0x00,0x00},
/* e */ {0x00,0x70,0x88,0x80,0x40,0x30,0x40,0x48,0x38,0x00,0x00,0x00,0x00},
/* f */ {0x20,0x20,0x20,0x78,0x94,0x92,0x92,0x52,0x3c,0x08,0x08,0x08,0x00},
/* g */ {0x20,0x20,0x10,0x10,0x18,0x18,0x18,0x24,0xa4,0x44,0x00,0x00,0x00},
/* h */ {0x08,0x08,0x08,0x24,0x24,0x24,0x12,0x12,0xb2,0x4c,0x00,0x00,0x00},
/* i */ {0x00,0x00,0x00,0x10,0x28,0x20,0x20,0x10,0x10,0x10,0x00,0x00,0x00},
/* j */ {0x00,0x40,0x40,0x78,0xa4,0xa2,0x92,0x92,0x52,0x4c,0x00,0x00,0x00},
/* k */ {0x00,0x00,0x00,0x98,0x90,0xf0,0x50,0x50,0x48,0x48,0x00,0x00,0x00},
/* l */ {0x00,0x00,0x8c,0x88,0x88,0x50,0x50,0x50,0x20,0x20,0x40,0xc0,0x00},
/* m */ {0x00,0x80,0x80,0x80,0x74,0x4a,0x48,0x48,0x24,0x24,0x24,0x00,0x00},
/* n */ {0x00,0x00,0x00,0xc0,0xa0,0x90,0x90,0x48,0x48,0xc8,0x00,0x00,0x00},
/* o */ {0x00,0x00,0x00,0x60,0x90,0x88,0x88,0x88,0x48,0x30,0x00,0x00,0x00},
/* p */ {0x00,0x00,0x00,0x8c,0x48,0x48,0x24,0x24,0xa4,0x7e,0x00,0x00,0x00},
/* q */ {0x00,0x30,0x48,0x84,0x84,0x84,0xfc,0x84,0x84,0x84,0x48,0x30,0x00},
/* r */ {0x00,0x80,0x80,0x80,0x70,0x48,0x44,0x24,0x24,0x24,0x18,0x00,0x00},
/* s */ {0x00,0x00,0x00,0x60,0x90,0x88,0x88,0x88,0x48,0x3e,0x00,0x00,0x00},
/* t */ {0x00,0x00,0x0c,0x40,0x20,0x20,0x20,0x20,0xa0,0x78,0x00,0x00,0x00},
/* u */ {0x00,0x00,0x00,0xc0,0xa0,0x90,0x90,0x48,0x48,0xc8,0x00,0x00,0x00},
/* v */ {0x00,0x00,0x00,0x6c,0x92,0x91,0x89,0x49,0x41,0xFF,0x00,0x00,0x00},
/* w */ {0x00,0x00,0x00,0x6c,0x92,0x91,0x89,0x49,0x41,0x22,0x00,0x00,0x00},
/* x */ {0x30,0x08,0x70,0x80,0x80,0x70,0xb0,0x80,0x80,0x70,0xb0,0x80,0x00},
/* y */ {0x00,0x20,0x20,0x20,0x78,0x94,0x94,0x52,0x4a,0xca,0x08,0x08,0x00},
/* z */ {0x30,0x08,0x70,0x80,0x80,0x80,0x80,0x80,0x40,0x70,0xb0,0x80,0x00},
/* { */ {0x00,0x0c,0x10,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x0c,0x00},
/* | */ {0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00},
/* } */ {0x00,0x60,0x10,0x10,0x10,0x10,0x0c,0x10,0x10,0x10,0x10,0x60,0x00},
/* ~ */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x89,0x91,0x60,0x00,0x00}
};
static GLubyte regular6x10[256][10] = {
/* */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ! */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* " */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* # */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* $ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* % */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* & */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ' */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ( */ {0x00,0x08,0x10,0x20,0x20,0x20,0x20,0x10,0x08,0x00},
/* ) */ {0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x20,0x40,0x00},
/* * */ {0x00,0x00,0x00,0x50,0x20,0x50,0x00,0x00,0x00,0x00},
/* + */ {0x00,0x00,0x00,0x20,0x70,0x20,0x00,0x00,0x00,0x00},
/* , */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* - */ {0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00},
/* . */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* / */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* 0 */ {0x00,0x70,0x88,0xc8,0xa8,0xa8,0x98,0x88,0x70,0x00},
/* 1 */ {0x00,0x70,0x20,0x20,0x20,0x20,0xa0,0x60,0x20,0x00},
/* 2 */ {0x00,0xF8,0x80,0x40,0x20,0x10,0x08,0x88,0x70,0x00},
/* 3 */ {0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00},
/* 4 */ {0x00,0x38,0x10,0xF8,0x90,0x50,0x50,0x30,0x10,0x00},
/* 5 */ {0x00,0x70,0x88,0x08,0xF0,0x80,0x80,0x80,0xF8,0x00},
/* 6 */ {0x00,0x70,0x88,0x88,0xF0,0x80,0x80,0x40,0x30,0x00},
/* 7 */ {0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x88,0xF8,0x00},
/* 8 */ {0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00},
/* 9 */ {0x00,0x30,0x10,0x08,0x78,0x88,0x88,0x88,0x70,0x00},
/* : */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ; */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* < */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* = */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* > */ {0x00,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x00},
/* ? */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* @ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* A */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* B */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* C */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* D */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* E */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* F */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* G */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* H */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* I */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* J */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* K */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* L */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* M */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* N */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* O */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* P */ {0x00,0x80,0x80,0x80,0xF0,0x88,0x88,0x88,0xF0,0x00},
/* Q */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* R */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* S */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* T */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* U */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* V */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* W */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* X */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* Y */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* Z */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* [ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* \ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ] */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ^ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* _ */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ` */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* a */ {0x00,0x34,0x48,0x48,0x38,0x08,0x30,0x00,0x00,0x00},
/* b */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* c */ {0x00,0x30,0x48,0x40,0x40,0x48,0x30,0x00,0x00,0x00},
/* d */ {0x00,0x70,0x88,0x88,0x88,0x98,0x68,0x08,0x08,0x00},
/* e */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* f */ {0x00,0x40,0x40,0x40,0x70,0x40,0x40,0x30,0x00,0x00},
/* g */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* h */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* i */ {0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x40,0x00,0x00},
/* j */ {0x40,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00,0x00},
/* k */ {0x00,0x44,0x68,0x50,0x48,0x40,0x40,0x40,0x00,0x00},
/* l */ {0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00},
/* m */ {0x00,0x54,0x54,0x54,0x54,0x68,0x00,0x00,0x00,0x00},
/* n */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* o */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* p */ {0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00,0x00,0x00},
/* q */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* r */ {0x00,0x40,0x40,0x40,0x40,0x70,0x00,0x00,0x00,0x00},
/* s */ {0x00,0x70,0x08,0x70,0x80,0x70,0x00,0x00,0x00,0x00},
/* t */ {0x00,0x20,0x40,0x40,0x40,0x60,0x40,0x40,0x00,0x00},
/* u */ {0x00,0x70,0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00},
/* v */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* w */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* x */ {0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00},
/* y */ {0x80,0x40,0x40,0x20,0x20,0x50,0x88,0x00,0x00,0x00},
/* z */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* { */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* | */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* } */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ~ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
static GLubyte regular8x13[256][13] = {
/* */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ! */{0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18},
/* " */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x36},
/* # */{0x00,0x00,0x00,0x66,0x66,0xff,0x66,0x66,0xff,0x66,0x66,0x00,0x00},
/* $ */{0x00,0x00,0x18,0x7e,0xff,0x1b,0x1f,0x7e,0xf8,0xd8,0xff,0x7e,0x18},
/* % */{0x00,0x00,0x0e,0x1b,0xdb,0x6e,0x30,0x18,0x0c,0x76,0xdb,0xd8,0x70},
/* & */{0x00,0x00,0x7f,0xc6,0xcf,0xd8,0x70,0x70,0xd8,0xcc,0xcc,0x6c,0x38},
/* ' */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x1c,0x0c,0x0e},
/* ( */{0x00,0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0c},
/* ) */{0x00,0x00,0x30,0x18,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x18,0x30},
/* * */{0x00,0x00,0x00,0x00,0x99,0x5a,0x3c,0xff,0x3c,0x5a,0x99,0x00,0x00},
/* + */{0x00,0x00,0x00,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,0x00,0x00},
/* , */{0x00,0x00,0x30,0x18,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* - */{0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00},
/* . */{0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* / */{0x00,0x60,0x60,0x30,0x30,0x18,0x18,0x0c,0x0c,0x06,0x06,0x03,0x03},
/* 0 */{0x00,0x00,0x3c,0x66,0xc3,0xe3,0xf3,0xdb,0xcf,0xc7,0xc3,0x66,0x3c},
/* 1 */{0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x38,0x18},
/* 2 */{0x00,0x00,0xff,0xc0,0xc0,0x60,0x30,0x18,0x0c,0x06,0x03,0xe7,0x7e},
/* 3 */{0x00,0x00,0x7e,0xe7,0x03,0x03,0x07,0x7e,0x07,0x03,0x03,0xe7,0x7e},
/* 4 */{0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x0c,0xff,0xcc,0x6c,0x3c,0x1c,0x0c},
/* 5 */{0x00,0x00,0x7e,0xe7,0x03,0x03,0x07,0xfe,0xc0,0xc0,0xc0,0xc0,0xff},
/* 6 */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xc7,0xfe,0xc0,0xc0,0xc0,0xe7,0x7e},
/* 7 */{0x00,0x00,0x30,0x30,0x30,0x30,0x18,0x0c,0x06,0x03,0x03,0x03,0xff},
/* 8 */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xe7,0x7e,0xe7,0xc3,0xc3,0xe7,0x7e},
/* 9 */{0x00,0x00,0x7e,0xe7,0x03,0x03,0x03,0x7f,0xe7,0xc3,0xc3,0xe7,0x7e},
/* : */{0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x00,0x00,0x00,0x00},
/* ; */{0x00,0x00,0x30,0x18,0x1c,0x1c,0x00,0x00,0x1c,0x1c,0x00,0x00,0x00},
/* < */{0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0xc0,0x60,0x30,0x18,0x0c,0x06},
/* = */{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0xff,0xff,0x00,0x00,0x00,0x00},
/* > */{0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x30,0x60},
/* ? */{0x00,0x00,0x18,0x00,0x00,0x18,0x18,0x0c,0x06,0x03,0xc3,0xc3,0x7e},
/* @ */{0x00,0x00,0x3f,0x60,0xcf,0xdb,0xd3,0xdd,0xc3,0x7e,0x00,0x00,0x00},
/* A */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0x66,0x3c,0x18},
/* B */{0x00,0x00,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* C */{0x00,0x00,0x7e,0xe7,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe7,0x7e},
/* D */{0x00,0x00,0xfc,0xce,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc7,0xce,0xfc},
/* E */{0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xc0,0xff},
/* F */{0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xff},
/* G */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xcf,0xc0,0xc0,0xc0,0xc0,0xe7,0x7e},
/* H */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0xc3,0xc3},
/* I */{0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e},
/* J */{0x00,0x00,0x7c,0xee,0xc6,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06},
/* K */{0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xe0,0xf0,0xd8,0xcc,0xc6,0xc3},
/* L */{0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
/* M */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xdb,0xff,0xff,0xe7,0xc3},
/* N */{0x00,0x00,0xc7,0xc7,0xcf,0xcf,0xdf,0xdb,0xfb,0xf3,0xf3,0xe3,0xe3},
/* O */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e},
/* P */{0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* Q */{0x00,0x00,0x3f,0x6e,0xdf,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c},
/* R */{0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe},
/* S */{0x00,0x00,0x7e,0xe7,0x03,0x03,0x07,0x7e,0xe0,0xc0,0xc0,0xe7,0x7e},
/* T */{0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff},
/* U */{0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3},
/* V */{0x00,0x00,0x18,0x3c,0x3c,0x66,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3},
/* W */{0x00,0x00,0xc3,0xe7,0xff,0xff,0xdb,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3},
/* X */{0x00,0x00,0xc3,0x66,0x66,0x3c,0x3c,0x18,0x3c,0x3c,0x66,0x66,0xc3},
/* Y */{0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x3c,0x66,0x66,0xc3},
/* Z */{0x00,0x00,0xff,0xc0,0xc0,0x60,0x30,0x7e,0x0c,0x06,0x03,0x03,0xff},
/* [ */{0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c},
/* \ */{0x00,0x03,0x03,0x06,0x06,0x0c,0x0c,0x18,0x18,0x30,0x30,0x60,0x60},
/* ] */{0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c},
/* ^ */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc3,0x66,0x3c,0x18},
/* _ */{0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/* ` */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x38,0x30,0x70},
/* a */{0x00,0x00,0x7f,0xc3,0xc3,0x7f,0x03,0xc3,0x7e,0x00,0x00,0x00,0x00},
/* b */{0x00,0x00,0xfe,0xc3,0xc3,0xc3,0xc3,0xfe,0xc0,0xc0,0xc0,0xc0,0xc0},
/* c */{0x00,0x00,0x7e,0xc3,0xc0,0xc0,0xc0,0xc3,0x7e,0x00,0x00,0x00,0x00},
/* d */{0x00,0x00,0x7f,0xc3,0xc3,0xc3,0xc3,0x7f,0x03,0x03,0x03,0x03,0x03},
/* e */{0x00,0x00,0x7f,0xc0,0xc0,0xfe,0xc3,0xc3,0x7e,0x00,0x00,0x00,0x00},
/* f */{0x00,0x00,0x30,0x30,0x30,0x30,0x30,0xfc,0x30,0x30,0x30,0x33,0x1e},
/* g */{0x7e,0xc3,0x03,0x03,0x7f,0xc3,0xc3,0xc3,0x7e,0x00,0x00,0x00,0x00},
/* h */{0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xfe,0xc0,0xc0,0xc0,0xc0},
/* i */{0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x18,0x00},
/* j */{0x38,0x6c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x00,0x00,0x0c,0x00},
/* k */{0x00,0x00,0xc6,0xcc,0xf8,0xf0,0xd8,0xcc,0xc6,0xc0,0xc0,0xc0,0xc0},
/* l */{0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78},
/* m */{0x00,0x00,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xfe,0x00,0x00,0x00,0x00},
/* n */{0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xfc,0x00,0x00,0x00,0x00},
/* o */{0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00},
/* p */{0xc0,0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0xc3,0xfe,0x00,0x00,0x00,0x00},
/* q */{0x03,0x03,0x03,0x7f,0xc3,0xc3,0xc3,0xc3,0x7f,0x00,0x00,0x00,0x00},
/* r */{0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xe0,0xfe,0x00,0x00,0x00,0x00},
/* s */{0x00,0x00,0xfe,0x03,0x03,0x7e,0xc0,0xc0,0x7f,0x00,0x00,0x00,0x00},
/* t */{0x00,0x00,0x1c,0x36,0x30,0x30,0x30,0x30,0xfc,0x30,0x30,0x30,0x00},
/* u */{0x00,0x00,0x7e,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00},
/* v */{0x00,0x00,0x18,0x3c,0x3c,0x66,0x66,0xc3,0xc3,0x00,0x00,0x00,0x00},
/* w */{0x00,0x00,0xc3,0xe7,0xff,0xdb,0xc3,0xc3,0xc3,0x00,0x00,0x00,0x00},
/* x */{0x00,0x00,0xc3,0x66,0x3c,0x18,0x3c,0x66,0xc3,0x00,0x00,0x00,0x00},
/* y */{0xc0,0x60,0x60,0x30,0x18,0x3c,0x66,0x66,0xc3,0x00,0x00,0x00,0x00},
/* z */{0x00,0x00,0xff,0x60,0x30,0x18,0x0c,0x06,0xff,0x00,0x00,0x00,0x00},
/* { */{0x00,0x00,0x0f,0x18,0x18,0x18,0x38,0xf0,0x38,0x18,0x18,0x18,0x0f},
/* | */{0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18},
/* } */{0x00,0x00,0xf0,0x18,0x18,0x18,0x1c,0x0f,0x1c,0x18,0x18,0x18,0xf0},
/* ~ */{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x8f,0xf1,0x60,0x00,0x00,0x00}
};
static GLuint fontOffset1[10];
static GLuint fontOffset2[10];
static GLuint fontOffset3[10];
static GLuint fontOffset4[10];
static int mrf[10] = { 0,0,0,0,0,0,0,0,0,0 };
static char buffer[2000];
static float dcx = 0.0F;
static float dcy = 0.0F;
static float dcz = 0.0F;
static int posval = 0;
static float pixpos[4] = { 0,0,0,0 };
static void *font = GLUT_BITMAP_8_BY_13 ;
static int alignement = LEFT;
void placeFontCursor(float x,float y,float z) {
glRasterPos4f(x,y,z,1.0F);
GLboolean glb[10];
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,glb);
posval = glb[0];
glGetFloatv(GL_CURRENT_RASTER_POSITION,pixpos);
}
void deplacementCursor(float x,float y,float z) {
dcx = x;
dcy = y;
dcz = z;
}
void setFont(void *f,int a) {
font = f;
alignement = a;
}
void setAlignement(int a) {
alignement = a;
}
void makeRasterFont(int w) {
GLuint i;
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
fontOffset1[w] = glGenLists(128);
fontOffset2[w] = glGenLists(128);
fontOffset3[w] = glGenLists(128);
fontOffset4[w] = glGenLists(128);
for ( i = 32 ; i < 126; i++ ) {
glNewList(i+fontOffset1[w],GL_COMPILE);
glBitmap(8,13,0.0,2.0,10.0,0.0,regular8x13[i-32]);
glEndList(); }
for ( i = 32 ; i < 126; i++ ) {
glNewList(i+fontOffset2[w],GL_COMPILE);
switch ( i ) {
case 'i' : glBitmap(8,10,0.0,2.0,3.0,0.0,regular6x10[i-32]);
break;
case 'f' : glBitmap(8,10,0.0,2.0,4.0,0.0,regular6x10[i-32]);
break;
default : glBitmap(8,10,0.0,2.0,6.0,0.0,regular6x10[i-32]);
break; }
glEndList(); }
for ( i = 32 ; i < 126; i++ ) {
glNewList(i+fontOffset3[w],GL_COMPILE);
glBitmap(8,13,0.0,2.0,10.0,0.0,symbol[i-32]);
glEndList(); }
for ( i = 32 ; i < 126; i++ ) {
glNewList(i+fontOffset4[w],GL_COMPILE);
glBitmap(8,13,0.0,2.0,8.0,0.0,dessin[i-32]);
glEndList(); }
}
void affichageChaine(int depth,int fonte) {
int ww = glutGetWindow();
if ( !mrf[ww] ) {
mrf[ww] = 1 ;
makeRasterFont(ww); }
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
glOrtho(0,w,0,h,0.0,1.0);
glMatrixMode(GL_MODELVIEW);
float largeurCaractere = 10.0F;
switch (fonte) {
case 2 : largeurCaractere = 6.0F ;
break;
case 3 : largeurCaractere = 10.0F ;
break;
case 4 : largeurCaractere = 8.0F ;
break; }
switch (alignement) {
case CENTER : { int len =(int) strlen(buffer);
float dx = (len*largeurCaractere)/2;
float dy = 6;
glRasterPos4f(pixpos[0]-dx+dcx,pixpos[1]-dy-dcy,-pixpos[2]-dcz,pixpos[3]); }
break;
case RIGHT : { int len =(int) strlen(buffer);
float dx = len*largeurCaractere;
float dy = 6;
glRasterPos4f(pixpos[0]-dx+dcx,pixpos[1]-dy-dcy,-pixpos[2]-dcz,pixpos[3]); }
break;
default : glRasterPos4f(pixpos[0]+dcx,pixpos[1]-dcy,-pixpos[2]-dcz,pixpos[3]);
break; }
dcx = dcy = dcz = 0.0F;
glPushAttrib(GL_DEPTH_TEST);
if ( depth )
glEnable(GL_DEPTH_TEST);
else {
glDisable(GL_DEPTH_TEST); }
if ( posval ) {
glPushAttrib(GL_LIST_BIT);
glListBase(fontOffset1[ww]);
switch (fonte) {
case 2 : glListBase(fontOffset2[ww]);
break;
case 3 : glListBase(fontOffset3[ww]);
break;
case 4 : glListBase(fontOffset4[ww]);
break; }
glCallLists((GLsizei) strlen(buffer),GL_UNSIGNED_BYTE,(GLubyte *) buffer);
glPopAttrib(); }
glPopAttrib();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
void simpleBitmapOutput(int depth,int fonte,char *format,...) {
va_list args;
va_start(args,format);
vsprintf(buffer,format,args);
va_end(args);
affichageChaine(depth,fonte);
}
void simpleBitmapOutput(int fonte,char *format,...) {
va_list args;
va_start(args,format);
vsprintf(buffer,format,args);
va_end(args);
affichageChaine(0,fonte);
}
void simpleBitmapOutput(char *format,...) {
va_list args;
va_start(args,format);
vsprintf(buffer,format,args);
va_end(args);
affichageChaine(1,1);
}
void bitmapOutput(void *font,char *format,...) {
char *p;
va_list args;
va_start(args,format);
vsprintf(buffer,format,args);
va_end(args);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
glOrtho(0,w,0,h,0.0,1.0);
glMatrixMode(GL_MODELVIEW);
switch (alignement) {
case CENTER : { int len =(int) strlen(buffer);
float dx = (len*8)/2;
float dy = 6;
glRasterPos4f(pixpos[0]-dx+dcx,pixpos[1]-dy-dcy,-pixpos[2]-dcz,pixpos[3]); }
break;
case RIGHT : { int len =(int) strlen(buffer);
float dx = len*8;
float dy = 6;
glRasterPos4f(pixpos[0]-dx+dcx,pixpos[1]-dy-dcy,-pixpos[2]-dcz,pixpos[3]); }
break;
default : glRasterPos4f(pixpos[0]+dcx,pixpos[1]-dcy,-pixpos[2]-dcz,pixpos[3]);
break; }
dcx = dcy = dcz = 0.0F;
glPushAttrib(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
if ( posval )
for ( p = buffer ; *p ; p++ )
glutBitmapCharacter(font,*p);
glPopAttrib();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
void bitmapOutput(GLfloat x,GLfloat y,GLfloat z,void *font,char *format,...) {
placeFontCursor(x,y,z);
va_list args;
va_start(args,format);
bitmapOutput(font,format,args);
va_end(args);
}
void bitmapStringOutput(char *format,...) {
va_list args;
va_start(args,format);
bitmapOutput(font,format,args);
va_end(args);
}
void bitmapStringOutput(GLfloat x,GLfloat y,GLfloat z,char *format,...) {
placeFontCursor(x,y,z);
va_list args;
va_start(args,format);
bitmapOutput(font,format,args);
va_end(args);
}
void lineOutput(int xi,int yi,int xf,int yf) {
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
glOrtho(0,w,0,h,0.0,1.0);
glMatrixMode(GL_MODELVIEW);
glPushAttrib(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
if ( posval ) {
glBegin(GL_LINES);
glVertex4f(pixpos[0]+xi,pixpos[1]-yi,-pixpos[2],pixpos[3]);
glVertex4f(pixpos[0]+xf,pixpos[1]-yf,-pixpos[2],pixpos[3]);
glEnd(); }
glPopAttrib();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
static int bold = 0;
static int anti = 0;
static float ecar = 0.0F;
void setBold(int b) {
bold = b;
}
void setAntialiased(int a) {
anti = a;
}
void setEcartementCaracteres(float e) {
ecar = e;
}
int getBold(void) {
return(bold);
}
int getAntialiased(void) {
return(anti);
}
float getEcartementCaracteres(void) {
return(ecar);
}
void strokeOutput(GLfloat x,GLfloat y,float fact,char *format,...) {
va_list args;
char buffer[2000],*p;
va_start(args,format);
vsprintf(buffer,format,args);
va_end(args);
glPushMatrix();
glTranslatef(x,y,0);
glScalef(0.005*fact,0.005*fact,0.005*fact);
float w;
glGetFloatv(GL_LINE_WIDTH,&w);
GLboolean b;
glGetBooleanv(GL_BLEND,&b);
GLboolean ls;
glGetBooleanv(GL_LINE_SMOOTH,&ls);
if ( bold )
glLineWidth(2.0);
else
glLineWidth(1.0);
if ( anti ) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH); }
else {
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH); }
for ( p = buffer ; *p ; p++ ) {
glutStrokeCharacter(GLUT_STROKE_ROMAN,*p);
glTranslatef(ecar,0.0F,0.0F); }
if ( b )
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
if ( ls )
glEnable(GL_LINE_SMOOTH);
else
glDisable(GL_LINE_SMOOTH);
glLineWidth(w);
glPopMatrix();
}
ModuleManipulateur.h: Gestion de la manipulation des scènes au clavier et à la souris
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Un manipulateur souris et clavier */
#ifndef MODULEMANIPULATEUR
#define MODULEMANIPULATEUR
int sourisManipulateur(int bouton,int etat,int x,int y) ;
int motionManipulateur(int x,int y) ;
void manipulateurSouris() ;
void setManipulateurDistance(float d) ;
int keyManipulateur(unsigned char key,int x,int y) ;
int specialManipulateur(int k, int x, int y) ;
void setManipulateurClavierAngle(float ax,float ay,float az) ;
void setManipulateurSourisAngle(float ax,float ay,float az) ;
void manipulateurClavier() ;
void sourisBasique(int bouton,int etat,int x,int y) ;
void motionBasique(int x,int y) ;
void keyBasique(unsigned char key,int x,int y) ;
void specialBasique(int k, int x, int y) ;
void setIdleWindow(int w) ;
void idleBasique(void) ;
void setManipulateurCleanUp(void (*func)(void));
typedef void (*fonctionVoid) (void);
void setManipulateurParametre0(float *param,float min,float max,float fct);
void setManipulateurParametre1(float *param,float min,float max,float fct);
void setManipulateurParametreFonction(fonctionVoid fonction);
void setManipulateurRefresh(fonctionVoid fonct);
#endif
ModuleManipulateur.cpp: Gestion de la manipulation des scènes au clavier et à la souris
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Un manipulateur souris et clavier */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleManipulateur.h"
static int mouvement = 0 ;
static int button = 0 ;
static int modifier = 0 ;
static float rotx = 0;
static float roty = 0;
static float rotz = 0;
static float transx = 0;
static float transy = 0;
static float zoom = 1.0F;
static int px ;
static int py ;
static int tx ;
static float mt[16];
static float manipulatorDistance = 1.0F;
static GLfloat view_rotx=0.0F ;
static GLfloat view_roty=0.0F ;
static GLfloat view_rotz=0.0F ;
static int anim = 0;
static float fact = 1.0F;
static int idleWindow = -1;
static float *param0 = NULL ;
static float *param1 = NULL ;
static float fct0;
static float min0;
static float max0;
static float fct1;
static float min1;
static float max1;
static fonctionVoid cleanUp = NULL;
static fonctionVoid refresh = NULL;
static fonctionVoid fonction = NULL;
static int getModifier() {
int modif = 0;
if ( ( (glutGetModifiers() & GLUT_ACTIVE_CTRL) != 0 ) && ( (glutGetModifiers() & GLUT_ACTIVE_ALT) != 0 ) )
return(5);
if ( (glutGetModifiers() & GLUT_ACTIVE_SHIFT) != 0 ) {
if ( (glutGetModifiers() & GLUT_ACTIVE_CTRL) != 0 )
modif = 2;
else
modif = 1; }
else
if ( (glutGetModifiers() & GLUT_ACTIVE_CTRL) != 0 )
modif = 3;
else
if ( (glutGetModifiers() & GLUT_ACTIVE_ALT) != 0 )
modif = 4;
return(modif);
}
int sourisManipulateur(int bouton,int etat,int x,int y) {
glGetFloatv(GL_PROJECTION_MATRIX,mt);
tx = glutGet(GLUT_WINDOW_WIDTH);
button = bouton;
if ( bouton == GLUT_LEFT_BUTTON ) {
modifier = getModifier();
if ( modifier ) {
px = x ;
py = y ;
if ( etat == GLUT_DOWN ) {
mouvement = 1 ;}
if ( etat == GLUT_UP ) {
mouvement = 0 ; }
return(1); } }
return(0);
}
int motionManipulateur(int x,int y) {
switch ( button ) {
case GLUT_LEFT_BUTTON : if ( mouvement == 1 ) {
switch ( modifier ) {
case 1 : roty += (x-px) ;
rotx += (y-py) ;
px = x;
py = y;
break;
case 2 : rotz += (x-px) ;
rotx += (y-py) ;
px = x;
py = y;
break;
case 3 : if ( ( y-py ) > 0 )
zoom *= pow(1.02F,(y-py)/5.0F) ;
if ( ( y-py ) < 0 )
zoom /= pow(1.02F,(py-y)/5.0F) ;
py = y;
break;
case 4 : transx += (x-px)*2.0F/tx/mt[0]*manipulatorDistance ;
transy -= (y-py)*2.0F/tx/mt[0]*manipulatorDistance ;
px = x;
py = y;
break;
case 5 : if ( param0 ) {
int dx = x-px ;
*param0 += dx*fct0;
if ( *param0 < min0 )
*param0 = min0;
if ( *param0 > max0 )
*param0 = max0; }
if ( param1 ) {
int dy = y-py ;
*param1 += dy*fct1;
if ( *param1 < min1 )
*param1 = min1;
if ( *param1 > max1 )
*param1 = max1; }
px = x;
py = y;
if ( fonction )
fonction();
break; }
return(1); }
break;}
return(0);
}
void setManipulateurSourisAngle(float ax,float ay,float az) {
rotx = ax;
roty = ay;
rotz = az;
}
void manipulateurSouris() {
glTranslatef(transx,transy,0.0F);
glRotatef(rotx,1.0f,0.0F,0.0F);
glRotatef(roty,0.0f,1.0F,0.0F);
glRotatef(rotz,0.0f,0.0F,1.0F);
glScalef(zoom,zoom,zoom);
}
void setManipulateurDistance(float d) {
manipulatorDistance = d;
}
int keyManipulateur(unsigned char key,int x,int y) {
modifier = getModifier();
if ( modifier == 1 ) {
switch ( key ) {
case 0x0D : anim = (anim+1)%2;
return(1);
break; } }
switch ( key ) {
case 'x' : view_rotx +=2 ;
return(1);
break;
case 'X' : view_rotx -=2 ;
return(1);
break;
case 'y' : view_roty +=2 ;
return(1);
break;
case 'Y' : view_roty -=2 ;
return(1);
break;
case 'z' : view_rotz +=2 ;
return(1);
break;
case 'Z' : view_rotz -=2 ;
return(1);
break;
case '#' : { static int fullScreen = 0;
static int tx;
static int ty;
static int px;
static int py;
fullScreen = !fullScreen;
if ( fullScreen ) {
px = glutGet(GLUT_WINDOW_X);
py = glutGet(GLUT_WINDOW_Y);
tx = glutGet(GLUT_WINDOW_WIDTH);
ty = glutGet(GLUT_WINDOW_HEIGHT);
glutFullScreen(); }
else {
glutPositionWindow(px,py);
glutReshapeWindow(tx,ty); } }
break;
case '\033' : if ( cleanUp )
cleanUp();
exit(0);
break ; }
return(0);
}
int specialManipulateur(int k,int x,int y) {
modifier = getModifier();
if ( modifier == 1 ) {
switch (k) {
case GLUT_KEY_LEFT :
case GLUT_KEY_PAGE_UP :
case GLUT_KEY_UP : fact *= 1.1F;
return(1);
break;
case GLUT_KEY_RIGHT :
case GLUT_KEY_PAGE_DOWN :
case GLUT_KEY_DOWN : fact /= 1.1F;
return(1);
break; } }
if ( modifier == 3 ) {
switch (k) {
case GLUT_KEY_UP : view_rotx = 0.0F;
view_roty = 0.0F;
view_rotz = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break;
case GLUT_KEY_DOWN : view_rotx = 180.0F;
view_roty = 0.0F;
view_rotz = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break;
case GLUT_KEY_LEFT : view_roty = 0.0F;
view_rotx = 0.0F;
view_rotz = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break;
case GLUT_KEY_RIGHT : view_roty = 180.0F;
view_rotx = 0.0F;
view_rotz = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break;
case GLUT_KEY_PAGE_DOWN : view_rotz = 0.0F;
view_rotx = 0.0F;
view_roty = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break;
case GLUT_KEY_PAGE_UP : view_rotz = 180.0F;
view_rotx = 0.0F;
view_roty = 0.0F;
rotx = 0;
roty = 0;
rotz = 0;
return(1);
break; }
return(0); }
float dif;
switch(modifier) {
case 0 : dif = 1.0F;
break;
case 4 : dif = 10.0F;
break; }
switch (k) {
case GLUT_KEY_UP : view_rotx -= dif;
return(1);
break;
case GLUT_KEY_DOWN : view_rotx += dif;
return(1);
break;
case GLUT_KEY_LEFT : view_roty -= dif;
return(1);
break;
case GLUT_KEY_RIGHT : view_roty += dif;
return(1);
break;
case GLUT_KEY_PAGE_DOWN : view_rotz += dif;
return(1);
break;
case GLUT_KEY_PAGE_UP : view_rotz -= dif;
return(1);
break; }
return(0);
}
void manipulateurClavier() {
glRotatef(view_rotx,1.0,0.0,0.0);
glRotatef(view_roty,0.0,1.0,0.0);
glRotatef(view_rotz,0.0,0.0,1.0);
}
void setManipulateurClavierAngle(float ax,float ay,float az) {
view_rotx = ax;
view_roty = ay;
view_rotz = az;
}
void sourisBasique(int bouton,int etat,int x,int y) {
if ( sourisManipulateur(bouton,etat,x,y) )
if ( refresh )
refresh();
else
glutPostRedisplay();
}
void motionBasique(int x,int y) {
if ( motionManipulateur(x,y) )
if ( refresh )
refresh();
else
glutPostRedisplay();
}
void keyBasique(unsigned char key,int x,int y) {
if ( keyManipulateur(key,x,y) )
if ( refresh )
refresh();
else
glutPostRedisplay();
}
void specialBasique(int k,int x,int y) {
if ( specialManipulateur(k,x,y) )
if ( refresh )
refresh();
else
glutPostRedisplay();
}
void setIdleWindow(int w) {
idleWindow = w;
}
void idleBasique(void) {
static int told;
GLint t = glutGet(GLUT_ELAPSED_TIME);
if ( anim ) {
rotx += (0.01F*(t-told)*fact);
roty += (0.01F*(t-told)*fact);
rotz += (0.01F*(t-told)*fact);
if ( idleWindow == -1 )
if ( refresh )
refresh();
else
glutPostRedisplay();
else
glutPostWindowRedisplay(idleWindow); }
told = t;
}
void setManipulateurCleanUp(void (*func)(void)) {
cleanUp = func;
}
void setManipulateurParametre0(float *param,float min,float max,float fct) {
param0 = param;
min0 = min;
max0 = max;
fct0 = fct;
}
void setManipulateurParametre1(float *param,float min,float max,float fct) {
param1 = param;
min1 = min;
max1 = max;
fct1 = fct;
}
void setManipulateurParametreFonction(fonctionVoid fonct) {
fonction = fonct;
}
void setManipulateurRefresh(fonctionVoid fonct) {
refresh = fonct;
}
ModuleReshape.h: Gestion de la fonction reshape
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de gestion des transformations */
/* de visualisation */
#ifndef MODULERESHAPE
#define MODULERESHAPE
void setParametresOrthoBasique(float xmin,float xmax,float ymin,float ymax,float zmin,float zmax) ;
void reshapeOrthoBasique(int w,int h) ;
void setParametresFrustumBasique(float xmin,float xmax,float ymin,float ymax,float zmin,float zmax,float dx,float dy,float dz) ;
void reshapeFrustumBasique(int w,int h) ;
void setParametresPerspectiveBasique(float angle,float ratio,float zmin,float zmax,float dx,float dy,float dz) ;
void setParametresPerspectiveBasique(float angle,float ratio,float zmin,float zmax,float dx,float dy,float dz,int fen) ;
void reshapePerspectiveBasique(int w,int h) ;
float getXmin(void) ;
float getYmin(void) ;
float getXmax(void) ;
float getYmax(void) ;
float getTaillePixel(void) ;
float anglePerspectiveBasique(void) ;
float ratioPerspectiveBasique(void) ;
#endif
ModuleReshape.cpp: Gestion de la fonction reshape
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de gestion des transformations */
/* de visualisation */
#include <stdio.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
static double orthoXmin;
static double orthoXmax;
static double orthoYmin;
static double orthoYmax;
static double orthoZmin;
static double orthoZmax;
static double frustumXmin;
static double frustumXmax;
static double frustumYmin;
static double frustumYmax;
static double frustumZmin;
static double frustumZmax;
static double frustumdx;
static double frustumdy;
static double frustumdz;
static double perspectiveAngle;
static double perspectiveRatio;
static double perspectiveZmin;
static double perspectiveZmax;
static double perspectivedx;
static double perspectivedy;
static double perspectivedz;
static double xmin;
static double ymin;
static double xmax;
static double ymax;
static float tpix;
float getXmin(void) {
return((float) xmin);
}
float getYmin(void) {
return((float) ymin);
}
float getXmax(void) {
return((float) xmax);
}
float getYmax(void) {
return((float) ymax);
}
float getTaillePixel(void) {
return(tpix);
}
void setParametresOrthoBasique(float xmin,float xmax,float ymin,float ymax,float zmin,float zmax) {
orthoXmin = xmin;
orthoXmax = xmax;
orthoYmin = ymin;
orthoYmax = ymax;
orthoZmin = zmin;
orthoZmax = zmax;
}
void reshapeOrthoBasique(int w,int h) {
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if( w <= h) {
xmin = orthoXmin;
xmax = orthoXmax;
ymin = orthoYmin*(double) h/w;
ymax = orthoYmax*(double) h/w; }
else {
xmin = orthoXmin*(double) w/h;
xmax = orthoXmax*(double) w/h;
ymax = orthoYmax;
ymin = orthoYmin; }
tpix =(float) (ymax-ymin)/h;
glOrtho(xmin,xmax,ymin,ymax,orthoZmin,orthoZmax);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void setParametresFrustumBasique(float xmin,float xmax,float ymin,float ymax,float zmin,float zmax,float dx,float dy,float dz) {
frustumXmin = xmin;
frustumXmax = xmax;
frustumYmin = ymin;
frustumYmax = ymax;
frustumZmin = zmin;
frustumZmax = zmax;
frustumdx = dx;
frustumdy = dy;
frustumdz = dz;
}
void reshapeFrustumBasique(int w,int h) {
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if( w <= h) {
xmin = frustumXmin;
xmax = frustumXmax;
ymin = frustumYmin*(double) h/w;
ymax = frustumYmax*(double) h/w; }
else {
xmin = frustumXmin*(double) w/h;
xmax = frustumXmax*(double) w/h;
ymax = frustumYmax;
ymin = frustumYmin; }
tpix =(float) (ymax-ymin)/h;
glFrustum(xmin,xmax,ymin,ymax,frustumZmin,frustumZmax);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(frustumdx,frustumdy,frustumdz);
}
static float angle;
static float ratio;
static int fenetre = -1;
void setParametresPerspectiveBasique(float angle,float ratio,float zmin,float zmax,float dx,float dy,float dz) {
perspectiveAngle = angle;
perspectiveRatio = ratio;
perspectiveZmin = zmin;
perspectiveZmax = zmax;
perspectivedx = dx;
perspectivedy = dy;
perspectivedz = dz;
}
void setParametresPerspectiveBasique(float angle,float ratio,float zmin,float zmax,float dx,float dy,float dz,int fen) {
setParametresPerspectiveBasique(angle,ratio,zmin,zmax,dx,dy,dz) ;
fenetre = fen;
}
float anglePerspectiveBasique(void) {
return(angle);
}
float ratioPerspectiveBasique(void) {
return(ratio);
}
void reshapePerspectiveBasique(int w,int h) {
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ratio = (float) w/(float) h;
if( ratio < perspectiveRatio) {
angle = perspectiveAngle/ratio*perspectiveRatio; }
else {
angle = perspectiveAngle; }
gluPerspective(angle,ratio,perspectiveZmin,perspectiveZmax);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(perspectivedx,perspectivedy,perspectivedz);
if ( fenetre != -1 )
glutPostWindowRedisplay(fenetre);
}
ModuleMenus.h: Gestion des menus
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Gestion des menus */
#ifndef MODULEMENUS
#define MODULEMENUS
void creationMenuBasique(void) ;
void setMenuCleanUp(void (*func)(void));
#endif
ModuleMenus.cpp: Gestion des menus
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Gestion des menus */
#include <stdlib.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
static void (*cleanUp)(void) = NULL;
static void select(int selection) {
switch (selection) {
case 0 : if ( cleanUp )
cleanUp();
exit(0); }
glutPostRedisplay();
}
void creationMenuBasique(void) {
glutCreateMenu(select);
glutAddMenuEntry("Quitter",0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
void setMenuCleanUp(void (*func)(void)) {
cleanUp = func;
}
ModuleFleche.h: Affichage de flèches
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de dessin de : */
/* - fleches en filaire et en volume */
/* - segment en volume */
/* - cone */
#ifndef MODULEFLECHE
#define MODULEFLECHE
void flecheEnFilaire(float dx,float dy,float dz,float cr,float cl) ;
void flecheEnVolume(float dx,float dy,float dz,float cr,float cl,float ct) ;
void biFlecheEnVolume(float dx,float dy,float dz,float cr,float cl,float ct) ;
void coneOuverture(float dx,float dy,float dz,float ang) ;
void segmentEnVolume(float dx,float dy,float dz,float ct) ;
#endif
ModuleFleche.cpp: Affichage de flèches
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de dessin de fleches */
/* en filaire et en volume */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
static void cylindre(double h,double r,int n) {
int i;
double *cs =(double *) calloc(n+1,sizeof(double)) ;
double *sn =(double *) calloc(n+1,sizeof(double)) ;
double *ncs =(double *) calloc(n+1,sizeof(double)) ;
double *nsn =(double *) calloc(n+1,sizeof(double)) ;
cs[0] = cs[n] = r ;
sn[0] = sn[n] = 0.0 ;
ncs[0] = ncs[n] = 1.0 ;
nsn[0] = nsn[n] = 0.0 ;
for ( i = 1 ; i < n ; i++ ) {
double a = 3.14159/n*2*i ;
ncs[i] = cos(a) ;
nsn[i] = sin(a) ;
cs[i] = r*ncs[i] ;
sn[i] = r*nsn[i] ; }
glBegin(GL_POLYGON) ;
glNormal3f(0.0,1.0,0.0) ;
for ( i = 0 ; i < n ; i++ ) {
glVertex3d(cs[i],h/2,sn[i]); }
glEnd() ;
glBegin(GL_POLYGON) ;
glNormal3f(0.0,-1.0,0.0) ;
for ( i = 0 ; i < n ; i++ ) {
glVertex3d(cs[i],-h/2,sn[i]); }
glEnd() ;
glBegin(GL_QUADS) ;
for ( i = 0 ; i < n ; i++ ) {
glNormal3d(ncs[i],0.0,nsn[i]) ;
glVertex3d(cs[i],h/2,sn[i]);
glNormal3d(ncs[i+1],0.0,nsn[i+1]) ;
glVertex3d(cs[i+1],h/2,sn[i+1]);
glVertex3d(cs[i+1],-h/2,sn[i+1]);
glNormal3d(ncs[i],0.0,nsn[i]) ;
glVertex3d(cs[i],-h/2,sn[i]); }
glEnd() ;
free(sn) ;
free(cs) ;
free(nsn) ;
free(ncs) ;
}
static void cone(double h,double r,int n) {
int i;
double *cs =(double *) calloc(n+1,sizeof(double)) ;
double *sn =(double *) calloc(n+1,sizeof(double)) ;
double *ncs =(double *) calloc(n+1,sizeof(double)) ;
double *nsn =(double *) calloc(n+1,sizeof(double)) ;
cs[0] = cs[n] = r ;
sn[0] = sn[n] = 0.0 ;
ncs[0] = ncs[n] = 1.0 ;
nsn[0] = nsn[n] = 0.0 ;
for ( i = 1 ; i < n ; i++ ) {
double a = 3.14159/n*2*i ;
ncs[i] = cos(a) ;
nsn[i] = sin(a) ;
cs[i] = r*ncs[i] ;
sn[i] = r*nsn[i] ; }
glBegin(GL_POLYGON) ;
glNormal3f(0.0,-1.0,0.0) ;
for ( i = 0 ; i < n ; i++ ) {
glVertex3d(cs[i],-h/2,sn[i]); }
glEnd() ;
glBegin(GL_QUADS) ;
for ( i = 0 ; i < n ; i++ ) {
glNormal3d(ncs[i],0.0,nsn[i]) ;
glVertex3d(0,h/2,0);
glNormal3d(ncs[i+1],0.0,nsn[i+1]) ;
glVertex3d(0,h/2,0);
glVertex3d(cs[i+1],-h/2,sn[i+1]);
glNormal3d(ncs[i],0.0,nsn[i]) ;
glVertex3d(cs[i],-h/2,sn[i]); }
glEnd() ;
free(sn) ;
free(cs) ;
free(nsn) ;
free(ncs) ;
}
void flecheEnFilaire(float dx,float dy,float dz,float cr,float cl) {
glPushMatrix();
glBegin(GL_LINES);
glVertex3f(0.0F,0.0F,0.0F);
glVertex3f(dx,dy,dz);
glEnd();
glPushMatrix();
double d = pow((double) (dx*dx+dy*dy+dz*dz),0.5);
dx /= d;
dy /= d;
dz /= d;
double a = acos(dz) * 360 / 3.14159;
glRotatef(a/2,-dy,dx,0);
glTranslatef(0.0F,0.0F,(float) d-cl);
glutSolidCone(cr,cl,10,10);
glPopMatrix();
glPopMatrix();
}
static int estEgal(float a,float b) {
return(fabs(a-b) < 0.00001) ;
}
void flecheEnVolume(float dx,float dy,float dz,float cr,float cl,float ct) {
glPushMatrix();
glBegin(GL_LINES);
glVertex3f(0.0F,0.0F,0.0F);
glVertex3f(dx,dy,dz);
glEnd();
double d = pow((double) (dx*dx+dy*dy+dz*dz),0.5);
glPushMatrix();
dx /= d;
dy /= d;
dz /= d;
if ( estEgal(dz,-1.0F) )
glRotatef(180.0F,1.0F,0.0F,0.0F);
else
if ( !estEgal(dz,1.0F) ) {
double a = acos(dz) * 180 / 3.14159;
glRotatef(a,-dy,dx,0); }
glTranslatef(0.0F,0.0F,(float) (d-cl)/2);
glPushMatrix();
glRotatef(90.0F,1.0F,0.0F,0.0F);
cylindre(d-cl,ct,36);
glPopMatrix();
glTranslatef(0.0F,0.0F,(float) d/2);
glPushMatrix();
glRotatef(90.0F,1.0F,0.0F,0.0F);
cone(cl,cr,36);
glPopMatrix();
glPopMatrix();
glPopMatrix();
}
void segmentEnVolume(float dx,float dy,float dz,float ct) {
glPushMatrix();
glBegin(GL_LINES);
glVertex3f(0.0F,0.0F,0.0F);
glVertex3f(dx,dy,dz);
glEnd();
double d = pow((double) (dx*dx+dy*dy+dz*dz),0.5);
glPushMatrix();
dx /= d;
dy /= d;
dz /= d;
if ( estEgal(dz,-1.0F) )
glRotatef(180.0F,1.0F,0.0F,0.0F);
else
if ( !estEgal(dz,1.0F) ) {
double a = acos(dz) * 180 / 3.14159;
glRotatef(a,-dy,dx,0); }
glTranslatef(0.0F,0.0F,(float) (d/2));
glPushMatrix();
glRotatef(90.0F,1.0F,0.0F,0.0F);
cylindre(d,ct,36);
glPopMatrix();
glPopMatrix();
glPopMatrix();
}
void biFlecheEnVolume(float dx,float dy,float dz,float cr,float cl,float ct) {
glPushMatrix();
glTranslatef(dx/2.0F,dy/2.0F,dz/2.0F);
flecheEnVolume(dx/2.0F,dy/2.0F,dz/2.0F,cr,cl,ct);
flecheEnVolume(-dx/2.0F,-dy/2.0F,-dz/2.0F,cr,cl,ct);
glPopMatrix();
}
void coneOuverture(float dx,float dy,float dz,float a) {
double d = pow((double) (dx*dx+dy*dy+dz*dz),0.5);
glPushMatrix();
dx /= d;
dy /= d;
dz /= d;
if ( estEgal(dz,-1.0F) )
glRotatef(180.0F,1.0F,0.0F,0.0F);
else
if ( !estEgal(dz,1.0F) ) {
double a = acos(dz) * 180 / 3.14159;
glRotatef(a,-dy,dx,0); }
glPushMatrix();
glRotatef(90.0F,1.0F,0.0F,0.0F);
glRotatef(180.0F,0.0F,0.0F,1.0F);
glTranslatef(0.0F,-d/2.0F,0.0F);
cone(d,tan(a/180.0*3.14159F)*d,120);
glPopMatrix();
glPopMatrix();
}
ModuleMatriceVecteur.h: Gestion des vecteurs et matrices en coordonnées homogènes
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de mathematiques matricielles */
#ifndef MODULEMATRICEVECTEUR
#define MODULEMATRICEVECTEUR
typedef float vecteur[4];
typedef float matrice[4][4];
void toIdentite(matrice a) ;
void toTranslation(matrice a,float dx,float dy,float dz) ;
void toRotationX(matrice m,float a) ;
void toRotationY(matrice m,float a) ;
void toRotationZ(matrice m,float a) ;
void toRotation(matrice m,float a,float x,float y,float z) ;
void toScale(matrice a,float rx,float ry,float rz) ;
void produitMatriceMatrice(matrice a,matrice b,matrice r) ;
void produitMatriceVecteur(matrice m,vecteur v,vecteur r) ;
void affichageMatrice(matrice a) ;
float distance(vecteur p1,vecteur p2) ;
void calculVecteurNorme(vecteur pi,vecteur pf,vecteur n) ;
int normalise(vecteur n) ;
void calculVecteur(vecteur pi,vecteur pf,vecteur n) ;
float produitScalaire(vecteur d1,vecteur d2) ;
void produitVectoriel(vecteur v1,vecteur v2,vecteur n) ;
#endif
ModuleMatriceVecteur.cpp: Gestion des vecteurs et matrices en coordonnées homogènes
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Module de mathematiques matricielles */
#include <math.h>
#include <stdio.h>
#include "ModuleMatriceVecteur.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif
/* ************************************************** */
/* -------------------------------------------------- */
/* Initialisation a l'identite */
/* -------------------------------------------------- */
void toIdentite(matrice a) {
for ( int i = 0 ; i < 4 ; i++ )
for ( int j = 0 ; j < 4 ; j++ )
a[i][j] = ( i == j) ? 1.0F : 0.0F;
}
/* -------------------------------------------------- */
/* Initialisation a la translation (dx,dy,dz) */
/* -------------------------------------------------- */
void toTranslation(matrice a,float dx,float dy,float dz) {
toIdentite(a);
a[0][3] = dx;
a[1][3] = dy;
a[2][3] = dz;
}
/* -------------------------------------------------- */
/* Initialisation a la rotation d'angle a */
/* autour de Ox */
/* -------------------------------------------------- */
void toRotationX(matrice m,float a) {
toIdentite(m);
double aa = a/180.0*M_PI;
m[2][1] =(float) sin(aa);
m[1][2] = -m[2][1];
m[1][1] = m[2][2] =(float) cos(aa);
}
/* -------------------------------------------------- */
/* Initialisation a la rotation d'angle a */
/* autour de Oy */
/* -------------------------------------------------- */
void toRotationY(matrice m,float a) {
toIdentite(m);
double aa = a/180.0*M_PI;
m[0][2] =(float) sin(aa);
m[2][0] = -m[0][2];
m[0][0] = m[2][2] =(float) cos(aa);
}
/* -------------------------------------------------- */
/* Initialisation a la rotation d'angle a */
/* autour de Oz */
/* -------------------------------------------------- */
void toRotationZ(matrice m,float a) {
toIdentite(m);
double aa = a/180.0*M_PI;
m[1][0] =(float) sin(aa);
m[0][1] = -m[1][0];
m[1][1] = m[0][0] =(float) cos(aa);
}
/* -------------------------------------------------- */
/* Initialisation a la rotation d'angle a */
/* autour de l'axe (x,y,z) passant par l'origine */
/* -------------------------------------------------- */
void toRotation(matrice m,float a,float x,float y,float z) {
toIdentite(m);
vecteur v = { x,y,z };
normalise(v);
double aa = a/180.0*M_PI;
float sn =(float) sin(aa);
float cs =(float) cos(aa);
m[0][0] = v[0]*v[0]+cs*(1-v[0]*v[0]);
m[0][1] = v[0]*v[1]*(1-cs)-sn*v[2];
m[0][2] = v[0]*v[2]*(1-cs)+sn*v[1];
m[1][0] = v[0]*v[1]*(1-cs)+sn*v[2];
m[1][1] = v[1]*v[1]+cs*(1-v[1]*v[1]);
m[1][2] = v[1]*v[2]*(1-cs)-sn*v[0];
m[2][0] = v[0]*v[2]*(1-cs)-sn*v[1];
m[2][1] = v[1]*v[2]*(1-cs)+sn*v[0];
m[2][2] = v[2]*v[2]+cs*(1-v[2]*v[2]);
}
/* -------------------------------------------------- */
/* Initialisation a la mise a l'echelle (rx,ry,rz) */
/* -------------------------------------------------- */
void toScale(matrice a,float rx,float ry,float rz) {
toIdentite(a);
a[0][0] = rx;
a[1][1] = ry;
a[2][2] = rz;
}
/* -------------------------------------------------- */
/* Produit matrice matrice */
/* -------------------------------------------------- */
void produitMatriceMatrice(matrice a,matrice b,matrice r) {
matrice rr;
int i,j;
for ( i = 0 ; i < 4 ; i++ )
for ( j = 0 ; j < 4 ; j++ ) {
rr[i][j] = 0.0F;
for ( int k = 0 ; k < 4 ; k++ ) {
rr[i][j] += a[i][k]*b[k][j]; } }
for ( i = 0 ; i < 4 ; i++ )
for ( j = 0 ; j < 4 ; j++ )
r[i][j] = rr[i][j];
}
/* -------------------------------------------------- */
/* Produit matrice vecteur */
/* -------------------------------------------------- */
void produitMatriceVecteur(matrice m,vecteur v,vecteur r) {
vecteur rr;
int i;
for ( i = 0 ; i < 4 ; i++ ) {
rr[i] = 0.0F;
for ( int j = 0 ; j < 4 ; j++ ) {
rr[i] += m[i][j]*v[j]; } }
for ( i = 0 ; i < 4 ; i++ ) {
r[i] = rr[i]; }
}
/* -------------------------------------------------- */
/* Affichage d'une matrice */
/* -------------------------------------------------- */
void affichageMatrice(matrice a) {
int i,j;
for ( i = 0 ; i < 4 ; i++ ) {
for ( j = 0 ; j < 4 ; j++ )
printf("%10f",a[i][j]);
printf("\n"); }
printf("\n");
}
/* -------------------------------------------------- */
/* Calcul de la distance entre deux sommets */
/* -------------------------------------------------- */
float distance(vecteur p1,vecteur p2) {
double x = p1[0] - p2[0] ;
double y = p1[1] - p2[1] ;
double z = p1[2] - p2[2] ;
double d2 = x*x + y*y + z*z ;
return((float) pow(d2,0.5)) ;
}
/* -------------------------------------------------- */
/* Calcul du vecteur norme colineaire a l'axe forme */
/* par deux sommets */
/* -------------------------------------------------- */
void calculVecteurNorme(vecteur pi,vecteur pf,vecteur n) {
double x = pf[0] - pi[0] ;
double y = pf[1] - pi[1] ;
double z = pf[2] - pi[2] ;
double d2 = distance(pi,pf) ;
n[0] =(float) (x / d2) ;
n[1] =(float) (y / d2) ;
n[2] =(float) (z / d2) ;
n[3] = 0.0F;
}
/* -------------------------------------------------- */
/* Normalisation d'un vecteur */
/* -------------------------------------------------- */
int normalise(vecteur n) {
double d2 = n[0]*n[0] + n[1]*n[1] + n[2]*n[2] ;
d2 =(float) pow(d2,0.5) ;
if ( d2 == 0.0F )
return(0);
n[0] =(float) (n[0]/d2) ;
n[1] =(float) (n[1]/d2) ;
n[2] =(float) (n[2]/d2) ;
return(1);
}
/* -------------------------------------------------- */
/* Calcul du vecteur entre deux sommets */
/* -------------------------------------------------- */
void calculVecteur(vecteur pi,vecteur pf,vecteur n) {
n[0] = pf[0] - pi[0] ;
n[1] = pf[1] - pi[1] ;
n[2] = pf[2] - pi[2] ;
n[3] = 0.0F;
}
/* -------------------------------------------------- */
/* Calcul du produit scalaire entre deux vecteurs */
/* -------------------------------------------------- */
float produitScalaire(vecteur d1,vecteur d2) {
return(d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2]) ;
}
/* -------------------------------------------------- */
/* Calcul du produit vectoriel entre deux vecteurs */
/* -------------------------------------------------- */
void produitVectoriel(vecteur v1,vecteur v2,vecteur n) {
n[0] = v1[1]*v2[2] - v1[2]*v2[1];
n[1] = v1[2]*v2[0] - v1[0]*v2[2];
n[2] = v1[0]*v2[1] - v1[1]*v2[0];
n[3] = 0.0F;
}
/* ************************************************** */
ModuleRemplissage.h: Remplissage de facettes triangulaires
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Remplissage d'une facette 2D */
#ifndef MODULEREMPLISSAGE
#define MODULEREMPLISSAGE
struct coord3D {
float x;
float y;
float z; } ;
struct facette3 {
coord3D s[3]; } ;
struct bitmap {
int tx ;
int ty ;
int **p ; } ;
void allocBitmap(int tx,int ty,bitmap *b);
void freeBitmap(bitmap *b);
void remplissageFacette(facette3 *f,bitmap *b);
#endif
ModuleRemplissage.cpp: Remplissage de facettes triangulaires
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Septembre 2005 */
/* Remplissage d'une facette 2D */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "ModuleRemplissage.h"
void ligne(int xi,int yi,int xf,int yf,int *px,int ymax) {
int i,cumul ;
int x = xi ;
int y = yi ;
int dx = xf - xi ;
int dy = yf - yi ;
int xinc = ( dx > 0 ) ? 1 : -1 ;
int yinc = ( dy > 0 ) ? 1 : -1 ;
dx = abs(dx) ;
dy = abs(dy) ;
if ( ( y >= 0 ) && ( y < ymax ) )
px[y] = x ;
if ( dx > dy ) {
cumul = dx / 2 ;
for ( i = 1 ; i <= dx ; i++ ) {
x += xinc ;
cumul += dy ;
if (cumul >= dx) {
cumul -= dx ;
y += yinc ; }
if ( ( y >= 0 ) && ( y < ymax ) )
px[y] = x ; } }
else {
cumul = dy / 2 ;
for ( i = 1 ; i <= dy ; i++ ) {
y += yinc ;
cumul += dx ;
if ( cumul >= dy ) {
cumul -= dy ;
x += xinc ; }
if ( ( y >= 0 ) && ( y < ymax ) )
px[y] = x ; } }
}
void ligneCote(int xi,int yi,int xf,int yf,int *px,int ymax) {
if ( xi > xf )
ligne(xf,yf,xi,yi,px,ymax) ;
else
ligne(xi,yi,xf,yf,px,ymax) ;
}
void Pixel(int x,int y,bitmap *b,int c) {
if ( ( x >= 0 ) && ( x < b->tx ) )
b->p[y][x] = c ;
}
void LigneDiscrete(int y,int x1,int x2,int c,bitmap *b) {
if ( x2 != -100 ) {
int i ;
int x = x1 ;
int dx = x2 - x1 ;
int xinc = ( dx > 0 ) ? 1 : -1 ;
dx = abs(dx) ;
Pixel(x,y,b,c) ;
for ( i = 1 ; i <= dx ; i++ ) {
x += xinc ;
Pixel(x,y,b,c) ; } }
}
void echange(float *p1,float *p2) {
float aux = *p1 ;
*p1 = *p2 ;
*p2 = aux ;
}
void echangeSommet(float *p1,float *p2) {
if ( p1[1] > p2[1] ) {
echange(&p1[0],&p2[0]) ;
echange(&p1[1],&p2[1]) ; }
}
void FacetteDiscrete(bitmap *b,int coul,float *p1,float *p2,float *p3) {
int *px1 =(int *) calloc(b->ty,sizeof(int)) ;
int *px2 =(int *) calloc(b->ty,sizeof(int)) ;
int *px3 =(int *) calloc(b->ty,sizeof(int)) ;
int i;
for ( i = 0 ; i < b->ty ; i++ )
px1[i] = px2[i] = px3[i] = -100000 ;
ligneCote((int) p1[0],(int) p1[1],(int) p2[0],(int) p2[1],px1,b->ty) ;
ligneCote((int) p1[0],(int) p1[1],(int) p3[0],(int) p3[1],px2,b->ty) ;
ligneCote((int) p2[0],(int) p2[1],(int) p3[0],(int) p3[1],px3,b->ty) ;
int *x1 =(int *) calloc(b->ty,sizeof(int)) ;
int *x2 =(int *) calloc(b->ty,sizeof(int)) ;
for ( i = 0 ; i < b->ty ; i++ )
x1[i] = x2[i] = -100000 ;
for ( i = 0 ; i < b->ty ; i++ ) {
if ( px1[i] > x1[i] )
x1[i] = px1[i] ;
if ( px2[i] > x1[i] )
x1[i] = px2[i] ;
if ( px3[i] > x1[i] )
x1[i] = px3[i] ; }
for ( i = 0 ; i < b->ty ; i++ )
x2[i] = x1[i] ;
for ( i = 0 ; i < b->ty ; i++ ) {
if ( ( px1[i] <= x2[i] ) && ( px1[i] != -100000 ) )
x2[i] = px1[i] ;
if ( ( px2[i] <= x2[i] ) && ( px2[i] != -100000 ) )
x2[i] = px2[i] ;
if ( ( px3[i] <= x2[i] ) && ( px3[i] != -100000 ) )
x2[i] = px3[i] ; }
for ( int y = 0 ; y < b->ty ; y++ )
LigneDiscrete(y,x2[y],x1[y],coul,b) ;
free(px1);
free(px2);
free(px3);
free(x1);
free(x2);
}
void allocBitmap(int tx,int ty,bitmap *b) {
b->tx = tx;
b->ty = ty;
b->p =(int **) calloc(ty,sizeof(int *));
for ( int i = 0 ; i < ty ; i++ )
b->p[i] =(int *) calloc(tx,sizeof(int));
}
void freeBitmap(bitmap *b) {
for ( int i = 0 ; i < b->ty ; i++ )
free(b->p[i]);
free(b->p);
}
void remplissageFacette(facette3 *f,bitmap *b) {
float p0[3];
float p1[3];
float p2[3];
p0[0] = f->s[0].x;
p0[1] = f->s[0].y;
p0[2] = f->s[0].z;
p1[0] = f->s[1].x;
p1[1] = f->s[1].y;
p1[2] = f->s[1].z;
p2[0] = f->s[2].x;
p2[1] = f->s[2].y;
p2[2] = f->s[2].z;
FacetteDiscrete(b,1,p0,p1,p2);
}
Remarques, erreurs
nicolas.janey@univ-fcomte.fr