Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / RenderImage not resizing correctly by virtual resolution

Author
Message
Roy Lazarovich
7
Years of Service
User Offline
Joined: 25th Jan 2017
Location:
Posted: 20th Mar 2017 12:34
Hello Everyone

I'm experiencing an issue where a render image that I've created is not being resized correctly by the virtual resolution, like all other sprites would, I've created a simple example that showcases the issue
Basically clicking anywhere on the screen will draw a red square, when the virtual resolution is the same as the window size, everything lines up correctly, but when the window size is different, and the virtual resolution kicks in to fit and center the view area the render image does not seem to receive the same treatment and so the red squares no longer line up, of course this gets more noticeable the bigger the difference in aspect ratio gets

I was wondering if anyone knows how I'd be able to compensate for this and get the red squares to line up correctly, I've tried to manually play with the size of the render image but couldn't get something that would work correctly in all situations

Thanks in advance for any help

Code demonstrating the issue follows:

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Mar 2017 19:12
Render image sizes hurt my head
The render image always uses the resolution of the device (or window), not your virtual resolution.

I found the best way to manage this issue is to "cheat".

Set your virtual resolution to the same as your screen resolution.
Render and get your image
Set the resolution back to virtual resolution.
Also, always use power of 2 images.

It also took me hours of messing around to understand the process! I have an app that renders to an image every cycle, and for this one I have had to use the complicated method of recalculating the dimensions, I can't resize the resolution every frame.
I believe this is because it uses the GPU to render the image.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Roy Lazarovich
7
Years of Service
User Offline
Joined: 25th Jan 2017
Location:
Posted: 20th Mar 2017 19:47
Thanks BatVink, I too will need to draw each cycle, would you mind sharing just the calculation?

Thanks again
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Mar 2017 22:30 Edited at: 20th Mar 2017 22:32
The comment above is pasted from one of my previous posts. Since then, I changed my method and used a square image, which removes the problem of stretched images.

The best explanation I can find of the calculation is this post by Paul
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Roy Lazarovich
7
Years of Service
User Offline
Joined: 25th Jan 2017
Location:
Posted: 20th Mar 2017 22:56
Thanks BatVink

Login to post a reply

Server time is: 2024-11-22 09:52:20
Your offset time is: 2024-11-22 09:52:20