Autor Beitrag
Borlox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Mi 29.01.03 22:44 
Hi Leute,

ich habe nach dem Tutorial von Shadow einen Würfel in OpenGL programiert, es klappt auch alles, aber ca. alle 2 Sekunden stockt es kurz und dann geht es weiter!
Zufällig habe ich es letztens noch einmal gestartet, nachdem ich ein anderes Spiel gespielt hatte und da lief dann das Programm flüssig!
Kann ja eigentlich nicht sein, dass da was ruckelt, bei nur einem Würfel!
Habe 1800 MHz, GeForce 3 usw. ! Müsste eigentlich klappen!

Hat jemand eine Idee, woran das liegen könnte, oder ob man noch etwas anderes freigeben oder initialisieren muss???

Danke
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 29.01.03 23:43 
Hi,

also wenn es mal flüssig geht und mal nich... dann liegt es sehr wahrscheinlich an den Treibern.. :)
Lad dir mal die neuesten Treiber für deine grafikkarte runter (Wahrscheinlich Detonator.. :) )

Au'revoir,
Aya~
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Mi 29.01.03 23:48 
Titel: Grafik
Naja, das habe ich vor kurzem auch schon mal gemacht! Hat nichts geholfen! Aber wenn das an den Treibern liegen würde, dann würden sicherlich so Spiele wie Half-Life oder Unreal Tournament 2003 auch nicht richtig laufen! Und die laufen alle flüssig!

Ich finde es ja auch sehr eigenartig!

Mir ist gerade eingefallen, das ich das Problem mit DelphiX auch schon mal hatte!
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Do 30.01.03 14:06 
Das könnte auch auf einen Fehler in der Gameloop hindeuten. Ich kenne Shadows Tutoriale nicht, aber könntest du vielleicht die Gameloop mal posten?

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
Boromir
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 45



BeitragVerfasst: Do 30.01.03 16:29 
Titel: MeinCode
Hier mein Code:
Sollte richtig sein?

ausblenden volle Höhe 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:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OpenGL, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
   procedure OnIdle(Sender:TObject;var Done:Boolean);
    { Private declarations }
  end;

var
  Form1: TForm1;
  DC:HDC;
  RC:HGLRC;
  Framerate:Integer;

implementation

{$R *.dfm}

procedure TForm1.onidle(Sender:TObject;var Done:Boolean); 
begin 
  Done:=FALSE;
  inc(framerate);
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glRotatef(2,0,0,1);
  glBegin(GL_QUADS); 
    glVertex3f(-1,-1, 1); 
    glVertex3f( 1,-1, 1); 
    glVertex3f( 1, 1, 1); 
    glVertex3f(-1, 1, 1); 

    glVertex3f(-1,-1,-1);
    glVertex3f(-1, 1,-1); 
    glVertex3f( 1, 1,-1); 
    glVertex3f( 1,-1,-1); 

    glVertex3f(-1, 1,-1); 
    glVertex3f(-1, 1, 1); 
    glVertex3f( 1, 1, 1); 
    glVertex3f( 1, 1,-1); 

    glVertex3f(-1,-1,-1); 
    glVertex3f( 1,-1,-1); 
    glVertex3f( 1,-1, 1); 
    glVertex3f(-1,-1, 1); 

    glVertex3f( 1,-1,-1); 
    glVertex3f( 1, 1,-1); 
    glVertex3f( 1, 1, 1); 
    glVertex3f( 1,-1, 1); 
    
    glVertex3f(-1,-1,-1); 
    glVertex3f(-1,-1, 1); 
    glVertex3f(-1, 1, 1); 
    glVertex3f(-1, 1,-1); 
  glEnd; 
  SwapBuffers(DC);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
application.terminate;
end;

procedure TForm1.Timer1Timer(Sender: TObject); 
begin
  form1.Caption:='FPS: '+inttostr(framerate);
  framerate:=0;
end;

procedure TForm1.FormCreate(Sender: TObject);
var 
  pfd:TPixelFormatDescriptor; 
  p:Integer; 
begin
  Application.OnIdle:=Form1.OnIdle;
  fillchar(pfd,sizeof(pfd),0); 
  DC:=getDC(Form1.Handle); 
  pfd.cDepthBits:=16; 
  pfd.cColorBits:=16; 
  pfd.dwFlags:=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER; 
  p:=choosePixelFormat(DC,@pfd);
  setPixelFormat(DC,p,@pfd);
  RC:=wglCreateContext(DC);
  wglMakeCurrent(DC,RC);
  glClearColor(0,0,0,0);
  glEnable(GL_DEPTH_TEST);

  glTranslatef(0,0,-1);
  glTranslatef(0,0,-1);
  glTranslatef(0,0,-1);
  glTranslatef(0,0,-1);
  glTranslatef(0,0,-1);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  wglMakeCurrent(DC,0); 
  wglDeleteContext(RC); 
  releaseDC(0,DC); 
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  glViewPort(0,0,clientwidth,clientheight);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity; 
  gluPerspective(45,clientwidth/clientheight,0.1,100);
  glMatrixMode(GL_MODELVIEW);
end;

end.
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Fr 31.01.03 14:31 
Oha, du führst also den Rendercode im OnIdle-Event aus.
Schon mal überlegt, was passiert, wenn das Programm einfach nicht Idle ist? Dieser Event wird nur ausgelöst, wenn keine Window-Message auf Verarbeitung wartet. Wenn jetzt aber eine ganze Menge Nachrichten warten, aus welchem Grund auch immer, wird OnIdle nicht so schnell ausgelöst.

Vielleicht solltest du nicht den OnIdle-Event verwenden, sondern die Messageloop selbst schreiben.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Fr 31.01.03 15:28 
Titel: ??
Ehrlich gesagt, habe ich gar keine Ahnung wozu das OnIdle Ereigniss eigentlich ist! Habe es halt nur abgeschrieben!
Wie funktioniert das mit der Messageloop? Habe keine Ahnung, wie ich das schreiben soll??

Danke
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 31.01.03 15:47 
im onidle stimmts schon, wenn man mit VCL arbeitet...

das wird immer dann aufgerufen, wenn gerade nichts anderes zu tun ist, was allen speicher verbraucht...
das ist aber eigentlich immer der Fall...

du solltest am ende der onidle prozedur aber noch ein done:=true einfügen...

schau mal auf
[url]www.delphigl.com[/url]!!!

Fiji-Fighter
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 31.01.03 15:57 
noch was:
du solltest das ganze im applicationoneventsidle machen!
habs gerade net gesehen...
keine Ahnung obs daran liegt aber ist wohl besser:

ausblenden Quelltext
1:
2:
3:
4:
5:
formcreate
begin
...
application.OnIdle := deineonidleprozedur;
end;


deineonidleprozedur wird also immer dann ausgeführt wenn nichts zu tun ist...

wie gesagt schau dir mal die Tuts auf der Page an...

Fiji-Fighter
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Fr 31.01.03 18:39 
@Fiji-Fighter: WENN er schon das OnIdle-Event verwendet, sollte er, wie er korrekt abgeschrieben hat, Done auf false setzen, damit OnIdle erneut aufgerufen wird.

@Borlox: Schau dir ein beliebiges WinAPI-Programm an (oder der Delphianer sagt dazu nonVCL), oder einfach mal im MSDN unter Message Loop mit PeekMessage oder so.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 31.01.03 21:13 
Zitat:
WENN er schon das OnIdle-Event verwendet, sollte er, wie er korrekt abgeschrieben hat, Done auf false setzen, damit OnIdle erneut aufgerufen wird


ja das stimmt natürlich net was ich da erzählt habe...

kA was da in mich gefahren ist ;)

Fiji-Fighter