On Ubuntu 16.04, I've tried to use WrapTexture to load an image to texture using code below:
But
glGenerateMipmap(GL_TEXTURE_2D); is not found.
I include these headers:
#include <GL/gl.h>
#include <GL/glut.h>
InitializeComponent();
cv::Mat image = cv::imread("./1.jpg");
_image = FindName<Image>("img1");
GLuint TextureID;
if (image.empty()) {
std::cout << "image empty" << std::endl;
} else {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glGenTextures(1, &TextureID);
glBindTexture(GL_TEXTURE_2D, TextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Set texture clamping method
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
cv::cvtColor(image, image, CV_RGB2BGRA);
glTexImage2D(GL_TEXTURE_2D, // Type of texture
0, // Pyramid level (for mip-mapping) - 0 is the top level
GL_BGR, // Internal colour format to convert to
image.cols, // Image width i.e. 640 for Kinect in standard mode
image.rows, // Image height i.e. 480 for Kinect in standard mode
0, // Border width in pixels (can either be 1 or 0)
GL_BGR, // Input image format (i.e. GL_RGB, GL_RGBA, GL_BGR etc.)
GL_UNSIGNED_BYTE, // Image data type
image.ptr()); // The actual image data itself
}
Ptr<Texture> NsTexture = GLRenderDevice::WrapTexture(TextureID, 300, 450, 0, false);
Ptr<TextureSource> NsTextureSource = MakePtr<TextureSource>(NsTexture);
_image->SetSource(NsTextureSource);
Result:
What is wrong here?
Many thanks