Bart
WiseBart
Hi all.
I'm trying to debug-draw a texture page/group.
So I use a simple vertex buffer with a square consisting of 2 triangles and pass the texture page.
After doing a preview in the Windows Graphics options, the texture page dimensions appear to be 1024x2048. So not square.
A rectangular (and not square) texture page still has (0, 0) as the top-left uv and (1, 1) as the bottom-right uv. texture_get_width and texture_get_height return these values in the 0-1 range.
Is there any way to know what the actual dimensions of a texture page turn out to be? Or to know the ratio of width to height?
Maybe there's a function I don't know of or a trick/workaround that I'm missing.
Although if I'm not mistaken it doesn't seem like this is currently possible in GM?
EDIT: Found the solution... Dividetexel width by texel height texel height by texel width to get the ratio of width to height. Thanks to @flyingsaucerinvasion for the correction.
Here's the explanation:
It doesn't seem to be possible to get the actual texture page size, although that's something that could be hard-coded. This is also possible. See the answer below.
I'm trying to debug-draw a texture page/group.
So I use a simple vertex buffer with a square consisting of 2 triangles and pass the texture page.
After doing a preview in the Windows Graphics options, the texture page dimensions appear to be 1024x2048. So not square.
A rectangular (and not square) texture page still has (0, 0) as the top-left uv and (1, 1) as the bottom-right uv. texture_get_width and texture_get_height return these values in the 0-1 range.
Is there any way to know what the actual dimensions of a texture page turn out to be? Or to know the ratio of width to height?
Maybe there's a function I don't know of or a trick/workaround that I'm missing.
Although if I'm not mistaken it doesn't seem like this is currently possible in GM?
EDIT: Found the solution... Divide
Here's the explanation:
Code:
// w = width, h = height, tw = texel width, th = texel height
w = 1 / tw;
h = 1 / th;
// So:
w * tw = h * th;
w / h = th / tw;
Last edited: