Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Bitmaps vs. Images vs. Roll your own

Author
Message
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Feb 2008 22:33
Please excuse what must sound like a newbie question (mainly because I'm a Dark GDK newbie.) After starting out a preliminary program in both SDL and SFML I stumbled on Dark GDK and have begun again.

After going through the docs and the tutorials I'm a bit confused about bitmaps, images, creating one's own bitmap and displaying the bitmap. I began with the project produced by the wizard for 2D and the "demo" built into it compiles and runs fine, with the asteroids tumbling as expected. Eventually my intent is to draw a background for each level with a grassy area and a roadway. To this end I removed the loading of the image and instead created my own bitmap as a test. Thsi resulted in nothing displaying. I assumed that I treat a bitmap the same as an image and just assign a sprite to it. This may be where I'm going wrong, but everything I've seen in the tutorials show sprites being applied to images that have been loaded. The docs talk about loading bitmaps vs. loading images so I have to assume that they're treated differently.

So, after all that, could someone explain the use of bitmaps and how they're displayed?

Thanks,
Lilith

Lilith, Night Butterfly
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 12th Feb 2008 23:07
What should be made a bit more clear in the docs perhaps is what it actually means when it says bitmap and image. The bitmap functions store the image data internally in a bitmap format and work only with bitmaps. The image functions will LOAD bitmaps still if that is the image format you want to work with!

Generally, the bitmap commands are for very specific cases where you wish to do special things (image editing and fades example) and you wouldnt use them for sprites and things. You might use them for backgrounds but for simple, static (unchanging) backgrounds I would just load your background image using dbLoadImage() and then use dbPasteImage() to draw it to the screen.

the sprite commands themselfs ONLY work with images loaded using dbLoadImage, they do not work with images loaded using dbLoadBitmap.

Hope this helps clear things up a bit Just remember, the word "bitmap" in the function name reffers more to how its internally handled and you can (and SHOULD) use dbLoadImage() to load bitmap file types too!

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Feb 2008 23:37
Quote: "Generally, the bitmap commands are for very specific cases where you wish to do special things (image editing and fades example) and you wouldnt use them for sprites and things. You might use them for backgrounds but for simple, static (unchanging) backgrounds I would just load your background image using dbLoadImage() and then use dbPasteImage() to draw it to the screen."


That clears things up a bit. As it stands I do want to modify the bitmap. The intitial program is to provide me a means of laying out my roadways graphically rather than trying to generate the internal representation of my maps by hand. Once the layout is set I'll write it out to file for retrieval. Since each level will have a different layout this, hopefully, will help me avoid hand editing mistakes and maybe provide a means of letting players design their own levels.

When it comes to the game itself the roadways will be drawn based on that internal representation, which will also be used to determine vehicle movement. I'll be starting out with a dbCreateBitmap call and then drawing the ground and roadways on top of that.

That said, I'm still not clear on how one tells the bitmap to display.

Lilith, Night Butterfly
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 13th Feb 2008 00:43
Right, well you can edit the bitmaps using the DGDK functions by setting the bitmap you want to draw to with dbSetCurrentBitmap() and then using the functions in Basic2D (dbInk, dbDot, etc) and then you can draw your edited bitmap using dbCopyBitmap().

Bitmap 0 is ALWAYS the screen so just copy from your custom bitmap to bitmap id 0 and it should display. Use the second prototype and you can even stretch your edited bitmap using different rectangles for the copy and the paste

If you're messing about with editing of stuff to paste to screen though I feel I should just point you at some functions I wrote myself to allow the editing of image data. When used properly these functions are faster to execute than things like dbDot (because the dbDot function locks the destination pixels for each draw whereas my functions allow you to batch alot of drawing for one lock) and I belive I pasted the code in this thread:

http://forum.thegamecreators.com/?m=forum_view&t=122165&b=22

For now though it might be best you use the default dgdk functions and ease yourself in more gently

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 13th Feb 2008 01:27
Once again, thanks. That is quite a handful of code. I figured on using the pointer to the pixels for my drawing. Speed isn't an issue for my purposes but I do deplore wasted time.

Lilith, Night Butterfly

Login to post a reply

Server time is: 2024-11-20 01:46:54
Your offset time is: 2024-11-20 01:46:54