Search Projects

Thursday, March 8, 2018

Flag of USA

We have already seen two flags Programs  - OpenGL Flag Hoisting program with Our Indian Tricolor and OpenGL program on flag of South Africa. Today in this post we are going to see another flag program. This flag is about USA.

Challenges

Flag of usa have mainly two parts - one with pattern of stars other the stripes. While maintaining the ration of flag, the pattern has to be drawn in left corner and white and red stripes to rest of the flag. Another problem is the 7 stripes along side of star patterns are smaller in length, we have to keep in mind about it.

Approach

First thing is done by drawing the star with GL_TRIANGLE_FAN, using the proper coordinates and angles. Next we draw the pattern of stars using the for loop function with if else conditions, which determines the alternate between rows of five or six stars.

Define a int variable that holds the value of no of stripes(13). This helps in drawing the stripes in loop as well as determine the number of stripes left. This variable also helps in fixing the length of 7 smaller stripes. Alternate stripe colors is done using the if else, and odd even conditions in it. The GL_QUADS has been used to drawn the stripes.

Unlike our other flag programs here we are displaying the whole screen with flag only. Also there is no pole and no hoisting like we have in Computer graphics OpenGL Flag Hoisting program .  You can watch the video demo of this projects on Youtube.




Source Code

Shoot an email to openglprojects@gmail.com for the Source code of this OpenGL Program, we will sent instruction to get the source code.

No comments:

Post a Comment