title: Can it be possible rendering multiple objects in one screen without creating shader in OpenGL?
body: <p>My course teacher taught me how to draw a figure e.g. square, triangle, circle. He did it using <code>glBegin</code> and <code>glEnd</code>. But when I try to draw multiple object for example <strong>circle within a square</strong>, I can't. After searching in online, I understood that <code>shader</code> is the thing that need to implement to draw or control how the objects will be rendered.</p>
  <p>But as my course teacher didn't teach me <code>shader</code>, is there any possible way to do that using legacy OpenGL I mean with <code>glBegin</code> and <code>glEnd</code>?</p>
  <p>I am using <code>Codeblocks</code> and <code>GLUT</code> to learn OpenGL. And the language I am using is <code>C++</code>.</p>
  <p>The code I wrote to draw only circles and that worked:</p>
  <pre><code>#include&lt;GL/gl.h&gt;
  #include&lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  #include &lt;GL/glut.h&gt;
  
  // Center of the cicle = (320, 240)
  int xc = 320, yc = 240;
  
  // Plot eight points using circle's symmetrical property
  void plot_point(int x, int y)
  {
    glBegin(GL_POINTS);
    glVertex2i(xc+x, yc+y);
    glVertex2i(xc+x, yc-y);
    glVertex2i(xc+y, yc+x);
    glVertex2i(xc+y, yc-x);
    glVertex2i(xc-x, yc-y);
    glVertex2i(xc-y, yc-x);
    glVertex2i(xc-x, yc+y);
    glVertex2i(xc-y, yc+x);
    glEnd();
  }
  
  // Function to draw a circle using bresenham's
  // circle drawing algorithm
  void mid_point_circle(int r)
  {
    int x=0,y=r;
    float pk=(5.0/4.0)-r;
  
    /* Plot the points */
    /* Plot the first point */
    plot_point(x,y);
    int k;
    /* Find all vertices till x=y */
    while(x &lt; y)
    {
      x = x + 1;
      if(pk &lt; 0)
        pk = pk + 2*x+1;
      else
      {
        y = y - 1;
        pk = pk + 2*(x - y) + 1;
      }
      plot_point(x,y);
    }
    glFlush();
  }
  
  // Function to draw two concentric circles
  void concentric_circles(void)
  {
    /* Clears buffers to preset values */
    glClear(GL_COLOR_BUFFER_BIT);
  
    int radius1 = 100, radius2 = 200;
    mid_point_circle(radius1);
    mid_point_circle(radius2);
  }
  
  void Init()
  {
    /* Set clear color to white */
    glClearColor(1.0,1.0,1.0,0);
    /* Set fill color to black */
    glColor3f(0.0,0.0,0.0);
    /* glViewport(0 , 0 , 640 , 480); */
    /* glMatrixMode(GL_PROJECTION); */
    /* glLoadIdentity(); */
    gluOrtho2D(0 , 640 , 0 , 480);
  }
  
  int main(int argc, char **argv)
  {
    /* Initialise GLUT library */
    glutInit(&amp;argc,argv);
    /* Set the initial display mode */
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    /* Set the initial window position and size */
    glutInitWindowPosition(0,0);
    glutInitWindowSize(640,480);
    /* Create the window with title &quot;Mid-point Circle&quot; */
    glutCreateWindow(&quot;Mid-point Circle&quot;);
    /* Initialize drawing colors */
    Init();
    /* Call the displaying function */
    glutDisplayFunc(concentric_circles);
    /* Keep displaying untill the program is closed */
    glutMainLoop();
    return 0;
  }
  </code></pre>