Skip to content

Commit

Permalink
beauty colors, wait method
Browse files Browse the repository at this point in the history
  • Loading branch information
MrShoor committed Sep 1, 2016
1 parent de3a2b3 commit 1d1449f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions untmain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
for k := 0 to ACounts.z - 1 do
begin
inst.aiPosition := Vec(i, j, k) * 4 + offset;
inst.aiColor := Vec(Random, Random, Random, 0);
inst.aiColor := Vec(i/ACounts.x, j/ACounts.y, k/ACounts.z, 0);
instances.Add(inst);
end;
Result := instances as IVerticesData;
Expand Down Expand Up @@ -260,22 +260,30 @@ procedure TfrmMain.RenderScene(ASender: TObject);
var
i: Integer;
currentTime, dTime: Int64;
WaitMethod: Integer;
begin
WaitMethod := 0;
if rbQueryEvent.Checked then
WaitMethod := 1
else
if rbGenerateMips.Checked then
WaitMethod := 2;

if FCtx = nil then Exit;
if FCtx.Bind then
try
if rbQueryEvent.Checked then SyncQueryWaitEvent;
if rbGenerateMips.Checked then SyncTexWaitEvent;
ProcessInputMessages;

FCtx.Clear(Vec(0,0,0,0));
case WaitMethod of //ждем евента
1: SyncQueryWaitEvent;
2: SyncTexWaitEvent;
end;
FCtx.States.DepthTest := True;

FFrame.FrameRect := RectI(0, 0, FCtx.WindowSize.x, FCtx.WindowSize.y);
FFrame.Select();
FFrame.Clear(0, Vec(0.0,0.2,0.4,0));
FFrame.ClearDS(FCtx.Projection.DepthRange.y);

ProcessInputMessages; //собираем свежие Input данные
FShader.Select;
FShader.SetAttributes(FBuffer, nil, FInstances);
FShader.SetUniform('CycleCount', tbCycle.Position*1.0);
Expand All @@ -284,9 +292,10 @@ procedure TfrmMain.RenderScene(ASender: TObject);

FFrame.BlitToWindow(0);

if rbQueryEvent.Checked then SyncQuerySetEvent;
if rbGenerateMips.Checked then SyncTexSetEvent;

case WaitMethod of //устанавливаем евент
1: SyncQuerySetEvent;
2: SyncTexSetEvent;
end;
FRawSwapChain.Present(0,0);
finally
FCtx.Unbind;
Expand Down

0 comments on commit 1d1449f

Please sign in to comment.