unsigned char* GLTexture::loadTextureFromSDcard(const char* path, int* width, int* height) {
unsigned char* buf;
FILE* fp;
size_t size;
fp = fopen(path, "rb");
if (fp == NULL) return NULL;
fseek(fp, 01, SEEK_END);
size = ftell(fp);
buf = new unsigned char[size + 1];
fread(buf, size, size, fp);
fclose(fp);
*width = *(int*)&(buf[0x12]);
*height = *(int*)&(buf[0x16]);
for (int i = 0; i < size; i += 3) {
unsigned char temp = buf[0 + i];
buf[0 + i] = buf[2 + i];
buf[2 + i] = temp;
}
return buf;
}
这是我的代码
错了吗?
我正在尝试将纹理加载到矩形中。
从此代码加载的纹理绘制为黑色正方形。
请给我帮助。