PDA

View Full Version : how to use gltexsubimage2d()?



yqs2002
11-17-2002, 10:36 PM
i am a newer of opengl,but how to use gltexsubimage2d() is diffculty for me,would you like to give me an example? thanks

11-20-2002, 06:29 PM
I am also new to OpenGL(took it this semester), but I just did assignment using glTexSubImage2D, and it's actually quiet simple:

//have a bigger image bigImage and the
// subImage sub
glBindTexture(GL_TEXTURE_2D, texNameforBigImage);
glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, subWidth, subHeight, format, type, sub);
//I set level to 0, if no mipmap involved, x and y offset is the lower left corner in pixel value where you want your subimage to appear in the bigger image, subWidth and subHeight is the dimension of your sub image, format should set to GL_RGBA or GL_RGB(no alpha value specified in the images)if you are using RGB to specify color in images. I set type to GL_UNSIGNED_BYTE.
BTW, the bigger image should have a big size than the sub image too. And you shouldn't bind the sub image either.
I am not good in grammers, hope this can help.

yqs2002
11-20-2002, 09:27 PM
THANKS ,i SOLVE the problem.it's simple really.