Archived

This topic is now archived and is closed to further replies.

How to slice lage bitmaps and using them with D3D

This topic is 6071 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

I asked before about using large textures and now I have few quastions more: DO I slice big bitmaps to smaller ones in paint program or should I slice them during loading? What is the best method of using them in D3D? How did you do it? Any comments and code samples would be nice...

Share this post


Link to post
Share on other sites
Hi Pexi,

My Preference, slice''em up before.
Whenever i can, i make sure my textures are a power of two before loading.
I made a little utility that does just that, it loads up a large arbitrary sized bitmap and it saves it in power of 2 slices.

Takes no time at all to program,

pseudo,
Create a TBitmap
Load your large image in the TBitmap
copyrect from large TBitmap to antoher TBitmap(128x128 for example) repeat for all offsets untill the large bitmap is done.
save second TBitmap or create your D3D texture directly from that TBitmap and then save it as a D3D texture.
That''s it.

Create a naming convention so that you know the 1st tile is part of a bigger picture. and adapt your loader accordingly.

With the above, it''s just as easy to create them at runtime.
If you have any questions, don''t hesitate to drop a line.

Let me know how it turns out,

Regards,

Gunner.

Share this post


Link to post
Share on other sites
Hmm, yes I have also created such a util.
However mine is a bit more complex. You can create ''pages'' and put multiple bitmaps on to it, and also name the bitmaps. I also have a DirectX loader class that can set the current texture to the correct page and set the texture transform to just use that little rect on the page. It also allows you to set the format to many different options, as well as setting up mipmaps.
Of course there is a plugin to cut up large bitmaps onto multiple pages. As well as one to create font bitmaps.
Anyway, if you would like it, email me - its part of BCBDXLib, but I still haven''t fixed one more annoying bug in the loader class (DirectX). I can give you the format, too.

------------------------------
BCB DX Library - RAD C++ Game development for BCB

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
C++ freak please mail it to pekka@heikura.com

To continue the topic. How do you use the slices when rendering? Do you use some kind of method which gives you back the correct slice example for that part of e terrain? I thought about loading the big texture and when rendering when some part of texture is needed I copyrect the correct part of the bitmap to texture and use it? It would probably be very slow.

Share this post


Link to post
Share on other sites
Hi Pexi,

Just map those 128 x 128 slices on 128 x 128 quads and tile them to form the bigger picture.

you will not be able to tell the diff.
Also, make sure you build you FVB(Flexible vertex buffer) with already lit polygons, you don''t want your lights to affect the rendering.

I made a demo/Tutorial a while back that shows you how to do all the above in Delphi with D3D 8... check it out at www.sysimage.com

Best regards,

Gunner.

Share this post


Link to post
Share on other sites