Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:39:11+00:00 2026-05-21T08:39:11+00:00

When trying to draw on an OpenGL widget with QT, the window display ends

  • 0

When trying to draw on an OpenGL widget with QT, the window display ends up rather distorted.
All that’s being done is the screen is cleared.

Screenshot

#include "glwidget.h"

// Mainwidget is a sub-class of GLWidget

GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(parent)
{
}

void GLWidget::resizeGL(int width,int height)
{
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, height, 0, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

GLWidget::~GLWidget()
{
    ;
}

#include <QtGui>
#include "mainwidget.h"

MainWidget::MainWidget()
{
    //this->showFullScreen();
    derp = 100;
}

void MainWidget::paintGL()
{
    glClearColor(0, 0, 0, 0);
    //drawTriangle(0, 0, 100, 100, derp, 0);
    derp = rand()%500;
}

void MainWidget::initializeGL()
{
    this->resizeGL(800, 600);
}

void MainWidget::drawTriangle(int x1,int y1, int x2, int y2, int x3, int y3)
{
    glBegin(GL_TRIANGLES);
    glVertex3f(x1, y1, 0.0f);
    glVertex3f(x2, y2, 0.0f);
    glVertex3f(x3, y3, 0.0f);
glEnd();
}

#include <QtGui>
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent)
{
    QGridLayout *layout = new QGridLayout;
    QTimer *timer = new QTimer(this);
    MainWidget *View = new MainWidget();
    layout->addWidget(View, 0, 0);
    setLayout(layout);
    connect(timer, SIGNAL(timeout()), View, SLOT(paintGL()));
    timer->start(50);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:39:11+00:00Added an answer on May 21, 2026 at 8:39 am

    Try clearing the color buffer occasionally. Note glClearColor() just latches some state and doesn’t actually clear any buffers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make OpenGL draw the figure that I'm loading with OPENFILENAME .
I am trying to draw circular maze in openGl.For that I created a simple
I'm trying to draw a circle in c using opengl, that's smaller than the
I'm trying to draw a simple circle using OpenGL ES. The problem is that
I'm currently trying to draw a quadratic surface with openGL.When using a single window,my
I have a simple OpenGL program and trying to draw an instanced array that
I am trying to draw a series of rectangles using OpenGL but some of
I'm trying to draw a polygon using c# and directx All I get is
I'm trying to draw over the whole screen by using the desktop canvas and
I am trying to perform several image manipulations using OpenGL ES 2.0 and display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.