my first Graphic Design
#include <GLUT/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
GLenum errorCheck()
{
GLenum code;
const GLubyte *string;
code = glGetError();
if (code != GL_NO_ERROR)
{
string = gluErrorString(code);
fprintf(stderr, "OpenGL error: %s\n", string);
}
return code;
}
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // Set display-window color to white;
glMatrixMode(GL_PROJECTION); // Set Projection parameters
gluOrtho2D(0.0, 200.0, 0.0, 150.0); // Specifies an orthogonal projection is to be used to the screen
}
void lineSegment(void)
{
glClear(GL_COLOR_BUFFER_BIT); // Clear the display window
glColor3f(0.0, 0.4, 0.2); // Set line segment color to green
glBegin(GL_LINES); // Cartesian endpoint coordinates
glVertex2i(180, 15);
glVertex2i(10, 145);
glEnd();
glFlush(); // proceed all OpenGL routines as quickly as possible
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50, 100);
glutInitWindowSize(400, 300);
glutCreateWindow("An Example OpenGL Program");
init();
glutDisplayFunc(lineSegment);
glutMainLoop();
return 0;
}
Page Source