moving to directx advice please

Started by
31 comments, last by tok_junior 19 years, 1 month ago
Do NOT listen to them, do NOT use *UP-calls.
The way to do it is to create one vertexbuffer that is large enough to contain all your quads. Then, when it's time to draw, you stick the vertices with their texturepointer into a vector or linked list. When you're done drawing, sort the list according to texture, copy the vertexdata into the vertexbuffer, and render it using one DrawPrimitive() for each texture.
Think it through a time or two, and it'll make sense ;)

Oh, and to texture the quads differently using one buffer, you can set a starting-vertex and the number of triangles to draw in the call to DrawPrimitive(), so just issue one DrawPrimitive()-call for each texture, setting the starting vertex and nr of primitives correctly.
I'm extremely tired, tell me if this doesn't make any sense, and i'll get back to you when i've slept ;)
Advertisement
so what i think your saying is....

render all like textured quads in the same pass..then switch textures.

so ill need to make sure to render my sprites after im done rendering all over the map...i guess drawing left to right and top to bottom doesnt matter any more.

uh this is confusing...

it was just so much easier when i had everything seperated...each tile had its own vertex buffer and knew how to render itself...

Does anyone have a bit of code i could look at...None of the tutorials do what im needing to do..which i find curious...i know im not the only one here...

ill continue reading..maybe there is something i missed.

it just seems like ill get into these huge nested for loops to do this.

again thanks for the help!
You could skip over to flipcode, there's a linked article on implementing a "vertexcache" there, which lets you draw one tile at a time, but not actually work with any buffers or real drawing until you're done.
I don't really like the design of that vcache, but it's pretty easy to extend it to texturesorting aswell.

Or you could just do it using a loop, and iterate the current portion of the map X nr of times, where X is the number of different textures you have. Then you only draw the tiles that uses the current texture.
The overhead of the loop is so small it shouldn't really make a difference.

This topic is closed to new replies.

Advertisement