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 / Drawing to a plane instead of the screen

Author
Message
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 21st Mar 2013 16:40
Is it possible to change the target of the render result, instead of everything being drawn to the screen could I draw it to a plane?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Mar 2013 16:48
I don't think you can do that yet - not unless you can somehow grab the image and use it as a texture. TGC are most likely gonna expand on the camera stuff soon, like being able to set an image as a render target, and be able to have more than one camera, all that useful stuff will make an appearance soon I'm sure.

I got a fever, and the only prescription, is more memes.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Mar 2013 16:52
You can draw and capture the back buffer without swapping. Sync swaps automatically but you can use the other commands. Which I can't look up because I am not home.


Demo 3 is out now!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Mar 2013 17:07
A Sync() will call Update(), Render() and Swap() in that order.

You can call any of those three independently, before the Sync() call (or instead of).

Update(time) updates all objects based on the given time, animation, physics, etc. in back buffer. If passed time=zero, it calls StepPhysics with the actual frame time (unless you've already called StepPhysics in the current frame).

Render() draws all sprites and text objects to the back buffer.

Swap() swaps the the screen and the back buffer and updates global time variables.

So, you can do all sorts of display changes and they don't appear to the user until you either call Sync() or Swap().

But you can also do all sorts of display changes and call Render() and they will be in the back buffer and not displayed until the next Swap() or Sync() call.

I believe the commands that copy the display (scissor commands and such) work with the back buffer.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 21st Mar 2013 17:38 Edited at: 21st Mar 2013 17:38
So does this mean I CAN draw the render to a plane?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Mar 2013 17:48 Edited at: 21st Mar 2013 17:52
You could use something like:
update(getFrameTime())
render2Dfront()
img = getImage(0,0,screen_width,screen_height)
clearScreen()
setObjectImage(plane,img)
render3D()
swap()

But I imagine it would be a very slow process (mainly the getImage part). Too slow really. You might be able to do a cool scene if you scale everything down, make a game you can render within a 320x240 patch of screen or maybe slightly larger, that way grabbing the image could be made much quicker. If you also used setImageMagFilter set to off you could have something that will display crisp on your plane.

Just a few thoughts I already had on this idea

EDIT: here's the game that got me thinking



this.mess = abs(sin(times#))
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 21st Mar 2013 18:14 Edited at: 21st Mar 2013 18:15
Oh if it's slow then it's not really an option.

I was thinking of using this process to create a glow effect with a shader. Get the rendered image, apply to object with glow shader.

But since my game is targeted at mobile devices, I don't want anything that is going to kill performance.

Guess I'll just have to wait it out for full screen shader support.

Cool looking game btw

Login to post a reply

Server time is: 2024-11-24 09:39:13
Your offset time is: 2024-11-24 09:39:13