Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Shamsuddin Ahmed
- 161-15-1027
- Draw triangle and rectangle only using lines
- */
- #include<windows.h>
- #include <GL/glut.h>
- void init(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0); // Set display window colour to white
- glMatrixMode(GL_PROJECTION); // Set projection parameters
- gluOrtho2D(0.0, 400.0, 0.0, 400.0);
- }
- void drawShapes(void)
- {
- glClear(GL_COLOR_BUFFER_BIT); // Clear display window
- //Set colour to black
- glColor3f(0.0, 0.0, 0.0);
- //Adjust the point size
- glPointSize(5.0);
- //Set colour to red
- glColor3f(1.0, 0.0, 0.0);
- // Draw an outlined triangle
- glBegin(GL_LINES);
- //Triangle Using Line
- glVertex2i(54.53, 269.1);
- glVertex2i(149.07, 269.1);
- glVertex2i(149.07, 269.1);
- glVertex2i(102.77, 355.92);
- glVertex2i(102.77, 355.92);
- glVertex2i(54.53, 269.1);
- //Triangle End
- //Rectangle Using Line
- glVertex2i(203.09, 236.3);
- glVertex2i(299.56, 236.3);
- glVertex2i(299.56, 236.3);
- glVertex2i(299.56, 338.56);
- glVertex2i(299.56, 338.56);
- glVertex2i(201.16,338.56);
- glVertex2i(201.16,338.56);
- glVertex2i(203.09, 236.3);
- //Rectangle Using Line
- glEnd();
- glFlush(); // Process all OpenGL routines
- }
- int main(int argc, char* argv[])
- {
- glutInit(&argc, argv); // Initalise GLUT
- glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // Set display mode
- glutInitWindowPosition(50, 100); // Set window position
- glutInitWindowSize(400, 300); // Set window size
- glutCreateWindow("An Example OpenGL Program"); // Create display window
- init(); // Execute initialisation procedure
- glutDisplayFunc(drawShapes); // Send graphics to display window
- glutMainLoop(); // Display everything and wait
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement