#ifndef GL_WIDGET_H
#define GL_WIDGET_H
#include <QGLWidget>
{
Q_OBJECT
public:
protected:
void initializeGL()
{
qglClearColor( Qt::white );
glEnable( GL_DEPTH_TEST );
}
void resizeGL( int w, int h )
{
glViewport( 0.0, 0.0, 100, 100 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -50, 50, -50, 50, -1, 1 );
glMatrixMode( GL_MODELVIEW );
}
void paintGL()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
qglColor( Qt::Black );
glPushMatrix();
glRotatef( 90.0, 0.0f, 1.0f, 0.0f );
renderText( 0.0, 0.0, 0.0, textStr );
glPopMatrix();
}
};
#endif
#ifndef GL_WIDGET_H
#define GL_WIDGET_H
#include <QGLWidget>
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
GLWidget( QWidget *parent ) : QGLWidget( parent ) {};
protected:
void initializeGL()
{
qglClearColor( Qt::white );
glEnable( GL_DEPTH_TEST );
}
void resizeGL( int w, int h )
{
glViewport( 0.0, 0.0, 100, 100 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -50, 50, -50, 50, -1, 1 );
glMatrixMode( GL_MODELVIEW );
}
void paintGL()
{
QString textStr = "Hello World";
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
qglColor( Qt::Black );
glPushMatrix();
glRotatef( 90.0, 0.0f, 1.0f, 0.0f );
renderText( 0.0, 0.0, 0.0, textStr );
glPopMatrix();
}
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks