How does the game resolution translate to glPoint2f coordinates?
by John Klimek · in Torque Game Builder · 02/05/2007 (12:10 pm) · 3 replies
I'm not sure if I should be posting this in the core/engine forum, but seeing as how that forum isn't very active I thought I'd post it here.
Basically here is my question:
Let's say the game was designed in 1024x768 but the user is playing in 1600x1200.
Now let's say (in a C++ custom t2dSceneObject) I want to draw a quad that takes up 1/4 of the screen (eg. the top left corner).
How can I draw this? What points would I pass to glVertex2f() ?
Also, do I need to know anything special about specifying texture coordinates when texturing the quad?
Thanks for your help!
Basically here is my question:
Let's say the game was designed in 1024x768 but the user is playing in 1600x1200.
Now let's say (in a C++ custom t2dSceneObject) I want to draw a quad that takes up 1/4 of the screen (eg. the top left corner).
How can I draw this? What points would I pass to glVertex2f() ?
Also, do I need to know anything special about specifying texture coordinates when texturing the quad?
Thanks for your help!
About the author
Recent Threads
#2
For example, I was looking at how the engine splits up tiled image maps. The c++ code has the dimensions in Pixels, whereas when working in TorqueScript, the dimensions are in GameCoordinates
02/05/2007 (9:38 pm)
Also, it wouldnt hurt to debug the source if it's available to you, because most of the stuff internally in the engine handles it in pixels. For example, I was looking at how the engine splits up tiled image maps. The c++ code has the dimensions in Pixels, whereas when working in TorqueScript, the dimensions are in GameCoordinates
#3
However, I was hoping for more of an explanation of how the engine (C++) handles coordinates.
I've been reading through the code but I'm still very confused. However, it appears as though the object position is stored in mWorldClipBoundy[4] (at least it seems like this from t2dStaticSprite::renderObject()), but I'm still confused on how everything relates.
What I'm really hoping for is for somebody to explain what that variable does (if it is in fact object position) and how it is translated from real coordinates (eg. window resolution) to game coordinates (eg. "pretend" resolution).
I'm thinking that if I understand that, and then how image maps work, I can write a simple t2dStaticSprite alternative and actually understand how the thing works.
(For those wondering, I'm trying to eventually create a 2D landscape like in Worms / Scorched Earth, but I'd like to dynamically generate the terrain and then overlay one bitmap image on top of it (eg. the terrain image)).
02/07/2007 (11:17 am)
Thanks for the reply!However, I was hoping for more of an explanation of how the engine (C++) handles coordinates.
I've been reading through the code but I'm still very confused. However, it appears as though the object position is stored in mWorldClipBoundy[4] (at least it seems like this from t2dStaticSprite::renderObject()), but I'm still confused on how everything relates.
What I'm really hoping for is for somebody to explain what that variable does (if it is in fact object position) and how it is translated from real coordinates (eg. window resolution) to game coordinates (eg. "pretend" resolution).
I'm thinking that if I understand that, and then how image maps work, I can write a simple t2dStaticSprite alternative and actually understand how the thing works.
(For those wondering, I'm trying to eventually create a 2D landscape like in Worms / Scorched Earth, but I'd like to dynamically generate the terrain and then overlay one bitmap image on top of it (eg. the terrain image)).
Torque Owner Jared Schnelle
The relationship of game coordinates, to screen (pixel) coordinates, is as follows:
$WIDTH_MULTIPLIER = getWord(%this.scenegraph.cameraSize, 0) / $levelEditor::DesignResolutionX;
$HEIGHT_MULTIPLIER = getWord(%this.scenegraph.cameraSize, 1) / $levelEditor::DesignResolutionY;
So if I want the quad to take up 1/4 of the screen, at 1600 pixels that's 400 pixels, so in game coordinates would be
%SpriteWidthInPixels = 400;
%SpriteWidthInGameCoordinates = %SpriteWithInPixels * $WIDTH_MULTIPLIER;
Hopefully that helps.