Blank screen in DDraw

Started by
0 comments, last by nagromo 20 years, 11 months ago
I am trying to draw a simple point using ddraw and finally got the screen set up, but it won''t draw anything. It will change display mode to 800 x 600 and display a black screen (no mouse) but will quit properly when I press ESC. I''m glad I programmed that in. Here''s my codeI already init''ed wincl)
  
    if (!RegisterClassEx (&wincl)) return false;
    
    hWnd = CreateWindowEx (0,szClassName,szClassName,WS_POPUP,
           INITAL_POS_X,INITAL_POS_Y,INITAL_SIZE_X,INITAL_SIZE_Y,HWND_DESKTOP,NULL,hInstance,NULL);
    
    if(hWnd==NULL) {
        MSGBOX("Init error.");
        KillWindow();
        return false;
    }
    
    if(FAILED(DirectDrawCreateEx(NULL,(void**)&lpdd,IID_IDirectDraw7,NULL))) {
        MSGBOX("Init error.");
        KillWindow();
        return false;
    }
    
    lpdd->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
    lpdd->SetDisplayMode(INITAL_SIZE_X,INITAL_SIZE_Y,32,0,0);
    
    INIT_DXSTRUCT(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    
    
    if (FAILED(lpdd->CreateSurface(&ddsd,&lpddsPrimary,NULL))) {
        MSGBOX("lpdd Init error.");
        KillWindow();
        return false;
    }
    
    if(FAILED(lpddsPrimary->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT,NULL))) {
        MSGBOX("Couldn''t lock surface.");
        KillWindow();
        return false;
    }
    
    UINT* buffer = (UINT*)ddsd.lpSurface;
    nPitch = ddsd.lPitch >> 2;
    
    PLOT32(10,10,RGB32(255,0,0),buffer);

  
I just put the plot32 in for testing. Here''s PLOT32: buffer[y*nPitch + x] = color; I got some of the source from an article here. Can anyone help?
Advertisement
...did you unlock the surface?

This topic is closed to new replies.

Advertisement