Jump to content
  • Advertisement


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


Directx Page flipping blues

This topic is 5968 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

hi everyone. i''ve written a short piece of code that creates a primary surface and then attempts to get the attached surfaces but i keep getting the DDERR_NOTFOUND error. what exactly can it not find? it cant be the primary surface because it definitely exists. heres the code i''ve written. any help would be much appreciated. //include all stuff, etc WNDCLASS mainWindowClass; LPDIRECTDRAW7 directDraw7; HINSTANCE mainWindowInstance; HWND mainWindowHandle; LPDIRECTDRAWSURFACE7 actives; //active surface DDSURFACEDESC2 surfaceDescription;//surface description LPDIRECTDRAWSURFACE7 front; //front buffer LPDIRECTDRAWSURFACE7 back; //back buffer LRESULT CALLBACK windowProc(HWND, UINT, WPARAM, LPARAM); void systemMsg(char *); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { mainWindowInstance=hInstance; mainWindowClass.style =CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW; mainWindowClass.lpfnWndProc =windowProc; mainWindowClass.cbClsExtra =0; mainWindowClass.cbWndExtra =0; mainWindowClass.hInstance =mainWindowInstance; mainWindowClass.hIcon =LoadIcon(NULL, IDI_APPLICATION); mainWindowClass.hCursor =LoadCursor(NULL, IDC_ARROW); mainWindowClass.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH); mainWindowClass.lpszMenuName =NULL; mainWindowClass.lpszClassName ="WINCLASS1"; if(RegisterClass(&mainWindowClass)==0) //can we register our class? { systemMsg("Could not register class."); return FALSE; } mainWindowHandle=CreateWindow("WINCLASS1", "Test", WS_POPUP, 0, 0, 1, 1, NULL, NULL, mainWindowHandle, NULL); if(mainWindowHandle==NULL) //was our window succelssful? { systemMsg("Could not create window."); return FALSE; } ShowWindow(mainWindowHandle, SW_SHOW); if(DirectDrawCreateEx(NULL, (LPVOID*)&directDraw7, IID_IDirectDraw7, NULL)!=DD_OK) { systemMsg("Could not create direct draw object."); return FALSE; } directDraw7->SetCooperativeLevel(mainWindowHandle, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN); if(directDraw7->SetDisplayMode(640, 480, 16, 0, 0)!=DD_OK) { systemMsg("Could not set display mode."); return FALSE; } memset(&surfaceDescription, 0, sizeof(surfaceDescription)); surfaceDescription.dwSize =sizeof(surfaceDescription); surfaceDescription.dwFlags =DDSD_CAPS | DDSD_BACKBUFFERCOUNT; surfaceDescription.ddsCaps.dwCaps =DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX; surfaceDescription.dwBackBufferCount =1; if(directDraw7->CreateSurface(&surfaceDescription, &front, NULL)!=DD_OK) { systemMsg("Cannot create primary surface."); return FALSE; } DDSCAPS2 ddscaps; ddscaps.dwCaps=DDSCAPS_BACKBUFFER; /** THE FOLLOWING CODE PRODUCES AN ERROR! THE GETATTACHEDSURFACE FUNCTION RETURNS A DDERR_NOTFOUND ERROR. I DONT UNDERSTAND WHY. I HAVE A FEELING ITS TO DO WITH THE THE LPDIRECTSURFACE7 VARIABLE DEFINITIONS BUT CANT SEE WHAT EXACTLY CAN ANYBODY HELP, PLEASE?? **/ if((front->GetAttachedSurface(&ddscaps, &back))!=DD_OK) { systemMsg("Could not get attached surfaces."); return FALSE; } systemMsg("Successful!"); return TRUE; } LRESULT CALLBACK windowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT windowPaintStruct; switch(msg) { case WM_CREATE: //window has been created { return 0; } case WM_PAINT: //window requires a re-spray { BeginPaint(hWnd, &windowPaintStruct); EndPaint(hWnd, &windowPaintStruct); return 0; } case WM_DESTROY: //window needs demolishing! { PostQuitMessage(0); return 0; } case WM_SIZE: //resize occured { //reference: w=LOWORD(lParam), h=HIWORD(lParam) return 0; } default: break; } return(DefWindowProc(hWnd, msg, wParam, lParam)); } void systemMsg(char *e) { MessageBox(mainWindowHandle, e, "Information", MB_OK); } see ya!!!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!