Archived

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

nagromo

Blank screen in DDraw

Recommended Posts

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?

Share this post


Link to post
Share on other sites