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

Started by
1 comment, last by MrSandman666 23 years, 1 month ago
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"
-----------------------------"Mr Sandman bring me a dream"
Advertisement
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 ]
Punika
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"
-----------------------------"Mr Sandman bring me a dream"

This topic is closed to new replies.

Advertisement