Reputation: 2173
I am writing an OpenGL app using Qt, and it builds and runs fine on my desktop, but when I try running the exact same code on my laptop, it builds but does not output anything? Here is my main.cpp
#include <QtGui/QApplication>
#include <QtOpenGL/QGLWidget>
#include "GLWidget.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
GLWidget window;
window.resize(1050,700);
window.setFixedSize(1050, 700);
window.show();
return app.exec();
}
I do not want the user to be able to resize the window, hence the fixed size. If I set a breakpoint on the last line of main, it never reaches it on my laptop. I have stepped through the code and right after show() is called (which is just an inline function) the debugger finishes with code 0. I checked all the project build and run settings, they are the same on both machines. My desktop has a 1920x1080 monitor, but my laptop is only 1366x768 could this have anything to do with it? Is there some sort of internal check going on under the hood in Qt that depends on my screens resolution? That is pretty much the only thing I can think of.
Upvotes: 1
Views: 340
Reputation: 162309
I do not want the user to be able to resize the window
May I ask why? May I presume you want the window to be a fixed size, because you want to use OpenGL to generate a image exactly this size? If so, then I must tell you, it will not work that way. OpenGL implementations will only render what will become visible on the screen (pixel ownership test). If parts of the window are not visible (and in your case this will be the case on the laptop) those pixels are simply not rendered. Reading out the framebuffer will leave those pixels undefined.
The proper way to tackle this problem is using either a PBuffer, or a Frame Buffer Object (FBO). FBOs are easier to use, but not as widely supported on Windows (Intel graphics on Windows have rather poor FBO support). FBOs are supported by all Linux OpenGL implementations (Mesa (also does Intel), ATI/AMD and NVidia). There are numerours FBO and PBuffer tutorials in the web.
Upvotes: 1