Archived

This topic is now archived and is closed to further replies.

Kiroke

Drawing rectangles in a for()

Recommended Posts

Hi I''m making a program with that function void DrawBlocks(BLOCK *blocks) { glColor3f(0.0, 1.0, 0.0); for(int i = 0 ; i < nbBlocks - 5; i++) { glPushMatrix(); glTranslatef(blocks.x,blocks[i].y, 0.0); glVertex3f(-3.0, -0.5, 0.0); glVertex3f(-3.0, 0.5, 0.0); glVertex3f(3.0, 0.5, 0.0); glVertex3f(3.0, -0.5, 0.0); glPopMatrix(); } } unfortunately i get a fatal error on the entire program and when i use the microsoft visual C++ debugger i get the crash in that function when it loop for the 18th time. Anyone knows if that thing has somthing to do with the matrix stack? Thx alot Kiroke

Share this post


Link to post
Share on other sites
once you use blocks as a single variable then as an array. accoring to your function def it should be treated like an array, therefore you have to use blocks.x

@$3.1415rin

Share this post


Link to post
Share on other sites