PDA

View Full Version : Loading textures, methods, ideas, suggestions are welcomed.



dagcrack
04-17-2005, 04:46 PM
Hello guys, todays problem relies on the texture loading, I'm working with PureBasic at the moment, which is fast enough in my opinion. but the method im using for the textures is really slow.

Im reading every pixel and storing it into an array, this is slow!.

heres a code snippet:


img = LoadImage(#PB_Any, filename.s)
Width.l=ImageWidth()
Height.l=ImageHeight()
Size.l=Width * Height

Dim ImageData.b(Size*3)

StartDrawing(ImageOutput())
For y=0 To Height-1
For x=0 To Width-1

Color = Point(x,y)
ImageData(i)=Red(Color)
i+1
ImageData(i)=Green(Color)
i+1
ImageData(i)=Blue(Color)
i+1

Next
Next
StopDrawing() after that I call gentextures and set the filter..

Does anyone know of a faster method for loading textures? in purebasic LoadImage is very fast, thats not the problem (a 2048x2048 blank bitmap takes 120 millisecs to load).

If theres no other method I could work with, what lib do you suggest me to use for reading the pixels? (that seems the slow part of my method).

thanks in advice

N64Marin
04-17-2005, 04:59 PM
Using precompressed texture and glCompressedTexImage?D

dorbie
04-17-2005, 05:22 PM
The problem is not image size but an incredibly inefficient read strategy coupled with a sub optimal choice of language.

Look at this for ideas:

http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=2;t=018357

You should try to make your reads more contiguous and do less work per pixel. A 24 bit BMP image can be loaded more directly ready for use as a texture.

Please post questions like this in the beginners section.