C Program to Color the Different Figures Drawn on the Console Using OpenGL
C Program to Color the Different Figures Drawn on the Console Using OpenGL
#include <GL/glut.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define xpix 500
#include <cstring>
using namespace std;
// Initialize gluBitmap
glutBitmapCharacter(
GLUT_BITMAP_TIMES_ROMAN_24, *c);
}
}
if ((color[0] != bc[0]
|| color[1] != bc[1]
|| color[2] != bc[2])
&& (color[0] != fillColor[0]
|| color[1] != fillColor[1]
|| color[2] != fillColor[2])) {
float bCol[] = { 1, 0, 0 };
float color[] = { 0, 1, 1 };
bound_it(x, y, color, bCol);
}
}
if (state == GLUT_DOWN) {
if (counter == 1) {
a1 = x;
b1 = y;
counter++;
}
else if (counter == 2) {
a2 = x;
b2 = y;
counter++;
}
else if (counter == 3) {
a3 = x;
b3 = y;
counter++;
}
else if (counter == 4) {
a4 = x;
b4 = y;
counter = 0;
}
}
}
}
// Initialize a vertices
glVertex2f(a1, b1);
glVertex2f(a2, b2);
glVertex2f(a3, b3);
glVertex2f(a4, b4);
glEnd();
if (color.r == oldColor.r
&& color.g == oldColor.g
&& color.b == oldColor.b) {
setPixelColor(x, y, newColor);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
draw_circle(pt, radius);
glEnd();
glFlush();
}
// Driver Code
int main(int argc, char** argv)
{
glutInit(&argc, argv);
// Function calls
glutInitDisplayMode(
GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800, 600);
glutInitWindowPosition(100, 100);
int mainWindow
= glutCreateWindow(
"<-- Boundary Fill on left || "
"Flood fill on Right -->");
init();
glutDisplayFunc(display);
glutMouseFunc(mousefloodfill);
int subWindow1
= glutCreateSubWindow(
mainWindow, 0, 0, 400, 600);
glutInitWindowPosition(100, 100);
glutDisplayFunc(world);
glutMouseFunc(mouseboundaryfill);
init2();
glutMainLoop();
return 0;
}