#include #include #include #include #include #include #ifdef __APPLE__ #include #include #include #else #include #include #endif using namespace cv; using namespace std; Mat image; GLuint imageTexture; void displayMe(void) { // Set every pixel in the frame buffer to the current clear color. glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glColor3f(1, 0, 0); glVertex3f(-1.0, -1.0, 0.5); glColor3f(0, 1, 0); glVertex3f(1.0, -1.0, 0); glColor3f(0, 0, 1); glVertex3f(1.0, 1.0, 0); glVertex3f(-1.0, 1.0, 0); glEnd(); // Flush drawing command buffer to make drawing happen as soon as possible. glFlush(); } int main(int argc, char** argv) { string image_path = samples::findFile("chart.png"); Mat image = imread(image_path, IMREAD_COLOR); #if (CV_VERSION_MAJOR >= 4) cvtColor(image, image, cv::COLOR_BGR2RGB); #else cvtColor(image, image, CV_BGR2RGB); #endif glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(1920, 1080); glutInitWindowPosition(0, 0); glutCreateWindow("opengl_opencv_example"); glutFullScreen(); glutDisplayFunc(displayMe); glutMainLoop(); return 0; }