Error, can not get AttachedSurface
LPDIRECTDRAW7 lpDD=0;
LPDIRECTDRAWSURFACE7 lpDDSPrimary=0;
LPDIRECTDRAWSURFACE7 lpDDSBack=0;
LPDIRECTDRAWSURFACE7 bit;
case WM_CREATE:
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
if(FAILED(DirectDrawCreateEx(0,(LPVOID*)&lpDD,IID_IDirectDraw7,0)))
MessageBox(hwnd,"DirectDrawCreateEx","Failed",MB_OK);
if(FAILED(lpDD->SetCooperativeLevel(hwnd,DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE|DDSCL_ALLOWREBOOT)))
MessageBox(hwnd,"CooperativeLevel","FAiled",MB_OK);
if(FAILED(lpDD->SetDisplayMode(800,600,16,0,0)))
MessageBox(hwnd,"DisplaySettings","Failed",MB_OK);
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps=DDSCAPS_FLIP|DDSCAPS_COMPLEX|DDSCAPS_PRIMARYSURFACE;
ddsd.dwBackBufferCount=1;
if(FAILED(lpDD->CreateSurface(&ddsd,&lpDDSPrimary,0)))
MessageBox(hwnd,"CreateSurface primary","error",MB_OK);
ddscaps.dwCaps=DDSCAPS_BACKBUFFER; //Does no difference
if(FAILED(lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack)))
MessageBox(hwnd,"GetAttachedSurface","error",MB_OK);
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN;
ddsd.dwHeight=100;
ddsd.dwWidth=100;
if(FAILED(lpDD->CreateSurface(&ddsd,&bit,0)))
MessageBox(hwnd,"Error, Load Bitmap Surface","Error",MB_OK);
bit=DDLoadBitmap(lpDD,"a.bmp",0,0);
// When The window is created, I get the message "Error, Could not get attached surface"
This is my own code.. What is wrong?
It´s just like the tutorials :S
ZeroMemory your ddscaps structure before setting the dwCaps value and calling GetAttachedSurface().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement