Witam. Mam w projekcie wczytać model 3d z pliku obj. Znalazłem na internecie gotowy przykład tylko, że pod 2D. Wiem, że kod trzeba przerobić. Częściowo przerobiłem. Natomiast nie wiem jak resztę. Zamieszczam poniżej ten kod. Podczas kompilacji wyskakuje mi błąd: `GL_TEXTURE_3D' undeclared (first use this function).

#include "stdafx.h"
#include <conio.h> 
#include <string.h>
#include <math.h>
#include "Texture.h"
#include <windows.h>
#include <GL/gl.h>
#include "glm.h"




#ifndef GL_BGR
#define GL_BGR GL_BGR_EXT
#endif

#ifndef GL_BGRA
#define GL_BGRA GL_BGRA_EXT
#endif

static GLint gl_max_texture_size;

GLuint glmLoadTexture(char *filename, GLboolean alpha, GLboolean repeat, GLboolean filtering, GLboolean mipmaps, GLfloat *texcoordwidth, GLfloat *texcoordheight)
{
GLuint tex;
int width, height,pixelsize;
int type;
int filter_min, filter_mag;
GLubyte *data, *rdata;
double xPow3, yPow3, zPow3;
int ixPow3, iyPow3, izPow3;
int xSize3, ySize3, zSize3;
GLint retval;

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max_texture_size);
char *numefis = filename;
while (*numefis==' ') numefis++;
Texture ttt;
LoadTGA(&ttt,(char *)numefis);
data = ttt.imageData;
width = ttt.width;
height = ttt.height;
type = ttt.type;
if(data == NULL) 
{
char err[80];
sprintf(err,"Nie można załadować tekstury %s!",numefis);
MessageBoxA(NULL, err, "ERROR", 1); // 
}


switch(type) {
case GL_LUMINANCE:
pixelsize = 1;
break;
case GL_RGB:
// case GL_BGR: 
pixelsize = 3;
break;
case GL_RGBA:
/// case GL_BGRA:
pixelsize = 4;
break;
default:
printf( "glmLoadTexture(): unknown type 0x%x", type);
pixelsize = 0;
break;
}

if((pixelsize*width) % 4 == 0)
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
else
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

xSize3 = width;
ySize3 = height;

/*if (xSize2 > gl_max_texture_size)
xSize2 = gl_max_texture_size;

if (ySize2 > gl_max_texture_size)
ySize2 = gl_max_texture_size;*/


/*************************************************************************************
// scale image to power of 2 in height and width 
xPow2 = log((double)xSize2) / log(2.0);
yPow2 = log((double)ySize2) / log(2.0);

ixPow2 = (int)xPow2;
iyPow2 = (int)yPow2;

if (xPow2 != (double)ixPow2)
ixPow2++;
if (yPow2 != (double)iyPow2)
iyPow2++;

xSize2 = 1 << ixPow2;
ySize2 = 1 << iyPow2; 

if((width != xSize2) || (height != ySize2)) 
{
rdata = (GLubyte*)malloc(sizeof(GLubyte) * xSize2 * ySize2 * pixelsize);
if (!rdata)
return 0; 
retval = gluScaleImage(type, width, height, GL_UNSIGNED_BYTE, data, xSize2, ySize2, GL_UNSIGNED_BYTE, rdata);

free(data);
data = rdata;
}
******************************************************************************************/

glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_3D, tex); 

if(filtering) 
{
filter_min = (mipmaps) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
filter_mag = GL_LINEAR;
}
else 
{
filter_min = (mipmaps) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
filter_mag = GL_NEAREST;
}

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, filter_min);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, filter_mag);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, (repeat) ? GL_REPEAT : GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, (repeat) ? GL_REPEAT : GL_CLAMP);

if(mipmaps)
gluBuild3DMipmaps(GL_TEXTURE_3D,GL_RGBA8, xSize3 ,ySize3, zSize3,	GL_RGBA,GL_FLOAT,data);
//gluBuil3DDMipmaps(GL_TEXTURE_3D, type, xSize3, ySize3, zSize3, type, GL_UNSIGNED_BYTE, data); 
else
glTexImage3D(GL_TEXTURE_3D, 0, type, xSize3, ySize3, zSize3, 0, type, GL_UNSIGNED_BYTE, data); 


free(data);


/**texcoordwidth = 1.; // texcoords are in [0,1]
*texcoordheight = 1.:*/


*texcoordwidth = xSize3; // size of texture coords 
*texcoordheight = ySize3;


return tex;
}