Jump to content
  • Advertisement
  • entries
  • comments
  • views

Texture organising

Sign in to follow this  


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;


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

CLoadResult R=lrOk;
int Ran=rand()%3;
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  


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!