#include <stdio.h>
#include<GL/gl.h>
#include <GL/glut.h>
void myDisplay(void);
void myInit(void);
main(int argc, char** argv)
{
glutInit(&argc, argv); //DISPLAY INITIALIZE THROUGH GLUT!
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // USED 1 BUFFER HERE, IN ANIMATION USED 2 BUFFER | DISPLAY COLOR MODE
glutInitWindowSize (640, 480); // Display Size
glutInitWindowPosition (200, 150); // where Window will pop up measuring from left top as 0,0 but in all other case measured from left bottom
glutCreateWindow ("Hello World"); // Windows Form name
glutDisplayFunc(myDisplay); //calling myDisplay from glutDisplayFunc as delegate!
myInit (); //Initialize
glutMainLoop(); //continuous calling main() so that program don't close
}
void myDisplay(void)
{
//------------------ chess ----------------//
//Put point in anti clock (right to left) wise to draw shape as you want!
glClear (GL_COLOR_BUFFER_BIT); //clear color data from buffer string
//glColor3f (1.0, 0.0, 0.0); //RGB or glColor3ub(255,0,0)
glPointSize(5.0); // 1PX = 5PX;
int x=50, y=50, k=1;
for(int i=1; i<9; i++)
{
for(int j=1; j<9; j++)
{
if(k%2==0)
{
glColor3ub(255,255,255);
}else{
glColor3ub(0,0,0);
}
glBegin(GL_POLYGON); //Start from here....
glVertex2i(x, y);
glVertex2i(x+50, y);
glVertex2i(x+50, y+50);
glVertex2i(x, y+50);
glEnd();
x+=50;
k++;
}
k++;
x=50;
y+=50;
//row=y;
}
glFlush (); //show in display [ Raster! will do work before Rasterization! ]
}
void myInit (void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); //What Ever color is available on window clear it with a RGBA color
glMatrixMode(GL_MODELVIEW); // Another model view is GL_PROJECTION to view object from different angle!
glLoadIdentity(); //matrix pattern like 3x3,2x2..... etc!
gluOrtho2D(0.0, 640.0, 0.0, 480.0); //how we will draw inside the graph/display
//........(left,right,bottom,top)
//for Responsive use % , where 0 = 0% and 1 = 100% or actual display size / initialized windows size!
//
}