Engine Material/Image Management System

Started by
4 comments, last by MeshMan 20 years, 2 months ago
Hi all, Ok, heres the problem. Im coding a game engine that supports both DX and GL in rendering DLL''s. OpenGL needs to store an image ID from the glGenTextures() function, im not sure what special things DX need. Well so far, i have an meImage class and an meMaterial class. Do i do the following: meRenderer::CreateMaterial(meMaterial *pMat) { pMat->SetID(glGenTextures(pMat->GetImage())); } So that im now storing an OpenGL specific ID in the material object. Or do the following: meRenderer::CreateImage(meImage *pImg) { pImg->SetID(glGenTextures(pImg)); } Anyone any ideas? I havnt reveiwed how i would work this stuff wth DX yet either. I know its kinda vague, but its kinda confused over the situation.
Advertisement
The hack that I''m using to solve this problem is something like:

#ifdef DIRECTX    typedef LPDIRECT3DTEXTURE9 TEXTURE_OBJECT_TYPE#else    typedef unsigned int TEXTURE_OBJECT TYPE#endif...struct MyTextureObject {    TEXTURE_OBJECT_TYPE tex;    ...} 


This uses the same-sized structure element to store the same information. Since it''s the same structure it doesn''t matter which version you''re referring to in other parts of the game.

Tom
"E-mail is for geeks and pedophiles." -Cruel Intentions
Ive no idea what you mean and if i mean what i think you mean, thats not going to help when the implementations of the renderers are stored in seperate DLL''s and loaded at runtime.
Make material and image base classes, which the OpenGL and Direct3D images/materials can derive from, and have the renderer create the image/material.
Yeah, cheers.

Im just working on that now. Should be done in about an hour. I have a lot of renaming to do, and like you mentioned, the abstract classes for the textures (images) and materials.
Hmmm, ran into a problem again.

This is some idea how my entire texture loading system works:

meTexture *pTexture = meEngine::GetTexureManager()->GetTexture("grass.tga");

The GetTexture() function searchs its list of loaded images, if not found, it does the following:

meTexture *pTexture = meEngine::GetTextureLoaderManager()->LoadTexture("grass.tga");

Which inside the LoadTexture() function it does:

meTexture *pTexture = new meTexture();
pTexure->Create(imgData, width, height, MEPF_RGBA);

But as you can, the pTexture->Create() functions just creates memory for the pixel data and returns the data pointer so you can fill it with the loaded image data. At what points do i THEN do a meRenderer::CreateTexture() call and what params would i pass?

Thanks.

This topic is closed to new replies.

Advertisement