PDA

View Full Version : Loadtexture form memory?



azrael11
28-01-2011, 11:36 AM
I use the
function LoadTexture(Filename: String; var Texture: GLuint; LoadFromRes : Boolean): Boolean;

I save an image to a streammemory name imagestrmemory.
How can i load from the memory an put in the loadtexture function so i can show it any time i want.

Thanks...

User137
28-01-2011, 12:38 PM
I guess you need to specify what libraries you use. I'm not familiar with LoadTexture() with those parameters.

That function only seems capable of loading from file or resource. I'm not sure if you can put a file from stream into resource at runtime... If not, you have to put the images to the resources before compiling.

azrael11
28-01-2011, 02:32 PM
I guess you need to specify what libraries you use. I'm not familiar with LoadTexture() with those parameters.

That function only seems capable of loading from file or resource. I'm not sure if you can put a file from stream into resource at runtime... If not, you have to put the images to the resources before compiling.

Yes this function loads an image file from the disk...

If anybody have a function that loads image from stream please post it here.

arthurprs
29-01-2011, 02:11 AM
This function is from which library?

azrael11
29-01-2011, 10:26 AM
This function is from which library?

from :
// Author : Jan Horn
// Email : jhorn@global.co.za
// Website : http://home.global.co.za/~jhorn
// Version : 1.01
// Date : 1 May 2001
// Description : A unit that used with OpenGL projects to load BMP and TGA
// files from the disk or a resource file.
// Usage : LoadTexture(Filename, TextureName, LoadFromResource);
//
// eg : LoadTexture('logo.tga', LogoTex, TRUE);
// will load a TGA texture from the resource included
// with the EXE. File has to be loaded into the Resource
// using this format "logo TGA logo.tga"

very old but good...

function LoadTexture(Filename: String; var Texture : GLuint; LoadFromRes : Boolean) : Boolean;
begin
result:=false;
if copy(filename, length(filename)-3, 4) = '.bmp' then
result:=LoadBMPTexture(Filename, Texture, LoadFromRes);
if copy(filename, length(filename)-3, 4) = '.tga' then
result:=LoadTGATexture(Filename, Texture);
end;

The function either load bmp image or tga with alpha or not...

User137
29-01-2011, 01:28 PM
In that case it might not be too impossible to look into LoadBMPTexture() and so forth, and then write a function LoadFromStreamBMP() that takes stream as parameter.

I haven't used streams in my own texture units just because i don't see reason to. Only purpose of streams would be to keep the texture in the physical memory instead of video memory, and for that purpose i can load texture from TBitmap.

However if i consider a case in game where i have 100 fullscreen loading screens for different levels it would be quite silly to load every one of them waiting in memory. Loading time from file is very fast also unless those functions are bad, but it also keeps the memory use lower.

azrael11
29-01-2011, 06:52 PM
In that case it might not be too impossible to look into LoadBMPTexture() and so forth, and then write a function LoadFromStreamBMP() that takes stream as parameter.

I haven't used streams in my own texture units just because i don't see reason to. Only purpose of streams would be to keep the texture in the physical memory instead of video memory, and for that purpose i can load texture from TBitmap.

However if i consider a case in game where i have 100 fullscreen loading screens for different levels it would be quite silly to load every one of them waiting in memory. Loading time from file is very fast also unless those functions are bad, but it also keeps the memory use lower.

I have the same opinion with you about loading images from file.
Something is wrong with the load bmp file.
The scene is this i have a cube with diferent texture in every plane of the cube.
With the hit of the key must delete the old ones and load another.
One texture is about 630 kb each, so 630x6 = 3780 3.6mb.
I think is big so i load instantly from a zip file that contains the six textures.
But from zip i can extract in memory (using 7zip header from progdigy.com) and i want to take it from the memory and put it in the cube.

Any good idea is acceptable :)

arthurprs
29-01-2011, 07:49 PM
You can modify the library (attach the files so we can take a look) or use another library (like http://imaginglib.sourceforge.net/ ).

azrael11
29-01-2011, 09:06 PM
You can modify the library (attach the files so we can take a look) or use another library (like http://imaginglib.sourceforge.net/ ).

That is my first thought but i thing i ask here (there are many great programmers here) to take an opinion.