-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed0e816
commit 7b217d4
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace VISU\Graphics\Rendering\Pass; | ||
|
||
use Closure; | ||
use VISU\FlyUI\FlyUI; | ||
use VISU\Graphics\Rendering\PipelineContainer; | ||
use VISU\Graphics\Rendering\PipelineResources; | ||
use VISU\Graphics\Rendering\RenderPass; | ||
use VISU\Graphics\Rendering\RenderPipeline; | ||
use VISU\Graphics\Rendering\Resource\RenderTargetResource; | ||
|
||
class FlyUIPass extends RenderPass | ||
{ | ||
public function __construct( | ||
private RenderTargetResource $renderTargetRes, | ||
private Closure $uiRenderCallback, | ||
) | ||
{ | ||
} | ||
|
||
/** | ||
* Executes the render pass | ||
*/ | ||
public function setup(RenderPipeline $pipeline, PipelineContainer $data): void | ||
{ | ||
$pipeline->writes($this, $this->renderTargetRes); | ||
} | ||
|
||
/** | ||
* Executes the render pass | ||
*/ | ||
public function execute(PipelineContainer $data, PipelineResources $resources): void | ||
{ | ||
$renderTarget = $resources->getRenderTarget($this->renderTargetRes); | ||
|
||
// activate the render target | ||
$resources->activateRenderTarget($this->renderTargetRes); | ||
|
||
// begin a FlyUI frame | ||
FlyUI::beginFrame($renderTarget->effectiveSizeVec(), $renderTarget->contentScaleX); | ||
|
||
// execute the UI render callback | ||
($this->uiRenderCallback)(); | ||
|
||
// end the FlyUI frame | ||
FlyUI::endFrame(); | ||
|
||
// reset the GL state as the VGContext might have changed it | ||
$resources->gl->reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace VISU\Graphics\Rendering\Renderer; | ||
|
||
use Closure; | ||
use GL\VectorGraphics\VGContext; | ||
use VISU\FlyUI\FlyUI; | ||
use VISU\Graphics\Rendering\Pass\FlyUIPass; | ||
use VISU\Graphics\Rendering\RenderPipeline; | ||
use VISU\Graphics\Rendering\Resource\RenderTargetResource; | ||
use VISU\Graphics\Rendering\Resource\TextureResource; | ||
use VISU\OS\Input; | ||
use VISU\Signal\Dispatcher; | ||
|
||
class FlyUIRenderer | ||
{ | ||
/** | ||
* Constructor | ||
*/ | ||
public function __construct( | ||
private VGContext $vg, | ||
private Dispatcher $dispatcher, | ||
private Input $input, | ||
) | ||
{ | ||
FlyUI::initailize($vg, $dispatcher, $input); | ||
FlyUI::$instance->setSelfManageVGContext(true); | ||
} | ||
|
||
/** | ||
* Attaches a render pass to the pipeline | ||
* | ||
* @param RenderPipeline $pipeline | ||
* @param RenderTargetResource $renderTarget | ||
* @param TextureResource $depthTexture | ||
*/ | ||
public function attachPass( | ||
RenderPipeline $pipeline, | ||
RenderTargetResource $renderTarget, | ||
Closure $uiRenderCallback | ||
) : void | ||
{ | ||
$pipeline->addPass(new FlyUIPass( | ||
$renderTarget, | ||
$uiRenderCallback | ||
)); | ||
} | ||
} |