Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderTexture::setVirtualViewport() misses a lot of pixels and has wrong offset #18712

Open
Nyrio opened this issue Mar 5, 2018 · 0 comments

Comments

@Nyrio
Copy link

Nyrio commented Mar 5, 2018

  • cocos2d-x version: 3.16
  • devices test on: Windows 10
  • VS version: Visual Studio Enterprise 2017

I wanted to capture a part of my scene with a code similar to the following (the design resolution is 1920*1080):

unsigned int SIZE_X = 960;
unsigned int SIZE_Y = 540;
unsigned int POS_X = 100;
unsigned int POS_Y = 100;

RenderTexture* texture = RenderTexture::create(SIZE_X, SIZE_Y);
texture->setVirtualViewport(Vec2(POX_X, POS_Y),
                            Rect(0, 0, 1920, 1080),
                            Rect(0, 0, SIZE_X, SIZE_Y));

texture->begin();
this->visit();
texture->end();

texture->saveToFile("test.png", Image::Format::PNG);

I've tried a lot of different combinations of parameters, but whatever I do, at most the pixels from the rectangle 0, 0, SIZE_X, SIZE_Y are captured, the rest is filled with transparent pixels. Also the offset is wrong.

Here is the result of the code above for a mockup scene, where red means transparent pixel:

offset_rtbegin

All the pixels that I have displayed in red are empty and they shouldn't, and the offset is wrong.

@Nyrio Nyrio changed the title RenderTexture::setVirtualViewport() misses a lot of pixels RenderTexture::setVirtualViewport() misses a lot of pixels and has wrong offset Mar 5, 2018
@drelaptop drelaptop added this to the 3.18 milestone May 22, 2018
@drelaptop drelaptop removed this from the 3.17.1 milestone Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants