Introduction To GLUT
Introduction To GLUT
The OpenGL specification describes an abstract API for drawing 2D and 3D graphics.
Although it is possible for the API to be implemented entirely in software, it is designed
to be implemented mostly or entirely in hardware.
Although the function definitions are superficially similar to those of the programming
language C, they are language-independent. As such, OpenGL has many language
bindings.
GLUT is the OpenGL Utility Toolkit, a window system independent toolkit for writing
OpenGL programs.
GLUT makes it considerably easier to learn about and explore OpenGL programming.
GLUT provides a portable API so you can write a single OpenGL program that works on
both Win32 PCs and X11 workstations.
#include<GL/glut.h>
Library
#include<stdlib.h>
#include<stdio.h>
void display(void)
{
which are bracketed by glBegin() and glEnd(),
glBegin(GL_POINTS); define the object to be drawn . Here a point (x,y)
will be drawn
glVertex2f(x,y);
It specifies the vertex's coordinates as single-
glEnd();
precision floating-point numbers.
do
{ if(abs(m)<=1){
x=x+1;
y=y+m;
glBegin(GL_POINTS);
Algo
glVertex2f(x,y); Implement
glEnd(); }
if(abs(m)>1){
y=y+1;
x=x+(1/m);
glBegin(GL_POINTS);
glVertex2f(x,y);
{
glClearColor() establishes what color the window will be
cleared to, and glClear() actually clears the window. Once
glClear(GL_COLOR_BUFFER_BIT);
the clearing color is set, the window is cleared to that color
glClearColor(0,0,0,0); whenever glClear() is called. This clearing color can be
changed with another call to glClearColor().
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100,100,-100,100);