Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

CreateSurface returning null in the ddsd.lpSurface pointer

ArmenDXArmenDX Member Posts: 2
From my understanding I'm setting up everything correctly and none of the function calls (ie: DirectDrawCreateEx(), SetCooperativeLevel(), and CreateSurface()) are failing, but ddsd.lpSurface is null. Anyone see something I don't?

// direct draw initialization
if(FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
MessageBox(0, "Error initializing directdraw", 0, 0);

// set the cooperative level with windows
if(FAILED(lpdd->SetCooperativeLevel(hwndMainWin, DDSCL_NORMAL)))
MessageBox(0, "Error setting coop level", 0, 0);

// clear ddsd and set size
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);

// set the proper flags
ddsd.dwFlags = DDSD_CAPS;

// request primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

// create the primary surface
if(FAILED(lpdd->CreateSurface(&ddsd, &lpddsPrimary, NULL)))
MessageBox(0, "Error creating surface", 0, 0);

if(ddsd.lpSurface == NULL)
MessageBox(0, "DFD", "DFD", 0);

Comments

  • GodLikeGodLike Member Posts: 4
    [b][red]This message was edited by GodLike at 2004-10-5 14:18:19[/red][/b][hr]
    see the lines below preceded by ->.

    : From my understanding I'm setting up everything correctly and none of the function calls (ie: DirectDrawCreateEx(), SetCooperativeLevel(), and CreateSurface()) are failing, but ddsd.lpSurface is null. Anyone see something I don't?
    :
    : // direct draw initialization
    : if(FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
    : MessageBox(0, "Error initializing directdraw", 0, 0);
    :
    : // set the cooperative level with windows
    : if(FAILED(lpdd->SetCooperativeLevel(hwndMainWin, DDSCL_NORMAL)))
    : MessageBox(0, "Error setting coop level", 0, 0);
    :
    -> // set display mode to winWidth, winHeight
    -> if(FAILED(lpdd->SetDisplayMode(winWidth, winHeight, winBpp, 0, 0)))
    -> MessageBox(0, "Error setting display mode", 0, 0);
    : // clear ddsd and set size
    : memset(&ddsd, 0, sizeof(ddsd));
    : ddsd.dwSize = sizeof(ddsd);
    :
    : // set the proper flags
    : ddsd.dwFlags = DDSD_CAPS;
    :
    : // request primary surface
    : ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    :
    : // create the primary surface
    : if(FAILED(lpdd->CreateSurface(&ddsd, &lpddsPrimary, NULL)))
    : MessageBox(0, "Error creating surface", 0, 0);
    :
    : if(ddsd.lpSurface == NULL)
    : MessageBox(0, "DFD", "DFD", 0);
    :



Sign In or Register to comment.