Results 1 to 3 of 3

Thread: Alpha channel weirdness with QGLContext

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Feb 2006
    Location
    Norwalk, CT, USA
    Posts
    6
    Qt products
    Qt3
    Platforms
    Unix/X11

    Talking Re: Alpha channel weirdness with QGLContext

    Solved!

    OK, this is for any programmer who comes along with a similar problem. If you need the alpha channel for any purpose, you need to enable it when you create the application by using a special X11 (this was done on Linux) version of the QApplication constructor.

    Code as follows:

    Qt Code:
    1. static int attrListDbl[] =
    2. {
    3. GLX_RGBA, GLX_DOUBLEBUFFER,
    4. GLX_RED_SIZE, 4,
    5. GLX_GREEN_SIZE, 4,
    6. GLX_BLUE_SIZE, 4,
    7. GLX_ALPHA_SIZE, 4,
    8. GLX_DEPTH_SIZE, 16,
    9. None
    10. };
    11.  
    12. int main( int argc, char ** argv )
    13. {
    14. Display * dpy = XOpenDisplay(0);
    15. int scr = DefaultScreen(dpy);
    16. XVisualInfo * vis = glXChooseVisual(dpy, scr, attrListDbl);
    17.  
    18. // QApplication a( argc, argv );
    19. QApplication a(dpy, argc, argv, (long unsigned int)vis);
    20.  
    21. CFormVolumeViewer w;
    22. a.setMainWidget((QWidget *)&w);
    23. w.show();
    24. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    25. return a.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 

    This enables the alpha channel for any subsequent QGLContext that you create. Remember that you still need to call QGLFormat::setAlpha(TRUE) before it will work.

    Unfortunately, it doesn't look like there's a WIN32 equivalent to this. I know from programming on WIN32 with OpenGL that you DO need to set the alpha bits using the Pixel Format Descriptor.
    Last edited by renaissanz; 15th March 2006 at 16:16. Reason: no win32 equivalent...

Similar Threads

  1. Alpha Channel support is broken for GIMP png and bmp files
    By mschifter in forum Qt Programming
    Replies: 3
    Last Post: 25th June 2015, 21:52
  2. SVG to alpha channel QPixmaps?
    By WinchellChung in forum Newbie
    Replies: 5
    Last Post: 24th August 2007, 21:07

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.