|
37 | 37 | # include "axmol/platform/FileUtils.h" |
38 | 38 | # include "axmol/ui/UIHelper.h" |
39 | 39 | # include "axmol/media/MediaEngine.h" |
| 40 | +# include "axmol/scene/Camera.h" |
40 | 41 | # include "axmol/ui/Button.h" |
41 | 42 | # include "axmol/ui/LayoutGroup.h" |
42 | 43 | # include "axmol/tlx/byte_buffer.hpp" |
@@ -499,35 +500,37 @@ static void createVideoControlTexture() |
499 | 500 | auto totalWidth = utils::nextPOT(numItems * panelW + (numItems - 1) * gap + (border * 2)); |
500 | 501 | auto totalHeight = utils::nextPOT(border * 2 + panelH); |
501 | 502 | auto imageSize = Size(static_cast<float>(totalWidth), static_cast<float>(totalHeight)); |
502 | | - auto* node = Node::create(); |
| 503 | + auto node = Node::create(); |
503 | 504 | node->setContentSize(imageSize); |
504 | 505 | node->setIgnoreAnchorPointForPosition(false); |
505 | 506 | node->setAnchorPoint(Anchors::bottomLeft); |
506 | 507 | node->setPosition(0, 0); |
507 | 508 | node->addChild(drawNode); |
508 | 509 |
|
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)); |
510 | 513 |
|
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)}); |
515 | 517 |
|
516 | | - g_mediaControlTextureRegions.clear(); |
| 518 | + g_mediaControlTextureRegions.clear(); |
517 | 519 |
|
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); |
527 | 526 |
|
528 | | - node->visit(); |
529 | | - scope->end(); |
| 527 | + g_mediaControlTextureRegions[item.first] = Rect(border + (panelW * i) + (gap * i), border, panelW, panelH); |
| 528 | + ++i; |
530 | 529 | } |
| 530 | + |
| 531 | + node->visit(); |
| 532 | + pass->end(); |
| 533 | + |
531 | 534 | Director::getInstance()->getRenderer()->render(); |
532 | 535 |
|
533 | 536 | g_mediaControlsTexture = rt; |
|
0 commit comments