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 / [SOLVED] unknown error

Author
Message
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 15th Jan 2019 00:18
I create a render image, set it to draw to it, render it, then try to get the image and i get an unknown error. if i use swap it works fine but i want to grab the image turn it into image two and make a sprite from image two. i don't know what i'm doing wrong work in dbpro that way.
A child's dream never dies.





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

Go to answer

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Jan 2019 16:04
I played around with it a little bit, it seems like it's crashing on the getImage command. The error I get is "Failed to create XAudio2", which makes no sense to me. On my work laptop, I don't have the proper runtimes so I don't get any audio in AppGameKit, this I'm aware of. However, it only throws me that error if I leave in the getimage command, which is weird.

The issue might be because you're rending everything to an image but then trying to grab the screen. Put setrendertoscreen() before the getImage command and it should work.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 15th Jan 2019 17:11
well I have it set get render to image so it will draw to the image and it should still be set to that image when I get a new image from. if I set reminder to screen it will draw to the screen which is not what I want. drawing to an image is in the background while the screen that the user sees can be unchanged. and yes it seems to be a problem with the get image I don't know what the deal is but it's really bugging me and why it has anything to do with audio is weird
A child's dream never dies.





Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2019 18:09
I'm not sure you need render image here, I think you could probably just swap and render to the backbuffer as you are doing and get the sprite image from there. Is there a reason you want to get the sprite image from a render image instead of the backbuffer?
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2019 18:12
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 15th Jan 2019 18:54 Edited at: 15th Jan 2019 18:59
honestly I'm confused I just started agk and it doesn't behave like darkbasic. all I want to do is making image in the background. then grab that image and make a sprite from it then paste that Sprite to the screen.and I want to do all of that without interfering with the screen because I will be doing similar things and my program constantly and I was under the impression that swap brought the back buffer to the screen. if we do not have rendered set to an image how do we know what image we draw 2 when we draw if we don't want to draw on the screen and if we just use swap how do we know which image in the back buffer we are swapping to I'm very confused and I don't completely understand what's swap does either
A child's dream never dies.





blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Jan 2019 20:38
If you don't want to see what you have drawn change swap() to ClearScreen()
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2019 23:06
Just think of it like this:

Swap() to backbuffer
Draw you stuff (to the backbuffer)
Render() (to the backbuffer)
Getimage() (from the back buffer)
Swap() to the screen
Set your sprite (to the screen)
Sync () render the screen to the user

User won't see what you are doing on the back buffer, you swap back out before you sync.

Try my edit of your code above. I think it should do what you want. I've not tested this snippet, but i do similar
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 15th Jan 2019 23:19
thanks ortu makes more sense. all i should have to do is swap clear screen draw again and get an image an from it. still confused as to the function of set render to image if I can't draw to an image and pull an image from it.
A child's dream never dies.





Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 16th Jan 2019 00:59
This post has been marked by the post author as the answer.
I believe render to image is for use with shaders where you render out the scene then send the image to a shader for post processing. Saves you from having to do a get image from the screen before passing it.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 16th Jan 2019 11:20
GetImage() will grab contents from the screen back buffer to an image. There is no need to GetImage on an image as it is already an image. Just use the rendered image for your sprite instead. You also do not need to use Render() on a render image as draw calls will be instantaneous. However, if you want sprites or text to appear on the rendered image, then you need to use DrawSprite and DrawText as they do not automatically appear on the image.

Here is an example of your code using a render image. You can find another example in the help files. file:///C:/Program%20Files%20(x86)/The%20Game%20Creators/AGK2/Tier%201/Help/Reference/Core/SetRenderToImage.htm

smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 16th Jan 2019 16:22
thanks tomtoad and ortu. @ tomtoad sometimes its good to get a piece of an image of an image when loading a sprite sheet for example or just grabbing part of an image. i can think of many uses. thank u guys for clarifying the usage of swap renderto and render make much more sense.
A child's dream never dies.





Login to post a reply

Server time is: 2024-11-21 13:09:05
Your offset time is: 2024-11-21 13:09:05