Autor Beitrag
Fabian E.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: Mi 06.09.06 19:52 
so... mein pong funktioniert eig soweit ganz gut!
Würde das aber gerne im fullscreen spielen!
funktioniert aber nicht so richtig!
Hab mir gedacht: ok, fear2d hat ne option dafür: Engine.DoFullscreen!
Ausprobiert: klappt nicht! Also eigentlich schon aber statt dem schwarzen hintergrund seh ich nur meine leere form. also ohne zeichenfläche! kann mir jemand sagen wo ich den fullscreen aufrufen muss oder wie ich das sonst hinbekomm?
danke!
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:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
unit UMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,
  F2D_Core,
  F2D_Objects, ExtCtrls;

type
  TMainForm = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
  private
    Engine: TEngine;
    procedure Kollision();
    procedure Neu(Left : Boolean);
  public
    { Public-Deklarationen }
  end;

var
  MainForm: TMainForm;
  Ball, Schlaeger_a, Schlaeger_b : TSimpleObject;
  Forw, back, Left2, Right, Up1, down1, up2, down2, Neu_Left : Boolean;



implementation

{$R *.dfm}

procedure TMainForm.Neu(Left : Boolean);
begin
Neu_Left := false;
If Left Then Neu_Left := true;
Ball.Position.X := clientheight/2;
Ball.Position.y := clientwidth/2;
Forw := false;
back := false;
Left2 := false;
Right := false;
Timer1.Enabled := true;
end;

procedure TMainForm.Kollision();
begin
If Ball.Position.Y >= clientheight-15
Then
    begin
         Forw := False;
         Back := true;
    end;

If Ball.Position.Y <= 5
Then
    begin
         Forw := true;
         Back := false;
    end;

If Ball.Position.x = clientwidth-15
Then
    begin
        Neu(false);
    end;

If Ball.Position.x = 5
Then
    begin
         Neu(true);
    end;

    If Ball.Position.X <= Schlaeger_a.Position.X+15
    Then
        If (ball.Position.y > Schlaeger_a.Position.Y-75) AND (Ball.Position.Y < Schlaeger_a.Position.Y+75)
        Then begin
         right := true;
         left2 := false;
    end;

    If Ball.Position.X >= Schlaeger_b.Position.X-15
    Then
        If (ball.Position.y > Schlaeger_b.Position.Y-75) AND (Ball.Position.Y < Schlaeger_b.Position.Y+75)
        Then begin
          right := false;
          left2 := true
    end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
forw := true;
left2 := true;
Engine := TEngine.Create(false);
Engine.Init(self);

Ball := TSimpleObject.Create;
Schlaeger_a := TSimpleObject.Create;
Schlaeger_b := TSimpleObject.Create;

  with Schlaeger_a do
  begin
  position.X := 20;
  position.Y := clientheight/2;
  z := 0;
  size.X := 15;
  size.Y := 150;
  Color := clred;
  texture := 'schlaeger';
  end;

  with Schlaeger_b do
  begin
  position.X := clientwidth-20;
  position.Y := clientheight/2;
  z := 0;
  size.X := 15;
  size.Y := 150;
  Color := clblue;
  texture := 'schlaeger';
  end;

  with Ball do
  begin
  position.X := clientwidth/2;
  position.Y := clientheight/2;
  z := 0;
  size.X := 50;
  size.Y := 50;
  usealpha := true;
  alpha := 255;
  Color := cllime;
  texture := 'ball';
  end;

  Application.OnIdle := ApplicationEventsIdle;
end;

procedure TMainForm.FormDestroy(Sender: TObject);
begin
Ball.Free;
Schlaeger_A.Free;
Schlaeger_B.Free;
Engine.Free;
end;

procedure TMainForm.ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
begin
if boolean(GetAsyncKeyState(87))
then up1 := true
else up1 := false;

if boolean(GetAsyncKeyState(83))
then down1 := true
else  down1 := false;

if boolean(GetAsyncKeyState(40))
then up2 := true
else  up2 := false;

if boolean(GetAsyncKeyState(38))
then down2 := true
else   down2 := false;
  Engine.DoBegin;

  Engine.TextureManager.AddTexture('ball.tga', 'ball');
  Engine.TextureManager.AddTexture('schlaeger.tga', 'schlaeger');
  Engine.TextureManager.AddTexture('ball.tga', 'ball');
  If Forw Then Ball.Position.Y := Ball.Position.Y +5;
  If Back Then Ball.Position.Y := Ball.Position.Y -5;
  If Right Then Ball.Position.x := Ball.Position.x +5;
  If Left2 Then Ball.Position.x := Ball.Position.x -5;
  If up1 Then Schlaeger_a.Position.Y := Schlaeger_A.Position.Y +20;
  If down1 Then Schlaeger_a.Position.Y := Schlaeger_A.Position.Y -20;
  If up2 Then Schlaeger_b.Position.Y := Schlaeger_b.Position.Y -20;
  If down2 Then Schlaeger_b.Position.Y := Schlaeger_b.Position.Y +20;

  Kollision;
  Ball.Draw(Engine, true);
  Schlaeger_a.Draw(Engine, true);
  Schlaeger_b.Draw(Engine, true);

  MainForm.Caption := 'FPS: ' + floattostr(Engine.FPS);
  Engine.DoEnd;
  Done := false;
end;

procedure TMainForm.Timer1Timer(Sender: TObject);
begin
If Neu_Left
Then begin
Forw := true;
Left2 := true;
end
Else begin
Back := true;
Right := true;
end;
Timer1.Enabled := false;
end;

end.
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Sa 09.09.06 08:52 
Hallo,

also anhand deines Sources kann man dir nicht sagen wo der fehler genau liegt! Aber ich denke es liegt daran das du deine FullScreen mode nicht koreckt auswählst oder OGL dann nicht goreckt initalisierst.

Cu
Neo
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 19.09.06 14:29 
in der neuen version funzt das glaube ich schon, mom ich suche mal eben den qt

das sollten die beiden neuen sein:
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:
procedure TEngine.DoFullscreen;
begin
  with Form do
  begin
    //Ecke oben links
    top := 0;
    left := 0;
    //Volle Größe
    clientwidth := screen.width;
    clientheight := screen.height;
    //Status maximiert
    Windowstate := wsMaximized;
    //Kein Rahmen
    SetWindowLong(Form.Handle, GWL_STYLE, WS_BORDER);
    //StayOnTop
    SetWindowPos(form.handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
  end;
end;

procedure TEngine.DoScreenshot;
type
 BITMAPFILEHEADER = packed record
    bfType: Word;
    bfSize: DWORD;
    bfReserved1: Word;
    bfReserved2: Word;
    bfOffBits: DWORD;
  end;
 
 BITMAPINFOHEADER = packed record
    biSize: DWORD;
    biWidth: Longint;
    biHeight: Longint;
    biPlanes: Word;
    biBitCount: Word;
    biCompression: DWORD;
    biSizeImage: DWORD;
    biXPelsPerMeter: Longint;
    biYPelsPerMeter: Longint;
    biClrUsed: DWORD;
    biClrImportant: DWORD;
  end;
 var
   f: file;
   FileInfo: BITMAPINFOHEADER;
   FileHeader: BITMAPFILEHEADER;
   pPicData:Pointer;
   Viewport: array[0..3] of integer;
   path: string;
   i: integer;
begin
  ZeroMemory(@FileHeader, SizeOf(BITMAPFILEHEADER));
  ZeroMemory(@FileInfo, SizeOf(BITMAPINFOHEADER));

  glGetIntegerv(GL_VIEWPORT, @Viewport);

  //Header
  FileHeader.bfType := 19778; //$4D42 = 'BM'
  FileHeader.bfOffBits := SizeOf(BITMAPINFOHEADER)+SizeOf(BITMAPFILEHEADER);

  //FileInfo
  FileInfo.biSize := SizeOf(BITMAPINFOHEADER);
  FileInfo.biWidth := Viewport[2];
  FileInfo.biHeight := Viewport[3];
  FileInfo.biPlanes := 1;
  FileInfo.biBitCount := 32;
  FileInfo.biSizeImage := FileInfo.biWidth*FileInfo.biHeight*(FileInfo.biBitCount div 8);
  FileHeader.bfSize := FileHeader.bfOffBits + FileInfo.biSizeImage;

  GetMem(pPicData, FileInfo.biSizeImage);
  try
    glReadPixels(0, 0, Viewport[2], Viewport[3], GL_BGRA, GL_UNSIGNED_BYTE, pPicData);
    //Dateiname
    i := 0;
    path := extractfilepath(paramstr(0));
    while fileexists(path + 'screen_' + inttostr(i) + '.bmp') do
      inc(i);
    AssignFile(f, path + 'screen_' + inttostr(i) + '.bmp');
    Rewrite(f, 1);
    try
      //Schreiben
      BlockWrite(F, FileHeader, SizeOf(BITMAPFILEHEADER));
      BlockWrite(F, FileInfo, SizeOf(BITMAPINFOHEADER));
      BlockWrite(F, pPicData^, FileInfo.biSizeImage );
    finally
      //Schließen
      CloseFile(f);
    end;
  finally
    //Freigeben
    FreeMem(pPicData, FileInfo.biSizeImage);
  end;
end;


wiki.delphigl.com/in...p/Timebased_Movement

wobei das schon in der engine eingebaut ist unter Engine.Timestep da bekommst du einfach den wert mit dem du integrieren musst.


mfg
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: So 24.09.06 01:06 
Hallo,

also das was du mit DoFullScreen machst ist nicht wriklich FullScreen in dem Sinne! Du weitest nur das Fenster auf die Desktop Dimensionen aus. Aber Window kann auch richtigen FullScreen. Sprich dein Programm hat expliziten zugriff auf den Monitor. Denn must du aber per Hand Initzialisieren und das OpenGL natürlich auch mitteilen!
ausblenden 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:
Procedure SetScreen(vSizeX, vSizeY: Integer; vColorDepth: Integer);
 Var
  Dev: tDevMode;
 Begin
  If (vSizeX=0) or (vSizeY=0) or (vColorDepth=0) Then
   Begin
    ChangeDisplaySettings(tDevMode(NIL^), 0);
    Exit;
   End;
  ZeroMemory(@Dev, SizeOf(Dev));
  Dev.dmSize:=SizeOf(Dev);
  Dev.dmPelsWidth:=vSizeX;
  Dev.dmPelsHeight:=vSizeY;
  Dev.dmFields:=dm_PelsWidth or
                dm_PelsHeight or
                dm_BitsPerPel;
  If (ChangeDisplaySettings(Dev, cds_FullScreen) = Disp_Change_Failed) Then
    ExitApp('Base.PAS', 'none', 'SetScreen', '', 'Bildschirmauflösung konnte nicht geändert werden.', dtWarning, '');
 End;

Procedure tWindow3D.CreateRenderContext;
 Begin
  If Not(RenderContext=0) Then
    Error('Ref_GL\Window3D.PAS', 'tWindow3D', 'CreateRenderContext', GetClassInfoForDebug, 'Es kann pro Fenster nur ein Render Kontext erzeugt werden.', dtFatal, '');
  RenderContext:=wglCreateContext(DeviceContext);
  If (RenderCOntext=0) Then
    Error('Ref_GL\Window3D.PAS', 'tWindow3D', 'CreateRenderContext', GetClassInfoForDebug, 'Der OpenGL Render Kontext konnte nicht erzeugt werden.', dtFatal, '');
  UseRenderContext;
 End;


So ungefäir habe hier nur ein par sehr alte Functionen aus einem Project von mir aber es sollte ungefäir zeigen wie es gehen sollte.

Cu
Neo
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 24.09.06 08:07 
ok, danke werd's mir für zukünftige versionen anschauen ;)