Jump to content
  • Advertisement

Archived

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

Guest Anonymous Poster

Why doesnt this work?

This topic is 6811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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:

Share this post


Link to post
Share on other sites
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......

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have other code in a function to flip the surface but my program cant even get past that function

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
PLEASE, I STILL NEED HELP, Please , if yo can please try to help me, thanx alot

Share this post


Link to post
Share on other sites
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......

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks, but one more question, what CAPS should I use for the GetAttachedSurface for the back buffer,
thanks alot

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
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......

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!