Sign in to follow this  

2D drawing in 3D - Batching drawing with untransformed coords w/ index buffer (C#)

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, A while back I followed a tutorial on 2D in Direct3D ( http://www.gamedev.net/reference/articles/article1972.asp ) Now, I got the basic method in this working just fine. The problem is I'm drawing something like 128 * 96 8x8 Quads every single frame (while in 1x zoom mode). My current method is horribly inefficient and just goes through, transforms for the current tile and then draws it (just the one tile by itself). Obviously this is slow as hell on anything but a freaking supercomputer. That same tutorial has a method of batching using a large vertex and index buffer but it only shows how to do it using transformed vertices. I'm not sure how I'd do the same with untransformed as I'm assuming doing the actual transformation to the world that I am currently doing will only apply at the time of drawing. So how would you draw a ton of same sized, side by side quads in a quick and efficient manner? Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by Martaver
How come you're using user primitives? Is there any particular reason you can't using hardware transforms?


It's almost like you're speaking a foreign language. Could you elaborate good sir?

Share this post


Link to post
Share on other sites
Use DrawIndexedPrimitives instead of DrawUserPrimitives.
Allocate a vertexBuffer which is not type of Transformed...
Allocate an indexBuffer. Write your scene vertices and indices
once into the created buffers.
Set vertexbuffer and indexbuffer in the device.

Share this post


Link to post
Share on other sites
Are the quads all changing every frame? If not, if its like a 128x96 (x8x8)map of tiled grass or something, why not render the tiles to larger quad(s) and use them as a starting point to render the units (or whatever) on top?
lets do some quick calculations:

128 * 8 = 1024
96 * 8 = 768

You can just create yourself a 1024x1024 texture at load time, render all your quads once to this texture, then use it as a starting point every frame (scaling it down vertically of course).
You could further optimize it by analyzing tiling boundaries. For instance if one quarter of this giant map is tiled (proly yes because 8x8 all tile) then you can store a 512x512 starting texture and render it 4 times, and this will probably be faster as most cards like smaller textures.

Share this post


Link to post
Share on other sites

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this