c++ - loading ogl texture using DEVIL -


here code

typedef struct texture {     glubyte *data;     gluint  bpp;     gluint width, height;     gluint id; }texture;  class textureloader {     public:     textureloader()     {         ilinit();         iluinit();     }     void load(ilenum filetype, const char *filename, texture *texture)     {         ilload(filetype, filename);          texture->width = ilgetinteger(il_image_width);         texture->height = ilgetinteger(il_image_height);         texture->bpp = ilgetinteger(il_image_bytes_per_pixel);          texture->data = ilgetdata();         ilenable(il_conv_pal);          unsigned int type = ilgetinteger(il_image_format);         glgentextures(1, &texture->id);         glbindtexture(gl_texture_2d,texture->id);         glubuild2dmipmaps(gl_texture_2d, texture->bpp, texture->width,             texture->height, type, gl_unsigned_byte, texture->data);         gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear_mipmap_nearest);     } }loader; 

and doesn't seem work.
there segmentation fault after calling glubuild2dmipmaps.
can't understand what's problem because code copy-pasted example(... call of textureloader::load:

vector <texture> bgtextures; bgtextures.resize(1); loader.load(il_jpg,"bgsnow.jpg",&bgtextures[0]); 

can me?

look @ return value of this:

ilload(filetype, filename);

by doing following code:

if (ilload(filetype, filename) == il_false) {     //make produce error or something. } 

as genpfault suggested, passing in incorrect filename.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -