View Full Version : can i load a texture file without auxDIBImageLoad?

05-10-2010, 11:28 AM
can i tell OPENGL to load texture from a memory address?
such as, i use windows function to load texture1.tga into memory, now memory 07000000-07010000 contains all data of texture1.tga .
can OPENGL read from this memory area and bind the texture to a polygon?

05-10-2010, 11:51 AM
i just read about another way to load texture:
which way is better?

05-10-2010, 03:20 PM
You bet! That's exactly what glTexImage2D does, where it takes a pointer in memory and loads it into the bound texture. The only caveat is you have to make sure whatever library you used laid out the image in a way OpenGL understands--no headers and such. If it's laid out in memory with one pixel after another and the channels line up correctly, it'll work fine.

05-11-2010, 03:27 AM
can someone tell me what's the correct program flow to bind texture to polygon? for example, i have successfully loaded all data of a TGA file into memory.
say address = 0x07000000-0x07010030
dword pMapFile contains the address 0x07000000
image format 128x128x32bit BGRA

the data in memory are like these:
x x x x x x x x x x x x x x x x x x 00 00 ff ff 00 ff 00 ff ff 00 00 ff ...... (header 18 bytes, color of each pixel follows)

i am following NEHE's OGL tutorial:

but i am using ASM instead of C language, so i tried to convert the codes into ASM. but the outcome is wrong.
i don't understand the purpose of:
glTexImage2D(...... , texture[0].imagedata)

what are " &texture[0].texID" "texture[0].texID" "texture[0].imagedata"
are they memory addresses? or just ID numbers?
how do they relate to the memory address 0x07000000 ?

in my program, the polygon only shows red/black strips , while the TGA contains red/green/blue colors.