A Handy Tip

Nibbie
Posts: 1
Joined: 2009.04
Post: #1
I haven't seen anyone else post this,
You can run your rendering in wireframe (more or less) with :

Code:
glDrawElements(GL_LINE_STRIP, m_NumIndicies, GL_UNSIGNED_SHORT, (GLvoid*)((char*)NULL)); //"Wire Frame"

glDrawElements(GL_POINTS, m_NumIndicies, GL_UNSIGNED_SHORT, (GLvoid*)((char*)NULL)); //"POINTS"

I find it very handy, I've seen a lot of gripes about the lack of wireframe in OpenGLES. Interesting to find that glDrawElements is limited to unsigned bytes or shorts for the type. limits your index array to 65535 as the highest value for an index.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Lack of wireframes? How you've described is how one could draw wireframes, so I'm not sure how it lacks it. I was also unaware that people expected a more magical way to draw things as wireframes.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #3
I am doing all my rendering with triangle strips for texturing. So its a bunch of seperate render calls as I have to change the texture between each if needed(well atleast the texture co-ords in my atlas). Just out of curiosity, this is the correct way to be drawing right?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
Skorche Wrote:Lack of wireframes? How you've described is how one could draw wireframes, so I'm not sure how it lacks it. I was also unaware that people expected a more magical way to draw things as wireframes.

He is probably referring to the iPhone not supporting glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

@kendric : If it works, it's correct. I don't use triangle strips for much of anything but sprites myself. For anything more than a few verts, it is better to send it all as one batch per texture if possible, using glDrawArrays or glDrawElements [edit] using GL_TRIANGLES (...derr, you'd be using glDrawArrays or glDrawElements anyway... I'm getting confused switching between Mac and iPhone Rasp )[/edit], but there's no requirement that says you can't/shouldn't use triangle strips. As a side-note: According to PowerVR, strip *ordering* while using [GL_TRIANGLES] should help performance, but I haven't seen any significant performance improvements myself.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #5
If you are doing 2d games its pretty much all sprites though, and you need z order controls so you couldn't do it as a batch right? Since texture 1 might have sprite 1,2,3 behind texture 2's sprites but texture 1's sprites 4,5,6 are in front. If the graphics engine is handling depth testing then I can see where it would work like you describe.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #6
Yes, you can do sprites as a batch. It really can improve performance quite dramatically. All you have to do is transform the vertices yourself and batch them by atlas. Look at the PowerVR recommendations doc which shows an example doing this with butterflies.

[adding] Personally, I don't generally batch sprites myself, since I don't usually have a performance need to do so, which is why I said I will use (four vertex) triangle strips for that. Like I said, if you're drawing objects with more than a few verts, then you'd be better off using triangles in a batch, rather than strips. But again, there is no requirement to go either way.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #7
I still am confused. How can you batch by atlas. There is no reason to expect that atlas 1 images will all be on the same z plane as atlas 2s images. I could see maybe building an array of arrays where the sub arrays are an atlas, and all its vertices that are on the same z, and then the next array has the next group of sprites with the same atlas and a common z. If you just did all of atlas 1 first and then atlas 2 your stacking order would be all messed up.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #8
@AnotherJake Ah. I guess that would be a more magical mode to draw things as wireframe. I had forgotten about that.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #9
kendric Wrote:If you just did all of atlas 1 first and then atlas 2 your stacking order would be all messed up.

Well use a z value for each sprite and turn on depth testing then I guess. Sprites don't always need to be z sorted individually, often times just sorted by grouped drawing order is enough (e.g. dust sprites in the foreground, asteroids in the middle ground, star sprites in the background, etc., where the particular order of sprites in each grouping is meaningless, only the order in which each group is drawn is important).

This is completely off-topic BTW. I hate splitting threads, so I hope you aren't confused anymore ;P If you are, then perhaps you should start a new thread on it.
Quote this message in a reply
Post Reply