[2.5👍] Multi-courbes en un temps record !
This commit is contained in:
parent
cdf981263b
commit
af614ebf4f
43
main.c
43
main.c
@ -24,8 +24,14 @@ float valmin[MAXC];
|
|||||||
float valmax[MAXC];
|
float valmax[MAXC];
|
||||||
int nc = 0;
|
int nc = 0;
|
||||||
|
|
||||||
|
// Defines
|
||||||
|
#define HORIZONTAL 0
|
||||||
|
#define VERTICAL 1
|
||||||
|
#define SUPERPOSER 2
|
||||||
|
|
||||||
// Variables globales
|
// Variables globales
|
||||||
int vx1 = 0, vx2 = 400, vy1 = 0, vy2 = 400;
|
int vx1 = 0, vx2 = 400, vy1 = 0, vy2 = 400;
|
||||||
|
int mode_affichage = HORIZONTAL;
|
||||||
|
|
||||||
float map(float smin, float smax, float val, float omin, float omax)
|
float map(float smin, float smax, float val, float omin, float omax)
|
||||||
{
|
{
|
||||||
@ -55,6 +61,14 @@ void ligne(int index, float hgx, float hgy, float bdx, float bdy)
|
|||||||
float pos_x = map(0, size-1, i-1, hgx, bdx);
|
float pos_x = map(0, size-1, i-1, hgx, bdx);
|
||||||
float pos_y = map(valmin[index], valmax[index], courbe[index][i], bdy, hgy);
|
float pos_y = map(valmin[index], valmax[index], courbe[index][i], bdy, hgy);
|
||||||
//printf("%d : {%f, %f}\n", i, pos_x, pos_y);
|
//printf("%d : {%f, %f}\n", i, pos_x, pos_y);
|
||||||
|
|
||||||
|
if(mode_affichage == VERTICAL)
|
||||||
|
{
|
||||||
|
float temp = pos_x;
|
||||||
|
pos_x = pos_y;
|
||||||
|
pos_y = temp;
|
||||||
|
}
|
||||||
|
|
||||||
glVertex2f(pos_x, pos_y);
|
glVertex2f(pos_x, pos_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +82,33 @@ void afficher(void)
|
|||||||
glClearColor(0.0,0.0,0.0,0.0);
|
glClearColor(0.0,0.0,0.0,0.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
ligne(0, -1.0, 1.0, 1.0, 0);
|
if(mode_affichage == HORIZONTAL)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 1; i < nc+1; i++)
|
||||||
|
{
|
||||||
|
float haut = map(0, nc, i-1, 1.0, -1.0);
|
||||||
|
float bas = map(0, nc, i, 1.0, -1.0);
|
||||||
|
ligne(i-1, -1.0, haut, 1.0, bas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode_affichage == VERTICAL)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 1; i < nc+1; i++)
|
||||||
|
{
|
||||||
|
float gauche = map(0, nc, i-1, -1.0, 1.0);
|
||||||
|
float droite = map(0, nc, i, -1.0, 1.0);
|
||||||
|
ligne(i-1, -1.0, gauche, 1.0, droite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode_affichage == SUPERPOSER)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 1; i < nc+1; i++)
|
||||||
|
{
|
||||||
|
ligne(i-1, -1.0, 1.0, 1.0, -1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
@ -214,6 +254,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
printCourbeTerminal();
|
printCourbeTerminal();
|
||||||
|
|
||||||
|
mode_affichage = SUPERPOSER;
|
||||||
int window = initWindow(argc, argv, afficher);
|
int window = initWindow(argc, argv, afficher);
|
||||||
|
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
Loading…
Reference in New Issue
Block a user