Qt中OpenGL模块下将图片转化为纹理,并传入shader中
QImage texture, buffer; buffer.load("C:/Users/wukesong/Pictures/flower.jpg"); texture = QGLWidget::convertToGLFormat(buffer);//转换为OpenGL支持的格式 glGenTextures(, &gColorSpec);//创建纹理数量 :一个 glBindTexture(GL_TEXTURE_2D, gColorSpec);//将纹理绑定到目标纹理上 glTexImage2D(GL_TEXTURE_2D, , , texture.width(), texture.height(), , GL_RGBA, GL_UNSIGNED_BYTE, texture.bits()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//滤波 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, );
相关推荐
sxaudq0 2020-05-09
wanghualin0 2014-05-19
dayenglish 2013-04-12
wanghualin0 2012-04-07
嗜简如命 2015-02-25
perseverancep 2015-02-25
hankern 2015-02-25