void LoadTextures(const char *textureName) { std::cout << "Loading Texture " << textureName << std::endl; int w, h, c, b; void *p = image_read(textureName, &w, &h, &c, &b); int i = image_internal_form(c, b); int e = image_external_form(c); int t = image_external_type(b); image_flip(w, h, c, b, p); glTexImage2D(GL_TEXTURE_2D, 0, i, w, h, 0, e, t, p); free(p); std::cout << "Done Loading Texture " << textureName << std::endl; }
static void init_tex(struct cube *C) { void *p; int w; int h; int c; int b; int i; for (i = 0; i < 6; ++i) if ((p = image_read(names[i], &w, &h, &c, &b))) { int f = image_internal_form(c, b); int e = image_external_form(c); int t = image_external_type(b); glBindTexture(GL_TEXTURE_2D, C->tex[i]); glTexImage2D (GL_TEXTURE_2D, 0, f, w, h, 0, e, t, p); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } }