//loadingtexture
xImageimage;
if(false==image.load(filename))
returnfalse;
xImageSizeimgSize=image.getSize();
image.scalePOT();//放大到2的幂
image.convert(PIXELFORMAT_B8R8G8A8);//转成BGRA格式
xImageSizetexSize=image.getSize();
glBindTexture(GL_TEXTURE_2D,m_texID);
glTexImage2D(GL_TEXTURE_2D,0,4,texSize.w,texSize.h,0,GL_BGRA_EXT,GL_UNSIGNED_BYTE,image.data());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexEnvi(GL_TEXTURE_2D,GL_TEXTURE_ENV_MODE,GL_MODULATE);
//savethescreentodisk
xImageimage;
ePIXEL_FORMATfmt=PIXELFORMAT_B8G8R8A8;
image.load(800,600,fmt);
glReadBuffer(GL_FRONT);
glReadPixels(00,800,600,glfmt,datatype,image.data());
image.save("screen.tga");
image.free();
freeimage库的下载地址:
http://freeimage.sf.net/
同时代码包里还附带一个类xml的配置文件解析器。
欢迎使用。有好的建议和bug请报告给我。
eMail:[email protected]
下载地址:http://xreal.51.net/Download/public_src.zip