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 / How to rotate Quad to simulate screen rotation?

Author
Message
GTRON
5
Years of Service
User Offline
Joined: 30th Jan 2019
Location: Netherlands
Posted: 15th Feb 2019 13:36
Hi All!

What I need to do is to allow the player to rotate the screen by 90 degree increments in the setup menu - so, if for example, they are running on an old-school CRT that's been rotated 90 degrees, they play the game in portrait orientation. I'm not targeting mobile platforms.

I've created a full-screen Quad with CreateQuad() and I render my entire game to this object via image.

I've tried simply using the RotateObject commands, however it seems like the orientation of the Quad is locked. I've also tried rotating Quad and setting the pivot point pre-drawing, however this results in the Quad not being drawn at all.

Does anyone have an idea on how I can achieve this? Thanks in advance!

p.s. I'm new to AppGameKit - however I'm loving it as an old-time Blitz coder. Hi to you all!

Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 15th Feb 2019 15:43
Do you need the quad? Can't you render it to an image, then texture a 3d plain or even a sprite with that image and rotate that?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 15th Feb 2019 15:56 Edited at: 15th Feb 2019 15:58
The stock vertex shader for a quad does not do any object rotation or camera based rotation either it is always fixed to the full screen.
The shader is listed here: https://www.appgamekit.com/documentation/guides/13_shaders.htm

You have a few choices that spring to mind - any of these would work:

1) Apply the image you rendered to a sprite and make the sprite fill the screen but you can rotate it.

2) In your full screen quad pixel shader, rotate the UV coords so that you can have the top left at any of the 4 corners. (For example UV.x = uvVarying.y and UV.y = uvVarying.x gives 180 degree rotation...etc...)

3) Replace the stock quad vertex shader and add in a matrix multiply for the camera rotation or object rotation.

4) Use a plane object instead. You will need to be careful to set the camera aspect correctly and place the camera at 0,0,-z where z is: PlaneSize/2/Tan(GetCameraFOV(1)/2) ....then you can just rotate the plane object or use SetCameraLookAt(1,0,0,0,roll) where roll will be 0,90,180,270 etc...
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 15th Feb 2019 15:56 Edited at: 15th Feb 2019 16:11
I don't think quads are meant to be rotated.
I think you would have to use a plane object if you want to rotate it then the 3D rotate commands will work
when you rotate a plane you would then have to change its size to match the resolution the getdevicewidth()
and getdeviceheight() may be used to do that but you may have to flip the image to match the rendered one
to do that

which effectively flips it left to right or flip top to bottom



Edit oh ofcourse you can render to a sprite DOH as homer would say
Good solution @Bengismo you can tell its like 230 am here and my mind is elsewhere
fubar
GTRON
5
Years of Service
User Offline
Joined: 30th Jan 2019
Location: Netherlands
Posted: 16th Feb 2019 02:44
Hey,

Thanks for all your suggestions. I need a bit more help to implement your suggestions.

Santman asked "Do you need the quad?" and Bengismo said using a sprite is an option, and fubarpk said use a plane.

I've only been using AppGameKit for a few weeks, so I'm a complete noob here - forgive me

I'm using a Quad because I need a full-screen image shader (I'm emulating a CRT).

So I'm not sure if I can do the same thing with a sprite or a plane? Is this true?

Here are the options you folk recommend:

(1) Use a sprite. Ok - can I apply a full-screen shader to a sprite? If so, that's cool. How do I make this fill the screen?

(2) Replace the stock Quad vertex shader so it rotates. I have no idea how to do this. I'm applying a shader to the Quad already - does this replace the default?

(3) Use a plane? Can I apply a full-screen image shader to the plane? Or do I render this to a texture?

So... I'm a bit in the dark here on how to implement the above... further detail would be awesome

Cheers!

Login to post a reply

Server time is: 2024-11-23 05:31:57
Your offset time is: 2024-11-23 05:31:57