Vampyre Imaging Library Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Imaging 0.26.4 Released!

Author Topic: Texture creation (OGL, DX, SDL) sizes  (Read 2136 times)

aksdb

  • Imaging User
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Texture creation (OGL, DX, SDL) sizes
« on: 27 December 2006, 18:24:53 »

It would be useful, if for example CreateGLTextureFromImage/File/etc. would somehow return the size of the texture (for example as var-parameters), as these methods may modify the actual size of the texture (power of 2). The size is always necessary to know (how to draw the texture otherwise?) so it saves time and performance if one does not have to additionally query the texture size from opengl/dx/sdl after creating the texture.
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: Texture creation (OGL, DX, SDL) sizes
« Reply #1 on: 28 December 2006, 01:42:36 »

Good idea. I think it could be done like this:
Code: (delphi) [Select]
function LoadGLTextureFromFile(const FileName: string; Width: PLongInt = nil; Height: PLongInt = nil): GLuint;
begin
  ... create texture ...
  if Width <> nil then
      Width^ := CreatedWidth;
  ...
end;

This way users that don't care about created texture's dimensions (like when you use it as regular texture mapped on 3D object) wouldn't need to give the function more parameters (like with var parameters) and those who need it can get it. No need to add it to SDL functions too as they return pointer to structure which already contains surface's width and height.
Logged

aksdb

  • Imaging User
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Texture creation (OGL, DX, SDL) sizes
« Reply #2 on: 28 December 2006, 18:05:54 »

Sounds great :) Thanks
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: Texture creation (OGL, DX, SDL) sizes
« Reply #3 on: 29 December 2006, 01:05:26 »

It has just been commited into SVN repository.
I hope it works OK because I haven't had much (any) time to test it yet.
Logged

aksdb

  • Imaging User
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Texture creation (OGL, DX, SDL) sizes
« Reply #4 on: 31 December 2006, 18:18:13 »

Seems to work great. At least it didn't cause any trouble so far and the textures are displayed correctly :)
Thanks for that fast response and implementation.

Btw. I saw you also started several Canvas methods, looks also great :)
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: Texture creation (OGL, DX, SDL) sizes
« Reply #5 on: 10 January 2007, 18:12:13 »

Good to hear it works ok.
Yes, I added rect/line/ellipse drawing to canvas but thats all for 0.22 release. I'm gonna redesign drawing
canvas routines to allow blending and patterns in future (near I hope) so I don't want to add too much stuff now
because I would have to rewrite it later.
Logged
 

Page created in 0.075 seconds with 20 queries.