Bonjour à tous
Est ce quelqu'un pourrait me dire pourquoi les coordonées s'affichent sur l'axe z=0 de mon programme.C'est très important car c'est pour un projet à rendre dans 2 jours.
Si quelqu'un pouvait m'aider,ça serait très très gentil et ça m'aiderait beaucoup car là je suis coincé.
Merci d'avance pour vos réponses
Paula
Voici le code de mon programme :
#include <GL/glut.h>
#include <stdio.h>
#define TIMER 10
#define CUBE 2
int tab2[50][50];
double eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz;
float xcoord, ycoord, zcoord;
int xbar, ybar, zbar;
int direct_x, direct_y, direct_z;
int tableau[15][15][15];
void initialise_tableau()
{
int i,j,k;
for (i=0; i<15; i++)
for (j=0; j<15; j++)
for (k=0; k<15; k++)
tableau[i][j][k] = 0 ;
//for (i=0; i<15; i++)
// for (j=10; j>8; j--)
// for (k=0; k<13; k++)
// tableau[i][j][k] = 0 ;
}
void initialise(){
int i,j;
for(i=0;i<50;i++){
for(j=0;j<50;j++){
if( (i%2)&& (j%2) == 0){
tab2[i][j]=4;
}
else{
tab2[i][j]==478;
}
}
}
}
static void reshape(int w,int h)
{
glViewport( 0, 0, (GLint)w, (GLint)h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(16, w/(float)h, 1, 100) ;
glMatrixMode( GL_MODELVIEW );
}
static void timer(int value)
{
glutPostRedisplay() ;
glutTimerFunc(TIMER, timer, value++) ;
}
static void keyboard(unsigned char k,int x,int y){
switch(k){
case 'q':
case 'Q':
case 27:
glutLeaveMainLoop();
break;
case '1':
eyex += 1;
break;
case '4':
eyex += -1;
break;
case '2':
eyey += 1;
break;
case '5':
eyey += -1;
break;
case '3':
eyez += 1;
break;
case '6':
eyez += -1;
break;
case 'a':
xcoord += 1;
break;
case 'z':
xcoord += -1;
break;
case 'e':
ycoord += 1;
break;
case 'r':
ycoord += -1;
break;
case 't':
zcoord += 1;
break;
case 'y':
zcoord += -1;
break;
}
}
void tracer_point2(){
int i,j;
int k;
glBegin(GL_POINTS);
for(i=0;i<50;i++){
for(j=0;j<50;j++){
if( (i%2)&& (j%2) == 0){
glColor3f(1.0,1.0,0);
k=tab2[i][j];
glVertex3f(i,k,j);
}
else{
glColor3f(0.0,1.0,1.0);
k=tab2[i][j];
glVertex3f(i,k,j);
}
}
}
glEnd();
}
void carre(int i , int j, int k){
glBegin(GL_LINE_STRIP);
glVertex3f(i,0.0,k);
glVertex3f(i+1 ,0.0,k);
glVertex3f(i+1,0.0,k+1);
glVertex3f(i,0.0,k+1);
glEnd();
}
void sol () {
int i;
int k;
glColor3f(0.5,0.5,0.5);
glBegin(GL_POLYGON);
glVertex3f(0.0,0.0,0.0);
glVertex3f(15.0 ,0.0,0.0);
glVertex3f(15.0,0.0,15.0);
glVertex3f(0.0,0.0,15.0);
glEnd();
}
void repere(){
int x,y;
//x=lfmt[I_NDIMX];
//y=lfmt[I_NDIMY];
glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex3f(0,0,0);
glVertex3f(215,0,0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,1.0,0.0);
glVertex3f(0,0,0);
glVertex3f(0,505,0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,1.0);
glVertex3f(0,0,0);
glVertex3f(0,0,215);
glEnd();
}
void init () {
eyex = 82;
eyey = 4;
eyez = 16;
centerx = 7;
centery =7;
centerz = 0;
upx = upz = 0;
upy = 1;
initialise_tableau();
//glEnable(GL_DEPTH_TEST);
}
static void display() {
int i,j,k;
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy,
upz);
glClear(GL_COLOR_BUFFER_BIT);
tracer_point2();
repere();
glFlush();
glutSwapBuffers();
}
int main(int argc,char*argv[]) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE);
glutCreateWindow("PROJET");
glutDisplayFunc(display);
glutPostRedisplay();
glutKeyboardFunc(keyboard);
glutTimerFunc(TIMER,timer,0);
glutReshapeFunc(reshape);
init();
glutMainLoop();
return 0;
}
Partager