У меня есть небольшое приложение на OpenGL + GLEW. Теперь я пытаюсь переписать его с помощью QT (вместо GLEW). Но у меня проблема. IDE пишет:glActiveTexture в Qt и QGLWidget?
'glActiveTexture' was not declared in this scope glActiveTexture(TextureUnit); ^
Вот что код в .cpp файле:
#include <iostream>
#include "texture.h"
Texture::Texture(GLenum TextureTarget, std::string& FileName)
{
m_textureTarget = TextureTarget;
m_fileName = FileName;
}
bool Texture::Load()
{
// A lot of code for reading the picture.
}
void Texture::Bind(GLenum TextureUnit)
{
glActiveTexture(TextureUnit);
glBindTexture(m_textureTarget, m_textureObj);
}
Вот код из .h файла.
#ifndef TEXTURE_H
#define TEXTURE_H
#include <string>
#include <QGLWidget>
class Texture
{
public:
Texture(GLenum TextureTarget, std::string& FileName);
bool Load();
void Bind(GLenum TextureUnit);
private:
std::string m_fileName;
GLenum m_textureTarget;
GLuint m_textureObj;
unsigned int width, height;
unsigned char * data;
};
#endif /* TEXTURE_H */
Я начинаю думать, что Qt не предоставляет такие возможности. Как я могу решить эту проблему? Буду рад любым идеям.
Должен ли я просто добавить '# include' и написать что-то вроде' QOpenGLFunctions_4_3_Core :: glActiveTexture (TextureUnit); '. Или это работает необычным образом? – user3051029
Прочитайте документацию, которую я связал. Вы не можете просто использовать это статически. Эти указатели должны быть запрошены во время выполнения после создания контекста GL. – derhass
Хорошо, спасибо. – user3051029