Domanda

Lavoro con un pezzo di codice legacy che utilizza Direct Draw e mi trovo in una situazione piuttosto imbarazzante. Non molto tempo fa ho aggiornato il mio sistema e ho dovuto adattarmi alla nuova situazione (caricando dDraw.dll) e tutto ha funzionato bene. Oggi ho esplorato un'altra soluzione legacy che utilizza anche le classi (file) che ho cambiato, ma sono bloccato con un errore di collegamento sopra menzionato. Ho controllato e confrontato le proprietà del progetto e cuciono bene.

Questo è il codice per l'inizializzazione DirectX, il codice "problematico" è in grassetto.

 typedef int (__stdcall *DirectDrawCreateFunc)(GUID FAR* a ,LPDIRECTDRAW FAR* b, IUnknown FAR* c);

    /* init_directx:
     *  Low-level DirectDraw initialization routine.
     */
    int CDCUtils::init_directx(HWND allegro_wnd)
    {
       LPDIRECTDRAW directdraw1;
       HRESULT hr;
       LPVOID temp;
       HINSTANCE ddraw = LoadLibrary("%WINDIR%\system32\ddraw.dll");
       if(ddraw== NULL)
       {
           return -1;
       }
       _ddrawLib =ddraw;
    DirectDrawCreateFunc ddFunc = (DirectDrawCreateFunc)GetProcAddress(ddraw,"DirectDrawCreate");
    if(ddFunc)
    {
     /* first we have to set up the DirectDraw1 interface... */
       hr = ddFunc(NULL, &directdraw1, NULL);
       if (FAILED(hr))
          return -1;
    }

       ///* first we have to set up the DirectDraw1 interface... */
       //hr = DirectDrawCreate(NULL, &directdraw1, NULL);
       //if (FAILED(hr))
       //   return -1;

       //...then query the DirectDraw2 interface
       //This is the only place where IID_IDirectDraw2 is mentioned in entire solution
       hr=directdraw1->QueryInterface(IID_IDirectDraw2, &temp);
       if (FAILED(hr))
          return -1;

       _directdraw = (LPDIRECTDRAW2)temp;
       directdraw1->Release();

       /* set the default cooperation level */
       hr = IDirectDraw2_SetCooperativeLevel(_directdraw, allegro_wnd, DDSCL_NORMAL);
       if (FAILED(hr))
          return -1;

       /* get capabilities */
       _ddcaps.dwSize = sizeof(_ddcaps);
       hr = IDirectDraw2_GetCaps(_directdraw, &_ddcaps, NULL);
       if (FAILED(hr)) {
          TRACE("Can't get driver caps\n");
          return -1;
       }

       _dxHwnd=allegro_wnd;
      return 0;
    } 

Qualche idea? Perché funziona in una soluzione e non in questo? Oh linker ti detesto.

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top