Showing posts with label CPP. Show all posts
Showing posts with label CPP. Show all posts

C++ openGL #12: Draw Triangle Fan

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Triangle Fan in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!

>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:

Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  like this

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(0,0,0);
 glBegin(GL_TRIANGLE_FAN);
    glVertex2f(0.0,0.0);
    glVertex2f(0.0,3.0);
    glVertex2f(2.0,3.0);
 glVertex2f(3.0,2.0);
    glVertex2f(3.50,.50);
    glVertex2f(3.0,-1.0);
    glVertex2f(2.0,-2.0);
    glVertex2f(0.0,-2.50);
 glVertex2f(-2.0,-2.0);
    glVertex2f(-3.0,-1.0);
 glEnd();
 glFlush();
}

For more clarification download source file:





C++ openGL #11: Draw Triangle Strip

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Triangle Strip in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!

>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:

Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  like this
v0->v1->v2->v3->v4
or
v4->v3->v2->v1->v0

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(0,0,0);
 glBegin(GL_TRIANGLE_STRIP);
    glVertex2f(-6.0,-4.0);
    glVertex2f(-6.0,2.0);
    glVertex2f(-3.0,-3.0);
 glVertex2f(-2.0,3.0);
    glVertex2f(0.0,-1.0);
 glEnd();
 glFlush();
}

For more clarification download source file:






C++ openGL #10: Draw Triangle

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Triangle in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!

>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:
Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->
or
v2->v1->v0

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(0,0,0);
 glBegin(GL_TRIANGLES);
    glVertex2f(-7.0,3.0);
    glVertex2f(7.0,-5.0);
    glVertex2f(-7.0,-5.0);
 glEnd();
 glFlush();
}

For more clarification download source file:



C++ openGL #09: Draw Quads Strip

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Quad Strip in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!
>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:
Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->v3->v4->v5->v6->v7
or
v7->v6->v5->v4->v3->v2->v1->v0

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_QUAD_STRIP);
    glVertex2f(-4.0,-2.0);
    glVertex2f(-4.0,2.0);
    glVertex2f(-2.0,-2.0);
    glVertex2f(-2.0,2.0);
    glVertex2f(6.0,-6.0);
    glVertex2f(6.0,6.0);
 glEnd();
 glFlush();
}

For more clarification download source file:




C++ openGL #08: Draw Quads

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Quads in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!
>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___

Now write code for draw object or lines
At first draw a graph like this one:
Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->v3
or
v3->v2->v1->v0
void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_QUADS);
    glVertex2f(5.0,2.0);
    glVertex2f(2.0,-5.0);
    glVertex2f(-5.0,-2.0);
    glVertex2f(-3.0,6.0);
 glEnd();
 glFlush();
}


For more clarification download source file:





C++ openGL #07: Draw Polygon

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Polygon in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!

>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:

Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->v3->v4
or
v4->v3->v2->v1->v0
And the main deference between Line loop and polygon: polygon fill with solid color ,on the other hand line loop only draw a line.
void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_POLYGON);
 glVertex2f(0.0,0.0);
    glVertex2f(5.0,2.0);
    glVertex2f(2.0,-5.0);
    glVertex2f(-0.5,-0.5);
    glVertex2f(-5.0,-2.0);
    glVertex2f(-3.0,6.0);
 glEnd();
 glFlush();
}


For more clarification download source file:







C++ openGL #06: Draw Lines Loop

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Line Loop in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!



>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___

Now write code for draw object or lines
At first draw a graph like this one:

Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->v3->v4
or
v4->v3->v2->v1->v0

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_LINE_LOOP);
 glVertex2f(0.0,0.0);
    glVertex2f(5.0,2.0);
    glVertex2f(2.0,-5.0);
    glVertex2f(-0.5,-0.5);
    glVertex2f(-5.0,-2.0);
    glVertex2f(-3.0,6.0);
 glEnd();
 glFlush();
}

For more clarification download source file:



C++ openGL #05: Draw Lines Strip

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Line Strip in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!
>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:
Now just put the value on your program between glBegain and glEnd.
when put the vertex on your program you mast follow a sequence  right to left or left to right like this
v0->v1->v2->v3->v4
or
v4->v3->v2->v1->v0

void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_LINE_STRIP);
 glVertex2f(0.0,0.0);
    glVertex2f(5.0,2.0);
    glVertex2f(2.0,-5.0);
    glVertex2f(-5.0,-2.0);
    glVertex2f(-3.0,6.0);
 glEnd();
 glFlush();
}

For more clarification download source file:












C++ openGL #04: Draw Lines

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

Now i'm showing you how draw the Line in openGL C++. Its  so easy tutorial just for beginners and basic concept of graph.
Let's enjoy!

>>>Now Create a new project-----
initialize the graph
void Initialize() {
 glClearColor(0, 0, 0, 1.0);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

this method,
Declare a 10x10 graph like below ___
Now write code for draw object or lines
At first draw a graph like this one:
Now just put the value on your program between glBegain and glEnd.
void Draw() {
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3d(255,0,0);
 glBegin(GL_LINES);
    glVertex2f(5.0,2.0);
    glVertex2f(2.0,-5.0);
    glVertex2f(-5.0,-2.0);
    glVertex2f(-3.0,6.0);

 glEnd();
 glFlush();
}

For more clarification download source file: