   simple library for loading textures
  Is there any library with texture-loading functions, where you can load textures by simply including it, and calling some kind of LoadTexture() function, or by writing only a little code.   
  Assuming we are talking about OpenGL here, I would recommend SOIL.   ;  SOIL is based on stb_image.c.  I actually like that API better.I ended up using libpng directly since PNG does everything I need and neither of the above handled 24bit.EDIT: Here's some PNG-loading code.// Everything needed to pass to glTexImage2D or relatedstruct Texture {Texture(const char *);~Texture();GLint internalformat;GLsizei width, height;GLenum format, type;GLvoid *pixels;};Texture::Texture(const char *path) : internalformat(0), width(0), height(0), format(0), type(GL_UNSIGNED_BYTE), pixels(NULL) {FILE *fp = fopen(path, "rb");if (!fp) {  goto clean_file;}  png_byte header[8];fread(header, 1, 8, fp);int is_png = png_check_sig(header, 8);if (!is_png) {  goto clean_file;}  png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);if (!png_ptr) {goto clean_file;}  png_infop info_ptr = png_create_info_struct(png_ptr);if (!info_ptr) {goto clean_read_struct;}png_infop end_info = png_create_info_struct(png_ptr);if (!end_info) {goto clean_read_struct;}if (setjmp(png_jmpbuf(png_ptr))) {goto clean_read_struct;}png_init_io(png_ptr, fp);png_set_sig_bytes(png_ptr, 8);GLint glMax;glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMax);png_set_user_limits(png_ptr, glMax, glMax);png_read_info(png_ptr, info_ptr);png_uint_32 twidth, theight;int bit_depth, color_type;png_get_IHDR(png_ptr, info_ptr, &twidth, &theight, &bit_depth, &color_type, NULL, NULL, NULL);width = twidth;height = theight;png_set_expand(png_ptr);   /* todo support 16 bit? */if (bit_depth == 16) {png_set_strip_16(png_ptr);} else if (bit_depth < 8) {png_set_packing(png_ptr);}switch (color_type) {    case PNG_COLOR_TYPE_GRAY:   internalformat = GL_LUMINANCE8;   format = GL_LUMINANCE;   break;    case PNG_COLOR_TYPE_GRAY_ALPHA:   internalformat = GL_LUMINANCE8_ALPHA8;   format = GL_LUMINANCE_ALPHA;   break;#if 1    /* everything else goes to the "one true format" */    case PNG_COLOR_TYPE_RGB:   png_set_bgr(png_ptr);   png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);   internalformat = GL_RGBA8;   format = GL_BGRA;   break;    case PNG_COLOR_TYPE_RGB_ALPHA:   png_set_bgr(png_ptr);   internalformat = GL_RGBA8;   format = GL_BGRA;   break;#else  case PNG_COLOR_TYPE_RGB: internalformat = GL_RGB8; format = GL_RGB; break;  case PNG_COLOR_TYPE_RGBA: internalformat = GL_RGBA8; format = GL_RGBA; break;#endif}png_read_update_info(png_ptr, info_ptr);int rowbytes = png_get_rowbytes(png_ptr, info_ptr);// allocate the image_data as a big block, to be given to opengl// row_pointers is tacked into the end to save a malloc   pixels = (byte *)malloc(sizeof(png_bytep)*rowbytes*height + sizeof(png_bytepp)*sizeof(png_bytep)*height);   png_bytep image_data = (png_bytep)pixels;   png_bytepp row_pointers = (png_bytepp)(image_data+sizeof(png_bytep)*rowbytes*height);for (int i = 0; i < height; ++i) {row_pointers[height - 1 - i] = image_data + i * rowbytes;}png_read_image(png_ptr, row_pointers);png_read_end(png_ptr, info_ptr);clean_read_struct:   png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);clean_file:fclose(fp);}Texture::~Texture() {  free (pixels);} [Edited by - CadetUmfer on June 26, 2009 11:10:05 AM];  What graphics API? If you're using D3D, there's D3DXCreateTextureFrom*().   ;Quote:Original post by CadetUmferSOIL is based on stb_image.c.  I actually like that API better.I ended up using libpng directly since PNG does everything I need and neither of the above handled 24bit.The one huge advantage to SOIL is that it handles DTX/ST3C compressed textures [smile]   