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 problem in AGK Studio

Author
Message
Hudd
14
Years of Service
User Offline
Joined: 23rd Aug 2007
Location:
Posted: 30th Apr 2022 17:13
I bought AppGameKit Studio and thought I would see if it runs my AppGameKit Classic game any better (which is massive).

It doesn't work at all, sadly. Has anyone got any idea what to do here? It works fine in AppGameKit classic.



At this point, the game cashes. No error message, no clues. (it's about to draw the shield design onto this background image)

Any ideas?
Virtual Nomad
Moderator
16
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st May 2022 02:21 Edited at: 1st May 2022 02:29
that code works as is in classic?

otherwise, try CreateRenderImage() and draw the background image to that.

also, what #Renderer are you setting?

if your code works out of the box in Classic, the above may be a Vulkan issue.

you can test that by adding #Renderer "Basic" and seeing how it fairs.
Hudd
14
Years of Service
User Offline
Joined: 23rd Aug 2007
Location:
Posted: 1st May 2022 16:46
Hi, thanks for the response.

Yes, the code works in Classic.

If I add #Renderer "Basic" then it is a bit different - I just get a black screen, nothing else.
(Without this line, the whole app crashes)
Hudd
14
Years of Service
User Offline
Joined: 23rd Aug 2007
Location:
Posted: 2nd May 2022 14:00
If I use CreateRenderImage() to create an empty image to work on
Then load the original image I want to add and draw it on
Then do the processing to add the other sprites it all works fine. Except... it needs to be on a transparent background. (i.e my shield is on a black background rather than a transparent background)

I'm guessing that this is the problem, using SetRenderToImage on a PNG with transparency?

Virtual Nomad
Moderator
16
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 2nd May 2022 14:50 Edited at: 2nd May 2022 14:51
i'm getting a little lost with what you're trying to do now that more sprites are involved but it sounds like you should look at SetClearColor(Spr,0,0,0) and SetSpriteTransparency(Spr,1) if you're trying to "remove" a black background. short of that, i'd remove the black manually.

also usure if you're still doing memblock stuff but there is the studio-exclusive SetSpriteBlendModes() that may accomplish what you want without memblocks. there is no online help for it so check it out in studio itself.

meanwhile, it sounds like you're building a sprite from parts, in general? if i have a chance later, i'll put something together (unless someone else beats me to it) where, with all of the above, i doubt it's the most efficient method.
Hudd
14
Years of Service
User Offline
Joined: 23rd Aug 2007
Location:
Posted: 3rd May 2022 09:53
What I want to do is:

Start with a blue/white shield PNG with transparency
Do memblock stuff to replace the blue and the white with user chosen colours
Add a shield icon to the picture (e.g a heraldic lion, user chosen) via drawsprite

My game does a lot of things like this. But the problem is that first bit.

As soon as it does the SetRenderToImage command, if that image has transparency, my app crashes (back to the editor)

i = LoadImage("shield.png")
SetRenderToImage(i,0) //crashes here


Hudd
14
Years of Service
User Offline
Joined: 23rd Aug 2007
Location:
Posted: 3rd May 2022 17:53
I see if I use errormode(2) I do get an error message about having to create a render image - not using any existing image.

I'm sure I will be able to code around this - or go back to using classic

Don't spend any more time on it, please, and thanks for pointing me in the right direction.
blink0k
Moderator
9
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 3rd May 2022 19:59 Edited at: 3rd May 2022 19:59
RenderImage under vulcan usually requires a power of 2 for the image size
Raven
17
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 4th May 2022 13:26
You should always be using images you've created via CreateRenderImage( ) with the SetRenderImage( ) command.
While I know that AppGameKit Classic doesn't strictly require you to do this., it should.

Mind this said, I'd argue the concept of a Render Buffer and Image Buffer can be a little confusing and part of why is because AppGameKit handles them as a single resource.
Dark BASIC Professional handled this much better., as a Render Buffer was a Bitmap while an Image Buffer was a Texture.
Now they main difference between the two., is that a Render Buffer needs to be a specific Rendering Format as well as be clearly marked as part of the Rendering Queue (i.e. to support Vertical Sync Buffer Flipping)., where-as an Image Buffer should always be more generic so that it can be converted to whatever format it is needed to be in for whatever you're using it for.

I would as a note suggest you DO NOT use Memblocks., instead just use Render Images with Shader to handle whatever you'd do.
Memblocks in AppGameKit are *VERY* Slow., and ideally you will want to simply use GetImage( ) once you've performed all of the changes as while this command is also somewhat slow (too slow for every loop) it's still faster than Memblocks.




Login to post a reply

Server time is: 2022-08-09 08:22:58
Your offset time is: 2022-08-09 08:22:58