Question
Can you please run this code on Opengl and attach the screenshot. #include #include #include void display() { // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Can you please run this code on Opengl and attach the screenshot.
#include
#include
#include
void display() {
// Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set the color of the triangle
glColor3f(1.0, 0.0, 0.0);
// Draw the triangle
glBegin(GL_TRIANGLES);
glVertex3f(-0.5, -0.5, 0.0);
glVertex3f(0.5, -0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
// Swap the front and back buffers to display the image
glutSwapBuffers();
}
int main(int argc, char** argv) {
// Initialize GLUT
glutInit(&argc, argv);
// Set the display mode
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
// Set the window size
glutInitWindowSize(400, 400);
// Create the window
glutCreateWindow("Triangle");
// Set the display function
glutDisplayFunc(display);
// Run the main loop
glutMainLoop();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started