Changeset 443 for GraphicTest/UMainForm.pas
- Timestamp:
- Nov 22, 2012, 12:28:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/UMainForm.pas
r442 r443 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 9 ExtCtrls, StdCtrls, DateUtils, UPlatform, LCLType, IntfGraphics, fpImage, 10 Math, GraphType, Contnrs, LclIntf, Spin, UFastBitmap, UDrawMethod 11 {$IFDEF opengl}, GL, OpenGLContext{$ENDIF}; 10 Math, GraphType, Contnrs, LclIntf, Spin, UFastBitmap, UDrawMethod; 12 11 13 12 const … … 24 23 ButtonSingleTest: TButton; 25 24 FloatSpinEdit1: TFloatSpinEdit; 26 Image1: TImage;27 25 Label1: TLabel; 28 26 Label2: TLabel; 29 27 ListViewMethods: TListView; 30 PageControl1: TPageControl;31 PaintBox1: TPaintBox;32 TabSheet1: TTabSheet;33 TabSheet2: TTabSheet;34 TabSheet3: TTabSheet;35 28 Timer1: TTimer; 36 29 procedure ButtonBenchmarkClick(Sender: TObject); 37 30 procedure ButtonSingleTestClick(Sender: TObject); 38 31 procedure ButtonStopClick(Sender: TObject); 39 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);40 32 procedure FormCreate(Sender: TObject); 41 33 procedure FormDestroy(Sender: TObject); 42 34 procedure FormShow(Sender: TObject); 35 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 43 36 procedure ListViewMethodsData(Sender: TObject; Item: TListItem); 44 37 procedure ListViewMethodsSelectItem(Sender: TObject; Item: TListItem; … … 46 39 procedure Timer1Timer(Sender: TObject); 47 40 private 48 {$IFDEF opengl}49 OpenGLControl1: TOpenGLControl;50 TextureId: GLuint;51 TextureData: Pointer;52 {$ENDIF}53 41 MethodIndex: Integer; 54 42 SingleTestActive: Boolean; 55 43 AllTestActive: Boolean; 56 procedure OpenGLControl1Resize(Sender: TObject);57 {$IFDEF opengl}58 procedure InitGL;59 {$ENDIF}60 44 procedure UpdateMethodList; 61 45 procedure UpdateInterface; 62 46 public 47 FrameSize: TPoint; 63 48 DrawMethods: TObjectList; // TObjectList<TDrawMethod> 64 Bitmap: TBitmap;65 49 Scenes: TObjectList; // TObjectList<TFastBitmap> 66 50 SceneIndex: Integer; … … 73 57 74 58 {$R *.lfm} 59 60 uses 61 UDrawForm; 62 75 63 76 64 { TMainForm } … … 82 70 I: Integer; 83 71 begin 84 TabSheet1.DoubleBuffered := True;72 FrameSize := Point(320, 240); 85 73 Randomize; 86 74 Scenes := TObjectList.Create; 87 75 for I := 0 to SceneFrameCount - 1 do begin 88 76 NewScene := TFastBitmap.Create; 89 NewScene.Size := Point(320, 240);77 NewScene.Size := FrameSize; 90 78 NewScene.RandomImage; 91 79 Scenes.Add(NewScene); 92 80 end; 93 Bitmap := TBitmap.Create;94 Bitmap.PixelFormat := pf24bit;95 Image1.Picture.Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y);96 Image1.Picture.Bitmap.PixelFormat := pf24bit;97 Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y);98 99 {$IFDEF opengl}100 OpenGLControl1 := TOpenGLControl.Create(Self);101 with OpenGLControl1 do begin102 Name := 'OpenGLControl1';103 Parent := TabSheet3;104 SetBounds(0, 0, 320, 240);105 InitGL;106 //OnPaint := OpenGLControl1Paint;107 OnResize := OpenGLControl1Resize;108 end;109 GetMem(TextureData, OpenGLControl1.Width * OpenGLControl1.Height * SizeOf(Integer));110 {$ENDIF}111 81 112 82 DrawMethods := TObjectList.Create; 113 83 for I := 0 to High(DrawMethodClasses) do begin 114 84 NewDrawMethod := DrawMethodClasses[I].Create; 115 NewDrawMethod.Bitmap := Image1.Picture.Bitmap;116 NewDrawMethod.PaintBox := PaintBox1;117 {$IFDEF opengl}118 NewDrawMethod.OpenGLBitmap := TextureData;119 NewDrawMethod.OpenGLControl := OpenGLControl1;120 {$ENDIF}121 NewDrawMethod.Init;122 85 DrawMethods.Add(NewDrawMethod); 123 86 end; … … 136 99 if MethodIndex >= 0 then 137 100 with TDrawMethod(DrawMethods[MethodIndex]) do begin 138 PageControl1.TabIndex := Integer(PaintObject);101 Init(DrawForm, FrameSize); 139 102 Application.ProcessMessages; 140 103 repeat … … 145 108 StepDuration := NowPrecise - StepStartTime; 146 109 until not SingleTestActive; 110 Done; 147 111 end; 148 112 finally … … 156 120 var 157 121 I: Integer; 158 C: Integer;159 122 StartTime: TDateTime; 160 123 StepStartTime: TDateTime; … … 167 130 for I := 0 to DrawMethods.Count - 1 do 168 131 with TDrawMethod(DrawMethods[I]) do begin 132 Init(DrawForm, FrameSize); 169 133 MethodIndex := I; 170 PageControl1.TabIndex := Integer(PaintObject);171 134 StartTime := NowPrecise; 172 135 repeat … … 177 140 StepDuration := NowPrecise - StepStartTime; 178 141 until ((NowPrecise - StartTime) > OneSecond * FloatSpinEdit1.Value) or not AllTestActive; 142 Done; 179 143 end; 180 144 finally … … 199 163 begin 200 164 ListViewMethods.Clear; 201 {$IFDEF opengl}FreeMem(TextureData, OpenGLControl1.Width * OpenGLControl1.Height);{$ENDIF}202 165 FreeAndNil(DrawMethods); 203 166 FreeAndNil(Scenes); 204 FreeAndNil(Bitmap);205 167 end; 206 168 … … 209 171 UpdateMethodList; 210 172 UpdateInterface; 173 DrawForm.Show; 211 174 end; 212 175 … … 238 201 end; 239 202 240 procedure TMainForm.OpenGLControl1Resize(Sender: TObject);241 begin242 {$IFDEF opengl}243 glViewport(0, 0, OpenGLControl1.Width, OpenGLControl1.Height);244 {$ENDIF}245 end;246 247 {$IFDEF opengl}248 procedure TMainForm.InitGL;249 begin250 glMatrixMode(GL_PROJECTION);251 glLoadIdentity;252 glOrtho(0, OpenGLControl1.Width, OpenGLControl1.Height, 0, 0, 1);253 // glOrtho(0, 1, 1, 0, 0, 1);254 glMatrixMode(GL_MODELVIEW);255 glLoadIdentity();256 glDisable(GL_DEPTH_TEST);257 glViewport(0, 0, OpenGLControl1.Width, OpenGLControl1.Height);258 //gluPerspective( 45.0, (GLfloat)(OpenGLControl1.Width)/(GLfloat)(OpenGLControl1.Height), 0.1f, 500.0 );259 260 //glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);261 //glTranslatef (0.0, 0.0,-3.0);262 // glClearColor(0.0, 0.0, 0.0, 1.0);263 264 glGenTextures(1, @TextureId);265 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);266 end;267 {$ENDIF}268 269 203 procedure TMainForm.UpdateMethodList; 270 204 begin
Note:
See TracChangeset
for help on using the changeset viewer.