Autor Beitrag
rmasterb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Sa 06.12.03 16:48 
hi leutz ich versuche mich gerade in directX einzuarbeiten und hab es mit dem tut selfdxd versaucht. es scheint auch alles soweit zu funktionieren(bisi jetzt), aber bei einer function scheitert es
ausblenden Quelltext
1:
2:
3:
if ( vbuffer.Lock( 0, sizeof( Vertices ), pVertices, 0 ) <> D3D_OK ) then Exit;
  Move( Vertices, pVertices^, sizeof( Vertices ) );
  vbuffer.Unlock;


der compiler schreibt folgendes:
Zitat:
[Fehler] Unit1.pas(85): Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

und zwar zeigt er auf das pVertices
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 06.12.03 16:50 
Das heißt dass er (vermutlich) einen TVertices statt eines PVertices erwartet.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 06.12.03 16:50 
schreibe anstatt "pVertices^" mal "@pVertices"
:-/
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 06.12.03 16:51 
obbschtkuche hat folgendes geschrieben:
Das heißt dass er (vermutlich) einen TVertices statt eines PVertices erwartet.

PVertices ist ja auch nur der Variablenname bzw. der Zeiger auf eine solche Variable...
man muss der Prozedur doch nicht den Typ übergeben :-/
Lhid
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 831



BeitragVerfasst: Sa 06.12.03 16:54 
Meinung und mich grundlegend verändert.--> Beiträge gelöscht


Zuletzt bearbeitet von Lhid am Sa 26.09.09 10:48, insgesamt 1-mal bearbeitet
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Sa 06.12.03 16:55 
nein ich mein das pVertice in der lock funktion
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 06.12.03 16:58 
anscheinend ist doch pVertices ein ZEiger, und den solltes du dann auch in dieser Funktion dreferenzieren...
also entwede durch ein ^ am Ende oder durch das @ :/
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 06.12.03 16:59 
Dann versuch pVertices^...

@pVertices wäre ja ein Zeiger auf einen Zeiger... Macht irgendwie wenig Sinn.
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Sa 06.12.03 17:01 
nein pVertice ist ein int soll aber ein byte sein
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 06.12.03 17:22 
obbschtkuche hat folgendes geschrieben:
@pVertices wäre ja ein Zeiger auf einen Zeiger... Macht irgendwie wenig Sinn.

kommt aber durchaus vor und das hätte es ja sein können ;)
hat uns ja keine Infos über den Variablentyp gegeben...
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: So 14.12.03 19:05 
Titel: problem mit vertexshader
nach einigen tutorials habe ich endlich das problem mit dem pointer hinbekommen, jedoch hab ich immer noch keine ahnung was ich mit der procedure setvertexshader() anfangen soll ich hab jetzt als dummy erst mal die variable i eingesetzt, das übungsziel isst niicht erreicht;sprich ich sehe nicht das gerenderte dreieck

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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, d3dx9, d3d9, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
  private
    procedure OnIdle(Sender: TObject; var done: boolean);
    { Private-Deklarationen }
  public
    procedure d3d_initialisieren;
    function initgeometrie: HRESULT;
    { Public-Deklarationen }
  end;

{type
 TD3DLVertex = packed record
    x: TD3DValue;
    y: TD3DValue;
    z: TD3DValue;
    dwReserved: DWORD;
    color: TD3DColor;
    specular: TD3DColor;
    tu: TD3DValue;
    tv: TD3DValue;
  end;
  }

type
  CUSTOMVERTEX = record
    x, y, z : Single;   // Positionskoordinaten
    color : TD3DColor;  // Farbe
  end;

const                   // Format von CUSTOMVERTEX
  D3DFVF_CUSTOMVERTEX = ( D3DFVF_XYZ or D3DFVF_DIFFUSE );

const   // das flag zum record
  D3DFVF_LVertexFormat = ( D3DFVF_XYZ or D3DFVF_RESERVED0 or D3DFVF_DIFFUSE or D3DFVF_SPECULAR or D3DFVF_TEX1 );

var
  Form1: TForm1;
  d3d9 : IDirect3d9;
  d3ddev9 : IDirect3DDevice9;
  vbuffer: IDirect3DVertexBuffer9;

implementation

function tform1.initgeometrie: HRESULT;
var
  Vertices: Array[0..2] of CUSTOMVERTEX;
  pVertices : Pointer;
begin
 // Wenn die Funktion vorzeitig abgebrochen wird, wird E_FAIL zurückgegeben
  Result := E_FAIL;

  // In das Vertex-Array werden die Koordinaten und Farben geschrieben
  Vertices[ 0 ].x := 1.0;
  Vertices[ 0 ].y := -1.0;
  Vertices[ 0 ].z := 0.0;
  Vertices[ 0 ].color := $FFFF0000;

  Vertices[ 1 ].x := -1.0;
  Vertices[ 1 ].y := -1.0;
  Vertices[ 1 ].z := 0.0;
  Vertices[ 1 ].color := $FF0000FF;

  Vertices[ 2 ].x := 0.0;
  Vertices[ 2 ].y := 1.0;
  Vertices[ 2 ].z := 0.0;
  Vertices[ 2 ].color := $FFFFFFFF;

  // Erstellen des Vertexbuffers
  if ( d3ddev9.CreateVertexBuffer( sizeof( CUSTOMVERTEX ) * 3, 0, D3DFVF_CUSTOMVERTEX,
    D3DPOOL_DEFAULT, vbuffer,nil ) <> D3D_OK ) then Exit;

  if ( vbuffer.Lock( 0, sizeof(vertices),pVertices, 0 ) <> D3D_OK ) then Exit;
  Move( Vertices, pVertices^, sizeof( Vertices ) );
  vbuffer.Unlock;


end;

procedure tform1.d3d_initialisieren;
begin
  d3d9:= Direct3DCreate9( D3D_SDK_VERSION );
  if d3d9 = nil then
    exit;
end;

{$R *.dfm}

procedure TForm1.OnIdle(Sender: TObject; var done: boolean);
var i:idirect3dvertexshader9;
begin
done:= false;
  // den Backbuffer löschen
  d3dDev9.Clear( 0, nil, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0, 0 );

  // Rendern der Szene
  d3dDev9.BeginScene;

  // Rendern des Vertexbuffers
  d3dDev9.SetStreamSource( 0, vBuffer,0, sizeof( CUSTOMVERTEX ) );
  d3dDev9.SetVertexShader(i);
  d3dDev9.DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

  // Ende des Renderns
  d3ddev9.EndScene;

  // Den Backbuffer mit dem Frontbuffer vertauschen.
  d3ddev9.Present(nil, nil, panel1.Handle , nil);
end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 if vbuffer <> NIL then vbuffer := NIL;
 if d3ddev9 <> NIL then d3ddev9 := NIL;
 if d3d9 <> NIL then d3d9:= NIL;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  d3ddm : TD3DDISPLAYMODE;
  d3dpp : TD3DPRESENT_PARAMETERS;
  DeviceTypeFlag : Cardinal;

begin
  d3d_initialisieren;

 // Auslesen der aktuellen Bildschirmeinstellungen (Auflösung, Format, Refreshrate)
 if ( d3d9.GetAdapterDisplayMode( D3DADAPTER_DEFAULT, d3ddm ) <> D3D_OK ) then
    Application.Terminate;

// Alle Werte des Records d3dpp werden auf 0 bzw Nil gestellt
  ZeroMemory( @d3dpp, sizeof( d3dpp ) );

// Das zukünftige Device wird über das Record eingestellt
  d3dpp.Windowed := TRUE;
  d3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;
  d3dpp.BackBufferFormat := d3ddm.Format;
  d3dpp.EnableAutoDepthStencil := TRUE;
  d3dpp.AutoDepthStencilFormat := D3DFMT_D16;

// Das Device wird erstellt
  if ( d3d9.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Handle,
        D3DCREATE_SOFTWARE_VERTEXPROCESSING,
        d3dpp, d3ddev9 ) <> D3D_OK ) then
    Application.Terminate;

  form1.initgeometrie;

//lichtberechnung aus
  d3ddev9.SetRenderState( D3DRS_LIGHTING, Cardinal( FALSE ) );
// Initialisierungsbefehle für die schleifenprocedure
  Application.OnIdle:= OnIdle;

end;

end.


ich denke mal das die lösung der aufgabe und meines problemes in dem setvertexshader liegen. sollte es auch andere möglichkeiten geben ein billiges dreieck per directx9 zu rendern (in einem window) währe ich auch nicht abgeneigt. ich würde mich auch über tuts freuen.