Advertisement

Need Help Getting Back Buffer...

Started by May 30, 2001 10:58 PM
3 comments, last by QBRADQ 23 years, 8 months ago
I am having a hard time with this stuff. What I am trying to do is gett a pointer to a back buffer attatched to a direct draw 7 primary surface. Here is my code: DDSURFACEDESC2 ddsd_primary; DDSCAPS2 ddscaps; ZeroMemory(&ddsd_primary, sizeof(ddsd_primary)); ddsd_primary.dwSize = sizeof(DDSURFACEDESC2); ddsd_primary.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd_primary.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd_primary.dwBackBufferCount = 1; hres = lpDD->CreateSurface(&ddsd_primary, &lpDDSPrimary, NULL); if(hres != DD_OK) MessageBox(hwnd, "CreateSurface failed in CDirectXFunctions::DirectDrawInit for lpDDSPrimary", "Error:DD006", MB_OK); //Back Buffer DDSURFACEDESC2 ddsd_backbuffer; ZeroMemory(&ddsd_backbuffer, sizeof(ddsd_backbuffer)); ddsd_primary.dwSize = sizeof(DDSURFACEDESC2); ddsd_primary.dwFlags = DDSD_CAPS; ddsd_primary.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; hres = lpDD->CreateSurface(&ddsd_primary, &lpDDSBackBuffer, NULL); if(hres != DD_OK) MessageBox(hwnd, "CreateSurface failed in CDirectXFunctions::DirectDrawInit for lpDDSBackBuffer", "Error:DD009", MB_OK); //Attatching back buffer ddscaps.dwCaps = DDSCAPS_BACKBUFFER; hres = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBackBuffer); if(hres != DD_OK) MessageBox(hwnd, "GetAttachedSurface failed for lpDDSPrimary in CDirectXFunctions::DirectDrawInit", "Error:008", MB_OK); I always get both error messages when I run this program, and it''s only for the back buffer. is there a function I can call that will creat the primary and back buffers at the same time and assigns pointers? I remember something about that in a tutorial I once read, but I''m not sure about that? Also, is my error notification code OK? And is using the same HRESULT variable for every one of my tests OK?
Tell him about the twinky...
Well, I did a little digging, and the error returned when I try to get the attatched surface is DDERR_NOTFOUND which means that the requested item is not found. So... what do I do about that?
Tell him about the twinky...
Advertisement
Here''s the code I use.

  DDSURFACEDESC2 ddsd;ZeroMemory(&ddsd,sizeof(ddsd));ddsd.dwSize = sizeof( ddsd );ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |                      DDSCAPS_FLIP |                      DDSCAPS_COMPLEX;ddsd.dwBackBufferCount = 1;lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );DDSCAPS2 ddscaps;ZeroMemory(&ddscaps,sizeof(ddscaps));ddscaps.dwCaps=DDSCAPS_BACKBUFFER;lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack);  


Ben
The Rabbithole
Thanks, I''ll try that. And BTW, thanks for replying at such an ungodly hour of the night I''ll get back to you to see if it worked.

(The only thing I see diferent is that I didn''t ZeroMemory the ddscaps, something I always do (initilize to zero EVERYTHING kids, it saves SO MUCH OF A HEADACHE!!!))
Tell him about the twinky...
It worked!!! YES!!! Now I can finaly continue with my programming
Tell him about the twinky...

This topic is closed to new replies.

Advertisement