我想将此图片加载到 2d 纹理中,然后将其绘制到屏幕上。主要问题是将图片加载到纹理变量中。以下代码输出正确的宽度和高度以及 rgba,但我如何将数据放入 3d 纹理中。
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
/* more includes... */
#include "stb_image.h"
using namespace std;
int main(int argc, char** argv) {
int x,y,n;
unsigned char *data = stbi_load("png.png", &x, &y, &n, 0);
if (data == NULL) {
// error
cout << "Error, data was null";
} else {
// process
cout << data << endl << endl;
}
stbi_image_free(data);
cout << x << endl << y << endl << n;
return 0;
}