PDA

View Full Version : sourcecode for a box (NewB)



Striker47
05-19-2001, 02:42 AM
I have a little sourcecode to create a box:

void Box(GLfloat scale) {
glBegin(GL_QUADS);

glVertex3f (-scale, scale,-scale);
glVertex3f ( scale, scale,-scale);
glVertex3f ( scale,-scale,-scale);
glVertex3f (-scale,-scale,-scale);

glVertex3f (-scale, scale, scale);
glVertex3f ( scale, scale, scale);
glVertex3f ( scale,-scale, scale);
glVertex3f (-scale,-scale, scale);

glVertex3f (-scale, scale,-scale);
glVertex3f (-scale, scale, scale);
glVertex3f (-scale,-scale, scale);
glVertex3f (-scale,-scale,-scale);

glVertex3f ( scale, scale,-scale);
glVertex3f ( scale, scale, scale);
glVertex3f ( scale,-scale, scale);
glVertex3f ( scale,-scale,-scale);

glVertex3f (-scale,-scale,-scale);
glVertex3f (-scale,-scale, scale);
glVertex3f ( scale,-scale, scale);
glVertex3f ( scale,-scale,-scale);

glVertex3f (-scale, scale,-scale);
glVertex3f (-scale, scale, scale);
glVertex3f ( scale, scale, scale);
glVertex3f ( scale, scale,-scale);
glEnd();
}

but when i want to start it with
putPurple(0.4);
my Programm crashes, can someone help me?

T2k
05-19-2001, 03:25 AM
try to draw a single triangle, quad, maybe you havent initialized opengl correctly ( wrong defined vertices etc. only produce opengl intern errors )

j
05-19-2001, 09:10 AM
What does putPurple(0.4) do? And why do I feel as if this is a joke?

j

Striker47
05-20-2001, 12:46 AM
sorry, I wrote purpleBox. Because first i wanted to create more colors, and it was an other procedure. (is it the correct english word???)

It must be box(0.4).
I have initialized opengl correctly, becase i can render other thing without any problems.

(sorry for my bad English)

T2k
05-20-2001, 06:58 AM
it seems that the code is ok, so search for other errorsurces, maybe you call this function after a glBegin(...), remove glBegin(..) and glEnd() in this function, if it works you have called glBegin before this functioncall and this causes the crash, or you call this function from a thread, which isn't the one with the renderingcontext ...