Ignore:
Timestamp:
Mar 20, 2011, 7:18:27 PM (14 years ago)
Author:
george
Message:
  • Added: OpenGL PBO method.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UMainForm.pas

    r211 r212  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    99  ExtCtrls, StdCtrls, DateUtils, UPlatform, LCLType, IntfGraphics, fpImage,
    10   Math, GraphType, Contnrs, LclIntf, UFastBitmap, UDrawMethod, GL, OpenGLContext;
     10  Math, GraphType, Contnrs, LclIntf, Spin, UFastBitmap, UDrawMethod, GL,
     11  OpenGLContext;
    1112
    1213const
     
    2324    ButtonStop: TButton;
    2425    ComboBox1: TComboBox;
     26    FloatSpinEdit1: TFloatSpinEdit;
    2527    Image1: TImage;
    2628    Label1: TLabel;
     
    4749    TextureId: GLuint;
    4850    TextureData: Pointer;
     51    MethodIndex: Integer;
    4952    procedure OpenGLControl1Resize(Sender: TObject);
    5053    procedure InitGL;
     
    104107    NewDrawMethod.OpenGLBitmap := TextureData;
    105108    NewDrawMethod.OpenGLControl := OpenGLControl1;
     109    NewDrawMethod.Init;
    106110    DrawMethods.Add(NewDrawMethod);
    107111    ComboBox1.Items.Add(NewDrawMethod.Caption);
     
    112116procedure TMainForm.ButtonStartClick(Sender: TObject);
    113117begin
     118  MethodIndex := ComboBox1.ItemIndex;
    114119  ButtonStop.Enabled := True;
    115120  ButtonStart.Enabled := False;
    116121  Timer1.Enabled := True;
    117   if ComboBox1.ItemIndex >= 0 then
    118   with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin
     122  if MethodIndex >= 0 then
     123  with TDrawMethod(DrawMethods[MethodIndex]) do begin
    119124    PageControl1.TabIndex := Integer(PaintObject);
    120125    Application.ProcessMessages;
     
    132137  NewItem: TListItem;
    133138  I: Integer;
    134 begin
     139  C: Integer;
     140  StartTime: TDateTime;
     141begin
     142  Timer1.Enabled := True;
    135143  with ListView1, Items do
    136144  try
    137     BeginUpdate;
     145    //BeginUpdate;
    138146    Clear;
    139147    for I := 0 to DrawMethods.Count - 1 do
    140148    with TDrawMethod(DrawMethods[I]) do begin
     149      MethodIndex := I;
    141150      PageControl1.TabIndex := Integer(PaintObject);
    142       Application.ProcessMessages;
    143       DrawFrameTiming(TFastBitmap(Scenes[0]));
    144       Application.ProcessMessages;
    145       DrawFrameTiming(TFastBitmap(Scenes[0]));
     151      StartTime := NowPrecise;
     152      repeat
     153        DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));
     154        SceneIndex := (SceneIndex + 1) mod Scenes.Count;
     155        Application.ProcessMessages;
     156      until (NowPrecise - StartTime) > OneSecond * FloatSpinEdit1.Value;
    146157      NewItem := Add;
    147158      NewItem.Caption := Caption;
     
    150161    end;
    151162  finally
    152     EndUpdate;
     163    //EndUpdate;
    153164  end;
    154165end;
     
    175186procedure TMainForm.Timer1Timer(Sender: TObject);
    176187begin
    177   if (ComboBox1.ItemIndex >= 0) then
    178   with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin
     188  if (MethodIndex >= 0) then
     189  with TDrawMethod(DrawMethods[MethodIndex]) do begin
    179190    if (FrameDuration > 0) then
    180191      Label2.Caption := FloatToStr(RoundTo(1 / (FrameDuration / OneSecond), -3))
     
    194205  glLoadIdentity;
    195206  glOrtho(0, OpenGLControl1.Width, OpenGLControl1.Height, 0, 0, 1);
     207//  glOrtho(0, 1, 1, 0, 0, 1);
    196208  glMatrixMode(GL_MODELVIEW);
    197209  glLoadIdentity();
Note: See TracChangeset for help on using the changeset viewer.