I am really stuck with recreating the below image in OpenGL using C++, Please help

  • john.angula
    Likes 0

    Problem Description


  • Sonar Systems admin
    Likes 0

    What do you have so far?

  • john.angula
    Likes 0

    SO far I have the following:

    #include <gl/gl.h>
    #include "Draw.h"
    #include <math.h>
    void drawPentagon(){
    
    
    
    glColor3f(0.0f, 0.0f, 1.0f);
        glBegin(GL_LINE_LOOP);
        glVertex2f(0.0, 0.8);
        glVertex2f(-0.3,0.5);
        glVertex2f(0.3,0.5);
        glVertex2f(-0.3,0.5);
        glVertex2f(-0.2,0.0); 
        glVertex2f(-0.2,0.0);
        glVertex2f(-0.05,0.0);
        glVertex2f(-0.05,0.3);
        glVertex2f(0.05,0.3);
        glVertex2f(0.05,0.0);
        glVertex2f(0.05,0.0);
        glVertex2f(-0.05,0.0);
        glVertex2f(0.2,0.0);
        glVertex2f(0.3,0.5);
        glEnd();
        /*reset color to black*/
        glColor3f(0.0f, 0.0f, 0.0f);
    }
    

    and

    #include <gl/gl.h>
    #include "Draw.h"
    #include <math.h>
    void drawCircle(){
    
    float theta;
    glColor3f(0.941f, 0.902f, 0.549f);
    
    glBegin(GL_POLYGON);
        for(int i = 0; i < 360; i ++)
            {
           theta =  i * M_PI/180;
           glVertex2f(1+0.3*cos(theta),1+0.3*sin(theta));
    
        }
    
        glEnd();
        /*reset color to black*/
        glColor3f(0.0f, 0.0f, 0.0f);
    
    }
    

    this is what I get:

     

  • Sonar Systems admin
    Likes 0

    Almost there, what do you need help with?

  • john.angula
    Likes 0

    I managed. Thank you.

  • Sonar Systems admin
    Likes 0

    Awesome

Login to reply