Why doesnt this work?

Started by
16 comments, last by GameDev.net 24 years, 4 months ago

Esap1,

Let me preface this by saying that I am not a Direct3D guru, but have some experience with COM.

The only thing that really jumped out at me was the fact that you were Querying an uninitialized interface pointer for itself..:


lpd3d->QueryInterface(IID_IDirect3D2, ...)

that line should read:

lpdd->QueryInterface(IID_IDirect3D2, (void**)&lpd3d)

Since you need to query the IDirectDraw interface for the IDirect3D interface.

As a side note, you might want to consider taking the time to create your own exception handling class, something that takes an HRESULT and maps it to a string definition of what went wrong.

HTH,

-mordell

__________________________________________

Yeah, sure... we are laughing WITH you ...
Advertisement
1 more thing, when I set hardware to 1 as it is there, it cant get past AddAttachedSurface, but if I set it to 0, it cant get past the CreateDevice, I just dont know what wrong:
Since you have a primary surface and a back surface, I assume you want to flip. But eeeeh, you didn't make code to flip your surface. Change that...

------------------
Dance with me......

I have other code in a function to flip the surface but my program cant even get past that function
PLEASE, I STILL NEED HELP, Please , if yo can please try to help me, thanx alot
Ok

1) Get lost of the DDSCL_MODEX
2) Use (DirectDraw->)QueryInterface before you set the display mode.
3) use "FrontBuffer->GetAttachedSurface(&caps, &BackBuffer);" instead of AddAttachedSurface();

I Use addattchedSurface to attach the z buffer.

I would go for the following items in the following order:
1) DirectDrawCreate()
2) SetCooperativeLevel()
3) QueryInterface()
4) SetDisplayMode()
5) CreateSurface()
6) GetAttachedSurface()
( 7) CreateSurface + AddAttachedSurface for zbuffer)
8) CreateDevice()
9) CreateViewPort()
10) AddViewPort()
11) SetCurrentViewPort()
12) SetTransform()

etc etc..........

------------------
Dance with me......

Thanks, but one more question, what CAPS should I use for the GetAttachedSurface for the back buffer,
thanks alot
DDSCAPS_BACKBUFFER

------------------
Dance with me......

I was wondering if yo have to CreateSurface a Backbuffer before you use AddAttachedSurface,
Also Im doing everything right
but AddAttachedSurface returns an error.
thank you!
Look at the following bit.

DDSURFACEDESC ddsd;

ZeroMemory(&ddsd, sizeof(ddsd));

ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY;

ddsd.dwBackBufferCount = 1;

err = dd->CreateSurface(&ddsd, &FrontBuffer, NULL);

if (err != DD_OK)
{
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
err = dd->CreateSurface(&ddsd, &FrontBuffer, NULL);
}

if (err != DD_OK)
{
return FALSE;
}

DDSCAPS caps;

caps.dwCaps = DDSCAPS_BACKBUFFER;
err = FrontBuffer->GetAttachedSurface(&caps, &BackBuffer);

if (err != DD_OK)
{
return FALSE;
}

memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT |DDSD_CAPS | DDSD_ZBUFFERBITDEPTH;
ddsd.dwHeight = height;
ddsd.dwWidth = width;
ddsd.dwZBufferBitDepth = bpp;
ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY;

err = dd->CreateSurface(&ddsd, &ZBuffer, 0);
if(err != DD_OK)
{
return FALSE;
}

err = BackBuffer->AddAttachedSurface(ZBuffer);

if(err != DD_OK)
{
return FALSE;
}

------------------
Dance with me......

This topic is closed to new replies.

Advertisement