Autor Beitrag
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Fr 12.12.03 18:23 
Okay, Ich habe ein Tutorial für Opengl
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
glLoadIdentity;
glTranslatef(-1.5,0,0);
glTranslatef(0,0,-6);
glBegin(GL_TRIANGLES);
  glColor3f(1,0,0);
  glVertex3f(-1.0,-1.0, 0.0);
  glColor3f(0,1,0);
  glVertex3f( 0.0, 1.0, 0.0);
  glColor3f(0,0,1);
  glVertex3f( 1.0,-1.0, 0.0);
glEnd();


Der Code soll ein Dreieck erzeugen. Ich habe es in der OnPaint des Form eingesetzt, bei uses opengl angegeben. Obwohl Delphi 6 kein Fehler ausgibt, ist nichts zu sehen. Kann mir ein sagen wieso? und wie man dies beheben kann.
Danke im Voraus

Moderiert von user profile iconPeter Lustig: verschoben; Code- durch Delphi-Tags ersetzt
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 12.12.03 18:29 
IMO müsste da irgendwo ein

ausblenden Delphi-Quelltext
1:
SwapBuffers(canvas.handle);					


oder

ausblenden Delphi-Quelltext
1:
glFlush();					


hin. Und vorher sollte OpenGL noch anständig initialisiert werden.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 12.12.03 19:31 
außerdem ist es sehr schlecht im OnPaint das ganze zu zeichnen..
mach das im OnIdle Ereignis oder in einer renderloop/schleife...

Referenzen und Tutrials dazu:
www.delphigl.com
www.delphigl.de

hier im Forum unter Tutorials

und nehe.gamedev.net
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Sa 13.12.03 16:32 
Titel: Gleiches Problem
Danke erstmal für die Tips und Tutorials.
Leider ist das Problem nicht behoben worden. Delphi gibt keinen Fehler aus, das Form wird erstellt und das wars dann auch schon. Kein Erbegnis auf Gl zeichen Operationen. :oops:
Kann mir jemand vieleicht das Fertige Programm aus dem Tutorial schicken? Wäre nett, dann könnte Ich vergleichen.
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 13.12.03 16:52 
Zeig doch mal deinen Quellcode her. Und welcher Fehler wird ausgegeben?
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Sa 13.12.03 19:27 
Titel: der Code
Hier ist der Code, so wie er im Tutorial steht:
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:
unit OpenGltest;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,opengl12, StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure SetDCPixelFormat(Handle: HDC);
    procedure InitGL;
    procedure DrawScene;
    procedure ApplicationEvents1Idle(Sender: TObject;
  var Done: Boolean);

  
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
   h_DC: hDC;
   hRC: HGLRC;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
InitOpenGL;
h_DC:=GetDC(Handle);
SetDCPixelFormat(h_DC);
hRC:=wglCreateContext(h_DC);
wglMakeCurrent(h_DC,hRC);
glTranslate(0,0,-5); 
glBegin(GL_QUADS); 
  glColor3f(1,0,0);  //Rot 
  glVertex3f(1,-1,0); 
  glColor3f(1,1,0);  //Gelb 
  glVertex3f(1,1,0); 
  glColor3f(0,1,0);  //Grün 
  glVertex3f(-1,1,0); 
  glColor3f(0,0,1);  //Blau 
  glVertex3f(-1,-1,0); 
glEnd;
end;

procedure tform1.SetDCPixelFormat(Handle: HDC);
var
 nPixelFormat: GLUint;
const
 pfd: PIXELFORMATDESCRIPTOR = (
      nSize: sizeof( PIXELFORMATDESCRIPTOR );
      nVersion: 1;
      dwFlags: PFD_DRAW_TO_WINDOW
       or PFD_SUPPORT_OPENGL
       or PFD_DOUBLEBUFFER;
      iPixelType: PFD_TYPE_RGBA;
      cColorBits: 16;
      cRedBits: 0;
      cRedShift: 0;
      cGreenBits: 0;
      cBlueBits: 0;
      cBlueShift: 0;
      cAlphaBits: 0;
      cAlphaShift: 0;
      cAccumBits: 0;
      cAccumRedBits: 0;
      cAccumGreenBits: 0;
      cAccumBlueBits: 0;
      cAccumAlphaBits: 0;
      cDepthBits: 16;
      cStencilBits: 0;
      cAuxBuffers: 0;
      iLayerType: PFD_MAIN_PLANE;
      bReserved: 0;
      dwLayerMask: 0;
      dwVisibleMask: 0;
      dwDamageMask: 0
    );
begin
nPixelFormat:=ChoosePixelFormat(h_DC, @pfd);
SetPixelFormat(h_DC,nPixelFormat,@pfd);
end;

procedure TForm1.InitGL;
begin
  glClearColor(0,0,0,0);
  glClearDepth(1);
  glDepthFunc(GL_LESS);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_DEPTH_TEST);

  glViewport(0,0,Width,Height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;
  gluPerspective(45,Width/Height,1,100);
  glMatrixMode(GL_MODELVIEW);
end;

procedure TForm1.DrawScene;
begin
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glLoadIdentity;
  //Hier wird später die Scene gezeichnet.

  SwapBuffers(h_DC);
end;

procedure TForm1.ApplicationEvents1Idle(Sender: TObject;
  var Done: Boolean);
begin
  DrawScene;
  Done:=False;
end;


end.

Es wird kein Fehler aus gegeben :oops: .
Phobeus
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1280

Linux (FC6), WinXP Pro (Box)
D6 Pers, D7 Pro, FPC 2.x
BeitragVerfasst: So 14.12.03 12:59 
Aus welchem Tutorial hast Du den das? Ich bezweifel ganz ernsthaft, dass Dir jemand empfohlen hat die Vertexdaten bei einem uninitalisierten Fenster zu zeichnen, danach beim rendern den Buffer.
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
zu löschen und danach nie wieder was zu machen.
Schau Dir mal bei unserer Seite
www.delphigl.com/ unter filez die Templates an!

_________________
"Menschen sterben nicht wenn man sie zu Grabe trägt, sondern wenn sie ihre Träume verlieren..."
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: So 14.12.03 23:22 
Titel: Danke an Phobeus
Jetzt funktioniert es.
Den Code habe ich aus dem diesem Forum. Der Tip kam von Fiji-Fighter. Er sagte
Zitat:
hier im Forum unter Tutorials

Vielleicht habe aber ich das Tutorial missverstanden und dadurch den fehlerhaften Code erzeugt :oops: :oops: :oops:
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mo 15.12.03 00:30 
davon gehe ich aus ;)
ahbe mir das auch mal durchgelesen gehabt und eigentlich hat Aya das richtig beschrieben ;)