Comment faire un cube avec openGL?

Fermé
Yann - 15 oct. 2015 à 20:09
 Yann - 15 oct. 2015 à 20:17
Bonjour, ça fait 3 h que je galère pour faire un cube. Je n'arrive pas à tourner les faces! Help! Pour l'instant l'erreur est: invalid suffix "yf" on floating constant


glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();
glRotatef(theta, 3.5f, 5.2f, 4.8f);

glBegin(GL_QUADS);

float x=0;
float y=0;
int i=0;
for (i=1; i<4; i++) {

if ((i==3) || (i==4)) {
x=x+1;
}
else {
x=0;
}

if ((i==3) || (i==2)) {
y=y+1;
}
else {
y=0;
}
}

glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.xf, 0.yf, 0.7f);

theta -= 5.5f;
}


glEnd();


Merci ;)

1 réponse

Et avec ça non plus il ne tourne pas! Help!


      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();
glRotatef(theta, 3.5f, 5.2f, 4.8f);

glBegin(GL_QUADS);

glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, 0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, 0.7f);
theta+=0.25;
glRotatef(theta, 3.5f, 5.2f, 4.8f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, 0.5f, 0.2f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.2f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.2f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, 0.2f);
theta+=0.25;
glRotatef(theta, 3.5f, 5.2f, 4.8f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, 0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, 0.7f);
theta+=0.25;
glRotatef(theta, 3.5f, 5.2f, 4.8f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, 0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.7f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, 0.7f);
theta+=0.25;
glRotatef(theta, 3.5f, 5.2f, 4.8f);
0