C++ openGL #03: Draw Points

Bismillahir Rahmanir Rahim
Assalamualaikum everyone!! 

_________________________________

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


***create a new project


int main(int iArgc, char** cppArgv) {
 glutInit(&iArgc, cppArgv);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
 glutInitWindowSize(476, 477);
 glutInitWindowPosition(250, 250);
 glutCreateWindow("Points");
 Initialize();
 glutDisplayFunc(Draw);
 glutMainLoop();
 return EXIT_SUCCESS;
}

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);
}

Here,
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);

means we take a graph 10x10 like below image
Now write a draw function:

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

According to the graph just put the value on your Draw function:


 For more clarification download source file:






Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →