Jump to content
  • entries
    743
  • comments
    1924
  • views
    583669

Texture organising

Sign in to follow this  
Aardvajk

440 views

The texture mapper seems to be working okay. I'm creating a temporary instance of my TextureMap class in the engine init function, creating a 256x256 texture then repeatedly throwing three images (32x32, 16x16 and 7x6) at the texture in random order with the map set to a granuality of 8x8, then dumping the finished texture out as in BGR format and it looks like this:


bool CEngine::OnAcquire(HWND Hw)
{
if(!Dev.Acquire(Hw,1024,768)) return false;
if(!Ver.Acquire(100)) return false;

if(!Tex.Acquire(256,256)) return false;

Tex.Fill(CRect(0,0,256,256),CColor(255,0,255));

CTextureMap Map; Map.Acquire(256,256,8,8);

CLoadResult R=lrOk;
while(R!=lrNoSpace)
{
int Ran=rand()%3;
switch(Ran)
{
case 0: R=LoadBGR("C:\\tex1.bgr",Map); break;
case 1: R=LoadBGR("C:\\tex2.bgr",Map); break;
case 2: R=LoadBGR("C:\\tex3.bgr",Map); break;
}

if(R==lrFileFailed) return false;
}

if(!Tex.SaveBGR("C:\\texture.bgr")) return false;

return true;
}







The texture is filled with pink before the images are loaded for the purposes of confirming this all works okay. The 7x6 images create a small wastage since the smallest cell size is 8x8, but the texture mapper can be configured to any cell size so this wastage could be reduced if needed, at the expense of a larger array and longer search times.

I've just implemented it as a bool array for now since it is a temporary object that is destroyed once the initialisation is finished. I can see an argument for implementing it with a bit for each cell, but I'm not going to bother about that at the moment.

The next step is to write some kind of function that will open and load my multiple image .spr files and figure out a nice tidy way of returning and storing the tu and tv co-ordinates for each image.

But, good progress anyway.
Sign in to follow this  


2 Comments


Recommended Comments

Whoa! How long are the search times for that using an 8x8 granuality?

And actually, you just reminded me that its probably prudent to test NxM textures instead of just NxN's in such a system. Hrrh.

Share this comment


Link to comment
No noticeable time taken really. Hard to say exactly since it is done at start-up but not more than a second or so tops. Could be a bit longer with a larger texture I guess but it's not like it has to be done more than once and if it started taking ages, its a good excuse to have a loading screen and a progress bar [smile].

Not quite sure what you mean by NxM and NxN. Do you mean testing for non-square images? I wanted a system I could basically throw almost anything at with a minimum of wastage.

Share this comment


Link to comment

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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!