Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Shamsuddin Ahmed
- 161-15-1027
- Draw Star 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);
- //Rectangle Using Line
- glVertex2i(150, 150); //A
- glVertex2i(250, 150); //B
- glVertex2i(250, 150);
- glVertex2i(250,250); //C
- glVertex2i(150, 250);
- glVertex2i(150, 150);
- glVertex2i(250,250);
- glVertex2i(150, 250); //D
- //Rectangle End
- //Start First Triangle Using Line
- glVertex2i(250,250); //C
- glVertex2i(200, 350); //E
- glVertex2i(200, 350); //E
- glVertex2i(150, 250); //D
- //End First Triangle Using Line
- //Start 2nd Triangle Using Line
- glVertex2i(150, 150); //A
- glVertex2i(200, 50); //G
- glVertex2i(200, 50); //G
- glVertex2i(250, 150); //B
- //End 2nd Triangle Using Line
- //Start 3rd Triangle Using Line
- glVertex2i(250, 150); //B
- glVertex2i(350, 200); //F
- glVertex2i(250,250); //C
- glVertex2i(350, 200); //F
- //End 3rd Triangle Using Line
- //Start 4th Triangle Using Line
- glVertex2i(150, 250); //D
- glVertex2i(50, 200); //H
- glVertex2i(50, 200); //H
- glVertex2i(150, 150); //A
- //End 4th Triangle 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