我正在用glsl版本1.20编写C ++ / OpenGL v3.1程序。我正在尝试调用glBindTexture(GL_TEXTURE_2D,m_texture_id_),其中m_texture_id_显然是包含纹理ID的GLuint。运行std :: runtime_error,这总是给我GL_INVALID_ENUM,虽然(至少对我来说)对glBindTexture的调用似乎是正确的。这是一些代码:
void Texture::Load(const std::string &filename) {
// Load only if we havent done so already
if(m_texture_id_ == 0) {
// skip
// Insert texture creation here
// Use gli::createTexture2D to load and create texture name and bind it
m_texture_id_ = gli::createTexture2D(filename);
glBindTexture(GL_TEXTURE_2D, m_texture_id_); // <----- Error occurs here!!!
// Set wrapping to repeat in both S and T directions
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// Set linear interpolation for magnification and linear-mipmap-linear for minification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// Construct mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
// unskip
}
}
之前有没有人遇到此错误?我应该采取哪些步骤来修复此错误?提前谢谢。