Home > Back-end >  QOpenGLWidget images show out
QOpenGLWidget images show out

Time:11-19

A simple program, the inheritance and QOpenGLWidget custom class, compile no problem, but performs a blank, did not draw the required point, how to return a responsibility? A derived class code is as follows:
.h
 # # ifndef MYOPENGLWINDOW_H 
# define MYOPENGLWINDOW_H

#include
#include
#include
The class myOpenglWindow: public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
Public:
Explicit myOpenglWindow (QWidget * parent=nullptr);

Protected:
Void initializeGL ();
Void resizeGL (int int w, h);
Void paintGL ();
Signals:

Public slots:
};

# endif//MYOPENGLWINDOW_H

.cpp
 # include "myopenglwindow. H" 
#include
# include "glut. H"
using namespace std;
MyOpenglWindow: : myOpenglWindow (QWidget * parent) : QOpenGLWidget (parent)
{

}

Void myOpenglWindow: : initializeGL ()
{
InitializeOpenGLFunctions ();
GlClearColor (1.0, 1.0, 1.0, 1.0);
Cout}

Void myOpenglWindow: : resizeGL (int w, int h)
{
GlViewport (0, 0, (GLsizei) w, (GLsizei) h);
GlMatrixMode (GL_PROJECTION);
GlLoadIdentity ();
GluOrtho2D (1.5, 1.5, 1.5, 1.5);
GlMatrixMode (GL_MODELVIEW);
GlLoadIdentity ();
}

Void myOpenglWindow: : paintGL ()
{
GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GlPointSize (10.0);
GlColor3d (1.0, 0.0, 0.0);
GlBegin (GL_POINTS);
GlVertex3d (0.0, 0.0, 0.0);
GlEnd ();
}

CodePudding user response:

Baidu search relevant keywords,

CodePudding user response:

Never use glut. H
I am no problem directly with opengl native function

CodePudding user response:

https://blog.csdn.net/p942005405/article/details/103739702
  • Related