qglwidget

How to take reliable QGLWidget snapshot

荒凉一梦 提交于 2019-12-07 06:18:00
问题 In my application I take snapshots of a QGLWidget's contents for two purposes: Not redraw the scene all the time when only an overlay changes, using a cached pixmap instead Lat the user take screenshots of the particular plots (3D scene) The first thing I tried is grabFrameBuffer() . It is natural to use this function as for the first application, what is currently visible in the widget is exactly what I want to cache. PROBLEM: On some hardware (e.g. Intel integrade graphics, Mac OS X with

How to scale glDrawPixels?

半腔热情 提交于 2019-12-07 05:25:34
问题 I need to scale the result of glDrawPixels image. I'm drawing a 640x480 pixels image buffer with glDrawPixels in a Qt QGLWidget. I tryed to do the following in PaintGL: glScalef(windowWidth/640, windowHeight/480, 0); glDrawPixels(640,480,GL_RGB,GL_UNSIGNED_BYTE,frame); But it doesn't work. I am setting the OpenGL viewport and glOrtho with the size of the widget as: void WdtRGB::paintGL() { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setup the OpenGL viewpoint glMatrixMode(GL

QGLWidget appears black in Windows 7

吃可爱长大的小学妹 提交于 2019-12-05 14:27:16
I wrote and tested some code in a Windows XP (Qt 4.7.2) using Visual Studio 2010 and then I tried on another machine with Windows 7 installed. The program opens a QDialog and creates a QGLWidget where I show webcam images (with some processing). While in Windows XP the images are shown correctly, at the moment that I test the program in a Windows 7 machine, the QGLWidget turns black and no image is shown. It is strange, though, that when I move around the window and it gets out of the borders of the screen, the image is shown for an instant and pitch black when I stop moving again, which makes

Sharing OpenGL VAO/VBO/etc. via QGLWidget

喜欢而已 提交于 2019-12-05 13:33:50
I am using a 3 layer hierarchy of QGLWidgets to share shaders and vertex data between 5 OpenGL viewports in my CAD-like app. The root context is used for compiling application-wide shaders, the per document context is used to share model vertex data, and the viewport contexts are the ones that actually do the rendering (and also contain grid vertex data and other per viewport stuff). The shader sharing seems to work fine, and so does the grid drawing, but when it comes to sharing vertex data it fails and to be honest - I cannot see how it is supposed to work... I built a 3D icon for an item

How to scale glDrawPixels?

青春壹個敷衍的年華 提交于 2019-12-05 10:28:09
I need to scale the result of glDrawPixels image. I'm drawing a 640x480 pixels image buffer with glDrawPixels in a Qt QGLWidget. I tryed to do the following in PaintGL: glScalef(windowWidth/640, windowHeight/480, 0); glDrawPixels(640,480,GL_RGB,GL_UNSIGNED_BYTE,frame); But it doesn't work. I am setting the OpenGL viewport and glOrtho with the size of the widget as: void WdtRGB::paintGL() { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setup the OpenGL viewpoint glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, windowWidth, windowHeight, 0, -1.0, 1.0); glDepthMask(0); /

How to take reliable QGLWidget snapshot

点点圈 提交于 2019-12-05 09:13:54
In my application I take snapshots of a QGLWidget's contents for two purposes: Not redraw the scene all the time when only an overlay changes, using a cached pixmap instead Lat the user take screenshots of the particular plots (3D scene) The first thing I tried is grabFrameBuffer() . It is natural to use this function as for the first application, what is currently visible in the widget is exactly what I want to cache. PROBLEM: On some hardware (e.g. Intel integrade graphics, Mac OS X with GeForce graphics), the image obtained does not contain the current screen content, but the content before

How to look for equivalent functions of OpenGL in QGLWidget?

故事扮演 提交于 2019-12-05 07:14:25
问题 I'm new to OpenGL and Glut. There is a project implemented by Glut. I googled and found that there is an OpenGL implementation in Qt, called QGLWidget. However, it's hard for me converting the old Glut code to new Qt code since I don't know how to find equivalent function for Glut functions in Qt. Part of the code look like this: glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); glutInitWindowSize(gray1->width,gray1->height); glutInitWindowPosition(100,100); glutCreateWindow(

Strategy for sharing OpenGL resources

不问归期 提交于 2019-12-05 07:04:23
I'm creating a CAD-like app (Qt-based), it will be a multiple document interface and each document will contain about 5 viewports (derived from QGLWidget). As such I need my flat shader to be shared across the entire application, and then the 3D assets (models stored as VBOs) to be shared across each document i.e. the 5 viewports. I thought as long as I shared around the shader program and VBO GLuint addresses all will automagickly work - it doesn't. I think because each viewport/context has it's own address space on the graphics card, if anyone knows better please inform! I would like to have

Rendering a OpenCV IplImage to a QGLWidget

跟風遠走 提交于 2019-12-04 16:27:31
I am having trouble with rendering a OpenGL scene. The background is I want to display the frames from a video capture device in a preview window. I am using OpenCV and Qt. And to test I am capturing from my MacBook webcam. The preview window is 200x200 and the frame captured is 640x480. I am not worried about maintaining aspect ratios. Other info from the IplImage struct: Debug: channels: 3 Debug: depth: 8 Debug: dataOrder: 0 Debug: align: 4. Alignment of image rows 4 or 8 Debug: origin: 0. 0=top left, 1=bottom left Debug: widthStep: 2560. Debug: colorModel: RGB So this image shows the

Undefined reference to vtable, Qt in Linux

浪尽此生 提交于 2019-12-01 17:40:01
问题 I was trying to compile a Qt and OpenGL program under Code::Blocks in Ubuntu 10.04. I get the 'undefined reference to 'vtable for GLWidget' #ifndef _GLWIDGET_H #define _GLWIDGET_H #include <QtOpenGL/QGLWidget> #include "stdlib.h" class GLWidget : public QGLWidget { Q_OBJECT // must include this if you use Qt signals/slots public: GLWidget(QWidget *parent = 0); ~GLWidget(); protected: void initializeGL(); void resizeGL(int w, int h); void paintGL(); void keyPressEvent(QKeyEvent *event); };