Jump to content
  • Advertisement

Archived

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

MrSandman666

Bitmaps from resource scripts?

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

I use OpenGL to display some bitmaps and the OpenGL part works fine as long as I load the bitmaps the conventional way: from a *.bmp file. If I include the same bitmaps in a resource script and try to load them then the bitmap dimensions are correct but the bitmap data is empty. This is the code I use:
  
BITMAP bm;
	GetObject(LoadBitmap(hInst, MAKEINTRESOURCE(FLARE)), sizeof( bm ), &bm);

	glGenTextures(1, &Image);
			
	// select the texture object

	glBindTexture(GL_TEXTURE_2D, Image);

	// Generate The Texture 

	glTexImage2D(GL_TEXTURE_2D, 0, 3, bm.bmWidth, bm.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bm.bmBits);
  
As I said, the size is read correctly but bm.bmBits is just empty. Any ideas? "Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
Advertisement
Instead of using LoadBitmap, try using LoadImage. That solved the problem I had the last time I ran into troubles with bitmaps.

HBITMAP hBM = LoadImage(hInst, MAKEINTRESOURCE(IDB_BM), IMAGE_BITMAP, 0,0, LR_DEFAULTSIZE);



==========================================
In a team, you either lead, follow or GET OUT OF THE WAY.

Share this post


Link to post
Share on other sites
I''m afraid that didn''t change a thing. Still the same problem: dimensions are correct but there is no data in bm.bmBits

"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What do you mean: Check hInst? I take directly from where it''s passed to WinMain:
  
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
hInst = hInstance;


how can THAT not be invalid? And anyways, how do I check whether it''s valid?


"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
What do you mean: Check hInst? I take directly from where it''s passed to WinMain:
  
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
hInst = hInstance;


how can THAT not be invalid? And anyways, how do I check whether it''s valid?


"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
I can''t remember precisely, but I think you have to ask for a DIBSECTION, not a BITMAP to get the bmBits member filled, and also the bitmap should be a DIB, you can specify this when you load it (LR_CREATEDIBSECTION).

Share this post


Link to post
Share on other sites
Well, no I have some Data, thanx TwoFlower. The only problem is is that the data is completely screwed up. The images are just some scrambled random trash that doesn''t lool like the image in the resource editor at all. Any ideas?

"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites
That''s probably because a DIB is a device independent bitmap (probably stored as 24bit). You will need to convert it to the same format as the display.
I know next to nothing about OpenGL so I don''t know if this is true or not.

Share this post


Link to post
Share on other sites
Hmmm, I followed your hint about the colors and I discovered something interesting:
It works when I leave the image at 16 bit but as the images are only black and white I usualy convert them to greyscale. But as soon as I get the color depth lower than 16 bits, everything gets screwed. This was not the case when I loaded the bitmaps directly from the *.bmp file. Does anybody know a way to work auround that? I have no idea what to do here.

"Mr Sandman bring me a dream"

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!