Advertisement

TOTWGPG: Bitmaps are still hazy to me

Started by January 29, 2002 09:47 PM
3 comments, last by pizza box 22 years, 7 months ago
I've been reading through TOTWGPG for a while now, and I've been stuck on bitmaps for quite some time. I can get a general understanding of how you load bitmaps first, then blit them onto a surface, but I find LaMothe's implementation to be very confusing. He briefly explains a topic then shows a very complex function to do all the dirty work without much documentation. I referred to the source code on the cd for help, but that was even worse. He adds many of his own functions without any explanation and I find his code very cluttered and confusing. If anyone has the time available, can you please post a brief explanation or example of how you can get a bitmap on the screen? I can load the bitmap, and create a surface for it, but how do I get the loaded bitmap onto that surface? Edited by - Sethius on January 29, 2002 10:48:20 PM
Use D3DX Function, it supports .bmp, .dds, .dib, .jpg, .png, and .tga
the Function is D3DXLoadSurfaceFromFile() check it on the DirectX SDK

I think learning bitmap file format is just a waste of time if your objective is actually just put them into a some memory location and show it on the screen for your game.
Its better to skip such dirty work by using existed code / API and concentrate with the game code / other stuff.
Advertisement
ZeroBit is right. Why do you need to know how does it work inside ? I mean all you need to know is which function loads a bitmap, where it gives you the pointer to data in memory and how to release it (if necessary) when your program quits. And also what is the internal organization of that bitmap in memory (RGB/RGBA, so that you can change its alpha channel if necessary - although you can do it in Paint shop pro manually).
I think that it`s a serious waste of time in the beginning to waste your expensive resources (time/energy) for such a thing.
You`d better learn how it is applied as textures and such a stuff. Later on you can try to learn how it works. But for example, what good is in the beginning to bother with details of how the window is created ? It just messes you up, and in the end, if it works, that`s enough in beginning.
Or maybe you could post directly the code which is confusing for you, so we might be able to help.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

You could also have a look at
http://www.aeon-software.com/resources.html

In the tutorial section is shown how to load a bitmap from a resource, and it is simple to change this to load from a file.

Giant

"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." --Albert Einstein
Andre is an old fashion guy when it comes to coding. There are a number of windows API calls that can load a bitmap into memory with a single function call. The problem is that when you use these functions you have to use the return type that Microsoft has created for these functions (often it''s a HBITMAP).

That''s all fine and dandy if all your ever going to load are bitmaps, but if your designing a "game engine" your usualy going to want to support multiple file formats. And that''s where you run into issues with things like HBITMAP, and LoadBitmap(). How can a TGA file be loaded into a HBITMAP? or a PNG file be loaded into a HBITMAP? So the solution to the problem is to create a file loading utility that is not fixed to put all the data into a HBITMAP.

I believe this is the way Andre was taking his engine. By using his own image loading libraries he wasn''t fixed to continualy use bitmap files especialy if something better had come along.

Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.

This topic is closed to new replies.

Advertisement