Einzelnen Beitrag anzeigen

Nogge

Registriert seit: 15. Jul 2004
336 Beiträge
 
Delphi 7 Professional
 
#3

Re: Direct3D-Oberfläche auf einen Teil eines Panels zeichnen

  Alt 29. Sep 2008, 15:18
Naja, ich benutze halt das, was nötig für die Erstellung einer Surface ist ;)

Delphi-Quellcode:
ZeroMemory(@d3dpp, sizeof(d3dpp));

  d3dpp.Windowed := true;
  d3dpp.hDeviceWindow := hMainWnd;
  d3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;
  d3dpp.BackBufferCount := 1;
  d3dpp.BackBufferWidth := SCREEN_WIDTH;
  d3dpp.BackBufferHeight := SCREEN_HEIGHT;
  d3dpp.BackBufferFormat := D3DDisplayMode.Format;

  // Create the D3D Device
  hRes := D3DObject.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp, D3DDevice);
  if (FAILED(hRes)) then
  begin
    result := E_FAIL;
    exit;
  end;

[...]

hRes := D3DDevice.CreateImageSurface(SCREEN_WIDTH, SCREEN_HEIGHT, D3DFMT_X8R8G8B8, D3DSurface);
  if (FAILED(hRes)) then
  begin
    result := E_FAIL;
    exit;
  end;

[...]

hRes := D3DSurface.LockRect(buffer, nil, 0);
  if (FAILED(hRes)) then
  begin
    result := E_FAIL;
    exit;
  end;

  // fill the buffer with the pixel information
  pDest := PByte(buffer.pBits);
  for i := 0 to high(data) do
  begin
    copyMemory(pDest, @data[i], sizeOf(TLine));
    inc(pDest, buffer.Pitch);
  end;

  hRes := D3DSurface.UnlockRect;
  if (FAILED(hRes)) then
  begin
    result := E_FAIL;
    exit;
  end;

[...]

D3DDevice.Clear(0, nil, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1, 0);

  if (SUCCEEDED( D3DDevice.BeginScene() )) then
  begin
    D3DDevice.CopyRects(D3DSurface, nil, 0, D3DBackBuffer, nil);

    if ( FAILED( D3DDevice.EndScene() ) ) then
    begin
      result := E_FAIL;
      exit;
    end;

    D3DDevice.Present(nil, nil, 0, nil);
  end
  Mit Zitat antworten Zitat