Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi DirectX Initialisierungs Problem (https://www.delphipraxis.net/81522-directx-initialisierungs-problem.html)

igel457 28. Nov 2006 16:47


DirectX Initialisierungs Problem
 
Hallo.

Wie ihr vieleicht mitbekommen habt, schreibe ich gerade eine kleine 2D Engine.
Mein Problem ist jedoch, dass diese bei manchen Leuten während der Initialisierung aussteigt.

Meine Frage: Sieht vielleicht jemand, der sich mit DirectX gut auskennt was ich falsch machen könnte? Ich habe meinen SourceCode mal ausschnittsweise geposted. Der gesammte Code findet sich unter folgender Addresse: http://andorra.cvs.sourceforge.net/a...w=markup#l_458

Delphi-Quellcode:
function InitDisplay(Appl:TAndorraApplication; AWindow:hWnd; AOptions:TAdDrawModes;
   ADisplay:TAdDrawDisplay):boolean;
var
  d3dpp:TD3DPresent_Parameters;
  d3ddm:TD3DDisplayMode;
  d3dcaps9:TD3DCaps9;
  d3ddi:TD3DADAPTER_IDENTIFIER9;
  dtype:TD3DDevType;
  hvp:boolean;
  vp : Integer;
  i:integer;

begin
  result := false;
  if Appl <> nil then
  begin
    with TAndorraApplicationItem(Appl) do
    begin

      [SNIP]

      //Get the device capilities.
      if failed(Direct3D9.GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dcaps9)) then
      begin
        WriteLog(ltFatalError,PChar('Error while getting adapter capilities.'));
        exit;
      end;

      //Get the current display mode
      if failed(Direct3D9.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, d3ddm)) then
      begin
        WriteLog(ltFatalError,PChar('Error while getting current adapter displaymode.'));
        exit;
      end;

      Fillchar(d3dpp,sizeof(d3dpp),0);
      with d3dpp do
      begin
        Windowed := not (doFullscreen in AOptions);
        SwapEffect := D3DSWAPEFFECT_DISCARD;

        if not (doVSync in AOptions) then
        begin
          Fullscreen_PresentationInterval := D3DPRESENT_INTERVAL_IMMEDIATE;
        end;

        if (ADisplay.BitCount = 0) or (Windowed) then
        begin
          BackBufferFormat := d3ddm.Format;
        end
        else
        begin
          case ADisplay.BitCount of
            16 : BackBufferFormat := D3DFMT_R5G6B5;
            24 : BackBufferFormat := D3DFMT_R8G8B8;
            32 : BackBufferFormat := D3DFMT_A8R8G8B8;
          else
            BackBufferFormat := D3DFMT_A8R8G8B8;
          end;
        end;
        if not Windowed then
        begin
          BackBufferWidth := ADisplay.Width;
          BackBufferHeight := ADisplay.Height;
          if ADisplay.Freq > 0 then
          begin
            Fullscreen_RefreshRateInHz := ADisplay.Freq;
          end;
        end;
      end;

      if hvp then
        vp := D3DCREATE_HARDWARE_VERTEXPROCESSING
      else
        vp := D3DCREATE_SOFTWARE_VERTEXPROCESSING;

       //Set weather to use HAL
       if doHardware in AOptions then
        dtype := D3DDEVTYPE_HAL
       else
        dtype := D3DDEVTYPE_REF;


      //HIER GIBTS DAS PROBLEM...
      //Create device
      if Failed(Direct3D9.CreateDevice(D3DADAPTER_DEFAULT, dtype, AWindow, vp, d3dpp, Direct3d9Device)) then
      begin      
        WriteLog(ltFatalError, 'Couldn''t initialize Direct3DDevice!');
        exit;
      end
      else
      begin
        result := true;
      end;

     [SNIP]
Wie schon im Quellcode gezeigt schmiert er bei manchen in der Zeile Direct3D9.CreateDevice ab. Ich denke, dass es etwas mit den Presentation Parameters zu tun hat.

Danke, hoffentlich findet sich etwas...
Igel457

JasonDX 28. Nov 2006 17:12

Re: DirectX Initialisierungs Problem
 
Hi

Ich hatte in letzter Zeit auch diverse Schwierigkeiten mit der Initialisierung.
Als erstes wuerde ich ueberpruefen (Siehe [msdn]IDirect3D::CheckDeviceType[/msdn]), ob dein Backbuffer-Format (A8R8G8B8) unterstuetzt wird. Viele Devices moegen nur X8R8G8B8 fuer 32Bit-RTs.
Ein weiterer Grund fuer den Absturz koennte sein, dass kein Hardware-Vertexprocessing unterstuetzt wird. - Ist mir erst heut wieder passiert *g*
Ganz hilfreich bei der richtigen Erstellung eines Devices war fuer mich das hier. Ich hoff es hilft dir auch weiter ;)

greetz
Mike

PS: Es ist immer hilfreich, das Ergebnis von Funktionen wie CreateDevice abzuspeichern, und dann ueber das auf Failed zu pruefen. Damit kannst du den Fehlercode auslesen, und mit dem Error Lookup, was mitm DX-SDK mitkommt (oder mit der MSDN-Library durchsuchenDXGetErrorString-Funktion) rausfinden, was der Code bedeutet ;)

igel457 28. Nov 2006 17:16

Re: DirectX Initialisierungs Problem
 
Danke für deine Antwort, ich schau mal was sich machen lässt...


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:15 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz