#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 (1024, 768); // 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)
{
//Put point in anti clock (right to left) wise to draw shape as you want!
glBegin(GL_POLYGON); //Start from here.... [ sea ]
glColor3ub(6,135,230);
glVertex2i(0, 0);
glVertex2i(768, 0);
glVertex2i(768, 200);
glVertex2i(0, 200);
glEnd();
glColor3ub(0,255,0);
glBegin(GL_POLYGON); //Start from here.... \___/
glVertex2i(100, 250);
glVertex2i(150, 200);
glVertex2i(550, 200);
glVertex2i(600, 250);
glEnd();
glBegin(GL_POLYGON); //Start from here.... /---|
glVertex2i(150, 250);
glVertex2i(560, 250);
glVertex2i(560, 280);
glVertex2i(180, 280);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [ window ]
glColor3ub(0,0,0);
glVertex2i(155, 255);
glVertex2i(175, 255);
glVertex2i(175, 275);
//glVertex2i(165, 275);
glEnd();
glColor3ub(0,255,0);
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(200, 280);
glVertex2i(220, 280);
glVertex2i(220, 350);
glVertex2i(200, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke1
glVertex2i(205, 360);
glVertex2i(215, 360);
glVertex2i(215, 365);
glVertex2i(205, 365);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke2
glVertex2i(215, 370);
glVertex2i(225, 370);
glVertex2i(225, 375);
glVertex2i(215, 375);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke3
glVertex2i(225, 380);
glVertex2i(235, 380);
glVertex2i(235, 385);
glVertex2i(225, 385);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(240, 280);
glVertex2i(260, 280);
glVertex2i(260, 350);
glVertex2i(240, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke1
glVertex2i(250, 360);
glVertex2i(260, 360);
glVertex2i(260, 365);
glVertex2i(250, 365);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke2
glVertex2i(260, 370);
glVertex2i(270, 370);
glVertex2i(270, 375);
glVertex2i(260, 375);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke3
glVertex2i(270, 380);
glVertex2i(280, 380);
glVertex2i(280, 385);
glVertex2i(270, 385);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(280, 280);
glVertex2i(300, 280);
glVertex2i(300, 350);
glVertex2i(280, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke1
glVertex2i(290, 360);
glVertex2i(300, 360);
glVertex2i(300, 365);
glVertex2i(290, 365);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke2
glVertex2i(300, 370);
glVertex2i(310, 370);
glVertex2i(310, 375);
glVertex2i(300, 375);
glEnd();
glBegin(GL_POLYGON); //Start from here.... [] smoke3
glVertex2i(310, 380);
glVertex2i(320, 380);
glVertex2i(320, 385);
glVertex2i(310, 385);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(320, 280);
glVertex2i(340, 280);
glVertex2i(340, 350);
glVertex2i(320, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(360, 280);
glVertex2i(380, 280);
glVertex2i(380, 350);
glVertex2i(360, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(400, 280);
glVertex2i(420, 280);
glVertex2i(420, 350);
glVertex2i(400, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(440, 280);
glVertex2i(460, 280);
glVertex2i(460, 350);
glVertex2i(440, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(480, 280);
glVertex2i(500, 280);
glVertex2i(500, 350);
glVertex2i(480, 350);
glEnd();
glBegin(GL_POLYGON); //Start from here.... []
glVertex2i(520, 280);
glVertex2i(540, 280);
glVertex2i(540, 350);
glVertex2i(520, 350);
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!
//
}