Results 1 to 1 of 1

Thread: renderPixmap() fails to load glsl shaders

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default renderPixmap() fails to load glsl shaders

    Hello,

    I am having some trouble getting QGLWidget::renderPixmap() to render images that use a pixel shader.

    In my application I have a loadShaders() function that is called from within initializeGL() in a custom class the inherits QGLWidget(). I use renderPixmap() to perform an offline animation export where we dump several .png files to disk and build up an animation sequence. When calling renderPixmap() the new QGLContext that is created makes a call to initializeGL() which then try's to load the pixel shaders. In loadShaders() the call to glCreateShader() fails and returns 0. This causes the rendered image to have no pixel shaders applied and the image is not as expected. I'm not sure why this fails and there are no errors in the GL error log.

    On linux and unix I have successfully gotten around this be passing useContext = true to the renderPixmap() function, which then uses the current glContext that is built up with QGLWidget when rendering the images. This seems to work great and gives the desired images using the pixel shaders; however, this is not supported on Windows. I am looking for a solution that will work on both linux, unix, and windows.

    I have also recreated this behavior with the 'grabber' example found in <Path_to_Qt>/examples/opengl/grabber. I have modified the glwidget class to use a very simple pixel shader (refer to attached files for source code changes). I've tested this example on linux using gcc 4.4.3. After running qmake I also had to add -DGL_GLEXT_PROTOTYPES to my DEFINES, and add -I/usr/include to my INCPATH in my Makefile to get that example to compile and link correctly. Depending on where GL/glx.h is on your system you may have to tweak the include path.

    In this simple example my shader just returns the color red for all pixels. When running this modified example the left-hand graphics widget shows all the gears red with no lighting meaning the shader was loaded successfully and is being used. When calling render to pixmap from the options the image that is rendered shows the red/green/blue gears which is the fall back rendering when the shaders fail to load. Calling the grab frame buffer option works as expected showing all the gears red. Tweaking the call to renderPixmap() to set useContext = true corrects the problem and shows the expected behavior when calling the render to pixmap option.

    Since useContext flag is not supported under windows, is there any other work around to use the renderPixmap() function with pixel shaders? Or is there a way to setup my shader program so renderPixmap() will correctly create the gl shader when initializing the new QGLContext?

    Or is there another approach I can take to get images that are rendered offline and show the pixel shaders? I have tried replacing renderPixmap() with grabFrameBuffer() but since this is an offlline rendering the results are not as expected. Not sure why this is, assuming it has to do with the rendering being done offline (i.e. there is no graphics window rendered to the screen). For this same reason using QPixmap::grabWindow() or QPixmap::grabWidget() doesn't work either.

    Any support that can be provided would be greatly appreciated.
    Thanks,
    John
    Attached Files Attached Files
    Last edited by jscurlee; 17th September 2010 at 22:56.

Similar Threads

  1. Replies: 3
    Last Post: 29th April 2010, 15:18
  2. custom plugin load fails...
    By raman_31181 in forum Qt Tools
    Replies: 3
    Last Post: 3rd July 2008, 09:37
  3. designer plugin fails to load
    By ModeZt in forum Qwt
    Replies: 6
    Last Post: 4th February 2008, 21:08
  4. [mac] QImage.load fails
    By snoopy67 in forum Qt Programming
    Replies: 4
    Last Post: 7th November 2007, 14:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.