有人可以举一个 freeimage(with opengl) 和 glfw3 的简单例子吗?
仅使用image er("io.png"); er->gen();
blackscree 时呈现
程序代码
class image
{
public:
FREE_IMAGE_FORMAT format;
FIBITMAP * img;
GLubyte* texture;
char* pixels;
GLuint texID;
int w,h;
image(char* cr){
format = FreeImage_GetFileType(cr);
img = FreeImage_Load(format,cr);
w = FreeImage_GetWidth(img);
h = FreeImage_GetHeight(img);
cout << w << " " << h << endl;
pixels = (char*)FreeImage_GetBits(img);
}
void gen()
{
glGenTextures(1,&texID);
glBindTexture(GL_TEXTURE_2D,texID);
glTexImage2D(GL_TEXTURE_2D,0,GL_BGR,w,h,0,GL_BGR,GL_TEXTURE_2D,pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
};
我正在尝试使用图像作为背景 opengl 应用程序