PDA

View Full Version : Problem drawing a cube



craterz
01-04-2012, 03:45 PM
I am trying to import a cube in the direct x format exported from blender. i wrote the importer and stored all of the vertex coordinates. i have checked to make sure the coordinates are correct after storing them and they are. Everything seems to line up, but when I render them, they look like this:

http://i39.photobucket.com/albums/e172/Craterz/problem-1.png













From the looks of it, the first triangle(in the back) is rendered correctly, but the next one is scaled, and possibly translated (the translation could be due to scaling), and the next one is scaled a little more and translated a little more, and so on and so forth. Any idea what could be causing this? I included my draw function in the image.

Thanks in advance :)

Edit: forum scaled the image and made text unreadable. Here is a link to it http://s39.photobucket.com/albums/e172/Craterz/?action=view&current=problem-1.png

carsten neumann
01-04-2012, 04:10 PM
Please post code snippets in the forum, surrounded with [ code]/[ /code] (no space after '['), to avoid any readability issues, thanks.

Your loop over the triangles starts with a glTranslate() call, those accumulate in the modelview matrix, you probably want to do this outside the loop.

craterz
01-04-2012, 06:41 PM
thanks, that did the trick. sorry about the formatting issue, i will use the proper formatting next time.