Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt OpenGL Quad not showing
Forum Updated to NodeBB v4.3 + New Features

Qt OpenGL Quad not showing

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 515 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mario1159
    wrote on last edited by Mario1159
    #1

    What my code is missing to display a quad?
    i don't get any error just the widget display the clear color, in this case black
    This is my current code;

    "MyOpenGLWidget.cpp"

    #include "MyOpenGLWidget.h"
    #include "QOpenGLWidget"
    #include <QOpenGLFunctions>
    
    MyOpenGLWidget::MyOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent)
    {
        qDebug("constructor");
    }
    void MyOpenGLWidget::initializeGL()
    {
        qDebug("initialize");
        initializeOpenGLFunctions();
        glClearColor(0, 0, 0, 0);
    }
    void MyOpenGLWidget::paintGL()
    {
        qDebug("paint");
        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity();
        glTranslatef(0.0, 0.0, -10.0);
        glBegin(GL_QUADS);
        glColor3f(1, 0, 0);
        glVertex2f(-0.5f, -0.5f);
        glVertex2f(0.5f, -0.5f);
        glVertex2f(-0.5f, 0.5f);
        glVertex2f(0.5f, 0.5f);
        glEnd();
        glFlush();
    }
    void MyOpenGLWidget::resizeGL(int width, int height)
    {
        qDebug("resize");
    }
    

    "mainwindow.cpp"

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "MyOpenGLWidget.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forums
      My best bet is that your openGL is so new that
      glBegin(GL_QUADS); is no longer supported in the core profile/openGL 3.3 ( i think)
      Its part of the so called old fixed pipeline.
      It might be possible to request older profile but would be better just to use
      modern openGl.
      https://learnopengl.com/Introduction
      https://learnopengl.com/Getting-started/Hello-Triangle

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved