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.

AppGameKit Studio Chat / [SOLVED] Baffled by RenderImage behaviour...

Author
Message
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 22nd Feb 2021 13:22
So, this is actually baffling the heck out of me.
Now if I use a Larger RenderImage; it will Render SOMETHING (it's still broken) but keep in mind I'm grabbing an 8x8 Pixel Image; I shouldn't need a RenderImage that's 512x512 or larger for that.

32x32 is the smallest that Hardware Supports... or Vulkan at any rate; and I'm "Fine" with that, but it's just some odd behaviour here.
Notice that if I just use the Screen (BackBuffer) it works perfectly; but ideally I don't want to be using On-Screen Rendering.



Now if anyone can figure out what I'm doing wrong, that'd be awesome.
As a note... the issue MIGHT be with CopyImage., I'm not sure; as I can use GetImage for anything On-Screen; it doesn't work for Off-Screen (i.e. Rendering to Images, rather than Screen Buffer).

The author of this post has marked a post as an answer.

Go to answer

hendron
5
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 22nd Feb 2021 14:09 Edited at: 22nd Feb 2021 14:33
I'm guessing it's because Render Images always use the full resolution of your window (not to be confused with virtual resolution, which actually has no effect at all on your rendering resolution), so your code is squashing a 1280 x 720 canvas into a 32 x 32 image. Try changing:



to

adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 22nd Feb 2021 15:39 Edited at: 22nd Feb 2021 15:39
This post has been marked by the post author as the answer.
Render images use the virtual resolution. Use SetVirtualResolution after calling SetRenderToImage and SetRenderToScreen.

For "Broken":
hendron
5
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 22nd Feb 2021 16:52
Quote: "Render images use the virtual resolution."



Huh, just tested this and I stand corrected. Has this always been the case? I could swear this didn't work when I tried it a while back, and the only way I could get a correct up-scaled render was to always use a render image that was the same size as my window and clip from it. Maybe I just did it wrong -- wouldn't surprise me. Thanks though, I'm glad I know this now.
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 23rd Feb 2021 00:19
I think it has always been the case. Calling SetVirtualResolution before SetRenderToImage/Screen doesn't work. It has to be after changing the render destination.
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 23rd Feb 2021 00:24
Awesomesauce... it'd been driving me crazy before work trying to figure out why it wasn't working.
AGK's help somewhat frustrates me at time, at just how verbose it is while explaining almost nothing.

Should've guessed it was an order thing, always tends to be with AGK.
Thanks
blink0k
Moderator
8
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Feb 2021 00:25
I used it in my hotdog game. Works fine. Great for rezing up/down a 3D scene
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 23rd Feb 2021 01:59
@Raven: You're welcome. Yes, it took me a long time to get it right because their examples just use the window virtual resolution for the image as well, so SetVirtualResolution isn't even in their example.
haliop787
User Offline
Joined: 22nd Mar 2020
Playing: With reality.
Posted: 23rd Feb 2021 05:23
You could also use

VirtualHeight/quality same for VirtualWidth/quality

So quality of 1 is the same as the virtual res.
Quality of 2 , is half of the res and still works good.

I use this in the options menu, where i let the user change the quality of rendered shaders and stuff.

It actually helps some mobile devices after checking you get like a tiny amount of FPS increase ( i actually use tons of rendered images and place them into sprites or quads depends on the DEPTH needed according to other entities in my games) also i never use GetImage i just use the rendered images as the sprites images.

Creating a rendered image
Creating a sprite with that renderedImage

Updating the render image automaticlly updating the sprites image.

We all should stop using getImage unless we at some point to save the image or stop using renderToImage for that image.

Just always render what ever we want on the entire resolution of the virtual one than resizing the sprite rather than the image.
Sometimes i actually do use renderImage 8x8 and it works it just looks bad.. but it works.
Nadav "Haliop" Rosenberg
Lets make the world great forever.

Login to post a reply

Server time is: 2021-02-27 22:38:55
Your offset time is: 2021-02-27 22:38:55