以下のようにして画像読み込みとテクスチャ作成が可能である。
【例】
#include <nvImage.h>//内部でglew.hをインクルードしている
#include <GL/glut.h>
... ...
//----- テクスチャID -----//
GLuint texture[1];
... ...
void LoadTexture()
{
nv::Image imgA;
if(!imgA.loadImageFromFile("test.png"))
{
std::cerr << "Can't Load Image \n";
return ;
}
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //拡大フィルタ
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //縮小フィルタ
glTexImage2D(GL_TEXTURE_2D,0,imgA.getInternalFormat(), imgA.getWidth(),imgA.getHeight(),0, imgA.getFormat(),imgA.getType(),imgA.getLevel(0));
}