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

Offline aksdb

  • Imaging User
  • *
  • 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.

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
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
  1. function LoadGLTextureFromFile(const FileName: string; Width: PLongInt = nil; Height: PLongInt = nil): GLuint;
  2. begin
  3.   ... create texture ...
  4.   if Width <> nil then
  5.       Width^ := CreatedWidth;
  6.   ...
  7. end;
  8.  

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.

Offline aksdb

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

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
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.

Offline aksdb

  • Imaging User
  • *
  • 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 :)

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
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.