Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

glDrawElements only drawing one of two triangles...

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Chris867   Members   

102
Like
0Likes
Like

Posted 29 October 2012 - 02:10 PM

I'm trying to draw an image into a window using OpenGL, but I can't seem to get it to draw both the triangles for the quad. It only draws one of them. I'm using two VBOs and a VAO with glDrawElements to draw. The code for the scene and the GL renderer are in the links below as well as a link to an image of the rendered single triangle.

scene2d.cpp: http://pastebin.com/L5umEBhf
ecglrenderer.cpp: http://pastebin.com/QjheWNXj
image: http://minus.com/mbklHNfIXZvkWr

What's the problem here? How would I go about debugging this issue?

Thanks,
Chris

#2 karwosts   Members   

840
Like
0Likes
Like

Posted 29 October 2012 - 02:56 PM

Can I ask why these vertices are arranged so oddly?

m_verticies[0].x = -1.0f; m_verticies[1].y = 1.0f; m_verticies[1].z = 0.0f;
		m_verticies[0].u = 0.0f; m_verticies[1].v = 0.0f;

		m_verticies[1].x = -1.0f; m_verticies[0].y = -1.0f; m_verticies[0].z = 0.0f;
		m_verticies[1].u = 0.0f; m_verticies[0].v = 1.0f;

		m_verticies[2].x = 1.0f; m_verticies[3].y = -1.0f; m_verticies[3].z = 0.0f;
		m_verticies[2].u = 1.0f; m_verticies[3].v = 1.0f;

		m_verticies[3].x = 1.0f; m_verticies[2].y = 1.0f; m_verticies[2].z = 0.0f;
		m_verticies[3].u = 1.0f; m_verticies[2].v = 0.0f;

Note that if you draw out the triangles (0,1,2) and (3,2,1) it doesn't make a quad, but rather a weird shape that only covers 75% of a quad (the second triangle should be (3,2,0))

Also your two triangles as they are are wound in opposing directions. (0,1,2) is clockwise, and (3,2,1) is counterclockwise. Do you have any face culling enabled?
My Projects:
Portfolio Map for Android - Free Visual Portfolio Tracker
Electron Flux for Android - Free Puzzle/Logic Game

#3 Chris867   Members   

102
Like
0Likes
Like

Posted 29 October 2012 - 03:00 PM

Yes. I have backface culling enabled. If the verticies aren't correct that's probably the reason why one of the triangles isn't showing up. I'll get them set up correctly and try again.

Edit:
The indices order was the problem. Switching it to (2,1,0,2,0,3) makes it work.

Edited by Chris867, 29 October 2012 - 03:04 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.