OpenGL/GLUT/GLUI

cs_abdoulzak Messages postés 7 Date d'inscription vendredi 29 octobre 2004 Statut Membre Dernière intervention 29 juin 2006 - 12 nov. 2005 à 20:03
KeniiyK Messages postés 326 Date d'inscription vendredi 13 août 2004 Statut Membre Dernière intervention 2 novembre 2007 - 16 nov. 2005 à 09:27
Salut à tous,

Je développe une interface graphique opengl dans le cadre d'un projet de
simulation.

Je veux dessiner différents points sur une console mais avec différentes
couleurs.

Pour les couleurs c'est OK, mais ils ont tous la même couleur.



Merci d'avance pour votre aide.

3 réponses

luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 6
13 nov. 2005 à 22:54
Et ? Post au moins la partie de ton programme en question.
0
cs_abdoulzak Messages postés 7 Date d'inscription vendredi 29 octobre 2004 Statut Membre Dernière intervention 29 juin 2006
14 nov. 2005 à 11:02
bonjour ,


Je vous envoie le code pour y voir un peux plus claire :





d'abord ma fonction display()




void myGlutDisplay ()



{



Point *temp;







// Clear the frame buffer...



glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );











glColor3fv (color);







float pointSize = 0;



glGetFloatv(GL_POINT_SIZE, &pointSize);







// myGlutDisplay results depending on the mode



glBegin (mode);



for (temp = ihm->head; temp != NULL; temp = temp->np)



glVertex2f (temp->x, temp->y);



glEnd ();







// Set the color of points to green



glColor3f (0.0,255.0,0.0);







// myGlutDisplay points



if (displayMachine)



glBegin (GL_POINTS);



for (temp = ihm->head; temp != NULL; temp = temp->np)



glVertex2f (temp->x, temp->y);



glEnd ();







// myGlutDisplay the number of a point



if (displayMachineNum)



for (temp = ihm->head; temp != NULL; temp = temp->np)



ihm->printw (temp->x - (world_width/ (6.0 * window_width)),



temp->y + (world_height/ window_height) * 15,



"%d", temp->point_num);







// Swap buffers



glutSwapBuffers ();



}






puis la fonction printw()



printw(GLfloat x, GLfloat y, char* format, ...)



{



GLvoid *font_style = GLUT_BITMAP_TIMES_ROMAN_10;



va_list arg_list;



char str[256];



int i;







va_start(arg_list, format);



vsprintf(str, format, arg_list);



va_end(arg_list);







glRasterPos2f (x, y);







for (i = 0; str[i] != '\0'; i++)



glutBitmapCharacter(font_style, str[i]);



}


Mer d'avance
0
KeniiyK Messages postés 326 Date d'inscription vendredi 13 août 2004 Statut Membre Dernière intervention 2 novembre 2007 2
16 nov. 2005 à 09:27
Tes points ont la meme couleur !!!???, oui et je parie qu'ils sont tous verts !!!!!!!!!

: // Set the color of points to green
glColor3f (0.0,255.0,0.0);

Pour changer la couleur fait glColor3f(R,G,B) avant chaque appel a glVertex2f(X,Y)
exemple :
// dessine un point rouge en 0.0 , 0.0
glColor3f(1.0,0.0,0.0);
glVertex2f(0.0,0.0);

// dessine un point vert en 0.0 , 0.0
glColor3f(0.0,1.0,0.0);
glVertex2f(0.0,0.0);

Et autre chose, avec glColor3f(...) les composantes sont normalisées donc sur 0..1

KeniiyK
0
Rejoignez-nous