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 / SetRenderToImage - Confused

Author
Message
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 13:34
Hi All and thanks in advance!

For the first time today I am using RenderToImage. I am a little confused as to how to use this:



This 'works' in the fact that I end up with a sprite of the right size with a box as the image. However my question is as follows:

The size of the image and sprite is 20x20. Yet the drawbox commands require me to draw HUGE boxes which seem way out of size of the image>

Am I doing something wrong? In my mind if the image is 20x20 then the box should be 0,0,19,19?

I control all the juicy in here!
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 12th Jan 2020 13:43 Edited at: 12th Jan 2020 13:44
It's cause the whole screen is your canvas.
So to create a box that is right at the borders of your image you'll need to create a box as large as your screen resolution.
You can think of it as the 20x20 pixels are streched over the whole screen.
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 13:56
janbo, thanks for that.

However, in my logic that means that if my screen is set to 1024,768

If I draw a box 0,0,1023,767 this *should* make a box on the sprite. But this cuts the right and bottom lines of the box off?

I control all the juicy in here!
Scraggle
Moderator
17
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 14:23
Scraggle, thanks but doesnt help me
I control all the juicy in here!
Scraggle
Moderator
17
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Jan 2020 14:35 Edited at: 12th Jan 2020 14:42
You're trying to render a one pixel line into an area approximately 250 times smaller. There aren't enough pixels in the render target to display it. After the scaling it is considered (by the GPU) to be unworthy of display.

The reason the top lines are visible is because after scaling they align perfectly with the target renders coordinates (0 still equals 0)

To explain further with easier maths: if your display was 1000x1000 and the render image was 100x100 you would only see the line if drawn every 100 pixels. If drawn at 50, 50 for example then on the render target it would be exactly half a pixel high. Depending on your GPU that would either be drawn at 50% opacity or ignored completely
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 15:03
Scraggle, Thanks, I get that now however, seems to have no impact on the last lines even if I exaggerate the line thickness...still loses the right and bottom lines



Here the lines are 5 'pixels' wide which are shown as very thick lines for the top and left but are missing for the bottom and right? See image attached.

It seems to be cropping somwehow?



I control all the juicy in here!

Attachments

Login to view attachments
Scraggle
Moderator
17
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Jan 2020 16:14
I can't help you with that small section of code.
At the very least I'd need to know what size resolution you are using.

I just tried that code with the obvious extra code I needed to make it run and it performed as expected.
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 17:25 Edited at: 12th Jan 2020 17:26
Okay, so I did the same in creating a small project using that code:



and I get this



Is there a reason the RGB(0,0,0) is NOT transparent?
I control all the juicy in here!

Attachments

Login to view attachments
Virtual Nomad
Moderator
14
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 12th Jan 2020 17:33 Edited at: 12th Jan 2020 17:34
Quote: "Is there a reason the RGB(0,0,0) is NOT transparent?"



BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 17:40
Thanks Nomad, added that. No Change?
I control all the juicy in here!
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 17:41
Used SetSpriteTransparency with 2, Additive Blending and it works!
I control all the juicy in here!
BitManip
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Essex
Posted: 12th Jan 2020 17:42
Thanks ALL
I control all the juicy in here!
Virtual Nomad
Moderator
14
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 12th Jan 2020 17:45 Edited at: 12th Jan 2020 17:46
,1 should have worked:

Attachments

Login to view attachments

Login to post a reply

Server time is: 2020-09-24 23:08:59
Your offset time is: 2020-09-24 23:08:59