IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

DirectX Discussion :

Comment créer un objet DirectDraw (LPDIRECTDRAW) sur mon "secondary monitor" ?


Sujet :

DirectX

  1. #1
    Membre régulier
    Homme Profil pro
    retraité ing. de recherche
    Inscrit en
    Janvier 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : retraité ing. de recherche
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 33
    Points : 102
    Points
    102
    Par défaut Comment créer un objet DirectDraw (LPDIRECTDRAW) sur mon "secondary monitor" ?
    Pour créer son interface DirectDraw associé à son moniteur principal, on fait

    LPDIRECTDRAW m_pDDObject;
    HRESULT hr = DirectDrawCreate(NULL, &m_pDDObject, NULL) ;
    On peut ensuite y appliquer son SetCooperativeLevel puis SetDisplayMode et encore CreateSurface sans problème

    D'après la doc, en toute généralité, pour ouvrir son interface sur un device quelconque, on fait

    LPDIRECTDRAW m_pDDObject;
    GUID guid;
    GUID FAR* lpGUID = &guid;
    hr = ConvertStringtoCLSID( cszguid, lpGUID);
    hr = DirectDrawCreate(lpGUID, &m_pDDObject, NULL) ;

    où le cszguid est le GUID sous forme texte de son display, obtenu par exemple par

    int iNbMonitors = GetSystemMetrics(SM_CMONITORS);
    et si on a deux moniteurs
    DISPLAY_DEVICE m_displayDevice[2];
    BOOL bOK0 = EnumDisplayDevices(NULL, 0, m_displayDevice[0], EDD_GET_DEVICE_INTERFACE_NAME);
    BOOL bOK1 = EnumDisplayDevices(NULL, 0, &m_displayDevice[1], EDD_GET_DEVICE_INTERFACE_NAME);

    MON PROBLEME :
    Bien que le guid obtenu semble parfaitement légal (tant pour le moniteur '0' par défaut que pour le secondary '1') l'appel
    hr = DirectDrawCreate(lpGUID, &m_pDDObject, NULL) ;
    me rend toujours un code d'erreur "farfelu" non documenté !

    Quelqu'un a-t-il une idée ? J'a été incapable de trouver sur le WEB un exemple ou le GUID du device n'est pas NULL (1.er paramètre du DirectDrawCreate)

    (XP SP2, NVidia 1700, 2 moniteurs 1600x1200), DirectX9 + Windows SDK version juin 2008)

  2. #2
    Expert éminent sénior
    Avatar de Mat.M
    Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2006
    Messages
    8 361
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 8 361
    Points : 20 381
    Points
    20 381
    Par défaut
    1-As tu regardé dans le MSDN
    Full-screen exclusive mode DirectDraw objects will take advantage of hardware acceleration regardless of whether they are running on the primary device or on a secondary device. However, they cannot use built-in support for spanning graphics operations across display devices. It is the application's responsibility to perform operations on the appropriate device.

    When the normal cooperative level is set, DirectDraw uses hardware acceleration only when the window is wholly within the display area of the primary device. When a window straddles two or more monitors, all blits are done in emulation and performance can be significantly slower. This is necessarily the case, because hardware buffers cannot blit to a display surface controlled by another piece of hardware.

    As long as you create the DirectDraw object for the null device—that is, pass NULL to DirectDrawCreate as the lpGUID parameter—DirectDraw will blit to the entire window regardless of where it is located. However, if the device is created by its actual GUID, this is not the case, and blit operations that cross an edge of the primary surface will be clipped (if you are using a clipper) or will fail, returning DDERR_INVALIDRECT.

    Note When you are blitting to a window in a MultiMon application, negative coordinates are valid when the logical location of the secondary monitor is to the left of the primary monitor.

    To get the best performance in a windowed MultiMon application, you need to create a DirectDraw object for each device, maintain off-screen surfaces in parallel on each device, keep track of which part of the window resides on each device, and perform separate blits to each device.

    ( note : j ai un vieux MSDN de 2001 essayer de trouver un vieux SDK de Dx par exemple Dx7 )

    2-est-ce que ta carte vidéo est capable de supporter 2 moniteurs selon le mode vidéo ( taille VRAM ) ?
    Essayer avec des petites résolutions genre 800*600*16bits

    3-As-tu regardé les codes d'erreurs de DirectDrawCreate ?

    DDERR_DIRECTDRAWALREADYCREATED
    DDERR_GENERIC
    DDERR_INVALIDDIRECTDRAWGUID
    DDERR_INVALIDPARAMS
    DDERR_NODIRECTDRAWHW
    DDERR_OUTOFMEMORY

  3. #3
    Membre régulier
    Homme Profil pro
    retraité ing. de recherche
    Inscrit en
    Janvier 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : retraité ing. de recherche
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 33
    Points : 102
    Points
    102
    Par défaut Serait-ce impossible par la voie que j'ai choisie ?
    Merci pour la réponse, mais, si je suis conscient des limitations de performances sur le 2ième moniteur, MSDN dit bien "you need to create a DirectDraw object for each device"

    Mea-Culpa le code d'erreur 0x88760231 que j’obtiens n’est pas farfelu comme je l’ai dit, mais est DDERR_INVALIDDIRECTDRAWGUID - encore fallait-il que je comprenne comment sont construits ces codes

    J'ai bien vérifié, ma carte graphique Quadro FX1700 est bien capable de gérer mes deux moniteurs, elle a 512MB - et j'a le même problème si je réduits ma résolution à 800x600.

    Je retrouve bien dans la Registry le « GUID » que m’a donné EnumDisplayDevices ( "\Registry\Machine\System\CurrentControlSet\Control\Video\{0348CA33-DECC-4B43-A8F7-CD8EF8A9962C}\0000 respectivement \0001 " ) mais comme la structure «GUID » ne contient pas de champs pour coder les « \0000 » respectivement « \0001 » finaux (qui visiblement codent le numéro du display dans mon système Dual Screen ) peut-être que le problème vient de là ? Serait-il impossible d’adresser individuellement les moniteurs quand on a une telle carte graphique « dual screen » au lieu de 2 cartes distinctes ?

    Sous http://msdn.microsoft.com/en-us/library/ms534607.aspx on trouve une possibilité (que je n’ai pas encore testée) résumé par

    An application can open a display by calling
    hdc = CreateDC(lpszDisplayName, NULL, NULL, lpDevMode);
    Et le lien entre le DeviceContext et la DirectDraw interface, on fait comment ??

Discussions similaires

  1. Réponses: 2
    Dernier message: 30/01/2007, 09h02
  2. Réponses: 3
    Dernier message: 30/01/2007, 09h01
  3. Comment créer un compte utilisateur distant sur WinXpPro
    Par Geolem dans le forum Windows XP
    Réponses: 2
    Dernier message: 09/10/2006, 12h44
  4. [VB6] Comment créer un objet TRIANGLE
    Par Lucas42 dans le forum VB 6 et antérieur
    Réponses: 14
    Dernier message: 17/05/2006, 16h15
  5. Réponses: 1
    Dernier message: 11/07/2005, 17h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo