Accueil > > > INTRODUCTION À OPENGL
INTRODUCTION À OPENGL
Information sur la source
Description
petit programme très simple implementant quelque fonctions de opengl, pour débuter ds le domaine de la 3D.
Source
- //main.c
-
- /*****************************************************************
- / BoBRobert
- /*****************************************************************
-
- /*Une petite "démo" pour commencer
- Bon ttes les fct ne st pas utils mais le but est de faire un moteur d'affichage réutilisable*/
- //#include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <GL/glut.h>
- #include <math.h>
- #include <time.h>
-
- //Mes objets perso
- #include "formes.h"
- //#include "readconf.h"
-
- void affichage();
- void clavier(unsigned char touche, int x, int y);
- void reshape(int, int);
- void mouse(int,int,int,int);
- void mousemotion(int,int);
-
- char presseL, presseD;/*varible globale pour l'état de la sourie*/
-
- int px,py,pz;
-
- /*Structure permettant la définition d'un point (ca peut kan meme servir lol)*/
- typedef struct{
- float x;
- float y;
- float z;
- float r;
- float g;
- float b;
- }point;
-
- /*fonction d'initialisation de la fenêtre de rendu*/
- /*paramètres en entrée :
- - Position de la fenêtre x,y
- - taille de la fenêtre x,y
- - nom de la fenêtre (string) max 19 caractères
- */
- void Glut_Window(int xPos,int yPos,int xTaille,int yTaille,char WinName[20]){
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
- glutInitWindowPosition(xPos,yPos);/*position de la fenetre*/
- glutInitWindowSize(xTaille,yTaille);/*taille de la fenetre*/
- glutCreateWindow(WinName);/*création de la fenetre*/
- }
-
-
- /*fonction de gestion du redimentionnement de la fenetre de rendu(pas super o point)*/
- void reshape(int xWin,int yWin){
- if(xWin<yWin)
- glViewport(0,(yWin-xWin)/2,xWin,xWin);
- else
- glViewport((xWin-yWin)/2,0,yWin,yWin);
- }
-
- /*Paramètres d'initialisation de la belle scène*/
- void Glut_Init_Screen(){
- glClearColor(0.0,1.0,1.0,0.0);//efface tt
- glColor3f(1.0,1.0,1.0);//initialise la couleure de font
- glPointSize(2.0);//taille des points
- glEnable(GL_DEPTH_TEST);
- }
-
-
- /*gère les entrées sortie*/
- void Glut_IO(){
- glutDisplayFunc(affichage);//No Comment lol
- glutKeyboardFunc(clavier);
- glutReshapeFunc(reshape);
- glutMouseFunc(mouse);
- glutMotionFunc(mousemotion);
- }
-
-
- /*gestion des évennement clavier*/
- void clavier(unsigned char touche,int x,int y)
- {
- switch (touche){
- case 'p': /*carre plein */
- glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
- glutPostRedisplay();
- break;
- case 'f': /*fil de fer */
- glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
- glutPostRedisplay();
- break;
- case 's': /* sommets*/
- glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
- glutPostRedisplay();
- break;
- /*case 'z':
- px++;
- glutPostRedisplay();
- break;
- case 'd':
- px--;
- glutPostRedisplay();
- break;*/
- case 'q' : /*quitte */
- exit(0);
- }
- }
-
- /*fonction déterminant l'état des boutons de la sourie*/
- void mouse(int button, int stat, int x, int y){
- //pour le bouton gauche
- //détermine si le bouton gauche est pressé
- if(button == GLUT_LEFT_BUTTON &stat == GLUT_DOWN){
- presseL=1;//état du bouton
- xold=x;
- yold=y;
- }
- //si relaché
- if(button ==GLUT_LEFT_BUTTON &stat == GLUT_UP)
- presseL=0;
-
- //pour le bouton droit
- }
-
- void mousemotion(int x, int y){
- if(presseL==1){
- anglex=anglex+(x-xold);
- angley=angley+(y-yold);
- glutPostRedisplay();
- }
- xold=x;
- yold=y;
- }
-
-
- /*fct d'affichage de la scène*/
- void affichage()
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- //Coeur3D();
- //glTranslatef(-px,0.0,-pz);
- cube();
- //Disque(1,1,1,1);
- //glutWireSphere(1,20,20);
-
- glFlush();
-
- glutSwapBuffers();
- }
-
-
- //Le Bo main
- int main(int argc, char **argv){
-
- printf("Welcome in THE opengl World\n");
- //read_conf();
- glutInit(&argc,argv);/*initialise GLUT*/
-
- Glut_Window(200,200,500,500,"OpenGL Power!!!!!!");/*initialisation de la fenetre*/
-
- Glut_Init_Screen();/*paramètres de la scène*/
-
- Glut_IO();/*entrées sorties*/
-
- glutMainLoop();
- return 0;
- }
-
- //formes.h a mettre ds un autre ficher
-
- /*lib de ttes les formes (lol)*/
-
- int anglex, angley, x, y, xold, yold;//variables globales de gestion de la position de la sourie
-
- /*définition d'objets divers et variée*/
-
- void rotation(){
- glLoadIdentity();
- glRotatef(-angley,1.1,0.0,0.0);
- glRotatef(-anglex,0.0,1.0,0.0);
- }
-
- //carré 2D
- void Carre2D(){
- //carré
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex2f(0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex2f(0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex2f(-0.5,0.5);
- glEnd();
- }
-
- //cube
- void cube(){
-
- rotation();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,-0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(0.5,-0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(0.5,0.5,-0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(-0.5,0.5,-0.5);
- glEnd();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,-0.5,0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(0.5,-0.5,0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(0.5,0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(-0.5,0.5,0.5);
- glEnd();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(-0.5,0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(-0.5,0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(0.5,0.5,0.5);
- glEnd();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,-0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(-0.5,-0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(-0.5,-0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(0.5,-0.5,0.5);
- glEnd();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,-0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(0.5,0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(0.5,0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(0.5,-0.5,0.5);
- glEnd();
-
- glBegin(GL_POLYGON);
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,-0.5,-0.5);
- glColor3f(0.0,1.0,0.0);
- glVertex3f(-0.5,0.5,-0.5);
- glColor3f(0.0,0.0,1.0);
- glVertex3f(-0.5,0.5,0.5);
- glColor3f(1.0,1.0,1.0);
- glVertex3f(-0.5,-0.5,0.5);
- glEnd();
- }
-
- //disque
- void Disque(int rayon,int R,int G, int B){
- int i;
- glBegin(GL_POLYGON);
- for(i=0;i<361;i++){
- glColor3f(R,G,B);
- glVertex3f(rayon*cos(i*3.14/180),rayon*sin(i*3.14/180),0);
- }
- glEnd();
- }
-
- //Arc de disque
- void ArcDisque(int rayon,int debut,int fin,int R,int G, int B){
- int i;
- glBegin(GL_POLYGON);
- glVertex3f(0,0,0);
- for(i=debut;i<fin;i++){
- glColor3f(R,G,B);
- glVertex3f(rayon*cos(i*3.14/180),rayon*sin(i*3.14/180),0);
- }
- glEnd();
- }
-
- //coeur en 2D(o comme il est bo :$)
- void Coeur2D(){
- glBegin(GL_POLYGON);
- //droite
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.0,-0.6);//a0
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.1,-0.5);//a1
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.2,-0.4);//a2
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.3,-0.25);//a3
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.4,-0.05);//a4
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.5,0.15);//a5
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.55,0.25);//a6
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.5,0.35);//a7
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.4,0.5);//a8
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.25,0.55);//a9
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.1,0.5);//a10
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.05,0.45);//a11
- glColor3f(1.0,0.0,0.0);
- glVertex2f(0.0,0.3);//a12
- //gauche
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.0,-0.6);//-a0
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.1,-0.5);//-a1
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.2,-0.4);//-a2
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.3,-0.25);//-a3
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.4,-0.05);//-a4
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.5,0.15);//-a5
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.55,0.25);//-a6
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.5,0.35);//-a7
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.4,0.5);//-a8
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.25,0.55);//-a9
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.1,0.5);//-a10
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.05,0.45);//-a11
- glColor3f(1.0,0.0,0.0);
- glVertex2f(-0.0,0.3);//-a12
- glEnd();
- }
-
- //coeur en 3D encore plus bo
- void Coeur3D(){
- //annimation
- rotation();
-
- glBegin(GL_POLYGON);
- //droite
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.0,-0.6,0.25);//a0
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.1,-0.5,0.25);//a1
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.2,-0.4,0.25);//a2
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.3,-0.25,0.25);//a3
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.4,-0.05,0.25);//a4
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,0.15,0.25);//a5
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.55,0.25,0.25);//a6
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,0.35,0.25);//a7
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.4,0.5,0.25);//a8
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.25,0.55,0.25);//a9
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.1,0.5,0.25);//a10
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.05,0.45,0.25);//a11
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.0,0.3,0.25);//a12
- //gauche
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.0,-0.6,0.25);//-a0
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.1,-0.5,0.25);//-a1
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.2,-0.4,0.25);//-a2
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.3,-0.25,0.25);//-a3
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.4,-0.05,0.25);//-a4
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,0.15,0.25);//-a5
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.55,0.25,0.25);//-a6
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,0.35,0.25);//-a7
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.4,0.5,0.25);//-a8
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.25,0.55,0.25);//-a9
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.1,0.5,0.25);//-a10
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.05,0.45,0.25);//-a11
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.0,0.3,0.25);//-a12
- glEnd();
-
- glBegin(GL_POLYGON);
- //droite
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.0,-0.6,-0.25);//a0
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.1,-0.5,-0.25);//a1
- glColor3f(1.0,1.0,0.0);
- glVertex3f(0.2,-0.4,-0.25);//a2
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.3,-0.25,-0.25);//a3
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.4,-0.05,-0.25);//a4
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,0.15,-0.25);//a5
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.55,0.25,-0.25);//a6
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.5,0.35,-0.25);//a7
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.4,0.5,-0.25);//a8
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.25,0.55,-0.25);//a9
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.1,0.5,-0.25);//a10
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.05,0.45,-0.25);//a11
- glColor3f(1.0,0.0,0.0);
- glVertex3f(0.0,0.3,-0.25);//a12
- //gauche
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.0,-0.6,-0.25);//-a0
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.1,-0.5,-0.25);//-a1
- glColor3f(1.0,1.0,0.0);
- glVertex3f(-0.2,-0.4,-0.25);//-a2
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.3,-0.25,-0.25);//-a3
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.4,-0.05,-0.25);//-a4
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,0.15,-0.25);//-a5
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.55,0.25,-0.25);//-a6
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.5,0.35,-0.25);//-a7
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.4,0.5,-0.25);//-a8
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.25,0.55,-0.25);//-a9
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.1,0.5,-0.25);//-a10
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.05,0.45,-0.25);//-a11
- glColor3f(1.0,0.0,0.0);
- glVertex3f(-0.0,0.3,-0.25);//-a12
- glEnd();
- }
//main.c
/*****************************************************************
/ BoBRobert
/*****************************************************************
/*Une petite "démo" pour commencer
Bon ttes les fct ne st pas utils mais le but est de faire un moteur d'affichage réutilisable*/
//#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <math.h>
#include <time.h>
//Mes objets perso
#include "formes.h"
//#include "readconf.h"
void affichage();
void clavier(unsigned char touche, int x, int y);
void reshape(int, int);
void mouse(int,int,int,int);
void mousemotion(int,int);
char presseL, presseD;/*varible globale pour l'état de la sourie*/
int px,py,pz;
/*Structure permettant la définition d'un point (ca peut kan meme servir lol)*/
typedef struct{
float x;
float y;
float z;
float r;
float g;
float b;
}point;
/*fonction d'initialisation de la fenêtre de rendu*/
/*paramètres en entrée :
- Position de la fenêtre x,y
- taille de la fenêtre x,y
- nom de la fenêtre (string) max 19 caractères
*/
void Glut_Window(int xPos,int yPos,int xTaille,int yTaille,char WinName[20]){
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(xPos,yPos);/*position de la fenetre*/
glutInitWindowSize(xTaille,yTaille);/*taille de la fenetre*/
glutCreateWindow(WinName);/*création de la fenetre*/
}
/*fonction de gestion du redimentionnement de la fenetre de rendu(pas super o point)*/
void reshape(int xWin,int yWin){
if(xWin<yWin)
glViewport(0,(yWin-xWin)/2,xWin,xWin);
else
glViewport((xWin-yWin)/2,0,yWin,yWin);
}
/*Paramètres d'initialisation de la belle scène*/
void Glut_Init_Screen(){
glClearColor(0.0,1.0,1.0,0.0);//efface tt
glColor3f(1.0,1.0,1.0);//initialise la couleure de font
glPointSize(2.0);//taille des points
glEnable(GL_DEPTH_TEST);
}
/*gère les entrées sortie*/
void Glut_IO(){
glutDisplayFunc(affichage);//No Comment lol
glutKeyboardFunc(clavier);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutMotionFunc(mousemotion);
}
/*gestion des évennement clavier*/
void clavier(unsigned char touche,int x,int y)
{
switch (touche){
case 'p': /*carre plein */
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glutPostRedisplay();
break;
case 'f': /*fil de fer */
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glutPostRedisplay();
break;
case 's': /* sommets*/
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
glutPostRedisplay();
break;
/*case 'z':
px++;
glutPostRedisplay();
break;
case 'd':
px--;
glutPostRedisplay();
break;*/
case 'q' : /*quitte */
exit(0);
}
}
/*fonction déterminant l'état des boutons de la sourie*/
void mouse(int button, int stat, int x, int y){
//pour le bouton gauche
//détermine si le bouton gauche est pressé
if(button == GLUT_LEFT_BUTTON &stat == GLUT_DOWN){
presseL=1;//état du bouton
xold=x;
yold=y;
}
//si relaché
if(button ==GLUT_LEFT_BUTTON &stat == GLUT_UP)
presseL=0;
//pour le bouton droit
}
void mousemotion(int x, int y){
if(presseL==1){
anglex=anglex+(x-xold);
angley=angley+(y-yold);
glutPostRedisplay();
}
xold=x;
yold=y;
}
/*fct d'affichage de la scène*/
void affichage()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Coeur3D();
//glTranslatef(-px,0.0,-pz);
cube();
//Disque(1,1,1,1);
//glutWireSphere(1,20,20);
glFlush();
glutSwapBuffers();
}
//Le Bo main
int main(int argc, char **argv){
printf("Welcome in THE opengl World\n");
//read_conf();
glutInit(&argc,argv);/*initialise GLUT*/
Glut_Window(200,200,500,500,"OpenGL Power!!!!!!");/*initialisation de la fenetre*/
Glut_Init_Screen();/*paramètres de la scène*/
Glut_IO();/*entrées sorties*/
glutMainLoop();
return 0;
}
//formes.h a mettre ds un autre ficher
/*lib de ttes les formes (lol)*/
int anglex, angley, x, y, xold, yold;//variables globales de gestion de la position de la sourie
/*définition d'objets divers et variée*/
void rotation(){
glLoadIdentity();
glRotatef(-angley,1.1,0.0,0.0);
glRotatef(-anglex,0.0,1.0,0.0);
}
//carré 2D
void Carre2D(){
//carré
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex2f(0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex2f(0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex2f(-0.5,0.5);
glEnd();
}
//cube
void cube(){
rotation();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(0.5,0.5,-0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(-0.5,0.5,-0.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,-0.5,0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(0.5,-0.5,0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(0.5,0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(-0.5,0.5,0.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(0.5,0.5,0.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,-0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(0.5,-0.5,0.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(0.5,0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(0.5,0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(0.5,-0.5,0.5);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex3f(-0.5,-0.5,0.5);
glEnd();
}
//disque
void Disque(int rayon,int R,int G, int B){
int i;
glBegin(GL_POLYGON);
for(i=0;i<361;i++){
glColor3f(R,G,B);
glVertex3f(rayon*cos(i*3.14/180),rayon*sin(i*3.14/180),0);
}
glEnd();
}
//Arc de disque
void ArcDisque(int rayon,int debut,int fin,int R,int G, int B){
int i;
glBegin(GL_POLYGON);
glVertex3f(0,0,0);
for(i=debut;i<fin;i++){
glColor3f(R,G,B);
glVertex3f(rayon*cos(i*3.14/180),rayon*sin(i*3.14/180),0);
}
glEnd();
}
//coeur en 2D(o comme il est bo :$)
void Coeur2D(){
glBegin(GL_POLYGON);
//droite
glColor3f(1.0,0.0,0.0);
glVertex2f(0.0,-0.6);//a0
glColor3f(1.0,0.0,0.0);
glVertex2f(0.1,-0.5);//a1
glColor3f(1.0,0.0,0.0);
glVertex2f(0.2,-0.4);//a2
glColor3f(1.0,0.0,0.0);
glVertex2f(0.3,-0.25);//a3
glColor3f(1.0,0.0,0.0);
glVertex2f(0.4,-0.05);//a4
glColor3f(1.0,0.0,0.0);
glVertex2f(0.5,0.15);//a5
glColor3f(1.0,0.0,0.0);
glVertex2f(0.55,0.25);//a6
glColor3f(1.0,0.0,0.0);
glVertex2f(0.5,0.35);//a7
glColor3f(1.0,0.0,0.0);
glVertex2f(0.4,0.5);//a8
glColor3f(1.0,0.0,0.0);
glVertex2f(0.25,0.55);//a9
glColor3f(1.0,0.0,0.0);
glVertex2f(0.1,0.5);//a10
glColor3f(1.0,0.0,0.0);
glVertex2f(0.05,0.45);//a11
glColor3f(1.0,0.0,0.0);
glVertex2f(0.0,0.3);//a12
//gauche
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.0,-0.6);//-a0
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.1,-0.5);//-a1
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.2,-0.4);//-a2
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.3,-0.25);//-a3
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.4,-0.05);//-a4
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.5,0.15);//-a5
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.55,0.25);//-a6
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.5,0.35);//-a7
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.4,0.5);//-a8
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.25,0.55);//-a9
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.1,0.5);//-a10
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.05,0.45);//-a11
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.0,0.3);//-a12
glEnd();
}
//coeur en 3D encore plus bo
void Coeur3D(){
//annimation
rotation();
glBegin(GL_POLYGON);
//droite
glColor3f(1.0,1.0,0.0);
glVertex3f(0.0,-0.6,0.25);//a0
glColor3f(1.0,1.0,0.0);
glVertex3f(0.1,-0.5,0.25);//a1
glColor3f(1.0,1.0,0.0);
glVertex3f(0.2,-0.4,0.25);//a2
glColor3f(1.0,0.0,0.0);
glVertex3f(0.3,-0.25,0.25);//a3
glColor3f(1.0,0.0,0.0);
glVertex3f(0.4,-0.05,0.25);//a4
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.15,0.25);//a5
glColor3f(1.0,0.0,0.0);
glVertex3f(0.55,0.25,0.25);//a6
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.35,0.25);//a7
glColor3f(1.0,0.0,0.0);
glVertex3f(0.4,0.5,0.25);//a8
glColor3f(1.0,0.0,0.0);
glVertex3f(0.25,0.55,0.25);//a9
glColor3f(1.0,0.0,0.0);
glVertex3f(0.1,0.5,0.25);//a10
glColor3f(1.0,0.0,0.0);
glVertex3f(0.05,0.45,0.25);//a11
glColor3f(1.0,0.0,0.0);
glVertex3f(0.0,0.3,0.25);//a12
//gauche
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.0,-0.6,0.25);//-a0
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.1,-0.5,0.25);//-a1
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.2,-0.4,0.25);//-a2
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.3,-0.25,0.25);//-a3
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.4,-0.05,0.25);//-a4
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,0.15,0.25);//-a5
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.55,0.25,0.25);//-a6
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,0.35,0.25);//-a7
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.4,0.5,0.25);//-a8
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.25,0.55,0.25);//-a9
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.1,0.5,0.25);//-a10
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.05,0.45,0.25);//-a11
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.0,0.3,0.25);//-a12
glEnd();
glBegin(GL_POLYGON);
//droite
glColor3f(1.0,1.0,0.0);
glVertex3f(0.0,-0.6,-0.25);//a0
glColor3f(1.0,1.0,0.0);
glVertex3f(0.1,-0.5,-0.25);//a1
glColor3f(1.0,1.0,0.0);
glVertex3f(0.2,-0.4,-0.25);//a2
glColor3f(1.0,0.0,0.0);
glVertex3f(0.3,-0.25,-0.25);//a3
glColor3f(1.0,0.0,0.0);
glVertex3f(0.4,-0.05,-0.25);//a4
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.15,-0.25);//a5
glColor3f(1.0,0.0,0.0);
glVertex3f(0.55,0.25,-0.25);//a6
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.35,-0.25);//a7
glColor3f(1.0,0.0,0.0);
glVertex3f(0.4,0.5,-0.25);//a8
glColor3f(1.0,0.0,0.0);
glVertex3f(0.25,0.55,-0.25);//a9
glColor3f(1.0,0.0,0.0);
glVertex3f(0.1,0.5,-0.25);//a10
glColor3f(1.0,0.0,0.0);
glVertex3f(0.05,0.45,-0.25);//a11
glColor3f(1.0,0.0,0.0);
glVertex3f(0.0,0.3,-0.25);//a12
//gauche
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.0,-0.6,-0.25);//-a0
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.1,-0.5,-0.25);//-a1
glColor3f(1.0,1.0,0.0);
glVertex3f(-0.2,-0.4,-0.25);//-a2
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.3,-0.25,-0.25);//-a3
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.4,-0.05,-0.25);//-a4
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,0.15,-0.25);//-a5
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.55,0.25,-0.25);//-a6
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,0.35,-0.25);//-a7
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.4,0.5,-0.25);//-a8
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.25,0.55,-0.25);//-a9
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.1,0.5,-0.25);//-a10
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.05,0.45,-0.25);//-a11
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.0,0.3,-0.25);//-a12
glEnd();
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|