Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Direct Draw back buffer problem

Direct Draw back buffer problem

Direct Draw back buffer problem

I am new at using directX and am clueless as to why my GetAttachedSurface returns an error. This program works just fine with only one surface. I have included my WinMain function.

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine, int nCmdShow)
    HRESULT hRet;

    MSG msg;
    HWND hWnd;
    WNDCLASS wc;

    LONGLONG cur_time;
    DWORD time_count;
    LONGLONG perf_cnt;
    bool perf_flag=false;
    LONGLONG next_time=0;
    LONGLONG last_time=0;
    double time_elapsed;
    double time_scale;

    wc.style        =CS_HREDRAW|CS_VREDRAW;
    wc.lpfnWndProc    =(WNDPROC)WindowProc;
    wc.cbClsExtra    =0;
    wc.cbWndExtra    =0;
    wc.hInstance    =hInstance;
    wc.hIcon        =LoadIcon(hInstance,"Rouslan");
    wc.hCursor        =LoadCursor(NULL,IDC_ARROW);
    wc.lpszMenuName    =MAKEINTRESOURCE(IDR_MENU1);
    if(!RegisterClass(&wc))return false;



    hWnd = CreateWindow(lpszAppName,lpszTitle,WS_POPUP,0,0,

    if(!hWnd)return false;


    if(hRet != DD_OK)return false;

    hRet = lpDD->SetCooperativeLevel(hWnd,DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE);
    if(hRet != DD_OK)return false;

    hRet = lpDD->SetDisplayMode(640,480,16,0,0);

    if(hRet != DD_OK)
        return false;

    ddsd.dwSize = sizeof(ddsd);
    hRet=lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
    if(hRet != DD_OK)return false;

    /////////GOOD UP TO HERE///////////

    DDSCAPS2 ddscaps;
        MessageBox(hWnd,"This message gets called","Hmm",MB_OK);
        return false;

    /////////BREAK DOWN HERE///////////



            if(!GetMessage(&msg,NULL,0,0))return msg.wParam;
            else cur_time=timeGetTime();


RE: Direct Draw back buffer problem

Well I'm not really sure, this is just a gues:

Three lines after /////////GOOD UP TO HERE///////////, try inserting

ddsCaps.dwCaps2 = 0;

The DDSCAPS structure actually has 4 members, (only dwCaps and dwCaps2 are used, though.) Since dwCaps2 wasn't getting initialized, it probably had a random value like 0xCCCCCCCC, which could cause GetAttachedSurface to fail when it tries to get a back buffer with a whole bunch of capabilities declared in dwCaps2.

Sorry if it doesn't work, this is just my guess-- I've actually been off the DirectDraw7 scene since DirectX 8 came out, so I'm a bit rusty in that subject.

Happy gaming

RE: Direct Draw back buffer problem

Thanks for trying but that didn't help. Anyways when I checked which error message it turned out to be DDERR_NOTFOUND. That seems strange to me.

RE: Direct Draw back buffer problem

Never mind. I just switched to Direct X 8 and couldn't be happier.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close