.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. HI am no problem directly with opengl native function
CodePudding user response:
https://blog.csdn.net/p942005405/article/details/103739702