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 Classic Chat / Render Image to Image?

Author
Message
pugmartin
21
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 6th May 2015 02:31
Hi All,

Can I ask if anyone can help me with rendering an image into another image?
Is this possible?

Basically I have a situation where I need to create a sprite manually using the Draw commands - DrawLine etc.
As these items draw above everything else, I want to save the drawn image as a sprite, rotate it, position text, paste the text onto the image (think of a gameshow spin wheel), rotate again, paste more text, etc etc.
This image would then be saved and can be used in game as a... gameshow spinwheel. Well done, you guessed it.

I am a little confused as to the usage of Render, Sync, Update etc and their impact to what I am hoping to do.

Below is basic code. Note the function call to CreateSpinWheel() - no combination of Render, Sync etc seems to bear fruit - I can manage to have the wheel show (built using the DrawLine function) OR the pasted text (and hence rotates as it should - albeit without the wheel behind), but cant seem to be able to get both together.
It feels as though an image can not be rendered into another image?

Any help or pointers would be greatly appreciated. Thanks.



Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 6th May 2015 10:38
When you use DrawLine(), that is actually rendering the line to the image so I don't think you need Sync() or Render().

Then use DrawSprite() to draw your wheel to Final_Img, again, this actually renders the sprite so no Sync() or Render() is required.

Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 6th May 2015 14:45
You can't just use "Render()" on its own. Render() is one of three commands that make up Sync().

Sync() is made up of Update(), Render() and Swap(). So if you're callin Render(), you need to call Update() to update all the sprite positions, Render() and then Swap().

You may also have a problem with mipmaps as you've turned them on for your Render images. I'd suggest turning mipmaps off.

Try also using SetScissor(0.0,0.0,0.0,0.0).

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th May 2015 15:15
There are 2 main ways of rendering to an image. The simplest for a one off render is to clear the screen, draw your lines etc, grab the image then clear the screen again IE.


If you are doing this regularly you might want to use SetRenderToImage but from the sound of it this is a one off when the sprite is created so the above would be best.

Using AppGameKit V2 Tier 1
pugmartin
21
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 7th May 2015 01:59
Thanks everyone for the great information.

I ended up playing about and going with baxslash's suggestion in the end.



Works well now, and allows build up of line drawn spinwheel and a sample item of text on top of this, built (once) on the main screen and saved as a sprite image and utilised as such.

However I have hit another stumbling block - I would like to rotate the wheel, apply text, save image, rotate, apply more text, save.. etc to build up rotated text around the wheel.
This does not seem to work - it appears the setspriteangle() call before drawsprite() has no impact on the orientation of the sprite?
Is this not applied immediately?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th May 2015 11:05 Edited at: 7th May 2015 14:25
Quote: "Is this not applied immediately?"


Not sure, maybe not. Try calling Update() after you rotate it and before you draw it.

Login to post a reply

Server time is: 2024-11-25 21:27:14
Your offset time is: 2024-11-25 21:27:14