Display quad, full screen
This commit is contained in:
parent
32bf572d00
commit
801a56a78f
42
main.cpp
42
main.cpp
|
@ -23,19 +23,17 @@ GLuint imageTexture;
|
||||||
|
|
||||||
void displayMe(void)
|
void displayMe(void)
|
||||||
{
|
{
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
// Set every pixel in the frame buffer to the current clear color.
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glTexImage2D( GL_TEXTURE_2D, // Type of texture
|
glBegin(GL_POLYGON);
|
||||||
0, // Pyramid level (for mip-mapping) - 0 is the top level
|
glColor3f(1, 0, 0); glVertex3f(-1.0, -1.0, 0.5);
|
||||||
GL_RGB, // Internal colour format to convert to
|
glColor3f(0, 1, 0); glVertex3f(1.0, -1.0, 0);
|
||||||
image.cols, // Image width i.e. 640 for Kinect in standard mode
|
glColor3f(0, 0, 1); glVertex3f(1.0, 1.0, 0);
|
||||||
image.rows, // Image height i.e. 480 for Kinect in standard mode
|
glVertex3f(-1.0, 1.0, 0);
|
||||||
0, // Border width in pixels (can either be 1 or 0)
|
glEnd();
|
||||||
GL_RGB, // Input image format (i.e. GL_RGB, GL_RGBA, GL_BGR etc.)
|
|
||||||
GL_UNSIGNED_BYTE, // Image data type
|
// Flush drawing command buffer to make drawing happen as soon as possible.
|
||||||
image.ptr()); // The actual image data itself
|
glFlush();
|
||||||
glEnd();
|
|
||||||
glFlush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -43,33 +41,17 @@ int main(int argc, char** argv)
|
||||||
string image_path = samples::findFile("chart.png");
|
string image_path = samples::findFile("chart.png");
|
||||||
Mat image = imread(image_path, IMREAD_COLOR);
|
Mat image = imread(image_path, IMREAD_COLOR);
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
||||||
glGenTextures(1, &imageTexture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, imageTexture);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#if (CV_VERSION_MAJOR >= 4)
|
#if (CV_VERSION_MAJOR >= 4)
|
||||||
cvtColor(image, image, cv::COLOR_BGR2RGB);
|
cvtColor(image, image, cv::COLOR_BGR2RGB);
|
||||||
#else
|
#else
|
||||||
cvtColor(image, image, CV_BGR2RGB);
|
cvtColor(image, image, CV_BGR2RGB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//GLint dims[4] = {0};
|
|
||||||
//glGetIntegerv(GL_VIEWPORT, dims);
|
|
||||||
//GLint fbWidth = dims[2];
|
|
||||||
//GLint fbHeight = dims[3];
|
|
||||||
//cout << fbWidth << "," << fbHeight << endl;
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
glutInitDisplayMode(GLUT_SINGLE);
|
glutInitDisplayMode(GLUT_SINGLE);
|
||||||
glutInitWindowSize(1920, 1080);
|
glutInitWindowSize(1920, 1080);
|
||||||
glutInitWindowPosition(0, 0);
|
glutInitWindowPosition(0, 0);
|
||||||
glutCreateWindow("Hello world!");
|
glutCreateWindow("opengl_opencv_example");
|
||||||
glutFullScreen();
|
glutFullScreen();
|
||||||
|
|
||||||
glutDisplayFunc(displayMe);
|
glutDisplayFunc(displayMe);
|
||||||
|
|
Loading…
Reference in New Issue