I have faced a programmatic error from the following code which I need to create TOYOTA LOGO using C++. This result is attached. your support is highly appreciated.
#include <GL/glut.h>
#include <math.h>
void drawEllipse(float centerX, float centerY, float radiusX, float radiusY)
{
glBegin(GL_TRIANGLE_FAN);
for (int angle = 0; angle <= 360; angle++)
{
float radians = angle * M_PI / 180;
float x = centerX + radiusX * cos(radians);
float y = centerY + radiusY * sin(radians);
glVertex2f(x, y);
}
glEnd();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT); // Clear the screen
// Draw red ellipse (outermost)
glColor3f(1.0f, 0.0f, 0.0f); // Set color to red
drawEllipse(0.0f, 0.0f, 0.6f, 0.3f);
glColor3f(0.0f, 0.0f, 0.0f); // Set color to Inner red hole
drawEllipse(0.0f, 0.0f, 0.4f, 0.2f);
// Draw Green ellipse (innermost)
glColor3f(2.0f, 2.0f, 2.0f); // Set color to white
drawEllipse(0.0f, 0.1f, 0.5f, 0.2f);
glColor3f(0.0f, 0.0f, 0.0f); // Set color to white
drawEllipse(0.0f, 0.1f, 0.40f, 0.1f);
// Draw silver ellipse (middle)
glColor3f(6.3f, 6.3f, 6.3f); // Set color to middle
drawEllipse(0.0f, 0.0f, 0.15f, 0.25f);
glColor3f(0.0f, 0.0f, 0.0f); // Set color to inner middle
drawEllipse(0.0f, 0.0f, 0.10f, 0.23f);
glFlush(); // Swap buffers to display drawing
}
int main(int argc, char** argv)
{
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // Set display mode
glutInitWindowSize(500, 500); // Set window size
glutInitWindowPosition(100, 100); // Set window position
glutCreateWindow("Toyota Logo"); // Create window with title
glutDisplayFunc(display); // Set display callback function
glutMainLoop(); // Enter main loop for event handling and drawing
return 0;
}
I believe that people in this community will fix my problem.
New contributor
user220158 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6