I am learning opengl recently, and I have do some code on qt. Using QOpenGLWidget, I can draw my own 3D garphics. I did it. I configured a new monitor for my laptop as an extension screen. So I can code and debug more conveniently. It still worked correctly. But while I close the extension screen(only my laptop screen), my 3d graphics cannot be displayed. It’s all black.
I don’t know how to solve this puzzling problem, although I’ve done a lot of trying. Here is my shader:
const char *vertexShaderSource = "#version 330 core
"
"layout (location = 0) in vec3 aPos;
"
"layout (location = 1) in vec3 color;
"
"layout (location = 2) in vec3 colorLine;
"
"out vec4 col;
"
"uniform mat4 model;
"
"uniform mat4 view;
"
"uniform mat4 projection;
"
"uniform bool useLineColor;
"
"void main()
"
"{
"
" gl_Position = projection * view * model * vec4(aPos.x, aPos.y, aPos.z, 1.0);
"
" if(useLineColor) col = vec4(colorLine.x/255.0f, colorLine.y/255.0f, colorLine.z/255.0f, 1.0);
"
" else col = vec4(color.x/255.0f, color.y/255.0f, color.z/255.0f, 1.0);
"
"}\0";
const char *fragmentShaderSource = "#version 330 core
"
"out vec4 FragColor;
"
"in vec4 col;
"
"void main()
"
"{
"
" FragColor = col;
"
"}
\0";
My laptop screen resolution is 19201080, and my new extension screen resolution is 1440900.
How should I solve this problem or debug my code to find the ultimate cause?
Thanks for any advice.
OpenGL version 3.3
Qt Creator 5.9.1 on Windows10
MSVC2015 64bit complier.