Errreur

RM50Man Messages postés 314 Date d'inscription mercredi 1 novembre 2000 Statut Membre Dernière intervention 20 août 2006 - 26 oct. 2005 à 00:08
vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008 - 28 oct. 2005 à 12:34
Mon code ne marche pas:
Le compilateur devcpp me met build error 1

#include <gl/glut.h> /* contient déjà <GL/gl.h> et <GL/glu.h> */
#include <gl/gl.h>
#include <gl/glu.h>

#include <math.h>

void resetgraph(), initgraph();

int SIZEX,SIZEY; /* taille de la fenêtre */
GLfloat light_pos[4] = { 0., 0., 1., 0.}; /* lum à l'infini */
float Cphi=0, Otheta=0, scale=3; /*orientations */

/* description géométrique de l'objet 2 (pyramide). */
#define SQRT2 1.4142138 /* sqrt(2) */
#define SQRT3S2 .8660254 /* sqrt(3)/2 */
#define HH .4714045 /* sqrt(2)/3 */
#define nb_faces 4
#define M_PI 3.1416
float coords[nb_faces][3] =
{ {0,SQRT2,0}, {-SQRT3S2,0,-.5}, {SQRT3S2,0,-.5}, {0,0,1.} };
/* couleurs aux sommets et non pas aux faces (i.e. interpolées) */
float colors[nb_faces][3] = { {.4,.4,.4},{1,0,0},{0,1,0},{0,0,1} };
int faces[nb_faces][3] = { {0,1,2}, {0,2,3}, {0,3,1}, {3,2,1} };
/* normales aux faces et non aux sommets (i.e. objet pas lisse) */
float normals[nb_faces][3] =
{ {0,1/3.,-2*HH},{HH,1/3.,SQRT3S2*HH},{-HH,1/3.,SQRT3S2*HH},{0,-1,0} };

void draw_scene() { /* tracé de la scène */
int i;
glPushMatrix();
glTranslatef(-4.,0.,0.);
glRotatef(Otheta*180/M_PI, 1,0,0); /* on oriente l'objet 1 */
glColor3f(1.,.5,.5);
glutSolidTorus(1.,2.,20,30);
glPopMatrix();

glPushMatrix();
glTranslatef(4.,0.,0.);
glRotatef(20, 1,0,0); /* on oriente l'objet 2 */
glScalef(scale,scale,scale);
glBegin(GL_TRIANGLES);
for(i=0; i<nb_faces; i++) {
glNormal3fv(normals[i]); /* normale commune à la face */
glColor3fv (colors[faces[i][0]]);
glVertex3fv(coords[faces[i][0]]);
glColor3fv (colors[faces[i][1]]); /* couleurs aux sommets */
glVertex3fv(coords[faces[i][1]]);
glColor3fv (colors[faces[i][2]]);
glVertex3fv(coords[faces[i][2]]);
}
glEnd();
glPopMatrix();
}
void redisplay() { /* routine générale d'affichage */
resetgraph(); /* on réinitialise l'affichage */
draw_scene(); /* on trace */
glutSwapBuffers(); /* on rend le tracé visible */
glFlush();
}
void reshape(int x,int y) { glViewport(0,0,SIZEX=x,SIZEY=y); } /* resize */

void idle() { /* animation */
static float temps = 0;
temps += 0.05; Cphi -= .003; Otheta += .01; scale = 3+.3*sin(temps);
glutPostRedisplay();
}
void main(int argc, char **argv) {
glutInit(&argc,argv); /* initialisation de GLUT */
initgraph(); /* initialisations graphiques */
glutMainLoop(); /* boucle des evenements */
}
void initgraph() { /* initialisations graphiques */
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutInitWindowSize(256,256);
glutCreateWindow("Essai !");
glutDisplayFunc(redisplay);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
}
void resetgraph() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* on efface */
glMatrixMode(GL_PROJECTION); /* on oriente la caméra */
glLoadIdentity();
gluPerspective(80., SIZEX/(float)SIZEY, .1, 100.);
glTranslatef(0,0,-10);
glRotatef(Cphi*180/M_PI, 0,1,0);
glMatrixMode(GL_MODELVIEW); /* on oriente la lumière */
glLoadIdentity();
glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
}

6 réponses

vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008
27 oct. 2005 à 21:44
je suis étonné que tu ne trouve pas le problemes. tu ne regarde pas les erreurs que devcpp te donnent

chez moi ça fonctionne trés bien, mes modifications:

j'ai enlever ta definition de M_PI parce qu'il est deja defini dans math.h

et pui j'ai changé ton main en
int main(int argc, char **argv) {
glutInit(&argc,argv); /* initialisation de GLUT */
initgraph(); /* initialisations graphiques */
glutMainLoop(); /* boucle des evenements */
return 0;
}

et tout fonctionne parfaitement donc je ne sais pas si c'était vraiment ça le probléme...
++
0
RM50Man Messages postés 314 Date d'inscription mercredi 1 novembre 2000 Statut Membre Dernière intervention 20 août 2006
27 oct. 2005 à 23:23
Moi g pas M_PI ds math.h
et ca marche toujours pas!!!!
ca me met Build error1
0
RM50Man Messages postés 314 Date d'inscription mercredi 1 novembre 2000 Statut Membre Dernière intervention 20 août 2006
27 oct. 2005 à 23:37
Je met le fichier
#include <math.h>
et i ve pas me l inclure
0
RM50Man Messages postés 314 Date d'inscription mercredi 1 novembre 2000 Statut Membre Dernière intervention 20 août 2006
27 oct. 2005 à 23:51
Erreur ds la makefile.win
# Project: Projet1
# Makefile created by Dev-C++ 4.9.7.0

CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES OBJ main.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -mwindows "C:/Dev-Cpp/include/gl/gl.h" "C:/Dev-Cpp/include/gl/glaux.h" "C:/Dev-Cpp/include/gl/glext.h" "C:/Dev-Cpp/include/gl/glu.h" "C:/Dev-Cpp/include/gl/glut.h"
INCS = -I"C:/Dev-Cpp/include"
BIN = Projet1.exe
CXXFLAGS = $(INCS)
CFLAGS = $(INCS)

.PHONY: all all-before all-after clean clean-custom

all: all-before Projet1.exe all-after


clean: clean-custom
rm -f $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CC) $(OBJ) -o "Projet1.exe" $(LIBS) $(CFLAGS)

main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
RM50Man Messages postés 314 Date d'inscription mercredi 1 novembre 2000 Statut Membre Dernière intervention 20 août 2006
27 oct. 2005 à 23:52
Cpp/include"

gcc.exe: Compilation of header file requested
gcc.exe: Compilation of header file requested
gcc.exe: Compilation of header file requested
gcc.exe: Compilation of header file requested

make.exe: *** [Projet1.exe] Error 1
0
vladisback Messages postés 61 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 5 août 2008
28 oct. 2005 à 12:34
personnellement, j'ai la derniére version de devcpp avec les header et tout ce qui faut dispo ici:
http://prdownloads.sourceforge.net/dev-cpp/devcpp-4.9.9.2_setup.exe

ensuite j'ai installer les librairies de glut en passant par le devpak manager de devcpp,
j'ai ensuite créé un nouveau projet glut puis j'ai remplacer le main.cpp par ton code et comme ça tout marche impecc
donc le probleme ne vient pas du code mais de ton install je pense...

j'espére que ça t'aidera !
a+
0
Rejoignez-nous