#ifndef SCENE_H
#define SCENE_H
#include <QOpenGLWidget>
#include <QKeyEvent>
class Scene : public QOpenGLWidget
{
public:
private:
void initializeGL();
void paintGL();
void resizeGL( int w, int h );
};
#endif // SCENE_H
#ifndef SCENE_H
#define SCENE_H
#include <QOpenGLWidget>
#include <QKeyEvent>
class Scene : public QOpenGLWidget
{
public:
Scene( QWidget *parent = 0 );
private:
void initializeGL();
void paintGL();
void resizeGL( int w, int h );
};
#endif // SCENE_H
To copy to clipboard, switch view to plain text mode
#include "scene.h"
#include <math.h>
#define GL_PI 3.1415f
QOpenGLWidget ( parent )
{
}
void Scene::initializeGL()
{
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glColor3f( 0.0f, 1.0f, 0.0f );
glShadeModel( GL_FLAT );
glFrontFace( GL_CW );
}
void Scene::paintGL()
{
GLfloat angle, x, y;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glBegin( GL_TRIANGLE_FAN );
glVertex3f( 0.0f, 0.0f, 75.0f );
for( angle = 0.0f; angle < ( 2.0f*GL_PI ); angle += ( GL_PI/8.f ) ){
x = 50.0f*sin( angle );
y = 50.0f*cos( angle );
glVertex2f( x, y );
}
glEnd();
glFlush();
}
void Scene::resizeGL(int w, int h)
{
glViewport( 0, 0, w, h );
glOrtho( -100.0f, 100.0f, -100.0f, 100.0f, 100.0f, -100.0f );
}
#include "scene.h"
#include <math.h>
#define GL_PI 3.1415f
Scene::Scene ( QWidget *parent ) :
QOpenGLWidget ( parent )
{
}
void Scene::initializeGL()
{
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glColor3f( 0.0f, 1.0f, 0.0f );
glShadeModel( GL_FLAT );
glFrontFace( GL_CW );
}
void Scene::paintGL()
{
GLfloat angle, x, y;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glBegin( GL_TRIANGLE_FAN );
glVertex3f( 0.0f, 0.0f, 75.0f );
for( angle = 0.0f; angle < ( 2.0f*GL_PI ); angle += ( GL_PI/8.f ) ){
x = 50.0f*sin( angle );
y = 50.0f*cos( angle );
glVertex2f( x, y );
}
glEnd();
glFlush();
}
void Scene::resizeGL(int w, int h)
{
glViewport( 0, 0, w, h );
glOrtho( -100.0f, 100.0f, -100.0f, 100.0f, 100.0f, -100.0f );
}
To copy to clipboard, switch view to plain text mode
Bookmarks