Accueil > > > ANIMATION D'UN CERCLE AVEC TOUCHES + FILM[2D][DEVC++4][GLUT]
ANIMATION D'UN CERCLE AVEC TOUCHES + FILM[2D][DEVC++4][GLUT]
Information sur la source
Description
haut: o bas : l gauche : k droite : m agrandir : h rétrécir : b Quitter : q Animer : c Fait par Matthias RENAULT avec Dev C++4 matthias.renault@voila.fr Nécessite GLUT Glut.dll fourni
Source
- //Les librairies
- #include <gl/glut.h>
- #include <math.h>
-
- //on déclare les procédures
- void display(void);
- void init(void);
- void film();
- void indispensable();
-
- //on déclare la fonction pour le cercle
- void cercles(int x, int y, int rayon2);
-
- //On déclare les variables
- bool choix = false; //boolenne
-
- int rayon[100];
- int xa[100]; //entière avec tableau : la 1ere "case" de xa vaut 50
- int ya[100];
-
- int i = 1; //i détermine combien de fois on a appuyé sur une touche
-
- float linex = 0.5; //à virgule flottante
- float liney = 0.5;
- float theta = 0.0f;
-
-
-
- void display (void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- if (!choix)
- {
- glBegin(GL_LINES);
- glColor3f (1.0, 0.0, 0.0);
- glVertex2f (linex - 0.01, liney);
- glVertex2f (linex + 0.01, liney);
- glVertex2f (linex, liney + 0.01);
- glVertex2f (linex, liney - 0.01);
- glEnd();
- cercles (xa[i], ya[i], rayon[i]); //on trace le cercle
- }
-
- if (choix == true)
- {
- cercles (xa[i], ya[i], rayon[i]); //on trace le cercle
- }
- glFlush();
-
- //On a deja fait le cercle
- choix = true;
-
- }
-
-
- //Toute la gestion alphanumérique
- void keyboard(unsigned char key, int x, int y)
- {
- switch (key)
- {
-
- case 'q': //quitter
- exit(0);
- break;
-
- case 'h': //cercle + grand
- rayon[i]++;
- indispensable();
- glutPostRedisplay();
- break;
-
- case 'b': //cercle + petit
- rayon[i]--;
- indispensable();
- glutPostRedisplay();
- break;
-
- case 'o': //on monte
- ya[i]--;
- indispensable();
- glutPostRedisplay();
- break;
- //on descend
- case 'l':
- ya[i]++;
- indispensable();
- glutPostRedisplay();
- break;
-
- case 'k': //à gauche
- xa[i]--;
- indispensable();
- glutPostRedisplay();
- break;
-
- case 'm': //à droite...
- xa[i]++;
- indispensable();
- glutPostRedisplay();
- break;
- //on lance le "film"!
- case 'c':
- film();
- break;
-
- default: //si rien, on retourne au début!
- break;
- }
- }
-
- void film()
- {
- int a; //le compteur
- for (a = 1; a <= i; a++)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- cercles (xa[a], ya[a], rayon[a]);
- }
- }
-
- void indispensable()
- {
- xa[i+1] = xa[i];
- ya[i+1] = ya[i];
- rayon[i+1] = rayon[i];
- i++;
- }
-
- //initiation perso...
- void init(void)
- {
- //on initialise les variables
- rayon[1] = 10;
- xa[1] = 50;
- ya[1] = 50;
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, 100, 100, 0, -100, 100);
- }
-
- //Histoire d'initier...
- int main (int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(600,600);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("Cercles");
- init();
- glutDisplayFunc(display);
- glutKeyboardFunc(keyboard);
- glutMainLoop();
- return 0;
- }
-
-
- //La fonction du cercle KITU!!!
- void cercles (int x, int y, int rayon2)
- {
- int theta = 0;
- glBegin(GL_POINTS);
- while (theta <= 360)
- {
- glVertex2f (x + rayon2 * (cos(theta)), y + rayon2 * (sin(theta))); //la fonction du cercle
- theta++;
- }
- glEnd();
- }
//Les librairies
#include <gl/glut.h>
#include <math.h>
//on déclare les procédures
void display(void);
void init(void);
void film();
void indispensable();
//on déclare la fonction pour le cercle
void cercles(int x, int y, int rayon2);
//On déclare les variables
bool choix = false; //boolenne
int rayon[100];
int xa[100]; //entière avec tableau : la 1ere "case" de xa vaut 50
int ya[100];
int i = 1; //i détermine combien de fois on a appuyé sur une touche
float linex = 0.5; //à virgule flottante
float liney = 0.5;
float theta = 0.0f;
void display (void)
{
glClear(GL_COLOR_BUFFER_BIT);
if (!choix)
{
glBegin(GL_LINES);
glColor3f (1.0, 0.0, 0.0);
glVertex2f (linex - 0.01, liney);
glVertex2f (linex + 0.01, liney);
glVertex2f (linex, liney + 0.01);
glVertex2f (linex, liney - 0.01);
glEnd();
cercles (xa[i], ya[i], rayon[i]); //on trace le cercle
}
if (choix == true)
{
cercles (xa[i], ya[i], rayon[i]); //on trace le cercle
}
glFlush();
//On a deja fait le cercle
choix = true;
}
//Toute la gestion alphanumérique
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'q': //quitter
exit(0);
break;
case 'h': //cercle + grand
rayon[i]++;
indispensable();
glutPostRedisplay();
break;
case 'b': //cercle + petit
rayon[i]--;
indispensable();
glutPostRedisplay();
break;
case 'o': //on monte
ya[i]--;
indispensable();
glutPostRedisplay();
break;
//on descend
case 'l':
ya[i]++;
indispensable();
glutPostRedisplay();
break;
case 'k': //à gauche
xa[i]--;
indispensable();
glutPostRedisplay();
break;
case 'm': //à droite...
xa[i]++;
indispensable();
glutPostRedisplay();
break;
//on lance le "film"!
case 'c':
film();
break;
default: //si rien, on retourne au début!
break;
}
}
void film()
{
int a; //le compteur
for (a = 1; a <= i; a++)
{
glClear(GL_COLOR_BUFFER_BIT);
cercles (xa[a], ya[a], rayon[a]);
}
}
void indispensable()
{
xa[i+1] = xa[i];
ya[i+1] = ya[i];
rayon[i+1] = rayon[i];
i++;
}
//initiation perso...
void init(void)
{
//on initialise les variables
rayon[1] = 10;
xa[1] = 50;
ya[1] = 50;
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 100, 100, 0, -100, 100);
}
//Histoire d'initier...
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600,600);
glutInitWindowPosition(100, 100);
glutCreateWindow("Cercles");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
//La fonction du cercle KITU!!!
void cercles (int x, int y, int rayon2)
{
int theta = 0;
glBegin(GL_POINTS);
while (theta <= 360)
{
glVertex2f (x + rayon2 * (cos(theta)), y + rayon2 * (sin(theta))); //la fonction du cercle
theta++;
}
glEnd();
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLETECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLE par ROMELARD Fabrice
Speakers: Julien Marechal, Gautier Confiant, Sébastien MEYER La session débute par le positionnement de la solution System Center par rapport aux concepts d'organisation ITIL. Le portail du catalogue de se...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE SECOND JOURTECHDAYS PARIS 2012 : PLEINIèRE SECOND JOUR par ROMELARD Fabrice
Après une première journée dédiée aux développeurs, cette seconde journée est dédiée au monde des entreprises et de ses applications. Ainsi, cette pleinière est dédiée à faire un 360 de l'évolution des applications Business aux demandes ac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|