OpenGL program to animate a flag using Bezier Curve algorithm
#include #include #include #define PI 3.1416 typedef struct point { GLfloat x, y, z; }; void bino(int n, int *C) { int k, j; for(k=0;k=k+1; j--) C[k]*=j; for(j=n-k;j>=2;j--) C[k]/=j; }…
q
#include #include #include #define PI 3.1416 typedef struct point { GLfloat x, y, z; }; void bino(int n, int *C) { int k, j; for(k=0;k=k+1; j--) C[k]*=j; for(j=n-k;j>=2;j--) C[k]/=j; }…
Algorithm (Cylinder):Step 1: Start Step 2: Let (h, k) be the central axis of cylinder. Step 3: Let ‘r’ be the radius of cylinder. Step 4: For each pair (h,…
#include GLfloat xRotated, yRotated, zRotated; GLdouble radius=0.5; GLfloat qaBlack[] = {0.5, 0.5, 0.5, 1.0}; //Black Color GLfloat qaGreen[] = {1.0, 1.0, 0.0, 1.0}; //Green Color GLfloat qaWhite[] = {1.0, 1.0,…
Algorithm: Step 1: Start Step 2: Render the cube using the array of vertices. Step 3: Obtain the co-ordinates of the cube with the origin at the center of the…
#include #include #include #include int x,y; int rFlag=0; void draw_pixel(float x1,float y1) { glColor3f(0.0,0.0,1.0); glPointSize(5.0); glBegin(GL_POINTS); glVertex2f(x1,y1); glEnd(); } void triangle() { glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(100,100); glVertex2f(250,400); glVertex2f(400,100); glEnd(); } float…
Algorithm:Step 1: Specify the four vertices that form a tetrahedronStep 2: Input the number of subdivisions n.Step 3: Select any three vertices that form one of the triangular faces of…
#include typedef GLfloat point2[2]; /* initial triangle – global variables */ point2 v[]={ {-1.0, -0.58}, {1.0, -0.58}, {0.0, 1.15} }; int n; /* number of recursive steps */ void triangle(…
Note that the program defines a display callback function named display Every glut program must have a display callback The display callback is executed whenever OpenGL decides the display must…
#include #include #include #include void main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\TurboC3\BGI"); cleardevice(); line( 150, 100, 242, 100); ellipse(242, 105, 0, 90, 10, 5); line(150, 100, 120,…