Archived

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

Reading OpenGL texture data from a resource bitmap...?

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

Well, hi again. Uhhhmmm... does anybody here know how I can get the data that I need to create an OpenGL texture object from a bitmap that I compiled into the executable via a resource file? I''m using MSVC++ for that. You know what I''m talking ''bout? You can include bitmaps like you can include dialog box templates or menus or accelerator tables. Now how do I access this bitmap ressource and strip the neccesarry information from it? Stuff like heigt, width and raw pixel data and how do I build a texture object from it. Till now I always used auxDIBImageLoad(FileName) but that requires an external file. Would be great if someone could help me. And please as quickly as possible. The deadline is approaching! Thanx in advance... ----------------------------- "Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
Hi MrSandman,
I think you must use use LockResource for it. Look at the MSDN for more information.

pseudo code:
void *pResTexture= LockResource(LoadResource(NULL, FindResource(NULL, MAKEINTRESOURCE(uID), "BMP")));
unsigned char *pTexture = ((HEADER)pResTexture)->Data;

my answer isn`t very good but i hope it helps



Punika

[ Power Productions ]

Share this post


Link to post
Share on other sites
Well, this is the way I''m doing it now:
  
void PSmanager::LoadTexture(char *FileName)
{

HBITMAP hbitmap;
BITMAP bmp;

hbitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_PARTICLE));

LockResource(hbitmap);

GetObject(hbitmap, sizeof(BITMAP), &bmp);

// create the texture

glGenTextures(1, &Image);

// select the texture object

glBindTexture(GL_TEXTURE_2D, Image);

// Generate The Texture

glTexImage2D(GL_TEXTURE_2D, 0, 3, bmp.bmWidth, bmp.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bmp.bmBits);

// enable linear filtering for this texture

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

}


The program "works" (meaning it doesn''t crash and displays something on the screen) but the textures are extremely distorted.
Anbody know a solution for this?

Thx in advance


-----------------------------
"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites