Einzelnen Beitrag anzeigen

Benutzerbild von igel457
igel457

Registriert seit: 31. Aug 2005
1.622 Beiträge
 
FreePascal / Lazarus
 
#1

DirectX Initialisierungs Problem

  Alt 28. Nov 2006, 16:47
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
Andreas
"Sollen sich auch alle schämen, die gedankenlos sich der Wunder der Wissenschaft und Technik bedienen, und nicht mehr davon geistig erfasst haben als die Kuh von der Botanik der Pflanzen, die sie mit Wohlbehagen frisst." - Albert Einstein
  Mit Zitat antworten Zitat