Skip to main content
GameDev.net gamedev.net
🔒 Locked

ddraw issues

Started by AAAP Sep 2, 2006 at 8:13 PM 0 replies 1k views
Original Post
AAAP
AAAP
H'okay, generally I was using openGL for 2D and 3D graphics, so I thought I'd diversify a bit and give DDraw a shot. Now, I've gotten this far: I have fully initialized everything, and have a working double buffer between my front n back surfaces. When I try to use other surfaces though, there are some issues. When I started, my goal was to make a smaller test surface and fill it blue, while the background was filled black. Simple enough, but when I do a colour fill on my test surface, it fills the entire front surface. That sucks!! Also, I found that when I attempt to use the DD7::BltFast function, I get a segfault. So I thought maybe my surface wasn't created properly. Anyway, here's some code. Gimme a hand please O_o

Sprite::Sprite(AppWindow * win, int X,int Y,int W,int H)
{
	window = win;
	x = X; y = Y; width = W; height = H;

	DDSURFACEDESC2 ddsd;
	ZeroMemory(&ddsd, sizeof(ddsd));
	ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
	ddsd.dwHeight = width;
	ddsd.dwWidth = height;
	lpDD->CreateSurface( &ddsd, &surface, NULL );
}

Sprite::~Sprite()

{    
}

void Sprite::_Draw()
{
HRESULT ddrval = DD_OK;
//ddrval =		lpDDSBack->BltFast( x, y, surface, NULL,
//				   DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
DDPIXELFORMAT ddpf;
 
ddpf.dwSize = sizeof(ddpf);
DDBLTFX ddbltfx;
ddbltfx.dwSize = sizeof(ddbltfx); 
ddbltfx.dwFillColor = 0; // Pure blue
RECT r, r2;
    r.left = 0;
    r.top = 0;
    r.right = 640;
    r.bottom = 480;
//lpDDSBack->Blt(&r2, NULL, &r2, DDBLT_COLORFILL, &ddbltfx);

ddrval = lpDDSBack->Blt(&r,surface, 0, 
        DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT, 0);
if ( ddrval != DD_OK )
{
	//lpDD->Release();
}
//ddrval = lpDDSOffscreen->Blt(NULL, surface, NULL, DDBLTFAST_WAIT, &ddbltfx);
//ddrval = lpDDSBack->Blt(NULL, surface, NULL, DDBLT_COLORFILL, &ddbltfx);
//lpDDSPrimary->Flip(surface, NULL);
//if(ddrval != DD_OK)
//return;
}
Things are commented/uncommented in various places as I was testing different things to try and figure out what was going on, so it's a little messy. Anyhow, I'm sure someone's dealt with this before. My Direct X SDK version is (December 2005), if that has anything to do with this.
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.