• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

AcidJazz

I need help with bitmaps & directdraw

5 posts in this topic

Well, the HDC and HBITMAP are just part of a way of using Windows GDI functions to help you load a bitmap from a file. Once you load the bitmap in, you can copy it to a DirectDraw surface and be done with the HDC and HBITMAP - you don't need to keep them around.

- Splat

0

Share this post


Link to post
Share on other sites
okay, how do you use hdc and hbitmap? I mean like how do you load them into memory then load them into a surface. My directx book doesn't cover hdc and hbitmap so grrr
0

Share this post


Link to post
Share on other sites
A couple things: First off, does your book even cover loading bitmaps? It should - if it doesn't its not very good.

Second, if you have the DirectX SDK installed, a sample file I believe called "ddutil.cpp" (never used it) contains a function DDReLoadBitmap() which handles taking a bitmap file and dumping the information correctly into a DirectDraw surface. You could either use that function or read it and learn how to do it yourself.

- Splat

0

Share this post


Link to post
Share on other sites
Ok, so you have DirectDraw set up and you want to load a bitmap and display it on the screen, right? It's really easy, there's only a couple of steps you need to follow:
1. Create a surface for the bitmap.
2. Load the bitmap into the surface.
3. Blit the bitmap onto the back buffer.
4. Flip the back buffer to the primary surface. (you can do this, right?)

1. and 2.
Luckily, Microsoft made a function that creates an offscreen surface and loads a bitmap into it: DDLoadBitmap(). To use this, though, you need to get the files "ddutil.cpp" and "ddutil.h" from the DirectDraw SDK. If you don't have them and want em, I can send them to you.
Now, after you've included the ddutil.h file, call DDLoadBitmap() like this:

LPDIRECTDRAWSURFACE4 lpDDSBitmap = NULL;

if ( ( lpDDSBitmap = DDLoadBitmap( lpDD, "bitmap.bmp", 0, 0) ) == NULL )
return FALSE;

Now the bitmap is loaded into lpDDSBitmap!

3.
To blit the bitmap onto the back buffer, call BltFast():

RECT rcFrom;
rcFrom.left = 0;
rcFrom.top = 0;
rcFrom.right = BITMAP_WIDTH;
rcFrom.bottom = BITMAP_HEIGHT;

if ( FAILED( lpDDSBack->BltFast( 0, 0, lpDDSBitmap, &rcFrom, DDBLTFAST_WAIT ) ) )
return FALSE;

What the DDLoadBitmap() function does is creates a HBITMAP and a DirectDraw sufrace, uses a Windows function (LoadImage()) to load the bitmap from a resource or a file into the HBITMAP, then blits the bitmap from the HBITMAP to the DirectDraw Surface using another Windows function (StretchBlt()).

If you need any more help, send me and email or post to this thread.

I would suggest that you look over the function really well before you use it so you know what it's doing...

------------------
- mallen22@concentric.net
- http://members.tripod.com/mxf_entertainment/

[This message has been edited by Matthew Allen (edited November 04, 1999).]

0

Share this post


Link to post
Share on other sites
Really you don't have to know or care about HBITMAPS or nearly any GDI object.

As another poster said, if you want to load bmp files, there is a function which does it for you, so you can just live in ignorant bliss =)

You can think of a DC ( a device context) as just that, the state of a particular device, like the screen you are reading this off of, or a printer.

A HBITMAP is basically a handle to a bitmap, be it a blank memory buffer, or if you get it from a DC, a copy of that contexts "output" or display.

0

Share this post


Link to post
Share on other sites
Okay, I understand how to initialize directdraw, and all the surfaces and flipping, but i don't really understand the whole bitmap part. I got some code from a guy and he created two HDCs and a HBITMAP and adsljkf grrr i just dont get it. Can someone explain HDC and HBITMAP and everything else there is in a process of displaying bitmaps to a surface. Do you need a HDC for every bitmap you display on the screen? grrr plz help hehe

Thanks, AcidJazz

P.S. If you wouldn't mind helping me a little one on one, just add me to your icq list, my uin is 16357086. If you have aim, my sn is AcidJazz13 Thanks again

0

Share this post


Link to post
Share on other sites