Skip to content

Commit a90a60c

Browse files
committed
Fix RenderTexturePass flip flag and VideoPlayer control buttons draw
1 parent ff35f81 commit a90a60c

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

axmol/renderer/RenderTexturePass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class AX_DLL RenderTexturePass : public Object
230230
Renderer* _renderer{nullptr};
231231
RenderTexture* _renderTexture{nullptr}; // weak ref
232232
bool _active{false};
233-
bool _autoFlipY{false};
233+
bool _autoFlipY{true};
234234

235235
// When enabled, begin() temporarily overrides the visiting camera and applies
236236
// backend-specific projection adjustments when needed. end() restores the

axmol/ui/VideoPlayer.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# include "axmol/platform/FileUtils.h"
3838
# include "axmol/ui/UIHelper.h"
3939
# include "axmol/media/MediaEngine.h"
40+
# include "axmol/scene/Camera.h"
4041
# include "axmol/ui/Button.h"
4142
# include "axmol/ui/LayoutGroup.h"
4243
# include "axmol/tlx/byte_buffer.hpp"
@@ -499,35 +500,37 @@ static void createVideoControlTexture()
499500
auto totalWidth = utils::nextPOT(numItems * panelW + (numItems - 1) * gap + (border * 2));
500501
auto totalHeight = utils::nextPOT(border * 2 + panelH);
501502
auto imageSize = Size(static_cast<float>(totalWidth), static_cast<float>(totalHeight));
502-
auto* node = Node::create();
503+
auto node = Node::create();
503504
node->setContentSize(imageSize);
504505
node->setIgnoreAnchorPointForPosition(false);
505506
node->setAnchorPoint(Anchors::bottomLeft);
506507
node->setPosition(0, 0);
507508
node->addChild(drawNode);
508509

509-
auto* rt = RenderTexture::createForCanvas(Vec2(totalWidth, totalHeight), PixelFormat::RGBA8, PixelFormat::D24S8);
510+
auto rt = RenderTexture::createForCanvas(Vec2(totalWidth, totalHeight), PixelFormat::RGBA8, PixelFormat::D24S8);
511+
auto camera = Camera::createOrthographic(imageSize.width, imageSize.height, -1024.0f, 1024.0f);
512+
camera->setPosition3D(Vec3(imageSize.width * 0.5f, imageSize.height * 0.5f, 0.0f));
510513

511-
{
512-
auto scope = RefPtr<RenderTexturePass>(RenderTexturePass::obtain(rt), tlx::adopt_object);
513-
scope->begin();
514-
scope->clear(ClearFlag::COLOR, {.color = Color(0, 0, 0, 0)});
514+
RefPtr<RenderTexturePass> pass(RenderTexturePass::obtain(rt), tlx::adopt_object);
515+
pass->begin(camera);
516+
pass->clear(ClearFlag::COLOR, {.color = Color(0, 0, 0, 0)});
515517

516-
g_mediaControlTextureRegions.clear();
518+
g_mediaControlTextureRegions.clear();
517519

518-
int i = 0;
519-
for (auto&& item : items)
520-
{
521-
auto midPoint =
522-
Vec2(border + (i * panelW) + (i * gap) + (panelW / 2.f), imageSize.height - border - (panelH / 2.f));
523-
item.second(midPoint);
524-
g_mediaControlTextureRegions[item.first] = Rect(border + (panelW * i) + (gap * i), border, panelW, panelH);
525-
++i;
526-
}
520+
int i = 0;
521+
for (auto&& item : items)
522+
{
523+
auto midPoint =
524+
Vec2(border + (i * panelW) + (i * gap) + (panelW / 2.f), imageSize.height - border - (panelH / 2.f));
525+
item.second(midPoint);
527526

528-
node->visit();
529-
scope->end();
527+
g_mediaControlTextureRegions[item.first] = Rect(border + (panelW * i) + (gap * i), border, panelW, panelH);
528+
++i;
530529
}
530+
531+
node->visit();
532+
pass->end();
533+
531534
Director::getInstance()->getRenderer()->render();
532535

533536
g_mediaControlsTexture = rt;

0 commit comments

Comments
 (0)