Question: Can your run this code on Opengl and paste a screenshot of the picture #include #include // Function prototypes void drawFish(); void display(); int main(int

Can your run this code on Opengl and paste a screenshot of the picture

#include #include

// Function prototypes void drawFish(); void display();

int main(int argc, char **argv) { // Initialize the OpenGL rendering context glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500, 500); glutInitWindowPosition(100, 100); glutCreateWindow("Fish");

// Set the background color to white glClearColor(1.0, 1.0, 1.0, 0.0);

// Set the projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.0, 1.0, -1.0, 1.0);

// Set the viewing transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity();

// Set the callback function for rendering the scene glutDisplayFunc(display);

// Start the event loop glutMainLoop();

return 0; }

// Function to draw the fish void drawFish() { // Set the color of the fish to orange glColor3f(1.0, 0.5, 0.0);

// Start drawing the fish using triangle strips glBegin(GL_TRIANGLE_STRIP);

// Specify the vertices of the fish glVertex2f(0.0, 0.0); glVertex2f(-0.5, 0.5); glVertex2f(-0.2, 0.2); glVertex2f(-0.8, 0.8); glVertex2f(-0.4, 0.4); glVertex2f(-1.0, 1.0);

// Finish drawing the fish glEnd(); }

// Callback function for rendering the scene void display() { // Clear the screen glClear(GL_COLOR_BUFFER_BIT);

// Draw the fish drawFish();

// Swap the buffers glutSwapBuffers(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!