Results 1 to 1 of 1

Thread: QOpenGLWindow with 16 bit QSurfaceFormat is brighter that should be on primary displa

  1. #1
    Join Date
    Jun 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QOpenGLWindow with 16 bit QSurfaceFormat is brighter that should be on primary displa

    I have two displays and want to write a program in Qt 5.5 that should do the next:
    1. on start: run main program window (MyMainWindow) on secondary display with button.
    2. on that button press: run second window (My16BitWindow) on the primary display (specified in the NVIDIA Control Panel as primary) in fullscreen mode. This window should have pixel format with 16 bits for all color channels: red, green, blue and alpha.


    I wrote such minimal program and its code is given below. But this program has the next problem that I cannot solve by myself.
    If I start the program and click on the button, then My16BitWindow starts and picture in this window is brighter that should be. If then I click on the MyMainWindow title, then the picture brighness becomes normal. If then I click again on the My16BitWindow, it may or may not become brighter again. And if I continue click on different windows including MyMainWindow and My16BitWindow, then sometimes My16BitWindow becomes brighter or becomes normal.

    The problem occurs only under all the following conditions:
    1. the My16BitWindow is running in the fullscreen mode
    2. the My16BitWindow is running on the primary display
    3. the My16BitWindow is running with the specified in its constructor 16 bit QSurfaceFormat.
    4. in the end of My16BitWindow::paintGL code 'update' method is always requested

    All of these conditions are essential and important for me.

    What I'm doing wrong?
    I compile this using Visual Studio 2010 compiler and QT Add-in extension for Visual studio.

    main.cpp

    Qt Code:
    1. #include "MyMainWindow.h"
    2. #include <QtWidgets/QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MyMainWindow w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.h
    Qt Code:
    1. #pragma once
    2. #include <QtWidgets/QMainWindow>
    3.  
    4. class MyMainWindow : public QMainWindow
    5. {
    6. Q_OBJECT;
    7. public:
    8. MyMainWindow(QWidget *parent = 0);
    9.  
    10. private slots:
    11. void onFullScreen();
    12. };
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.cpp
    Qt Code:
    1. #include "MyMainWindow.h"
    2. #include "My16bitWindow.h"
    3. #include <QPushButton>
    4. #include <QDesktopWidget>
    5. #include <QApplication>
    6.  
    7. MyMainWindow::MyMainWindow(QWidget *parent) : QMainWindow(parent)
    8. {
    9. QPushButton* pButton = new QPushButton("Fullscreen");
    10. setCentralWidget(pButton);
    11. QObject::connect(pButton, SIGNAL(released()), this, SLOT(onFullScreen()));
    12. }
    13.  
    14. void MyMainWindow::onFullScreen()
    15. {
    16. int iScreen = 0; // primary display number
    17. QRect rect = qApp->desktop()->screenGeometry(iScreen);
    18.  
    19. My16BitWindow* pWindow = new My16BitWindow;
    20. pWindow->setGeometry(rect);
    21. pWindow->setScreen(qApp->screens().at(iScreen));
    22. pWindow->show();
    23. pWindow->showFullScreen();
    24. }
    To copy to clipboard, switch view to plain text mode 
    My16bitWindow.h
    Qt Code:
    1. #pragma once
    2. #include <QOpenGLWindow>
    3.  
    4. class My16BitWindow : public QOpenGLWindow
    5. {
    6. Q_OBJECT;
    7. public:
    8.  
    9. My16BitWindow();
    10.  
    11. void initializeGL() override;
    12. void paintGL() override;
    13. };
    To copy to clipboard, switch view to plain text mode 
    My16bitWindow.cpp
    Qt Code:
    1. #include "My16bitWindow.h"
    2. #include <QOpenGLFunctions>
    3.  
    4. My16BitWindow::My16BitWindow() : QOpenGLWindow()
    5. {
    6. int bits = 16;
    7. QSurfaceFormat glFormat;
    8. glFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    9. glFormat.setRedBufferSize(bits);
    10. glFormat.setBlueBufferSize(bits);
    11. glFormat.setGreenBufferSize(bits);
    12. glFormat.setAlphaBufferSize(bits);
    13. setFormat(glFormat);
    14. }
    15.  
    16. void My16BitWindow::initializeGL()
    17. {
    18. QOpenGLFunctions* f = context()->functions();
    19. f->glClearColor(0.5, 0.0, 0.0, 1.0);
    20. }
    21.  
    22. void My16BitWindow::paintGL()
    23. {
    24. QOpenGLFunctions* f = context()->functions();
    25. f->glClear(GL_COLOR_BUFFER_BIT);
    26.  
    27. requestUpdate(); // Schedule an update
    28. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 5th July 2017, 14:28
  2. Qt 5.4 + QOpenGLWindow + iOS: using the Apple GameCenter
    By mkdotcom in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd January 2015, 18:39
  3. Replies: 1
    Last Post: 19th December 2012, 23:24
  4. Replies: 0
    Last Post: 29th June 2010, 14:35
  5. PRIMARY Selections
    By hayati in forum Newbie
    Replies: 9
    Last Post: 12th September 2006, 13:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.