PDA

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



supercoollee
05-10-2010, 12:28 PM
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?

supercoollee
05-10-2010, 12:51 PM
i just read about another way to load texture:
http://forum.gamedeception.net/archive/index.php?t-5425.html
which way is better?

strattonbrazil
05-10-2010, 04: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.

supercoollee
05-11-2010, 04: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:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24

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:
glGenTexture(1,&texture[0].texID)
glBindTexture(GL_TEXTURE_2D,texture[0].texID)
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.