Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Di 15.08.06 18:38 
hi leute

ich arbeite grade mit directx (9 sdk) und möchste im meiner form einen bereich haben wo meine direct x engine nach dem initialisieren angezeigt wird...
wie geht das ?
unter anderem gebe ich direct x die verfügung über meine form in:
ausblenden Delphi-Quelltext
1:
hDeviceWindow:=Handle;					

aber ich wüsste nicht wie der code aussehen sollte um direct x meinetwegen in einem panel oder paintbox oder so auftreten zu lassen. wie setze ich die eingrenzung am besten um ?

der initialisierungsprozess sieht so aus :
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
procedure TForm1.D3DInit;
var
  hr    : HRESULT;
  d3dpp : TD3DPRESENTPARAMETERS;
begin
  lpd3d:=Direct3DCreate9(D3D_SDK_VERSION);
  if(lpd3d=nil) then FatalError(0,'Fehler beim Erstellen von Direct3D!');
  Konsole.text:=Konsole.text + '<' + gettime + '> Direct3D SDK Version 9 geladen.' + #13#10;


  ZeroMemory(@d3dpp, SizeOf(d3dpp));

  with d3dpp do begin

    SwapEffect:=D3DSWAPEFFECT_DISCARD;
    hDeviceWindow:=Handle;      // HWND von TForm
    BackBufferCount:=1;        
    Konsole.text:=Konsole.text + '<' + gettime + '> BackBuffer erstellt: 1.' + #13#10;

    Windowed          := TRUE;         // "FALSE" für Fullscreen-Modus
    Konsole.text:=Konsole.text + '<' + gettime + '> Starte im Fenstermodus.' + #13#10;
    BackBufferWidth   := 640;
    BackBufferHeight  := 480;
    BackBufferFormat  := D3DFind16BitMode;
    Konsole.text:=Konsole.text + '<' + gettime + '> BackBuffer Format ist 16bit.' + #13#10;
  end;

  hr:=lpd3d.CreateDevice(D3DADAPTER_DEFAULT,
                         D3DDEVTYPE_HAL,
                         Handle,
                         D3DCREATE_SOFTWARE_VERTEXPROCESSING,    // wahlweise "HARDWARE"
                         @d3dpp,
                         lpd3ddevice);
  Konsole.text:=Konsole.text + '<' + gettime + '> Direct3D Device erschaffen.' + #13#10;
  if FAILED(hr) then FatalError(hr,'Fehler beim Erzeugen des 3D-Device');
  Application.OnIdle := OnIdle;
end;



wie begrenze ich den bereich ?
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 15.08.06 18:59 
Hm ich kenne mich mit DirectX nicht aus, aber hast du mal versucht, statt dem Form handle das Handle einer Komponente zu übergeben? z.B. eine TPaintBox, oder vielleicht TPaintBox.Canvas.Handle oder sowas?

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Di 15.08.06 21:22 
sowas in der art hatte ich ja vor aber ich wüsste den code jetzt nicht...also wos hingehört.
pRoTeUs
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 47

Windows XP prof
Delphi 2005 prof
BeitragVerfasst: Di 15.08.06 21:37 
Abend,

also ich hab zwar keine Ahnung von Direct3D, aber ich würde mal schätzen dass hier geschiet:
ausblenden Delphi-Quelltext
1:
:hDeviceWindow:=Handle;      // HWND von TForm					


Übergib statt dem Handle von Form1 einfach das Handle eines Panels.
ausblenden Delphi-Quelltext
1:
hDeviceWindow:=Panel1.Handle;					


Mfg
proteus
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 15.08.06 22:32 
Also dass das ne nähere Erklärung erforderte ^^

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Di 15.08.06 23:19 
...jo schon. ist eigentlich ganz einfach, warums mit PaintBox nicht geht...

D3D erwartet ein Handle vom Typ HWND (Handle of a WiNDow),

das Handle von TPaintbox ist aber vom Typ HDC (Handle for a Device Context).

Letzteres wird von den Windows-Zeichenfunktionen benutzt, aber damit hat D3D ja nichts zu tun.

grüße g1o