textures - CubeMap in OpenGL doesn't show at all -


i'm trying load 6 pictures texture of cube in opengl. blow loading code:

gltexparameteri(gl_texture_cube_map_arb, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_cube_map_arb, gl_texture_min_filter, gl_linear_mipmap_linear);  gltexparameteri(gl_texture_cube_map_arb, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_cube_map_arb, gl_texture_wrap_t, gl_clamp_to_edge); gltexparameteri(gl_texture_cube_map_arb, gl_texture_wrap_r, gl_clamp_to_edge);  (int = 0;i < 6;++i) {     int width, height, channel;     unsigned char* img = soil_load_image(skybox[i].c_str(), &width, &height, &channel, soil_load_auto);     glteximage2d(cubetarget[i], 0, gl_rgb, width, height, 0, gl_rgb, gl_unsigned_byte, img);     delete img; }  glenable(gl_texture_cube_map_arb); 

the rendering code passed. weird thing cube rendered white. seems texture isn't loaded @ all. change loading code see whether 2d texture work:

glgentextures(1, texture); glbindtexture(gl_texture_2d, texture[0]); int width, height, channel; unsigned char* img = soil_load_image(skybox[0].c_str(), &width, &height, &channel, soil_load_auto); glteximage2d(gl_texture_2d, 0, gl_rgb, width, height, 0, gl_rgb, gl_unsigned_byte, img); delete img;  if(texture[0] == 0) return false;  glbindtexture(gl_texture_2d, texture[0]); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear);  glenable(gl_texture_2d); 

the result can see texture after all, no matter how strange distribution caused texture coordinates. gathered following information:

  1. the lib use loading image works well;

  2. the setting of cubemap superbibble chapter 9. same code work when compiling code of book.

btw, have suggestion loading image library? 1 use seems stop updating long time...

appending: find out if try load 1 img skybox faces' texture, shown. long use variable replace specific value, nothing won't displayed.

finally figure out. it's because resolution of last picture different others.

realy kind of wasting lot of time.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -