• 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.

graeme

i'm sorry... another blitting post

6 posts in this topic

I feel a bit bit posting so many questions in the last 48hrs, but honestly I have been running into brick wall after brick wall, and searching online archives is proving to be only partially helpful. This is the deal, I am trying to create a bitmap with the display image in it, and then blit this into a moving window with no borders, and then blit an animated figure into that. I have the animation sorted out, it''s just the display that is not working at all. I''m not getting compiler errors, just no visible results. I have two functions, one that is called at the initialisation of the program, grabDisplay, which is supposed to fill bmDisplay, a global variable. Then, at the beginning of a function rePaint, before the animated bitmaps are displayed I want to blit the relevant portion of the bmDisplay onto my window. Eventually I want to update the bmDisplay bitmap, but for now just success with the original static one would be good enough. this is the grabDisplay function: BOOL grabDisplay (){ HDC hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); //get hdc for the display HDC hdcDisplay= CreateCompatibleDC(hdcScreen); //dwScreenDC = GetDC(NULL); hbmDisplay = CreateCompatibleBitmap(hdcScreen, screenX, screenY); HDC hdcDst = CreateCompatibleDC(NULL); SelectObject(hdcDisplay, hbmDisplay); if (!BitBlt(hdcDisplay, 0,0, screenX, screenY, hdcScreen, 0, 0, SRCCOPY)) PostQuitMessage(0); DeleteObject(hdcDisplay); DeleteObject(hdcScreen); return TRUE; } and the beginning of the painting function: void rePaint(HWND hwnd){ // ShowWindow(hwnd,SW_HIDE); HDC hdc; hdc = GetDC(hwnd); //Copy from the Display Bitmap prepeared during grabDisplay HDC hdcDisplay = CreateCompatibleDC(NULL); HBITMAP hbmT2 = SelectBitmap(hdcDisplay,hbmDisplay); if (!BitBlt(hdc, 0,0, WINDOW_WIDTH, WINDOW_HEIGHT, hdcDisplay, myX, myY, SRCCOPY)) PostQuitMessage(0); SelectBitmap(hdcDisplay,hbmDisplay); DeleteDC(hdcDisplay); ... and so on My confusion is over the SelectBitmap command, I assume that this then binds the bitmap to the hdc associated with it in this operation so that, in the next line, where the blitting to that hdc the bitmap is changed? Or am I wrong? Very confused because this format appeared to work in earlier attempts at this. Again, sorry for a question which may seem like I''m not taking the time to work this out on my own, but believe me I am (I have only been learning c++ for a couple of weeks now) thanks, graeme
0

Share this post


Link to post
Share on other sites
OK, it''s been a few days since I made the original post, and I have read up on the topic and I made some changes to the code but it still doesn''t work!!

I am trying to copy the screen at the beginning of the program.

The window moves across the desktop and each frame i am trying to copy the windows area from the desktop bitmap that I made at the beginning, and blit it into the window. I then blit a frame from an animation into the window.

The background is not being blitted correctly, the animation is copying over itself without the old picture being erased by the process of blitting in from the bitmap which holds the display.

This is the function which is called once at the beginning of the program to initialise the display bitmap: (hbmDisplay, a global variable)

HDC hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); //get hdc for the display
HDC hdcMem= CreateCompatibleDC(hdcScreen);


SelectBitmap(hdcMem, hbmDisplay);

if (!BitBlt(hdcMem,
0,0,
screenX, screenY,
hdcScreen,
0,
0,
SRCCOPY))
PostQuitMessage(0);

DeleteObject(hdcScreen);
DeleteObject(hdcMem);

return TRUE; etc

............................

this is the code which is executed every frame, it copies from the bitmap stored in hbmDisplay:


void rePaint(HWND hwnd){

HDC hdc;


//Copy from the Display Bitmap prepeared during grabDisplay
hdc = GetDC(hwnd);

HDC hdcDisplay = CreateCompatibleDC(NULL);

HBITMAP hbmT2 = SelectBitmap(hdcDisplay,hbmDisplay);
if (!BitBlt(hdc,
0,0,
WINDOW_WIDTH, WINDOW_HEIGHT,
hdcDisplay,
myX,
myY,
SRCCOPY))
PostQuitMessage(0);


DeleteDC(hdcDisplay);
DeleteObject(hbmT2);///???


Can any of you good people please tell me what you think may be wrong?

I cannot wait to wake up in the morning and see all your helpful posts!!! It feels like the eve of my birthday!! This problem has made my life miserable for the last 3 days!









0

Share this post


Link to post
Share on other sites
Hey Graeme, wassup?

I took a quick glance over your code, but didn''t examine it as thouroughly as I should have - I''m about three winks from nodding off. It looks like you''re not grabbing the desktop properly. I think your question came up a few months back in one of the microsoft newsgroups pertaining to gdi. A google news search might be warranted. A good reference site for gdi is www.fengyuan.com. His GDIObj.exe is a must if your running W2K or XP. In the meantime, here''s the function that I use to capture the desktop to a bitmap.

Cheers,

  
// ----------------------------------------------------------------------------

// Function captures current desktop storing the image in the bitmap parameter

//

BOOL __stdcall CaptureDesktop(HBITMAP *hBmpScr)
{

*hBmpScr = NULL;

HWND hwndDeskTop = GetDesktopWindow();

UpdateWindow(hwndDeskTop);

Sleep(500); // give the desktop time to repaint itself


HDC hdc = GetWindowDC(hwndDeskTop);

int iWidth = GetDeviceCaps(hdc, HORZRES);
int iHeight = GetDeviceCaps(hdc, VERTRES);

HDC memdc = CreateCompatibleDC(hdc);

*hBmpScr = CreateCompatibleBitmap(hdc, iWidth, iHeight);

HBITMAP hBmpPre = (HBITMAP)SelectObject(memdc, *hBmpScr);

BitBlt(memdc, 0, 0, iWidth, iHeight, hdc, 0, 0, SRCCOPY);

*hBmpScr = (HBITMAP)SelectObject(memdc, hBmpPre); // ??


DeleteDC(memdc);

DeleteObject(hBmpPre);

ReleaseDC(hwndDeskTop, hdc);

return ( *hBmpScr != NULL );

}


‘But truth's a menace, science a public danger.’ Brave New World, Aldous Huxley
0

Share this post


Link to post
Share on other sites
PS. This might be helpful too.

http://www.john.findlay1.btinternet.co.uk/gengfx/dog.zip



‘But truth's a menace, science a public danger.’ Brave New World, Aldous Huxley
0

Share this post


Link to post
Share on other sites
That stuff is really helpful, thanks alot for that. I am trying to dissect the dog cpp, and a vague conception of czech is coming in handy here (I know Russian and it''s pretty similar,) in order to stop the flickering (I think I need to do a few searches on double-buffering, no?)
ArunVB replied in an earlier post of mine, suggesting I use ''REGION or CRgn (MFC Class) to create transparent regions.''
I have downloaded some source code, and one exe does this to great effect but it only uses one bitmap and I think to transfer this to multi bitmapped animation would be way beyond me.
Thanks again!
0

Share this post


Link to post
Share on other sites
Sorry, I didn''t realize the notes to the dog program were written in czech! But I thought it was pretty cool how the dog ran outside of the window and that sounded sort of like what you were wanting to do.

‘But truth's a menace, science a public danger.’ Brave New World, Aldous Huxley
0

Share this post


Link to post
Share on other sites