• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Texture creation (OGL, DX, SDL) sizes

Started by aksdb, 27 December 2006, 18:24:53

Previous topic - Next topic

aksdb

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.

Galfar

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.


Galfar

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.

aksdb

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 :)

Galfar

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.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk