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

Strabbi

DX7 Surface Ends up with garbage in it

6 posts in this topic

haven't used colorkeys at all....but i'm well into a DirectX 6 project, using clippers and standard DirectDraw stuff a lot...so if you'd post the basic way your setting up your surface, your DirectDraw device, and then the Blt setup and call...i'd love to help ya find your problem.
0

Share this post


Link to post
Share on other sites
Ok, Setting up offscreen surface:

HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
HRESULT err;

hbm = (HBITMAP)LoadImage(
NULL, filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);

if (hbm == NULL)
return NULL;

//
// Get the size of the bitmap.
//
GetObject(hbm, sizeof(bm), &bm);

//
// Now, return to DirectX function calls.
// Create a DirectDrawSurface for this bitmap.
//
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;

err = g->pDD->CreateSurface(&ddsd, &pdds, NULL);
if (FAILED(err))
{
g->TraceErrorDD(err);
TRACE(tracef," Creating surface\n");
return NULL;
}

err = g->DDCopyBitmap(pdds, hbm, 0, 0);
if(FAILED(err))
{
g->TraceErrorDD(err);
TRACE(tracef," On DDCopyBitmap\n");
return NULL;
}

DeleteObject(hbm);

return pdds;

Setting up DirectDraw Device:

// Set the "cooperative level" so we can use full-screen mode
hr = pDD->SetCooperativeLevel(ddWnd,
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); // | DDSCL_NOWINDOWCHANGES
if (FAILED(hr)) {
TRACE(tracef,"Error setting Exclusive,Fullscreen mode\n");
pDD->Release();
return FALSE;
}
// Set 640x480x256 full-screen mode
hr = pDD->SetDisplayMode(640, 480, 8);
if (FAILED(hr)) {
TRACE(tracef,"Error setting display mode: %d\n", int(LOWORD(hr)));
pDD->Release();
return FALSE;
}

oh, and:

DDSURFACEDESC ddsd; // A structure to describe the surface we want
DDSCAPS ddscaps; // ??
HRESULT hr; // Holds return values for function calls
DDCOLORKEY ck;

memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;

hr = pDD->CreateSurface(&ddsd, &pDDSPrimary, NULL);
if (FAILED(hr))
{
TRACE(tracef,"Error: pDD->CreateSurface (primary)\n");
TraceErrorDD(hr);
pDD->Release();
pDD = NULL;
return 1;
}

ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
hr = pDDSPrimary->GetAttachedSurface(&ddscaps, &pDDSBack);

if (FAILED(hr)) {
TRACE(tracef,"Error: CreateSurface (back)\n");
TraceErrorDD(hr);
return 2;
}

ck.dwColorSpaceLowValue = RGB(0,0,0);
ck.dwColorSpaceHighValue = RGB(0,0,0);
pDDSPrimary->SetColorKey(DDCKEY_SRCBLT,&ck);

// success
return 0;

Ok, and the Blt setup and call:
NOTE: Check Surfaces Restores all lost surfaces.
menutl is the surface returned by the first call.

// RECT src;
HRESULT err;

CheckSurfaces();

// SetRect(&src,0,0,15,31);

err = g->pDDSBack->BltFast(100,50,menutl,NULL,
DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
if(FAILED(err))
{
g->TraceErrorDD(err);
TRACE(tracef," Blitting menutl\n");
}

NOTE: No Errors show up in my TRACE log file (and I know the TRACE works, because my comments show up.)

Also: Everything else works but the blt from the other surface (any of them). IE: I can draw text on screen, and fill the background to any color I want.

Wow is that ever a long post. Thanks in advance for all your help.

0

Share this post


Link to post
Share on other sites
OK, I figured it out myself.

I got rid of LoadImage, and DDCopyBitmap, and read the bitmap file into structures, and copied it manually (1 byte at a time) into the locked surface.

(Oh, and I'm registered now too)

0

Share this post


Link to post
Share on other sites
Just to let you know, DirectDraw doesn't do a real good job at emulating color keys. I've found that it only really works if the hardware supports it. I think source color-keying is supported in the HEL, but destination color-keying is not.
0

Share this post


Link to post
Share on other sites
Have you tried excluding the NOCOLORKEY statement. I never used it and and it worked.

------------------
The last truth is that there is no magic(Feist)

0

Share this post


Link to post
Share on other sites
I'm writing a game (Isn't everyone in here) that (among other things), is required to read a .bmp file into an Offscreen Surface. It just ends up filled with random garbage when I Blt it to the screen.

Here's the wierd part: When I blit it without a colorkey, it looks like garbage, but if I set a color key (RGB(0,0,0) to RGB(0,0,0)) It doesn't draw anything.

What's going on?

0

Share this post


Link to post
Share on other sites