Jump to content
  • Advertisement

Archived

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

MeshMan

Engine Material/Image Management System

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

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Make material and image base classes, which the OpenGL and Direct3D images/materials can derive from, and have the renderer create the image/material.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • 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!