Texture organising

Published August 12, 2006
Advertisement
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.
Previous Entry BGRA format
Next Entry Pixel Comic
0 likes 2 comments

Comments

Mushu
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.
August 12, 2006 09:34 AM
Aardvajk
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.
August 12, 2006 01:45 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement