c++ - GL_INVALID_OPERATION in glGenerateMipmap(incomplete cube map) -
i'm trying learn opengl , i'm using soil load images.
i have following piece of code:
gluint texid = 0; bool loadcubemap(const char * basefilename) { glactivetexture(gl_texture0); glgentextures(1, &texid); glbindtexture(gl_texture_cube_map, texid); const char * suffixes[] = { "posx", "negx", "posy", "negy", "posz", "negz" }; gluint targets[] = { gl_texture_cube_map_positive_x, gl_texture_cube_map_negative_x, gl_texture_cube_map_positive_y, gl_texture_cube_map_negative_y, gl_texture_cube_map_positive_z, gl_texture_cube_map_negative_z }; (int = 0; < 6; i++) { int width, height; std::string filename = std::string(basefilename) + "_" + suffixes[i] + ".png"; std::cout << "loading: " << filename << std::endl; unsigned char * image = soil_load_image(filename.c_str(), &width, &height, 0, soil_load_rgb); if (!image) { std::cerr << __function__ << " cannot load image " << filename << " (" << soil_last_result() << ")" << std::endl; return false; } glteximage2d(gl_texture_2d, 0, gl_rgb, width, height, 0, gl_rgb, gl_unsigned_byte, image); soil_free_image_data(image); } gltexparameteri(gl_texture_cube_map, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_cube_map, gl_texture_min_filter, gl_linear_mipmap_linear); gltexparameteri(gl_texture_cube_map, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_cube_map, gl_texture_wrap_t, gl_clamp_to_edge); gltexparameteri(gl_texture_cube_map, gl_texture_wrap_r, gl_clamp_to_edge); glgeneratemipmap(gl_texture_cube_map); glbindtexture(gl_texture_cube_map, 0); return true; }
when call this, images load successfully, error in console:
---- ogl debug ---- message <1>: 'api' reported 'error' 'high' severity: gl_invalid_operation in glgeneratemipmap(incomplete cube map) ---- backtrace ----
and no cubemap displaying @ all. see mistake in code?
you never specify texture image cube map faces. instead call glteximage2d
on gl_texture_2d
target of cube faces.
Comments
Post a Comment