Tutorial
Here is a simple example on how to use the GLUT wrapper classes. For usage of geometric classes and algorithms see the source code and examples.
This program displays a window and draws a line:
#include <simge/glut/Application.hpp>
#include <simge/glut/Planar.hpp>
using namespace simge::glut;
class MyWindow : public Planar
{
public:
MyWindow()
: Planar("Hello")
{
glClearColor(0.8, 0.9, 1.0, 0.0);
glColor3f(1.0, 0.0, 0.0);
}
void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2d(10, 10);
glVertex2d(100, 100);
glEnd();
glFlush();
}
};
int main(int argc, char* argv[])
{
Application app(argc, argv);
MyWindow win;
app.run();
}
Notes:
- The
Planar
class provides a windows with a 2D surface to draw. - The string passed to
Planar
constructor is the title of the window. - One time setup OpenGL commands goes to constructor.
- The OpenGL drawing commands goes into
paintGL
method.