Page 2 of 2

Re: Calculate the size of a texture

Posted: 02 Nov 2009, 23:00
by jK
Argh wrote:So, therefore, the answer would be...

Code: Select all

local sizex, sizey = gl.TextureInfo(gl.Texture(file))
huh? how did you get that impression? (gl.Texture returns a boolean not a string!)


Edit:

Code: Select all

  local loaded = gl.Texture(textureString)
  if (loaded) then
    local texinfo = gl.TextureInfo(textureString)
    Spring.Echo('Texture dims', texinfo.xsize, texinfo.ysize)
  end
btw this can `fail` under some conditions IF the code gets executed in a gl.CreateList(), cuz then the loading will get delayed until the next videoframe, but gl.Texture will still return true (w/o loading the texture).

Re: Calculate the size of a texture

Posted: 02 Nov 2009, 23:08
by Argh
:oops:

You are correct. Use that. My apologies, I forgot what was returned.

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 03:36
by Tribulex
So i discovered the problem. Of course, this isnt documented ANYWHERE. Before you call gl.TextureInfo(file), you must call gl.Texture(file).

Yay.

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 06:44
by Tribulex
As a thank you to you all, ill show you some eyesex. If you look at this closely, you will realize that I have done something very awesome. All those boxes are drawn with the same texture :)

Image

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 20:44
by Sheekel
I do not see it, care to explain this awesomeness for us laymen?

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 21:41
by Tribulex
Sheekel wrote:I do not see it, care to explain this awesomeness for us laymen?
The texture is stretched, but the corners stay unstretched, through magic.

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 22:33
by aegis
nine slices?

Re: Calculate the size of a texture

Posted: 03 Nov 2009, 22:34
by lurker
AF wrote:assumed
No, he said he wanted it to draw a wireframe in the first post, and subsequent posts.

Re: Calculate the size of a texture

Posted: 04 Nov 2009, 15:29
by Forboding Angel
lurker wrote:
AF wrote:assumed
No, he said he wanted it to draw a wireframe in the first post, and subsequent posts.
Wrong Thread.

@trib, ok I can see now why you wanted this. You're making gui elements and didn't want the corners to appear stretched so that you can probably have resizing windows without it looking like ass.

Am I fairly close?

Re: Calculate the size of a texture

Posted: 05 Nov 2009, 02:44
by Tribulex
Boned it. Or nailed it? I forget the expression. Something like that, but yes, that is it.

Re: Calculate the size of a texture

Posted: 09 Nov 2009, 06:12
by Forboding Angel
:lol:

That would be nailed :wink:

Boned it sounds like you're telling me that I made a "boner" (1930's or 40's slang for oshit/whoops/fuckup). I actually started laughing when I read that lol

Re: Calculate the size of a texture

Posted: 11 Nov 2009, 00:30
by Tribulex
Forboding Angel wrote::lol:

That would be nailed :wink:

Boned it sounds like you're telling me that I made a "boner" (1930's or 40's slang for oshit/whoops/fuckup). I actually started laughing when I read that lol
Or fucked it. Boner is another term for a hard phallus in this country.



English is my 3rd langauge sorry for inconsistencies etc...

Re: Calculate the size of a texture

Posted: 12 Nov 2009, 21:24
by Tribulex
This framework will be used for xta