#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)
{
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;
glBegin(GL_POINTS); //Start from here.... [GL_TRIANGLE, GL_POLYGON]
//Put point in anti clock (right to left) wise to draw shape as you want!
glVertex2i(100, 50); //1st point, for 3D glVertex3i(x,y,z)
glVertex2i(100, 130); //2nd point, for 3D glVertex3i(x,y,z)
glVertex2i(150, 130); //3rd point, for 3D glVertex3i(x,y,z)
glEnd(); //...... will end here
glColor3ub(0,0,255);
glBegin(GL_POINTS); //Start from here.... [GL_TRIANGLE, GL_POLYGON]
//Put point in anti clock (right to left) wise to draw shape as you want!
glVertex2i(200, 50); //1st point, for 3D glVertex3i(x,y,z)
glVertex2i(200, 130); //2nd point, for 3D glVertex3i(x,y,z)
glVertex2i(250, 130); //3rd point, for 3D glVertex3i(x,y,z)
glEnd(); //...... will end here
//------------------ Ship ----------------//
//Put point in anti clock (right to left) wise to draw shape as you want!
glColor3ub(0,255,0);
glBegin(GL_POLYGON); //Start from here....
glVertex2i(300, 100);
glVertex2i(350, 50);
glVertex2i(550, 50);
glVertex2i(600, 100);
glEnd();
glBegin(GL_POLYGON); //Start from here....
glVertex2i(400, 100);
glVertex2i(420, 100);
glVertex2i(420, 200);
glVertex2i(400, 200);
glEnd();
glBegin(GL_POLYGON); //Start from here....
glVertex2i(440, 100);
glVertex2i(460, 100);
glVertex2i(460, 200);
glVertex2i(440, 200);
glEnd();
glBegin(GL_POLYGON); //Start from here....
glVertex2i(480, 100);
glVertex2i(500, 100);
glVertex2i(500, 200);
glVertex2i(480, 200);
glEnd();
//glBegin(GL_POLYGON); //Start from here....
//glVertex2i(300, 100);
//glVertex2i(350, 50);
//glVertex2i(550, 50);
//glVertex2i(600, 100);
//glEnd();
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!
//
}