Getting the screen resolution in T3D
by Dave Wagner · in Torque 3D Professional · 09/03/2013 (8:59 am) · 3 replies
I have some code that I'm porting from TGE to T3D.
In TGE to get the screen resolution I would use VIDEO::getResolution();.
How to I do the equivalent in T3D?
I see how you would do if you have a point to the canvas but I'm not sure the best way to do it since my class doesn't have a pointer to the canvas. Should I do a Sim::FindObject() to find the canvas and then do a canvas->getPlatformWindow()->getVideoMode().resolution?
In TGE to get the screen resolution I would use VIDEO::getResolution();.
How to I do the equivalent in T3D?
I see how you would do if you have a point to the canvas but I'm not sure the best way to do it since my class doesn't have a pointer to the canvas. Should I do a Sim::FindObject() to find the canvas and then do a canvas->getPlatformWindow()->getVideoMode().resolution?
#2
You could use GFX->getActiveRenderTarget() and the extract the size from the returned GFXTarget (see GuiCanvas::renderFrame() for an example). Or you could make use of GFX->getViewport() to determine the size of the rendering within the window. However, these values will change depending on the current rendering stage.
If you don't want to deal with the Canvas itself, you could go through the PlatformWindowManager using the WindowManager define. Unless you have more than one window in your game you may be able to do WindowManager->getFirstWindow() and go from there. Of course, this won't tell you when the resolution changes and you'll need to deal with that yourself.
- Dave
09/03/2013 (10:29 am)
It depends on the resolution you are looking for and at what point in the rendering pipeline you want the information.You could use GFX->getActiveRenderTarget() and the extract the size from the returned GFXTarget (see GuiCanvas::renderFrame() for an example). Or you could make use of GFX->getViewport() to determine the size of the rendering within the window. However, these values will change depending on the current rendering stage.
If you don't want to deal with the Canvas itself, you could go through the PlatformWindowManager using the WindowManager define. Unless you have more than one window in your game you may be able to do WindowManager->getFirstWindow() and go from there. Of course, this won't tell you when the resolution changes and you'll need to deal with that yourself.
- Dave
#3
09/03/2013 (11:12 am)
Thanks Dave! That's exactly what I was looking for.
Torque Owner Robert Fritzen
Phantom Games Development