Calculate the size of a texture - Page 2

Calculate the size of a texture

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Calculate the size of a texture

Post 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).
Last edited by jK on 02 Nov 2009, 23:09, edited 2 times in total.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Calculate the size of a texture

Post by Argh »

:oops:

You are correct. Use that. My apologies, I forgot what was returned.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post 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.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post 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
Sheekel
Posts: 1391
Joined: 19 Apr 2005, 19:23

Re: Calculate the size of a texture

Post by Sheekel »

I do not see it, care to explain this awesomeness for us laymen?
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post 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.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Calculate the size of a texture

Post by aegis »

nine slices?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Calculate the size of a texture

Post by lurker »

AF wrote:assumed
No, he said he wanted it to draw a wireframe in the first post, and subsequent posts.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Calculate the size of a texture

Post 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?
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post by Tribulex »

Boned it. Or nailed it? I forget the expression. Something like that, but yes, that is it.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Calculate the size of a texture

Post 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
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post 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...
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Calculate the size of a texture

Post by Tribulex »

This framework will be used for xta
Post Reply

Return to “Lua Scripts”