void Example::LoadTextures(const string& filename, TargaImage &Texture, GLuint* ID) { if (!Texture.load(filename)) std::cerr << "Could not load the grass texture" << std::endl; glGenTextures(1, ID); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, *ID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, Texture.getWidth(), Texture.getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, Texture.getImageData()); }
void glcTexture2D::init() { TargaImage textureImg; if(!textureImg.load(m_TextureFilename)) { std::cerr << "Could not load the texture" << std::endl; b_Initialized = false; return; } glGenTextures(1, &m_ID); glBindTexture(GL_TEXTURE_2D, m_ID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, textureImg.getWidth(), textureImg.getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, textureImg.getImageData()); b_Initialized = true; }