<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2020194800836807725</id><updated>2026-10-05T01:37:52.709+05:30</updated><category term="Games"/><category term="Tutorial"/><category term="Complex Projects"/><category term="Simple Project"/><category term="Solar system"/><category term="3D Projects"/><category term="Data Structures and Algorithms"/><category term="Networking Based Project"/><category term="Android"/><category term="3D Objects"/><category term="Gear Motion"/><category term="BigO"/><category term="Clock"/><category term="Complex Project"/><category term="Flag"/><category term="Font Demo"/><category term="Nuclear Power Plant"/><category term="OpenGL Tutorial"/><category term="Simulation"/><category term="Time Complexity"/><category term="Tower of Hanoi"/><category term="Triangular Animation"/><category term="Fluids"/><category term="Graphics Editor"/><category term="Linked List"/><category term="Ludo Board Game"/><category term="Mancala board games"/><category term="Minesweeper"/><category term="Moving Ship"/><category term="OpenGL ES"/><category term="Python"/><category term="Robot"/><category term="SNAKE XENZIA GAME"/><category term="Simple Drawing"/><category term="Simple Haloed Lined Wireframe"/><category term="Simple Move Light"/><category term="Sorting"/><category term="Sphere"/><category term="Spot Light Swing"/><category term="Taj Mahal"/><category term="The Edge Game"/><category term="sample c++ opengl code"/><category term="3D Bi-Cycle"/><category term="3D Car"/><category term="3D Game"/><category term="3D Laptop"/><category term="3D Zoo"/><category term="AI"/><category term="Algorithm"/><category term="Animation"/><category term="Aquarium"/><category term="Artificial intelligence"/><category term="Astronomer"/><category term="Batman"/><category term="Bellman-Ford Algorithm"/><category term="Block Breaker"/><category term="Blockshooting"/><category term="Bucket Sort"/><category term="Bézier curves"/><category term="C#"/><category term="Chess"/><category term="Code Blocks"/><category term="Colors"/><category term="Crab Pong"/><category term="Cricket"/><category term="Cross Zero"/><category term="DSAV"/><category term="Data Communication"/><category term="Doll"/><category term="Electromagnetic induction"/><category term="Engineering Students"/><category term="Escapa"/><category term="Fighter Jet"/><category term="First Come First Serve"/><category term="Flag Hoisting"/><category term="GlutDino"/><category term="Glutplane"/><category term="Hawkeye"/><category term="IC engine"/><category term="Insurance"/><category term="Java"/><category term="Java OpenGL Graphics Programming"/><category term="Light Torus"/><category term="Martyr’s Monument"/><category term="Memory Game"/><category term="Memory blocks game"/><category term="Menu"/><category term="Mickey Mouse"/><category term="Miniature Steam Engine"/><category term="Motion Blur"/><category term="MoveLight"/><category term="Movie Based Projects"/><category term="Multiplex"/><category term="OS Based Projects"/><category term="Olympic"/><category term="OpenGL Programming"/><category term="OpenGL Projects"/><category term="Origami"/><category term="PI Day"/><category term="Paint"/><category term="Paper Folding"/><category term="Particles Drop"/><category term="Path Finding"/><category term="Pendulum"/><category term="Physics Projects"/><category term="Pong Game"/><category term="Project Report"/><category term="Projects Report"/><category term="Puzzles"/><category term="Queuqe"/><category term="Random Flowing lines"/><category term="Ray"/><category term="Rigid Body"/><category term="Rings"/><category term="Rubiks Cube"/><category term="Screen Saver"/><category term="Screen Saver Ship"/><category term="Shadow Cube"/><category term="Shadowfun"/><category term="Shaheed Minar"/><category term="Ship Iceberg"/><category term="Solar"/><category term="Space Invaders"/><category term="Space Shooter"/><category term="Stack"/><category term="Stars"/><category term="Sun"/><category term="Tic Tac Toe"/><category term="Toll Tax Collection"/><category term="Traffic Signal"/><category term="Transformation"/><category term="Transformers"/><category term="Trippy"/><category term="Whirlpool"/><category term="flag of usa"/><category term="iOS"/><category term="iPhone"/><category term="moth"/><category term="moving car"/><category term="opengl c++ examples"/><category term="ping pong"/><category term="poke ball"/><category term="qix like"/><category term="rendering"/><category term="water ripple effects"/><title type='text'>OpenGL Projects</title><subtitle type='html'>OpenGLProjects provides VTU CSE notes, AI resources, programming tutorials, computer graphics, lab programs, project ideas, source code and career resources for engineering students.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.openglprojects.in/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>239</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4576003190272243760</id><published>2026-10-02T03:04:27.510+05:30</published><updated>2026-10-02T03:04:27.510+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Time Complexity"/><title type='text'>How to Calculate Time Complexity</title><content type='html'>&lt;h2&gt;What Is Time Complexity?&lt;/h2&gt;

&lt;p&gt;Time complexity describes how the running time of an algorithm changes when the input size grows.&lt;/p&gt;

&lt;p&gt;It does not measure the exact time in seconds. Instead, it shows how efficiently an algorithm works.&lt;/p&gt;

&lt;p&gt;For example, an algorithm may take:&amp;nbsp;&lt;/p&gt;&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;&amp;nbsp;1 step for 1 item.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;10 steps for 10 items.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;1,000 steps for 1,000 items.&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;p style=&quot;text-align: left;&quot;&gt;

  This algorithm grows in a direct way. Its time complexity is called O(n).

  Here,
  𝑛
  represents the size of the input.

&lt;/p&gt;
&lt;h2&gt;What is Big O Notation?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.openglprojects.in/2026/09/computer-sciencebig-o-notation-practice-problems.html&quot;&gt;Big O notation&lt;/a&gt; is used to describe time complexity.&lt;/p&gt;

&lt;p&gt;It focuses on the general growth of an algorithm and ignores small details, such as:&lt;/p&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
  &lt;li&gt;

    The computer’s speed.&amp;nbsp;&lt;/li&gt;
  &lt;li&gt;Small constants.&amp;nbsp;&lt;/li&gt;
  &lt;li&gt;Minor operations.&amp;nbsp;&lt;/li&gt;
  &lt;li&gt;Exact execution time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some common time complexities are:&lt;/p&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Complexity&lt;/th&gt;
        &lt;th&gt;Name&lt;/th&gt;
        &lt;th&gt;Example&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;O(1) &lt;/td&gt;
        &lt;td&gt;Constant Time&lt;/td&gt;
        &lt;td&gt; Accessing an array item&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(log ⁡n) &lt;/td&gt;
        &lt;td&gt;Logarithmic Time&lt;/td&gt;
        &lt;td&gt;Binary search &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(n) &lt;/td&gt;
        &lt;td&gt;Linear Time&lt;/td&gt;
        &lt;td&gt; Reading every item in a list&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(n log⁡ n) &lt;/td&gt;
        &lt;td&gt;Linearithmic Time&lt;/td&gt;
        &lt;td&gt;Efficient sorting &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(n&lt;sup&gt;2&lt;/sup&gt;) &lt;/td&gt;
        &lt;td&gt;Quadratic Time&lt;/td&gt;
        &lt;td&gt;Comparing every pair of items&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(2&lt;sup&gt;n&lt;/sup&gt;) &lt;/td&gt;
        &lt;td&gt;Exponential Time&lt;/td&gt;
        &lt;td&gt;Some recursive problems&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;O(n!) &lt;/td&gt;
        &lt;td&gt;Factorial Time&lt;/td&gt;
        &lt;td&gt; Trying every possible arrangement&lt;/td&gt;
      &lt;/tr&gt;

    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;The lower the growth rate, the better the algorithm usually performs for large inputs.&lt;/p&gt;
&lt;h2&gt;Why Is Time Complexity Important?&lt;/h2&gt;
&lt;p&gt;Time complexity helps you compare algorithms before writing or running them.&lt;br /&gt;&lt;br /&gt;

  Suppose you need to search for a name in a list. You could check every name one by one, or you could use a faster
  search method if the list is sorted.&lt;/p&gt;

Understanding time complexity helps you:&amp;nbsp;&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;&amp;nbsp;Choose better algorithms.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Write faster programs.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Handle large amounts of data.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Find slow parts of your code.&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Prepare for coding interviews.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;h2&gt;How to Calculate Time Complexity&lt;/h2&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguq1l7nly7dayM7GE3vMWFppLu8Zpvlu9hf6MXrGvLXYQOI-AtQixkYDmBh6-pY0Q_vNfLuMwMCzvrCDS79F8cLkUed4II7PiOcl2PxeP5iyh2Ws2lcqbtuPL9QJamnwHB97X12RP22HAqb7W39KAwvaclpI37RooEGVyXhyPGEaJ2o4bkDgGHaiz5SSc0/s1408/How%20to%20Calculate%20Time%20Complexity.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1408&quot; height=&quot;219&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguq1l7nly7dayM7GE3vMWFppLu8Zpvlu9hf6MXrGvLXYQOI-AtQixkYDmBh6-pY0Q_vNfLuMwMCzvrCDS79F8cLkUed4II7PiOcl2PxeP5iyh2Ws2lcqbtuPL9QJamnwHB97X12RP22HAqb7W39KAwvaclpI37RooEGVyXhyPGEaJ2o4bkDgGHaiz5SSc0/w400-h219/How%20to%20Calculate%20Time%20Complexity.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;Use these simple steps to calculate the time complexity of an algorithm.&lt;/p&gt;
&lt;!--[ Steps ]--&gt;
&lt;ol class=&quot;steps&quot;&gt;
  &lt;li&gt;&lt;b&gt;Step 1: Identify the Input Size&lt;/b&gt;&lt;/li&gt;

&lt;p&gt;Find the value that represents the input size.&lt;/p&gt;
&lt;p&gt;Usually, this value is called &lt;code&gt;𝑛&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;
&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;def print_items(items):
	for item in items:
		print(item)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The input size is the number of items in the list. We call it
  &lt;code&gt;𝑛&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;

&lt;!--[ Steps ]--&gt;
  &lt;li&gt;&lt;b&gt;Step 2: Count the Main Operation&lt;/b&gt;&lt;/li&gt;

&lt;p&gt;Find the operation that is repeated the most.&lt;/p&gt;

&lt;p&gt;In the example above, &lt;code class=&quot;hljs language-css&quot; data-highlighted=&quot;yes&quot; data-result-language=&quot;css&quot;&gt;&lt;span class=&quot;hl-attribute&quot;&gt;print(item)&lt;/span&gt;&lt;/code&gt; runs once for every item.&lt;/p&gt;

&lt;p&gt;If the list contains 𝑛 items, the operation runs 𝑛 times.&lt;/p&gt;

&lt;p&gt;Therefore, the time complexity is:&lt;/p&gt;

𝑂(𝑛)


&lt;!--[ Steps ]--&gt;
  &lt;li&gt;&lt;b&gt;Step 3: Check Loops&lt;/b&gt;&lt;/li&gt;
&lt;p&gt;A single loop that runs 𝑛 times usually has a time complexity of
  𝑂(𝑛).&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;for i in range(n):
  print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The loops runs 𝑛 times, so: Time complexity: O(n)&lt;/p&gt;
&lt;!--[ Steps ]--&gt;
  &lt;li&gt;&lt;b&gt;Step 4: Check Nested Loops&lt;/b&gt;&lt;/li&gt;

The outer loop runs 𝑛 times. For each outer-loop cycle, the inner loop also runs times. The total number of operations is: 𝑛 x 𝑛 = 𝑛&lt;sup&gt;2&lt;/sup&gt; so, the time complexity is : O(n&lt;sup&gt;2&lt;/sup&gt;)

&lt;p&gt;Nested loops usually multiply their time complexities.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for i in range (n):
for j in range (n):
print (i, j)&lt;/code&gt;&lt;/pre&gt;
&lt;!--[ Steps ]--&gt;
  &lt;li&gt;&lt;b&gt;Step 5: Check Separate Loops&lt;/b&gt;&lt;/li&gt;

&lt;p&gt;Separate loops are usually added together.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;for i in range(n):
									print(i) 
                                 for j in range(n):
                                 print(j)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first loop takes 𝑂(𝑛).&lt;/p&gt;

&lt;p&gt;The second loop also takes 𝑂(𝑛).&lt;/p&gt;

&lt;p&gt;Together: 𝑂(𝑛)+𝑂(𝑛)=𝑂(2𝑛)&lt;/p&gt;

&lt;p&gt;In Big O notation, constants are removed: 𝑂(2𝑛)=𝑂(𝑛)&lt;/p&gt;

&lt;p&gt;Therefore, the final time complexity is: O(n)&lt;/p&gt;

&lt;!--[ Steps ]--&gt;
  &lt;li&gt;Step 6: Remove Constants&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(5𝑛)=𝑂(𝑛)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;𝑂(3𝑛&lt;sup&gt;2&lt;/sup&gt;+2𝑛+10)=𝑂(𝑛)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We keep only the fastest-growing term.&lt;/p&gt;
&lt;h2&gt;Common Time Complexity Examples&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;O(1): Constant Time&lt;/h4&gt;
&lt;p&gt;An operation takes the same amount of time regardless of the input size.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;def get_first_item(items):
return items[0]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The function gets one item. It does not need to check every item.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;Time complexity: O(1)&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;O(n): Linear Time&lt;/h4&gt;
&lt;p&gt;The running time grows directly with the input size.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;def find_item(items, target):
for item in items:
if item == target:
return True
return False&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the worst case, the function checks every item.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;Time complexity: O(n)&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;O(log n): Logarithmic Time&lt;/h4&gt;
&lt;p&gt;The input becomes smaller during each step.&lt;/p&gt;

&lt;p&gt;A common example is binary search.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Time complexity: O(log n)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If a search space is divided in half again and again, &lt;a href=&quot;https://www.openglprojects.in/2014/03/first-come-first-serve-algorithm.html&quot;&gt;the algorithm&lt;/a&gt; often has logarithmic time complexity.&lt;/p&gt;

&lt;h4&gt;O(n log n): Linearithmic Time&lt;/h4&gt;
&lt;p&gt;This complexity often appears in efficient sorting algorithms, such as merge sort.&lt;/p&gt;

&lt;p&gt;An algorithm may process all
  𝑛
  n items while also dividing the problem into smaller parts.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Time complexity: O(n log n)&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;O(n²): Quadratic Time&lt;/h4&gt;
&lt;p&gt;The algorithm performs an operation for every pair of items.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
def show_pairs(items):
for first in items:
for second in items:
print(first, second)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Both loops run n times
𝑛 × 𝑛 = 𝑛&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Time Complexity : 𝑛&lt;sup&gt;2&lt;/sup&gt; &lt;/p&gt;

&lt;h2&gt;How to Calculate Complexity of Loops&lt;/h2&gt;
&lt;h4&gt;A Loop That Increases by One&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;
i=1

while i &amp;lt; n:
	print (i)
    i*=2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The value doubles after every step:  1, 2, 4, 8, 16, ...&lt;/p&gt;
&lt;p&gt;The number of steps is about log &lt;sub&gt;2&lt;/sub&gt; n.&lt;/p&gt;
&lt;p&gt;Time Complexity : O (log n)&lt;/p&gt;
&lt;p&gt;Two Nested Loops With Different Sizes&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
   for i in range (n):
   	for j in range (m):
		print (i, j)&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;The Outer loop runs n times&lt;/p&gt;
        &lt;p&gt;the inner loop runs m times&lt;/p&gt;
        &lt;p&gt;Therefeore o(nxm)=O(nm)&lt;/p&gt;
        
        &lt;p&gt;Do not always replace both variables with
. If the input sizes are different, keep both variables.&lt;/p&gt;
    &lt;h4 style=&quot;text-align: left;&quot;&gt;How to Calculate Recursive Time Complexity  &lt;/h4&gt;&lt;p&gt;Recursion can be more difficult to analyze. &lt;br /&gt;&lt;br /&gt;Consider this function:&lt;/p&gt;&lt;pre data-comment=&quot;python&quot; data-source=&quot;&quot;&gt;def countdown(n):
    if n==0:
&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;
  &amp;nbsp;&lt;/span&gt;print(n)
countdown(n - 1) &lt;/pre&gt;

The function calls itself once for each value of 𝑛.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Therefore:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&amp;lt;code&amp;gt;Time complexity: O(n)&amp;lt;/code&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Now consider a function that makes two recursive calls:&amp;nbsp;
  &lt;pre data-comment=&quot;python&quot; data-source=&quot;&quot;&gt;&lt;code&gt;
    def example(n):&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if n &amp;lt;=1: &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;example(n - 1) &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;example(n - 1) 
    &lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;The number of calls grows very quickly. Its time complexity is approximately: &amp;lt;code&amp;gt;O(2ⁿ)&amp;lt;/code&amp;gt;&lt;/p&gt;
  &lt;p&gt;When analyzing recursion, ask: &lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;How many recursive calls are made? &lt;/li&gt;
    &lt;li&gt;How much does the input shrink each time? &lt;/li&gt;
    &lt;li&gt;Is there one recursive call or more than one? &lt;/li&gt;
    &lt;li&gt;Is the result stored and reused? &lt;/li&gt;
  &lt;/ul&gt;

  &lt;h2&gt;Best, Average, and Worst Cases&lt;/h2&gt;

  &lt;p&gt;An algorithm can behave differently depending on the input. &lt;/p&gt;

  &lt;h3&gt;Best Case&lt;/h3&gt;
  &lt;p&gt;&lt;/p&gt;The algorithm finishes as quickly as possible. For example, a search
  function may find the target in the first position.&lt;p&gt;&lt;/p&gt;
  &lt;h3&gt;Average Case&lt;/h3&gt;
  &lt;p&gt;The algorithm takes an average amount of time for
    typical input. &lt;/p&gt;
  &lt;h3&gt;Worst Case&lt;/h3&gt;
  &lt;p&gt;The algorithm takes the most time possible. For example, a search function may find the
    target at the last position or not find it at all. When people discuss Big O notation, they often mean the
    worst-case time complexity. &lt;/p&gt;

  &lt;h2&gt;Time Complexity Rules to Remember&lt;/h2&gt;
  &lt;p&gt;These rules make calculations easier:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;A single statement is usually 𝑂 ( 1 ).&lt;/li&gt;
    &lt;li&gt;A loop that runs 𝑛 n times is usually 𝑂 ( 𝑛 ).&lt;/li&gt;
    &lt;li&gt;Nested loops are usually multiplied.&lt;/li&gt;
    &lt;li&gt;Separate sections are added.&lt;/li&gt;
    &lt;li&gt;Constants are removed.&lt;/li&gt;
    &lt;li&gt;Keep the fastest-growing term.&lt;/li&gt;
    &lt;li&gt;A loop that repeatedly divides the input often has 𝑂 ( log ⁡ 𝑛 ) complexity.&lt;/li&gt;
    &lt;li&gt;If an algorithm handles two input sizes, use 𝑂 ( 𝑛 𝑚 ) when appropriate.&lt;/li&gt;
  &lt;/ul&gt;

  &lt;h2&gt;Worked Example &lt;/h2&gt;

  &lt;p&gt;Consider this code:&lt;/p&gt;

  &lt;pre data-comment=&quot;python&quot; data-source=&quot;&quot;&gt;&lt;code&gt;
    def process(numbers):&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt; for number in numbers: &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;print(number) &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;for i in range(len(numbers)): &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;for j in range(len(numbers)): &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;print(i, j) 
    &lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt; Let the number of items be &lt;code&gt;𝑛&lt;/code&gt;.
  &lt;/p&gt;
  &lt;p&gt; The first loop has: 𝑂 ( 𝑛 )

  &lt;/p&gt;
  &lt;p&gt; The nested loops have: 𝑂 ( 𝑛 2 )

  &lt;/p&gt;
  &lt;p&gt; Together: 𝑂 ( 𝑛 ) + 𝑂 ( 𝑛 2 )

  &lt;/p&gt;
  &lt;p&gt; The 𝑛&lt;sup&gt;2&lt;/sup&gt; term grows faster than the 𝑛 n term, so we remove 𝑂 ( 𝑛 ) O(n).&lt;/p&gt;
  &lt;p&gt; Final answer: Time complexity: O(n²) &lt;/p&gt;

  &lt;h2&gt;Time Complexity vs Space Complexity&lt;/h2&gt;
  &lt;p&gt;&lt;a href=&quot;https://www.openglprojects.in/2026/09/Time-Complexity-Practice-Problems-a-Comprehensive-Guide.html&quot;&gt;Time complexity&lt;/a&gt; measures how much time an algorithm needs. Space complexity measures how much extra memory it
    needs.&lt;/p&gt;

  &lt;p&gt;For example:&lt;/p&gt;

  &lt;pre data-comment=&quot;python&quot; data-source=&quot;&quot;&gt;&lt;code&gt;def copy_items(items): &lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;result=[] &lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;for item in items:&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt; result.append(item) &lt;br /&gt;return result&lt;/code&gt;&lt;/pre&gt;

  &lt;p&gt;The function processes every item, so its time complexity is: &lt;code&gt;O(n)&lt;/code&gt; It also creates a new list
    containing &lt;code&gt;𝑛&lt;/code&gt; items, so its extra space complexity
    is: text O(n)&lt;/p&gt;

  &lt;p&gt;These are different measurements, but both are important when evaluating an algorithm.
  &lt;/p&gt;
  &lt;h2&gt;Frequently Asked Questions &lt;/h2&gt;

  &lt;p&gt;&lt;b&gt;Is O(1) always faster than O(n)?&lt;/b&gt;&lt;/p&gt;
  &lt;p&gt;
    Usually, yes for large inputs. However, actual speed can depend on
    the hardware, programming language, and operations being performed. &lt;/p&gt;

  &lt;p&gt;&lt;b&gt;Are constants ignored in Big O?&lt;/b&gt;&lt;/p&gt;
  &lt;p&gt;
    Big O focuses on how an algorithm grows as the input becomes very large. Constants have less effect on growth than
    terms
    such as 𝑛 n, 𝑛 2 n 2 , or 2 𝑛 2 n . &lt;/p&gt;

  &lt;p&gt;&lt;b&gt;What is the fastest time complexity?&lt;/b&gt;&lt;/p&gt;
  &lt;p&gt;
    𝑂 ( 1 ) O(1) is generally considered
    the most efficient common time complexity. However, an 𝑂 ( log ⁡ 𝑛 ) O(logn) algorithm can also be very fast for
    large inputs. &lt;/p&gt;

  &lt;p&gt;&lt;b&gt;Is O(n²) always bad?&lt;/b&gt;&lt;/p&gt;
  &lt;p&gt;Not always. For small inputs, an 𝑂 ( 𝑛 2 ) O(n 2 ) algorithm may work well. It
    becomes a problem when the input size grows. &lt;/p&gt;

  &lt;p&gt;&lt;b&gt;How do I analyze a loop that runs from 1 to n?&lt;/b&gt;&lt;/p&gt;
  &lt;p&gt;
    If it increases by one
    each time, it usually has 𝑂 ( 𝑛 ) O(n) time complexity. &lt;/p&gt;

  &lt;p&gt;To calculate time complexity, identify the input size, count repeated operations, analyze loops and recursion,
    combine the terms, and remove constants.&lt;/p&gt;
  &lt;p&gt;The
    most important patterns are:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;One operation: 𝑂 ( 1 ) O(1). &lt;/li&gt;
    &lt;li&gt;One loop: 𝑂 ( 𝑛 ) O(n). &lt;/li&gt;
    &lt;li&gt;A loop that halves the input:𝑂 ( log ⁡ 𝑛 ). &lt;/li&gt;
    &lt;li&gt;Nested loops: 𝑂 ( 𝑛 2 ) O(n 2 ). &lt;/li&gt;
    &lt;li&gt;Efficient sorting: often 𝑂 ( 𝑛 log ⁡ 𝑛 ).&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;With practice, you can look at a piece of code and quickly estimate how its running time will grow.&lt;/p&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4576003190272243760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/how-to-calculate-time-complexity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4576003190272243760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4576003190272243760'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/how-to-calculate-time-complexity.html' title='How to Calculate Time Complexity'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguq1l7nly7dayM7GE3vMWFppLu8Zpvlu9hf6MXrGvLXYQOI-AtQixkYDmBh6-pY0Q_vNfLuMwMCzvrCDS79F8cLkUed4II7PiOcl2PxeP5iyh2Ws2lcqbtuPL9QJamnwHB97X12RP22HAqb7W39KAwvaclpI37RooEGVyXhyPGEaJ2o4bkDgGHaiz5SSc0/s72-w400-h219-c/How%20to%20Calculate%20Time%20Complexity.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4724214497568741219</id><published>2026-09-27T02:59:22.899+05:30</published><updated>2026-09-27T03:00:31.978+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="BigO"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Big O Examples in Python</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;
  Here are some common Big O examples in Python, with short code snippets and
  explanations of time complexity of each of them. First we see the general examples then we go with some practice exercise with solutions.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://i.pinimg.com/736x/73/7a/74/737a7429a1fdf2d2ac87ec320f8876b1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;720&quot; height=&quot;640&quot; src=&quot;https://i.pinimg.com/736x/73/7a/74/737a7429a1fdf2d2ac87ec320f8876b1.jpg&quot; width=&quot;427&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2&gt;Steps to Learn the Big O Examples in Python&lt;/h2&gt;
&lt;ol class=&quot;steps&quot;&gt;
  &lt;li&gt;
    First we are go through the Common &lt;b&gt;Big O classes&lt;/b&gt;
    &lt;i&gt;𝑂(1), 𝑂(log 𝑛), 𝑂(𝑛), 𝑂(𝑛 log 𝑛),&lt;/i&gt; and &lt;i&gt;𝑂(𝑛2)&lt;/i&gt; in simple code
    pattern
    &lt;span style=&quot;display: inline-block; vertical-align: top;&quot;&gt;&lt;/span&gt;
  &lt;/li&gt;
  &lt;li&gt;Learn the Python Data Structures with quick overview&lt;/li&gt;
  &lt;li&gt;Go Through the Practical Example with code snippets.&amp;nbsp;&lt;/li&gt;
  &lt;li&gt;See Some Interview Questions&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;1. Common Big O classes Examples in Python&lt;/h2&gt;

&lt;h3&gt;1.1. Constant time — O(1)&lt;/h3&gt;
&lt;p&gt;
  Operations that take the same amount of time regardless of input size ie n.
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def find_first_index(list1):
    print(list1[0])
&lt;/code&gt;&lt;/pre&gt;
Whether items contains 10 elements or 10 million elements, accessing items[0] is
&lt;b&gt;O(1)&lt;/b&gt;.
&lt;h3&gt;1.2. Linear time — 𝑂(𝑛)&lt;/h3&gt;
&lt;p&gt;
  The work grows proportionally with the input size, execution time scales one
  to one with input size.
&lt;/p&gt;
&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;def print_items(items):
    for item in items:
        print(item)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  If there are &lt;code&gt;n&lt;/code&gt; items, the loop runs &lt;code&gt;n&lt;/code&gt; times.
  Searching an unsorted Python list can take O(n) in the worst case.
&lt;/p&gt;

&lt;h3&gt;1.3. Logarithmic - O(log n)&lt;/h3&gt;
&lt;p&gt;
  The algorithm repeatedly cuts the problem down, often by half with every
  iteration. It is highly efficient for large datasets.
&lt;/p&gt;
&lt;p&gt;A classic example is &lt;span&gt;binary search: &lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def binary_search(arr, target):
    left, right = 0, len(arr) 

    while left &amp;lt;= right:
        mid = (left + right) 

        if arr[mid] == target:
            return True
        elif arr[mid] &amp;lt;target:
            left = mid + 1
        else:
            right = mid - 1

    return False
&lt;/code&gt;    &lt;/pre&gt;
&lt;p&gt;Each step eliminates about half of the remaining elements.&lt;/p&gt;
&lt;h3&gt;1.4. Linearithmic -&amp;nbsp;&amp;nbsp;O(n log n)&lt;/h3&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;
  The Time of an alogorithm grows at a liner log arthmic rate with the size of
  input, n which means performace is impacted with the input size and lograthim
  of the input size. Common in efficient sorting algorithms.
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;items.sort()
&lt;/code&gt;    &lt;/pre&gt;
&lt;p&gt;
  Python&#39;s &lt;code&gt;list.sort()&lt;/code&gt; / &lt;code&gt;sorted()&lt;/code&gt; use
  &lt;span&gt;Timsort, whose worst-case time complexity is &lt;span&gt;O(n log n).&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;numbers = [5, 2, 8, 1, &amp;gt;3]
numbers.sort()
&lt;/code&gt;    &lt;/pre&gt;
&lt;h3&gt;1.5.&amp;nbsp; Quadratic -&amp;nbsp;O(n²)&lt;/h3&gt;
&lt;p&gt;Usually occurs when you have a loop inside another loop.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def print_pairs(items):
    for x in items:
        for y in items:
            print(x, y)&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;For &lt;code&gt;n&lt;/code&gt; items:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Outer loop → &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Inner loop → &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Total → &lt;code&gt;n × n&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p 6=&quot;&quot;&gt;A common example is a simple comparison of every pair.&lt;/p&gt;
&lt;h3 8=&quot;&quot;&gt;1.6.&amp;nbsp; Exponential - O(2ⁿ)&lt;/h3&gt;
&lt;p 9=&quot;&quot;&gt;The amount of work doubles as &lt;code&gt;n&lt;/code&gt; increases by one.&lt;/p&gt;
&lt;p 10=&quot;&quot;&gt;A classic example is the naive recursive Fibonacci implementation:&lt;/p&gt;
&lt;pre 11=&quot;&quot;&gt;&lt;code&gt;def fibonacci(n):
    if n &amp;lt;= 1:
        return n

    return fibonacci(n - 1) + fibonacci(n - 2)
&lt;/code&gt;    &lt;/pre&gt;
&lt;p&gt;
  This repeatedly calculates the same values. Using dynamic programming can
  reduce this dramatically.
&lt;/p&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;The Time Complexities in python Summarized&lt;/h2&gt;

&lt;p&gt;&lt;b&gt;O(1) — Constant time complexity&lt;/b&gt;: An algorithm exhibits constant &lt;a href=&quot;https://www.openglprojects.in/2026/09/amortized-time-complexity-definition-and-examples.html&quot; target=&quot;_blank&quot;&gt;time complexity &lt;/a&gt;when its execution duration remains unchanged irrespective of the input magnitude. Illustration: retrieving an element from an array.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(log n) — Logarithmic time complexity&lt;/b&gt;: An algorithm demonstrates logarithmic time complexity when its execution duration increases logarithmically relative to the input magnitude. Illustration: binary search methodology.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(n) — Linear time complexity&lt;/b&gt;: An algorithm exhibits linear time complexity when its execution duration increases proportionally with the input magnitude. Illustration: linear search methodology.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(n log n) — Linearithmic time complexity&lt;/b&gt;: An algorithm demonstrates linearithmic time complexity when its execution duration increases at a linear-logarithmic proportion relative to the input magnitude. Illustration: merge sort algorithm.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(n²) — Quadratic time complexity&lt;/b&gt;: An algorithm exhibits quadratic time complexity when its execution duration increases quadratically with the input magnitude. Illustration: bubble sort algorithm.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(2n) — Exponential time complexity&lt;/b&gt;: An algorithm demonstrates exponential time complexity when its execution duration increases exponentially relative to the input magnitude. Illustration: naive recursive Fibonacci sequence implementation.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;O(n!) — Factorial time complexity&lt;/b&gt;: An algorithm exhibits factorial time complexity when its execution duration increases at a factorial proportion with the input magnitude. Illustration: brute-force approach to the traveling salesman problem&lt;/p&gt;

&lt;h2&gt;Quick Summary Table Python examples&lt;/h2&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
    &lt;table&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Big O&lt;/th&gt;
          &lt;th&gt;Python example&lt;/th&gt;
          &lt;th&gt;Idea&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(1) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;code&gt;items[0]&lt;/code&gt;
          &lt;/td&gt;
          &lt;td&gt;Constant&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(log n) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;Binary search&lt;/td&gt;
          &lt;td&gt;Halves the problem&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(n) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;code&gt;for x in items&lt;/code&gt;
          &lt;/td&gt;
          &lt;td&gt;Visit each item&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(n log n) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;code&gt;items.sort()&lt;/code&gt;
          &lt;/td&gt;
          &lt;td&gt;Efficient sorting&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(n²) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;Nested loops&lt;/td&gt;
          &lt;td&gt;Compare pairs&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;span&gt;O(2ⁿ) &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;Naive Fibonacci&lt;/td&gt;
          &lt;td&gt;Repeated branching&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;h2&gt;2. Common Python data structures&lt;/h2&gt;
&lt;p&gt;Now we are going to see common &lt;a href=&quot;https://docs.python.org/3/tutorial/datastructures.html&quot; target=&quot;_blank&quot;&gt;Python data structures&lt;/a&gt; (&lt;code&gt;list&lt;/code&gt;,
    &lt;code&gt;dict&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;tuple&lt;/code&gt;)&lt;/p&gt;
&lt;h4&gt;Python Data Structures — Big O Cheat Sheet&lt;/h4&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Operation&lt;/th&gt;
            &lt;th&gt;List&lt;/th&gt;
            &lt;th&gt;Tuple&lt;/th&gt;
            &lt;th&gt;Set&lt;/th&gt;
            &lt;th&gt;Dict&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;Access by index&lt;/td&gt;
            &lt;td&gt;O(1)&lt;/td&gt;
            &lt;td&gt;O(1)&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Search (x in)&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Append&lt;/td&gt;
            &lt;td&gt;O(1) amortized&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Insert at beginning&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Insert at end&lt;/td&gt;
            &lt;td&gt;O(1) amortized&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Delete by value&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Access by key&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;—&lt;/td&gt;
            &lt;td&gt;O(1) avg.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Sorting&lt;/td&gt;
            &lt;td&gt;O(n log n)&lt;/td&gt;
            &lt;td&gt;sorted() → O(n log n)&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h2&gt;2.1. Python List&lt;/h2&gt;
A Python &lt;code&gt;list&lt;/code&gt; is essentially a dynamic array.
&lt;h3&gt;Access — O(1)&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;numbers = [10, 20, 30, 40, 50]
print(numbers[3])
 &lt;/code&gt;&lt;/pre&gt;   
&lt;p&gt;Python can directly calculate where index &lt;code&gt;3&lt;/code&gt; is located.&lt;/p&gt;
&lt;p&gt;O(1)&lt;/p&gt;
&lt;h3&gt;Append — O(1) amortized&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;numbers.append(60)&lt;/code&gt;&lt;/pre&gt;   
&lt;p&gt;Usually, Python simply adds the element at the end.&lt;/p&gt;
&lt;p&gt;O(1) amortized&lt;/p&gt;

&lt;p&gt; &quot;amortized&quot;? Occasionally Python needs to allocate a larger block of memory and copy elements, which takes O(n), but over many appends the average cost is O(1).
&lt;/p&gt;
&lt;h3&gt;Insert at beginning — O(n)&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;numbers.insert(0, 5)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Existing elements have to be shifted:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[10, 20, 30, 40]
 ↓
[5, 10, 20, 30, 40]&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt;(n)&lt;/p&gt;

&lt;p&gt; if you frequently add/remove items from the beginning, consider &lt;code&gt;collections.deque&lt;/code&gt; instead of a list.&lt;/p&gt;

&lt;h3&gt;Searching a List — O(n)&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;numbers = [10, 20, 30, 40, 50]

if 40 in numbers:
    print(&quot;Found&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; may need to check:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;10 → 20 → 30 → 40&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt;Worst case:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;10 → 20 → 30 → 40 → 50 → not found&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt;So searching a list is typically:&lt;/p&gt;

O(n)

&lt;h3&gt; Dictionary — O(1) Average&lt;/h3&gt;
&lt;p&gt;Dictionaries use hash tables.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;person = {
    &quot;name&quot;: &quot;Alice&quot;,
    &quot;age&quot;: 25
}

print(person[&quot;name&quot;])&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt; Finding &quot;name&quot; is typically:&lt;/p&gt;

&lt;p&gt;O(1) average&lt;/p&gt;

&lt;p&gt;This is why dictionaries are extremely useful for fast lookups.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Instead of:&lt;/p&gt;

users = [&quot;Alice&quot;, &amp;gt;&quot;Bob&quot;, &amp;gt;&quot;Charlie&quot;]
&lt;pre&gt;&lt;code&gt;
if &amp;gt;&quot;Charlie&quot; &amp;gt;in users:
    ...
 &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;    
you could use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
users = &amp;gt;{
    &amp;gt;&quot;Alice&quot;: &amp;gt;101,
    &amp;gt;&quot;Bob&quot;: &amp;gt;102,
    &amp;gt;&quot;Charlie&quot;: &amp;gt;103
}

if &amp;gt;&quot;Charlie&quot; &amp;gt;in users:
    ...
 &lt;/code&gt;&lt;/pre&gt;   
&lt;p&gt;The list lookup is O(n), while dictionary lookup is O(1) average.&lt;/p&gt;

&lt;h3&gt;Set — O(1) Average Lookup&lt;/h3&gt;
&lt;p&gt;Sets are also hash-table based.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;numbers = {10, 20, 30, 40, 50}

if &amp;gt;30 &amp;gt;in numbers:
    &amp;gt;print(&quot;Found&quot;)&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt;Average:&lt;/p&gt;

&lt;p&gt;O(1)&lt;/p&gt;

&lt;p&gt; makes sets particularly useful when you need to repeatedly ask:

&lt;br /&gt;&quot;Have I seen this value before?&quot;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;seen = &amp;gt;set()

for number in numbers:
    &amp;gt;if number in seen:
        &amp;gt;print(&quot;Duplicate!&quot;)
    seen.add(number)&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt; Each lookup is approximately O(1), so the entire loop is approximately:

&lt;br /&gt;O(n)   &lt;/p&gt;

&lt;h3&gt;Tuple&lt;/h3&gt;
&lt;p&gt;Tuples are similar to lists for indexing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;numbers = (10, 20, 30, 40)

print(numbers[2])&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt; access:

&lt;br /&gt;O(1)&lt;/p&gt;

&lt;p&gt;Tuples are immutable, so you cannot do:

&lt;/p&gt;&lt;pre&gt;&lt;code&gt;numbers.append(50)   &amp;gt;# Error&lt;/code&gt;&lt;/pre&gt;
    
&lt;p&gt; Searching is still:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;30 &amp;gt;in numbers&lt;/code&gt;&lt;/pre&gt;
    
&lt;h3&gt;What is the difference between list and tuple?&lt;/h3&gt;
&lt;!--[ Note info ]--&gt;
&lt;p class=&quot;note&quot;&gt;&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt; The List is changable, in which items can be added or remove but in the Tuple it can not be changed. If you want the items that you created can not be changed by anyone, than you can use tuple.
&lt;br /&gt;list1=[1,2,3]&lt;br /&gt;
list1[1]=1000&lt;br /&gt; 
print(list1)&lt;br /&gt; 
tup =(1,2,3)&lt;br /&gt; 
# tup[1]=100 # it can not be changed.&lt;br /&gt;
&lt;/p&gt;

&lt;h3&gt; Big O Patterns to Memorize&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;list[index]       → O(1)

list.append(x)    → O(1) amortized

list.pop()        → O(1)

list.insert(0,x)  → O(n)

list.pop(0)       → O(n)

x in list         → O(n)

x in set          → O(1) average

dict[key]         → O(1) average

for x in list     → O(n)

nested loops      → O(n²)

list.sort()       → O(n log n)&lt;/code&gt;&lt;/pre&gt;
    
&lt;h2&gt; Practice exercises with solutions&lt;/h2&gt;
&lt;h5&gt;Exercise 1&lt;/h5&gt;

&lt;pre&gt;&lt;code&gt;def ex1(lst):
    return lst[0] + lst[-1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of ex1 in terms of n = len(lst)?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def ex1(lst):
    return lst[0] + lst[-1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Two list index operations: lst[0] and lst[-1].&lt;br /&gt; 
    Each index access is O(1). &lt;br /&gt;Time complexity: O(1).&lt;/p&gt;

&lt;h5&gt;Exercise 2&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;def ex2(lst):
    total = 0
    for x in lst:
        total += x
    for x in lst:
        total -= x
    return total
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;ex2&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt; The function has two separate loops, 
    each iterating through the list once.&lt;br /&gt;
    First loop: runs n times → O(n).&lt;br /&gt;Second loop: runs n times → O(n).&lt;br /&gt;Total: O(n) + O(n) = O(n).
&lt;br /&gt;&lt;b&gt;Time complexity:&lt;/b&gt; O(n).
&lt;/p&gt;
&lt;h5&gt;Exercise 3&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;def ex3(lst):
    for i in range(len(lst)):
        for j in range(i, len(lst)):
            print(lst[i], lst[j])&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;ex3&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The function has nested loops, where the inner loop runs from the current index of the outer loop to the end of the list. In the worst case, this results in approximately n² iterations. 
   &lt;br /&gt;Outer loop: i from 0 to n−1.&lt;br /&gt;
   Inner loop: j from i to n−1 → about (n − i) iterations.&lt;br /&gt;
   Total iterations ≈ n + (n−1) + … + 1 = n(n+1)/2 = O(n²)&lt;br /&gt;     
&lt;b&gt;Time complexity:&lt;/b&gt; O(n²).&lt;/p&gt;

&lt;h5&gt;Exercise 4&lt;/h5&gt;

&lt;pre&gt;&lt;code&gt;def ex4(n):
    count = 0
    while n &amp;gt; 1:
        n = n // 2
        count += 1
    return count
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;ex4&lt;/code&gt; in terms of the input value &lt;code&gt;n&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The function divides &lt;code&gt;n&lt;/code&gt; by 2 in each iteration until &lt;code&gt;n&lt;/code&gt; becomes 1. 
    This results in approximately log₂(n) iterations.&lt;br /&gt; 
    Each iteration halves &lt;code&gt;n&lt;/code&gt;.&lt;br /&gt;
    Number of halvings until &lt;code&gt;n&lt;/code&gt; becomes 1 is about log₂(n).&lt;br /&gt;
    &lt;b&gt;Time complexity:&lt;/b&gt; O(log n).&lt;/p&gt;

&lt;h5&gt;Exercise 5&lt;/h5&gt;

&lt;pre&gt;&lt;code&gt;def ex5(lst, target):
    for i in range(len(lst)):
        if lst[i] == target:
            return i
    return -1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the worst-case time complexity of &lt;code&gt;ex5&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt; In the worst case, the target is not found in the list, and the function must iterate through all elements. 
    &lt;b&gt;Worst-case time complexity:&lt;/b&gt; O(n).&lt;/p&gt;

&lt;h5&gt;Exercise 6&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def ex6(lst):
    d = {}
    for x in lst:
        d[x] = d.get(x, 0) + 1
    return d&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;ex6&lt;/code&gt;? (Assume average-case dictionary operations.)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The function iterates through the list once, and each dictionary operation (get and set) is O(1) on average. &lt;br /&gt;
    Loop runs n times.&lt;br /&gt;Each dict lookup/insert (d.get, d[...]) is O(1) on average.&lt;br /&gt;
    &lt;b&gt;Average-case time complexity: O(n).&lt;/b&gt;&lt;/p&gt;

&lt;h5&gt;Exercise 7&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def ex7(lst):
    result = []
    for x in lst:
        result.append(x * 2)
    return result
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What are the time and space complexities of &lt;code&gt;ex7&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt; The function iterates through the list once, 
    performing a constant-time operation for each element. 
    Time complexity: O(n). The function creates a new list of the same size as the input list. Space complexity: O(n).&lt;/p&gt;
    &lt;ul&gt;
        &lt;li&gt;Loop runs n times; each &lt;code&gt;&lt;span class=&quot;hl-built_in&quot;&gt;append&lt;/span&gt;&lt;/code&gt; is O(1) amortized.&lt;/li&gt;
        &lt;li&gt;Creates a new list of size n.
Time complexity: O(n).&lt;br /&gt;
Space complexity: O(n) extra space for &lt;code&gt;&lt;span class=&quot;hl-keyword&quot;&gt;result&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
    &lt;/ul&gt;

&lt;h5&gt;Exercise 8&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def ex8(lst):
    total = 0
    for x in lst:
        for y in lst:
            total += x * y
    return total
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;ex8&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt; The function has nested loops, where the inner loop runs for each element of the list.
    In the worst case, this results in approximately n² iterations. &lt;/p&gt;
   &lt;ul&gt;
        &lt;li&gt;Outer loop: n iterations.&lt;/li&gt;
        &lt;li&gt;Inner loop: n iterations for each outer iteration.&lt;/li&gt;
   &lt;li&gt; Total operations ≈ n × n = n².&lt;br /&gt;
    Time complexity: O(n²).&lt;/li&gt; &lt;/ul&gt;

&lt;h5&gt;Exercise 9&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def example(arr):
    arr.sort()

    for x in arr:
        print(x)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;mystery&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Python&#39;s list.sort() uses Timsort, whose worst-case time complexity is: O(n log n), therafter loop is O(n) Therefore: O(n log n + n) The dominant term is n log n.&lt;br /&gt;Time complexity:O(n log n)  &lt;/p&gt;
&lt;h5&gt;Exercise 10&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def example(arr):
    arr.sort()

    for x in arr:
        print(x)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the time complexity of &lt;code&gt;mystery&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Each call creates two more calls: &lt;code&gt;T(n) = 2T(n-1) + O(1)&lt;/code&gt;This produces exponential growth O(2ⁿ)&lt;br /&gt;Time complexity:O(2ⁿ)  &lt;/p&gt;
&lt;h5&gt;Exercise 11&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;
def mystery(arr):
    for i in range(len(arr)):
        for j in range(i + 1, len(arr)):
            if arr[i] == arr[j]:
                return True

    return False
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; What is the worst-case complexity?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Worst case means no duplicate is found, so both loops run almost completely. &lt;code&gt;n × n&lt;/code&gt;&lt;br /&gt;Worst-case complexity Time complexity:O(n²)  &lt;/p&gt;

&lt;h2&gt;20 Big-O Practice Questions in Python &lt;/h2&gt;
&lt;p&gt;Try to identify the time complexity of each snippet before checking the answer key.Assume n = len(arr) where
    applicable. &lt;/p&gt;
&lt;h5&gt;1. Easy&lt;/h5&gt;&lt;pre&gt;&lt;code&gt;def example(n): for i in range(n): print(i) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;2. Constant work&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def
example(arr): print(arr[0]) print(arr[-1]) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;3. Two loops&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): for i in range(n):
print(i) for j in range(n): print(j) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;4. Nested loops&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): for i in range(n): for j
in range(n): print(i, j) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;5. Different loop sizes&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): for i in range(n): for j in
range(10): print(i, j) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;6. Logarithmic&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): i = 1 while i &amp;lt; n: print(i) i *=2 Your
    &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;7. Dividing&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): while n &amp;gt; 1: n //= 2 &lt;/code&gt;&lt;/pre&gt;&lt;h5&gt;Answer: O(?)&lt;/h5&gt; &lt;h5&gt;8. Nested with logarithm&lt;/h5&gt; &lt;pre&gt;&lt;code&gt;def
        example(n): for i in range(n): j = 1 while j &amp;lt; n: print(i, j) j *=2 &lt;/code&gt;&lt;/pre&gt;&lt;h5&gt;Answer: O(?) &lt;/h5&gt;&lt;h5&gt;9. Triangular loop
    &lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): for i in range(n): for j in range(i): print(i, j) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;10. Three nested loops
    &lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): for i in range(n): for j in range(n): for k in range(n): print(i, j, k) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;
        11. List search&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def contains(arr, target): for x in arr: if x == target: return True return False What is
    the worst-case complexity? &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;12. Dictionary lookup&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def find_user(users, name): return
    users[name] Assume users is a Python dictionary. &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;13. Sorting + loop&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(arr):
    arr.sort() for x in arr: print(x) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;14. Nested list membership&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(arr, values):
    for x in arr: if x in values: print(x) Assume values is a list. &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;15. Nested dictionary
        membership&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(arr, values): for x in arr: if x in values: print(x) This time, assume values is a
    set. &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;16. Recursive — one branch&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): if n &amp;lt;= 1: return example(n - 1) Your
        &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;17. Recursive — two branches&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): if n &amp;lt;= 1: return example(n - 1) example(n -
            1) &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;18. Sneaky one&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): i = 1 while i &amp;lt; n: for j in range(n): print(i,
                j) i *=2 &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;19. Very sneaky&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(n): i = 1 while i &amp;lt; n: j=1 while j &amp;lt; n:
                    print(i, j) j *=2 i *=2 &lt;/code&gt;&lt;/pre&gt;Answer: O(?) &lt;h5&gt;20. Interview challenge&lt;/h5&gt;&lt;pre&gt;&lt;code&gt; def example(arr): n =
                    len(arr) for i in range(n): j = i while j &amp;lt; n: print(arr[i], arr[j]) j +=1 &lt;/code&gt;&lt;/pre&gt;Answer: O(?)

 &lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt; 
  &lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;#&lt;/th&gt;
            &lt;th&gt;Python code / question&lt;/th&gt;
            &lt;th&gt;Answer&lt;/th&gt;
            &lt;th&gt;Why?&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;for i in range(n):&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;Loop runs n times&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;2&lt;/td&gt;
            &lt;td&gt;print(arr[0])&amp;lt;br&amp;gt;print(arr[-1])&lt;/td&gt;
            &lt;td&gt;O(1)&lt;/td&gt;
            &lt;td&gt;Fixed number of operations&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;3&lt;/td&gt;
            &lt;td&gt;Two separate for loops of n&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;n + n = 2n → O(n)&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;4&lt;/td&gt;
            &lt;td&gt;for i in range(n)&amp;lt;br&amp;gt;inside for j in range(n)&lt;/td&gt;
            &lt;td&gt;O(n²)&lt;/td&gt;
            &lt;td&gt;n × n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;5&lt;/td&gt;
            &lt;td&gt;for i in range(n)&amp;lt;br&amp;gt;inside for j in range(10)&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;n × 10 = 10n → O(n)&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;6&lt;/td&gt;
            &lt;td&gt;i = 1 → i *= 2&lt;/td&gt;
            &lt;td&gt;O(log n)&lt;/td&gt;
            &lt;td&gt;Value doubles each time&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;7&lt;/td&gt;
            &lt;td&gt;n //= 2 repeatedly&lt;/td&gt;
            &lt;td&gt;O(log n)&lt;/td&gt;
            &lt;td&gt;Problem size halves each time&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;8&lt;/td&gt;
            &lt;td&gt;n loop + inner loop doubling j&lt;/td&gt;
            &lt;td&gt;O(n log n)&lt;/td&gt;
            &lt;td&gt;n × log n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;9&lt;/td&gt;
            &lt;td&gt;Inner loop runs i times&lt;/td&gt;
            &lt;td&gt;O(n²)&lt;/td&gt;
            &lt;td&gt;0 + 1 + ... + n ≈ n²/2&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;10&lt;/td&gt;
            &lt;td&gt;Three nested n loops&lt;/td&gt;
            &lt;td&gt;O(n³)&lt;/td&gt;
            &lt;td&gt;n × n × n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;11&lt;/td&gt;
            &lt;td&gt;Search through a list&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;May examine every element&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;12&lt;/td&gt;
            &lt;td&gt;users[name] using dictionary&lt;/td&gt;
            &lt;td&gt;O(1) average&lt;/td&gt;
            &lt;td&gt;Hash-table lookup&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;13&lt;/td&gt;
            &lt;td&gt;arr.sort() + loop&lt;/td&gt;
            &lt;td&gt;O(n log n)&lt;/td&gt;
            &lt;td&gt;Sorting dominates O(n) loop&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;14&lt;/td&gt;
            &lt;td&gt;Loop + x in values where values is a list&lt;/td&gt;
            &lt;td&gt;O(n²)&lt;/td&gt;
            &lt;td&gt;n searches × O(n) search&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;15&lt;/td&gt;
            &lt;td&gt;Loop + x in values where values is a set&lt;/td&gt;
            &lt;td&gt;O(n) average&lt;/td&gt;
            &lt;td&gt;n × O(1) set lookup&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;16&lt;/td&gt;
            &lt;td&gt;example(n - 1) once&lt;/td&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;One recursive call per level&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;17&lt;/td&gt;
            &lt;td&gt;Two example(n - 1) calls&lt;/td&gt;
            &lt;td&gt;O(2ⁿ)&lt;/td&gt;
            &lt;td&gt;Two branches at every level&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;18&lt;/td&gt;
            &lt;td&gt;n work inside log n loop&lt;/td&gt;
            &lt;td&gt;O(n log n)&lt;/td&gt;
            &lt;td&gt;n × log n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;19&lt;/td&gt;
            &lt;td&gt;log n loop inside log n loop&lt;/td&gt;
            &lt;td&gt;O(log² n)&lt;/td&gt;
            &lt;td&gt;log n × log n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;20&lt;/td&gt;
            &lt;td&gt;Inner loop starts at i&lt;/td&gt;
            &lt;td&gt;O(n²)&lt;/td&gt;
            &lt;td&gt;Approximately n²/2 operations&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;&lt;/div&gt;
  &lt;h2&gt; Python Big-O Interview Questions&lt;/h2&gt;
  &lt;p&gt;Find 20 interview-style straightforward questions in tabular format below.&lt;/p&gt;
  &lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;#&lt;/th&gt;
            &lt;th&gt;Interview Question&lt;/th&gt;
            &lt;th&gt;What to Identify&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;What is the time complexity of accessing arr[i] in a Python list?&lt;/td&gt;
            &lt;td&gt;Time complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;2&lt;/td&gt;
            &lt;td&gt;What is the time complexity of x in my_list?&lt;/td&gt;
            &lt;td&gt;Average/worst case&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;3&lt;/td&gt;
            &lt;td&gt;What is the time complexity of x in my_set?&lt;/td&gt;
            &lt;td&gt;Average case&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;4&lt;/td&gt;
            &lt;td&gt;What is the complexity of dict[key]?&lt;/td&gt;
            &lt;td&gt;Average case&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;5&lt;/td&gt;
            &lt;td&gt;What is the complexity of arr.append(x)?&lt;/td&gt;
            &lt;td&gt;Amortized complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;6&lt;/td&gt;
            &lt;td&gt;What is the complexity of arr.insert(0, x)?&lt;/td&gt;
            &lt;td&gt;Time complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;7&lt;/td&gt;
            &lt;td&gt;What is the complexity of arr.pop()?&lt;/td&gt;
            &lt;td&gt;Time complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;8&lt;/td&gt;
            &lt;td&gt;What is the complexity of arr.pop(0)?&lt;/td&gt;
            &lt;td&gt;Time complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;9&lt;/td&gt;
            &lt;td&gt;What is the complexity of arr.sort()?&lt;/td&gt;
            &lt;td&gt;Time complexity&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;10&lt;/td&gt;
            &lt;td&gt;What is the complexity of this code?&lt;/td&gt;
            &lt;td&gt;Nested loops&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;11&lt;/td&gt;
            &lt;td&gt;What is the complexity of this code?&lt;/td&gt;
            &lt;td&gt;Logarithmic loop&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;12&lt;/td&gt;
            &lt;td&gt;What is the complexity of this code?&lt;/td&gt;
            &lt;td&gt;n × log n&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;13&lt;/td&gt;
            &lt;td&gt;What is the complexity of this code?&lt;/td&gt;
            &lt;td&gt;Triangular loop&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;14&lt;/td&gt;
            &lt;td&gt;What is the complexity of this recursive function?&lt;/td&gt;
            &lt;td&gt;Recursion&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;15&lt;/td&gt;
            &lt;td&gt;What is the complexity of this recursive function?&lt;/td&gt;
            &lt;td&gt;Recursion tree&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;16&lt;/td&gt;
            &lt;td&gt;Can O(n²) ever be faster than O(n)?&lt;/td&gt;
            &lt;td&gt;Big-O interpretation&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;17&lt;/td&gt;
            &lt;td&gt;What is the difference between O(n) and O(2n)?&lt;/td&gt;
            &lt;td&gt;Simplification&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;18&lt;/td&gt;
            &lt;td&gt;What is the difference between average and worst-case complexity?&lt;/td&gt;
            &lt;td&gt;Complexity concepts&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;19&lt;/td&gt;
            &lt;td&gt;What is space complexity?&lt;/td&gt;
            &lt;td&gt;Memory usage&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;20&lt;/td&gt;
            &lt;td&gt;Given two solutions, which has better asymptotic complexity?&lt;/td&gt;
            &lt;td&gt;Comparison&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://i.pinimg.com/736x/73/7a/74/737a7429a1fdf2d2ac87ec320f8876b1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;720&quot; height=&quot;1080&quot; src=&quot;https://i.pinimg.com/736x/73/7a/74/737a7429a1fdf2d2ac87ec320f8876b1.jpg&quot; width=&quot;720&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4724214497568741219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/big-o-examples-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4724214497568741219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4724214497568741219'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/big-o-examples-in-python.html' title='Big O Examples in Python'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-6754679386950379119</id><published>2026-09-25T00:04:41.040+05:30</published><updated>2026-09-25T00:04:41.040+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="BigO"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><title type='text'>Big O Examples in C++</title><content type='html'>Big O notation describes how an algorithm’s running time or space usage grows as
the input size 𝑛 n increases.&amp;nbsp;&lt;div&gt;In C++, you can see common Big O classes like 𝑂(1), 𝑂(log 𝑛), 𝑂(𝑛), 𝑂(𝑛 log 𝑛), and 𝑂(𝑛&lt;sup&gt;2&lt;/sup&gt;) in simple code patterns and STL operations.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://media.licdn.com/dms/image/v2/D4E10AQFyi5d458qZxQ/image-shrink_800/image-shrink_800/0/1734626710419?e=2147483647&amp;amp;v=beta&amp;amp;t=TYxuYmnC6Z4Nyq1dKAm_4qhqyXl_crkJ3J7bqTlx7ZI&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1040&quot; data-original-width=&quot;800&quot; height=&quot;1040&quot; src=&quot;https://media.licdn.com/dms/image/v2/D4E10AQFyi5d458qZxQ/image-shrink_800/image-shrink_800/0/1734626710419?e=2147483647&amp;amp;v=beta&amp;amp;t=TYxuYmnC6Z4Nyq1dKAm_4qhqyXl_crkJ3J7bqTlx7ZI&quot; width=&quot;800&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;Common Big O classes with C++ examples&lt;/h2&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;𝑂(1) – Constant time&lt;/h4&gt;
&lt;div&gt;&lt;b&gt;The runtime does not depend on input size.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
  &lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;
// Accessing an array element by index
int arr[1000];
int x = arr[5];  // O(1)

// Simple arithmetic / assignment
int y = a + b;           // O(1)
bool equal = (a == b);   // O(1)

// Push/back on vector (amortized)
std::vector&amp;lt;int&amp;gt; v;
v.push_back(10);  // amortized O(1)&lt;/code&gt;&lt;/pre&gt;
Typical 𝑂(1) patterns: single statements, no loops depending on 𝑛, direct index access, basic arithmetic.
&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;𝑂(𝑛) – Linear time&amp;nbsp;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
  Runtime grows proportionally with 𝑛 usually a single loop over all
  elements.&amp;nbsp;
&lt;/h4&gt;
  &lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;// Sum of first n integers (loop version)
int sumOfNumbers(int n) {
    int sum = 0;
    for (int i = 1; i &amp;lt;= n; ++i) {  // runs n times
        sum += i;                    // O(1) work each time
    }
    return sum;                      // overall O(n)
}

// Linear search in an array
int linearSearch(const int arr[], int n, int target) {
    for (int i = 0; i &amp;lt; n; ++i) {   // up to n iterations
        if (arr[i] == target)
            return i;
    }
    return -1;                       // O(n)
}

// Traversing a vector
std::vector&amp;lt;int&amp;gt; v = {1,2,3,4,5};
for (int x : v) {                   // n elements
    std::cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &quot; &quot;;          // O(1) per element
}                               // total O(n)&lt;/code&gt;&lt;/pre&gt;
  &lt;p style=&quot;text-align: left;&quot;&gt;
    Patterns: one loop from 0 to 𝑛−1, iterating over a container once.&amp;nbsp;
  &lt;/p&gt;

&lt;h4 style=&quot;text-align: left;&quot;&gt;𝑂(log 𝑛) – Logarithmic time&amp;nbsp;&lt;/h4&gt;
&lt;p style=&quot;text-align: left;&quot;&gt;
  &lt;b&gt;Runtime grows with the number of times you can halve the problem; classic
    example is binary search.&amp;nbsp;&lt;/b&gt;
&lt;/p&gt;

&lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;// Binary search on a sorted array (iterative)
int binarySearch(const int arr[], int n, int target) {
    int left = 0, right = n - 1;
    while (left &amp;lt;= right) {                 // each step halves the range
        int mid = left + (right - left) / 2;
        if (arr[mid] == target) return mid;
        if (arr[mid] &amp;lt; target) left = mid + 1;
        else right = mid - 1;
    }
    return -1;                              // O(log n)
}&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;text-align: left;&quot;&gt;
  &lt;b&gt;Also common in C++ STL:&lt;/b&gt;
  &lt;code&gt;std::lower_bound, std::upper_bound, std::binary_search&lt;/code&gt; on sorted
  ranges are 𝑂(log 𝑛).
&lt;/p&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
  𝑂 ( 𝑛 log ⁡ 𝑛 )&amp;nbsp; – Linearithmic time&amp;nbsp;
&lt;/h4&gt;
&lt;p style=&quot;text-align: left;&quot;&gt;
  Typical for &lt;a href=&quot;https://www.openglprojects.in/2012/04/dynamic-sorting-algorithm-visualizer.html&quot; target=&quot;_blank&quot;&gt;efficient sorting&lt;/a&gt; and some divide-and-conquer algorithms.&amp;nbsp;
&lt;/p&gt;
&lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;#include 
#include 

std::vector v = {5, 2, 9, 1, 5, 6};
std::sort(v.begin(), v.end());  // introsort: average O(n log n)&lt;/code&gt;&lt;/pre&gt;
Most comparison-based sorts in C++ (std::sort, std::stable_sort) are 𝑂 ( 𝑛 log 𝑛
) on average. 𝑂 ( 𝑛 2 )  – Quadratic time Usually nested loops
where both depend on 𝑛 n; common in naive sorting algorithms.

&lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;
// Bubble sort (worst/average case)
void bubbleSort(int arr[], int n) {
    for (int i = 0; i &amp;lt; n - 1; ++i) {          // ~n times
        for (int j = 0; j &amp;lt; n - i - 1; ++j) {  // ~n times
            if (arr[j] &amp;gt; arr[j + 1]) {
                std::swap(arr[j], arr[j + 1]); // O(1)
            }
        }
    }                                          // total O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;br /&gt;}

// Simple double loop example
for (int i = 0; i &amp;lt; n; ++i) {        // n
    for (int j = 0; j &amp;lt; n; ++j) {    // n
        std::cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; j;  // O(1)
    }                                // n * n = O(n&lt;sup&gt;2&lt;/sup&gt;)
}&lt;/code&gt;&lt;/pre&gt;
Also: worst-case of insertion sort and selection sort are
𝑂(𝑛&lt;sup&gt;2&lt;/sup&gt;).&amp;nbsp;
&lt;h4 style=&quot;text-align: left;&quot;&gt;𝑂(2&lt;sup&gt;𝑛&lt;/sup&gt;)– Exponential time&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
  Common in naive recursive solutions like Fibonacci without memoization.

  &lt;pre data-comment=&quot;cpp&quot;&gt;&lt;code&gt;
// Naive recursive Fibonacci
int fib(int n) {
    if (n &amp;lt;= 1) return n;          // base case O(1)
    return fib(n - 1) + fib(n - 2); // each call branches into 2
}                                  // roughly O(2&lt;sup&gt;n&lt;/sup&gt;)&lt;/code&gt;&lt;/pre&gt;
  Each increment of 𝑛 roughly doubles the number of calls.

  &lt;h2&gt;Big O of common C++ STL operations&lt;/h2&gt;
  These are useful “real-world” examples when analyzing C++ code:&amp;nbsp;
&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::vector:&amp;nbsp;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;operator[], at(): 𝑂 ( 1 )&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;push_back: amortized 𝑂 ( 1 )&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;insert/erase in the middle: 𝑂 ( 𝑛 )&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::vector:&amp;nbsp;&lt;/code&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::array:&amp;nbsp;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;&amp;nbsp;Index access: 𝑂 ( 1 )&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::list&lt;/code&gt; (doubly linked list):&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;&amp;nbsp;Insert/erase at known iterator: 𝑂 ( 1 )&lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Traversal to find an element: 𝑂 ( 𝑛 )&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::unordered_set,&lt;/code&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::unordered_map:&amp;nbsp;&lt;/code&gt; &lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;Average insert/lookup/erase: 𝑂 ( 1 )&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;Worst case (bad hash): 𝑂 ( 𝑛 )&amp;nbsp;&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::set&lt;/code&gt;, &lt;code data-highlighted=&quot;yes&quot;&gt;std::map&lt;/code&gt; (balanced BST):&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;Insert/lookup/erase: 𝑂 ( log ⁡ 𝑛 )&amp;nbsp;&amp;nbsp;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code data-highlighted=&quot;yes&quot;&gt;std::sort&lt;/code&gt;, &lt;code data-highlighted=&quot;yes&quot;&gt;std::stable_sort:&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;Average: 𝑂 ( 𝑛 log ⁡ 𝑛 )&amp;nbsp;&lt;/li&gt;
    &lt;li&gt;
      Worst case for &lt;code data-highlighted=&quot;yes&quot; data-result-language=&quot;css&quot;&gt;&amp;lt;&lt;span class=&quot;hl-selector-tag&quot;&gt;std::sort: &lt;/span&gt;&amp;gt;&lt;/code&gt;typically 𝑂 ( 𝑛 log ⁡ 𝑛 )  with
      introsort&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
&lt;h2&gt;Practical Big O Examples in C++&lt;/h2&gt;
  Presenting Few Simple Examples in C++ for &lt;a href=&quot;https://www.openglprojects.in/2026/09/computer-sciencebig-o-notation-practice-problems.html&quot;&gt;Big O Notation&lt;/a&gt;&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
     
&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Complexity&lt;/th&gt;
            &lt;th&gt;Example&lt;/th&gt;
            &lt;th&gt;Evaluation&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;th&gt;O(1)&lt;/th&gt;
            &lt;td&gt;Addition of a + b&lt;/td&gt;
            &lt;td&gt;A fixed number of operations regardless of input size&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(n)&lt;/th&gt;
            &lt;td&gt;Loop from 0 to n-1&lt;/td&gt;
            &lt;td&gt;Loop executes n times&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(log n)&lt;/th&gt;
            &lt;td&gt;Binary search&lt;/td&gt;
            &lt;td&gt;Search space is roughly halved each iteration&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(n²)&lt;/th&gt;
            &lt;td&gt;Two nested loops&lt;/td&gt;
            &lt;td&gt;n × n = n² iterations&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(n³)&lt;/th&gt;
            &lt;td&gt;Three nested loops&lt;/td&gt;
            &lt;td&gt;n × n × n = n³ iterations&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(2ⁿ)&lt;/th&gt;
            &lt;td&gt;Naive recursive Fibonacci&lt;/td&gt;
            &lt;td&gt;More precisely, its running time is O(φⁿ), often simplified to O(2ⁿ)&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;th&gt;O(n!)&lt;/th&gt;
            &lt;td&gt;Recursive factorial&lt;/td&gt;
            &lt;td&gt;The recursive factorial is O(n), not O(n!)&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Evaluation&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp;1. O(1) — Constant&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt;cin &amp;gt;&amp;gt; a &amp;gt;&amp;gt; b;&amp;nbsp; &lt;br /&gt;cout &amp;lt;&amp;lt; a + b;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;&lt;div&gt;There is a fixed amount of work, so:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp;Time = O(1)&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Even if the values of &lt;b&gt;a&lt;/b&gt; and &lt;b&gt;b &lt;/b&gt;are very large, the number of program steps doesn&#39;t depend on n.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2. O(n) — Linear&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt; for (int i = 0; i &amp;lt; n; ++i) {
    cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; &quot;;
}&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
  
  &lt;div&gt;The loop executes n times.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Time = O(n)&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3. O(log n) — Logarithmic&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The binary search is a good example:&amp;nbsp;&lt;/div&gt;
  
  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt;while (left &amp;lt;= right) {&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;int mid = left + (right - left) / 2;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;...&lt;br /&gt;}&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div&gt;Every iteration eliminates approximately half of the remaining elements.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;1000 → 500 → 250 → 125 → ... → 1&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Time = O(log n)&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;One minor issue: your array contains only 7 elements, so technically that particular program has a fixed-size input and could be viewed as O(1). To demonstrate &lt;b&gt;O(log n)&lt;/b&gt; properly, use an array whose size depends on &lt;b&gt;n&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;4. O(n²) — Quadratic&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt;for (int i = 1; i &amp;lt;= n; ++i) {
    for (int j = 1; j &amp;lt;= n; ++j) {
        ...
    }
}&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;The inner loop runs n times for every one of the n outer iterations:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;b&gt;n × n = n²&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;Therefore:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Time = O(n²)&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;5. O(n³) — Cubic&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You have three nested loops:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;for (int i = 1; i &amp;lt;= n; ++i)
    for (int j = 1; j &amp;lt;= n; ++j)
        for (int k = 1; k &amp;lt;= n; ++k)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That&#39;s:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp;n × n × n = n³&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Therefore:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Time = O(n³)&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&lt;b&gt;6. O(2ⁿ) — Exponential&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Fibonacci example - A simple recursive algorithm that makes two recursive calls at each level:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&amp;nbsp;
int fibonacci(int n) {&amp;nbsp;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if (n &amp;lt;= 1) {&amp;nbsp;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;return n;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return fibonacci(n - 1) + fibonacci(n - 2);&amp;nbsp;&lt;/div&gt;&lt;div&gt;} &lt;/div&gt;int main(){&amp;nbsp;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;int n;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;cin &amp;gt;&amp;gt; n;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;cout &amp;lt;&amp;lt; &quot;Fibonacci of &quot; &amp;lt;&amp;lt; n &amp;lt;&amp;lt; &quot; is: &quot;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;lt;&amp;lt; fibonacci(n) &amp;lt;&amp;lt; endl;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;cout &amp;lt;&amp;lt; &quot;This is O(2^n) - Exponential Complexity&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;br /&gt;&lt;div&gt;return 0;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;O(2ⁿ)&lt;/b&gt; Commonly used simplified bound for this basic Big O Examples in C++&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;
  
7. O(n!) — Factorial&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To actually demonstrate O(n!), generate all permutations of n elements:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre data-comment=&quot;.cpp&quot;&gt;&lt;code&gt;#include&amp;nbsp;&amp;lt;iostream&amp;gt;&lt;br /&gt;#include&amp;nbsp;&amp;lt;vector&amp;gt;&lt;div&gt;#include&amp;nbsp;&amp;lt;algorithm&amp;gt;
using namespace std;&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void generatePermutations(vector&amp;lt;int&amp;gt;&amp;amp; arr, int index) { &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if (index == arr.size()) { &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;for (int x : arr) { &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &quot; &quot;; &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;} &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;cout &amp;lt;&amp;lt; endl; &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return; } &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;for (int i = index; i &amp;lt; arr.size(); ++i){ &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;swap(arr[index], arr[i]); &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;generatePermutations(arr, index + 1); &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;swap(arr[index], arr[i]);&lt;/div&gt;&lt;div&gt; } &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;} &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int main() { &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;int n; &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;cin &amp;gt;&amp;gt; n; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;vector arr(n); &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for (int i = 0; i &amp;lt; n; ++i) { &lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;arr[i] = i + 1;&lt;/div&gt;&lt;div&gt; } &lt;/div&gt;&lt;div&gt;generatePermutations(arr, 0); &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;cout &amp;lt;&amp;lt; &quot;This is O(n!) - Factorial Complexity&quot;; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;return 0; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For &lt;b&gt;n&lt;/b&gt; elements, there are:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;n! = n × (n-1) × (n-2) × ... × 1&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;permutations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the algorithm has &lt;b&gt;O(n!)&lt;/b&gt; time complexity (ignoring the additional &lt;b&gt;O(n)&lt;/b&gt; work needed to print each permutation).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.bigocalc.com/&quot; target=&quot;_blank&quot;&gt;Calculate Big O time and space complexity&lt;/a&gt; with your own code.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/6754679386950379119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/big-o-examples-in-c-plus-plus.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6754679386950379119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6754679386950379119'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/big-o-examples-in-c-plus-plus.html' title='Big O Examples in C++'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5235767697646136946</id><published>2026-09-20T02:02:21.289+05:30</published><updated>2026-09-20T02:02:21.289+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="BigO"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><title type='text'>Big O Cheat Sheet - Decoding Time and Space Complexity</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpcS_J9cuiD5ZdVjexyCRUfk0Imc1NhV5pPimovOkqmju-Y96qr4xQOXtLJkssjHcc-0YMxot0iEHxG9qnH4Tsg4sGOYQlJDnnDMtiyQNSVgnAucMxdWKdB3BpOD1krRCBH0i-ZEVTBiHe2Yidq2jcwEHMQswkgtUvShXeiyEPvHU4iA6YCeH50-Bk0bUA/s1536/Big-O-Cheat-Sheet-Decoding-Time-and-Space-Complexity.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;1536&quot; height=&quot;427&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpcS_J9cuiD5ZdVjexyCRUfk0Imc1NhV5pPimovOkqmju-Y96qr4xQOXtLJkssjHcc-0YMxot0iEHxG9qnH4Tsg4sGOYQlJDnnDMtiyQNSVgnAucMxdWKdB3BpOD1krRCBH0i-ZEVTBiHe2Yidq2jcwEHMQswkgtUvShXeiyEPvHU4iA6YCeH50-Bk0bUA/w640-h427/Big-O-Cheat-Sheet-Decoding-Time-and-Space-Complexity.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;An algorithm is a step-by-step set of instructions designed to solve a specific problem or complete a task. There are multiple ways or multiples set of instructions to solve any problem or task. We may use different method to get the same solution, say different paths to reach same destination.&lt;/p&gt;

&lt;p&gt;Imagine you&#39;re a programmer faced with solving a problem. There are often many ways to approach it, each with its own method or algorithm. But how do you know which solution is best? This is where evaluating algorithms comes into play.&lt;/p&gt;

&lt;p&gt;Performance and efficiency are key factors when choosing an algorithm. Performance refers to how quickly your algorithm runs—its execution time. Efficiency, on the other hand, involves how much memory or resources your algorithm consumes. Both aspects are crucial because they affect how well your application runs in the real world.&lt;/p&gt;

&lt;p&gt;For programmers, understanding these factors isn’t just about making software work; it’s about making it work well. This is where Big O, which we also call as Big O notation come to picture. &lt;/p&gt;

&lt;p&gt;Understanding algorithm efficiency is essential for writing software that remains fast, reliable, and scalable. Big O notation provides a standard way to describe how an algorithm’s performance changes as the size of its input increases.&lt;/p&gt;

&lt;p&gt;We have explained &lt;a href=&quot;Big O cheat sheet&quot;&gt;Big O Notations with Practice Problems&lt;/a&gt; in our previous post, here were are going to go for Big O cheat sheet which explains the most common time and space complexities, shows practical examples, and provides guidance for choosing efficient algorithms and data structures.&lt;/p&gt;


&lt;!--[ Alert default ]--&gt;
&lt;div class=&quot;alert outline&quot;&gt;&lt;b&gt;What Is Big O Notation?&lt;/b&gt;
  
Big O notation describes the upper bound of an algorithm’s growth rate. In simple terms, it answers this question:&lt;br /&gt;

How does the amount of work or memory required by an algorithm change as the input size increases?&lt;br /&gt;

The input size is commonly represented by 
𝑛
n. Big O focuses on the dominant factor and ignores constants and lower-order terms.&lt;br /&gt;
&lt;/div&gt;



For example:&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;𝑂
(
2
𝑛
+
10
)
=
𝑂
(
𝑛
)
O(2n+10)=O(n)&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As 
𝑛
n becomes large, the 
2
𝑛
2n term matters more than the constant 
10
10, so the algorithm is classified as linear.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Big O can describe:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;b&gt;Time complexity: &lt;/b&gt;How long an algorithm takes to run.&amp;nbsp;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;b&gt;Space complexity:&lt;/b&gt; How much additional memory an algorithm requires.&amp;nbsp;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;b&gt;Scalability:&lt;/b&gt; How performance changes with larger inputs.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;


&lt;!--[ Table ]--&gt;&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Complexity&lt;/th&gt;
        &lt;th&gt;Name&lt;/th&gt;
        &lt;th&gt;Example&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
       &lt;tr&gt;&lt;td&gt;O(1)                  &lt;/td&gt;&lt;td&gt;Constant  &lt;/td&gt;&lt;td&gt;    Accessing an array element by index &lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td&gt;O(log ⁡n)     &lt;/td&gt;&lt;td&gt;Logarithmic   &lt;/td&gt;&lt;td&gt;Binary search          &lt;/td&gt;   &lt;/tr&gt;          
 &lt;tr&gt;&lt;td&gt;O(n)                 &lt;/td&gt;&lt;td&gt;Linear      &lt;/td&gt;&lt;td&gt; Scanning an array   &lt;/td&gt;  &lt;/tr&gt;              
 &lt;tr&gt;&lt;td&gt;O(n log⁡ n)  &lt;/td&gt;&lt;td&gt;Linearithmic  &lt;/td&gt;&lt;td&gt;Efficient comparison-based sorting &lt;/td&gt; &lt;/tr&gt;
 &lt;tr&gt;&lt;td&gt;O(n&lt;sup&gt;2&lt;/sup&gt;)            &lt;/td&gt;&lt;td&gt;Quadratic     &lt;/td&gt;&lt;td&gt;Comparing every pair of elements&lt;/td&gt;   &lt;/tr&gt; 
 &lt;tr&gt;&lt;td&gt;O(n&lt;sup&gt;3&lt;/sup&gt;)          &lt;/td&gt;&lt;td&gt;Cubic         &lt;/td&gt;&lt;td&gt;Some matrix algorithms   &lt;/td&gt;  &lt;/tr&gt;         
&lt;tr&gt; &lt;td&gt;O(2&lt;sup&gt;n&lt;/sup&gt;)           &lt;/td&gt;&lt;td&gt;Exponential   &lt;/td&gt;&lt;td&gt;Brute-force subset generation  &lt;/td&gt;    &lt;/tr&gt; 
 &lt;tr&gt;&lt;td&gt;O(n!)             &lt;/td&gt;&lt;td&gt;Factorial    &lt;/td&gt;&lt;td&gt; Brute-force permutation generation &lt;/td&gt; &lt;/tr&gt;

    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Big O for Common Data Structures
&lt;/h2&gt;&lt;p&gt;The following table shows typical time complexities for frequently used data structures. Values can vary depending on the implementation and operation.&lt;/p&gt;&lt;/div&gt;
&lt;!--[ Table ]--&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Data structure &lt;/th&gt;
        &lt;th&gt;Access &lt;/th&gt;
        &lt;th&gt;Search&lt;/th&gt;
        &lt;th&gt;Insertion&lt;/th&gt;
        &lt;th&gt;Deletion&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;&lt;td&gt;Array                &lt;/td&gt;&lt;td&gt; O(1)                     &lt;/td&gt;&lt;td&gt; O(n)                   &lt;/td&gt;&lt;td&gt;O(n)                    &lt;/td&gt;&lt;td&gt; O(n)&lt;/td&gt; &lt;/tr&gt;                  
 &lt;tr&gt;&lt;td&gt;Dynamic array        &lt;/td&gt;&lt;td&gt; O(1)                    &lt;/td&gt;&lt;td&gt; O(n)                  &lt;/td&gt;&lt;td&gt; O(1) amortized at end    &lt;/td&gt;&lt;td&gt; O(n)  &lt;/td&gt; &lt;/tr&gt;                  
 &lt;tr&gt;&lt;td&gt;Linked list         &lt;/td&gt;&lt;td&gt; O(n)                     &lt;/td&gt;&lt;td&gt;O(n)                     &lt;/td&gt;&lt;td&gt; O(1) with a known node  &lt;/td&gt;&lt;td&gt; O(1) with a known node &lt;/td&gt; &lt;/tr&gt;  
&lt;tr&gt;&lt;td&gt;Hash table          &lt;/td&gt;&lt;td&gt; Not typically indexed            &lt;/td&gt;&lt;td&gt; O(1) average           &lt;/td&gt;&lt;td&gt; O(1) average             &lt;/td&gt;&lt;td&gt;O(1) average   &lt;/td&gt; &lt;/tr&gt;         
 &lt;tr&gt;&lt;td&gt;Binary search tree   &lt;/td&gt;&lt;td&gt;O(log ⁡n) average &lt;/td&gt;&lt;td&gt; O(log ⁡n) average &lt;/td&gt;&lt;td&gt; O(log⁡ n) average &lt;/td&gt;&lt;td&gt; O(log⁡n)O average &lt;/td&gt; &lt;/tr&gt;
 &lt;tr&gt;&lt;td&gt;Balanced search tree &lt;/td&gt;&lt;td&gt; O(log⁡ n)      &lt;/td&gt;&lt;td&gt;O(log⁡ n)       &lt;/td&gt;&lt;td&gt; O(log ⁡n)        &lt;/td&gt;&lt;td&gt; O(log ⁡n)  &lt;/td&gt; &lt;/tr&gt;    
 &lt;tr&gt;&lt;td&gt;Heap                 &lt;/td&gt;&lt;td&gt; Not generally supported         &lt;/td&gt;&lt;td&gt; O(n)                  &lt;/td&gt;&lt;td&gt; O(log ⁡n)      &lt;/td&gt;&lt;td&gt; O(log⁡ n)    &lt;/td&gt; &lt;/tr&gt;    


    &lt;/tbody&gt;
  &lt;/table&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;





Big O Quick Reference&lt;/h2&gt;&lt;div&gt;&amp;nbsp;
&lt;!--[ Table ]--&gt;&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Complexity   &lt;/th&gt;
        &lt;th&gt;Practical interpretation &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
     &lt;tr&gt;&lt;td&gt;O(1)                 &lt;/td&gt;&lt;td&gt; Excellent; unaffected by input size              &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;O(log⁡ n)   &lt;/td&gt;&lt;td&gt; Very efficient; scales well                     &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; O(n)                 &lt;/td&gt;&lt;td&gt; Efficient for most ordinary workloads            &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; O(n log⁡ n) &lt;/td&gt;&lt;td&gt; Efficient for large-scale sorting and processing &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;O(n &lt;sup&gt;2&lt;/sup&gt;)             &lt;/td&gt;&lt;td&gt; Often acceptable for small inputs                &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; O(n&lt;sup&gt;3&lt;/sup&gt;)          &lt;/td&gt;&lt;td&gt; Usually limited to small datasets               &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;O(2&lt;sup&gt;n&lt;/sup&gt;)            &lt;/td&gt;&lt;td&gt; Becomes impractical quickly                     &lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; O(n!)           &lt;/td&gt;&lt;td&gt; Practical only for very small inputs             &lt;/td&gt; &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;The Big O Hierarchy (Best to Worst)&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Complexity&lt;/th&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Practical Metaphor&lt;/th&gt;
            &lt;th&gt;Common Culprit / Example&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;O(1)&lt;/td&gt;
            &lt;td&gt;Constant&lt;/td&gt;
            &lt;td&gt;Grabbing a specific TV remote&lt;/td&gt;
            &lt;td&gt;Hash map lookup, array index access&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(log n)&lt;/td&gt;
            &lt;td&gt;Logarithmic&lt;/td&gt;
            &lt;td&gt;Binary search in a phone book&lt;/td&gt;
            &lt;td&gt;Halving search space (balanced BSTs)&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(n)&lt;/td&gt;
            &lt;td&gt;Linear&lt;/td&gt;
            &lt;td&gt;Scanning a single-file line of people&lt;/td&gt;
            &lt;td&gt;Single loop over an unsorted array&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(n log n)&lt;/td&gt;
            &lt;td&gt;Linearithmic&lt;/td&gt;
            &lt;td&gt;Sorting a deck via merge-sort/quicksort&lt;/td&gt;
            &lt;td&gt;Efficient comparison-based sorts&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(n &lt;sup&gt;2&lt;/sup&gt;)&lt;/td&gt;
            &lt;td&gt;Quadratic&lt;/td&gt;
            &lt;td&gt;Comparing every photo with every other photo&lt;/td&gt;
            &lt;td&gt;Nested loops over the same dataset&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(2&lt;sup&gt;n&lt;/sup&gt;)&lt;/td&gt;
            &lt;td&gt;Exponential&lt;/td&gt;
            &lt;td&gt;Branching puzzle decisions (include/exclude)&lt;/td&gt;
            &lt;td&gt;Naive recursive Fibonacci, subset generation&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;O(n!)&lt;/td&gt;
            &lt;td&gt;Factorial&lt;/td&gt;
            &lt;td&gt;Generating all travel route permutations&lt;/td&gt;
            &lt;td&gt;Traveling Salesperson brute force&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5235767697646136946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/blog-post_20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5235767697646136946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5235767697646136946'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/blog-post_20.html' title='Big O Cheat Sheet - Decoding Time and Space Complexity'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpcS_J9cuiD5ZdVjexyCRUfk0Imc1NhV5pPimovOkqmju-Y96qr4xQOXtLJkssjHcc-0YMxot0iEHxG9qnH4Tsg4sGOYQlJDnnDMtiyQNSVgnAucMxdWKdB3BpOD1krRCBH0i-ZEVTBiHe2Yidq2jcwEHMQswkgtUvShXeiyEPvHU4iA6YCeH50-Bk0bUA/s72-w640-h427-c/Big-O-Cheat-Sheet-Decoding-Time-and-Space-Complexity.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-58992538830553768</id><published>2026-09-18T23:37:07.070+05:30</published><updated>2026-09-18T23:37:07.070+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Time Complexity"/><title type='text'>Amortized Time Complexity: Definition and Examples</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Amortized time complexity&lt;/b&gt; measures the average cost per operation over a sequence of operations on a data structure, even when some individual operations are expensive. Unlike worst-case analysis (which looks at a single operation in isolation) or average-case analysis (which relies on probability), amortized analysis guarantees that any sequence of n operations will take at most a certain total time, regardless of the order or pattern of operations.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLEjvXyw1C_FwHj1UP2YnmfvhKyQ6KsV_Q0olMG-M70qqR6iLZTFldyrjTQ-uzE2dqXmjoxbYYN8-WgpZMieTOJ25f5V13lHL_W2hKUNDkSbAUjVPTDINX2QRQ3X_wC5zW9U-YflD0jbQjR70pKNEiZ3aEfvENtu5UdUVuDWTARMorW2RpNurmu4a3_e5i/s1024/Amortized%20Time%20Complexity%20Definition%20and%20Examples.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;559&quot; data-original-width=&quot;1024&quot; height=&quot;350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLEjvXyw1C_FwHj1UP2YnmfvhKyQ6KsV_Q0olMG-M70qqR6iLZTFldyrjTQ-uzE2dqXmjoxbYYN8-WgpZMieTOJ25f5V13lHL_W2hKUNDkSbAUjVPTDINX2QRQ3X_wC5zW9U-YflD0jbQjR70pKNEiZ3aEfvENtu5UdUVuDWTARMorW2RpNurmu4a3_e5i/w640-h350/Amortized%20Time%20Complexity%20Definition%20and%20Examples.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2&gt;Key Idea&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Some operations are cheap most of the time but occasionally trigger an expensive &quot;cleanup&quot; or &quot;resize&quot; step. Amortized analysis spreads the cost of these rare expensive operations across the many cheap ones that precede them, showing that the average cost per operation remains low.
Formally, if a sequence of m operations costs at most T(m) total time, the &lt;b&gt;amortized cost per operation&lt;/b&gt; is&lt;code data-highlighted=&quot;yes&quot; data-result-language=&quot;css&quot;&gt;&lt;span class=&quot;hl-selector-tag&quot;&gt;T(m) / m.&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;h2&gt;Three Methods of Amortized Analysis&lt;/h2&gt;
There are three standard techniques for performing amortized analysis:&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Aggregate Method: Compute the total cost of m operations, then divide by m.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Accounting (Banker&#39;s) Method: Assign a &quot;charge&quot; to each operation; cheap operations overpay and store credit to subsidize expensive ones.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Potential Method: Define a potential function Φ that represents stored &quot;energy&quot;; amortized cost = actual cost + change in potential.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h2&gt;Classic Example 1: Dynamic Array (ArrayList, Python list, C++ vector)&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;
The Problem&amp;nbsp;&lt;/h3&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;A dynamic array starts with a small fixed capacity and grows as elements are appended. When the array is full, it must allocate a larger array and copy all existing elements—a costly O(n) operation.&amp;nbsp;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Naive Approach: Increase by 1&amp;nbsp;&lt;/h3&gt;&lt;div&gt;If the array grows by just 1 slot each time it fills up:&lt;/div&gt;&lt;div&gt;•	The i-th insertion costs O(i) to copy i−1 elements.&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Total cost for n insertions: 1 + 2 + 3 + ... + n = O(n²).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	&lt;b&gt;Amortized cost:&lt;/b&gt; O(n²) / n = O(n) per insertion.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is inefficient.&amp;nbsp;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Smart Approach: Doubling Strategy&amp;nbsp;&lt;/h3&gt;&lt;div&gt;Instead, double the capacity whenever the array is full:&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Most insertions cost O(1) (just place the element).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Occasionally, when capacity is reached (at sizes 1, 2, 4, 8, ...), copy all elements to a new array of double size—costing O(n) for that insertion.&amp;nbsp;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Aggregate Analysis&amp;nbsp;&lt;/h3&gt;&lt;div&gt;For n insertions:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	Cost of n simple insertions: n × O(1) = O(n).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Cost of all resizing operations: 1 + 2 + 4 + 8 + ... + 2ᵏ ≤ 2n (geometric series, where 2ᵏ ≤ n).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Total cost: O(n) + O(2n) = O(3n) = O(n).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Amortized cost per insertion: O(n) / n = O(1).&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Even though some insertions are O(n), the average is constant.&amp;nbsp;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Accounting Method Explanation&amp;nbsp;&lt;/h3&gt;&lt;div&gt;Charge each insertion $3:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	$1 pays for the actual insertion.&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	$2 is stored as credit on the newly inserted element.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When resizing from size n to 2n:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	The n/2 most recently added elements each have $2 credit, totaling $n.&lt;/div&gt;&lt;div&gt;•	This credit pays for copying all n elements to the new array.&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	The current insertion still costs $1, so total charge remains $3.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thus, every insertion has an amortized cost of O(1).&amp;nbsp;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Potential Method&amp;nbsp;&lt;/h3&gt;&lt;div&gt;Define potential Φ = 2 × (number of elements) − (capacity).&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	For a normal insertion: actual cost = 1, potential increases by 2 → amortized cost = 1 + 2 = 3.&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	For a resize: actual cost = n, potential drops by n → amortized cost = n − n = 0.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Again, amortized cost per operation is O(1).
&lt;h2&gt;Classic Example 2: Hash Table with Resizing&lt;/h2&gt;
Hash tables provide O(1) average-case lookup, insertion, and deletion. However, when the load factor (elements / buckets) exceeds a threshold, the table must resize and rehash all elements—an O(n) operation.&amp;nbsp;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Amortized Analysis&amp;nbsp;&lt;/h3&gt;&lt;div&gt;Using the doubling strategy (like dynamic arrays):&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	Most insertions cost O(1) (hash and place in bucket).&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Occasional resizing costs O(n) to rehash all elements.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For n insertions:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•	Total hashing operations: n (initial) + 1 + 2 + 4 + ... + 2ᵏ ≤ 3n.&amp;nbsp;&lt;/div&gt;&lt;div&gt;•	Amortized cost per insertion: &lt;code data-highlighted=&quot;yes&quot; data-result-language=&quot;ini&quot;&gt;&lt;span class=&quot;hl-attr&quot;&gt;O(3n) / n &lt;/span&gt;=&lt;span class=&quot;hl-string&quot;&gt;O(1)&lt;/span&gt;&lt;/code&gt;.
&lt;p&gt;This is why hash tables are said to have O(1) amortized time complexity for insertions, even though worst-case individual operations are O(n).&lt;/p&gt;
&lt;h2&gt;Classic Example 3: Queue Using Two Stacks&lt;/h2&gt;
A queue (FIFO) can be implemented with two stacks (LIFO):&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Enqueue:&lt;/b&gt; Push onto stack_in (O(1)).&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Dequeue:&lt;/b&gt; If stack_out is empty, pop all elements from stack_in and push them onto stack_out (O(n)), then pop from stack_out (O(1)).&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Amortized Analysis&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&amp;nbsp;Each element is pushed onto stack_in once, moved to stack_out once, and popped once.&amp;nbsp;&lt;/li&gt;&lt;li&gt;&amp;nbsp;Total cost for n enqueue + n dequeue operations: O(3n) = O(n).&amp;nbsp;&lt;/li&gt;&lt;li&gt;&amp;nbsp;Amortized cost per operation: O(n) / (2n) = O(1).&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Even though a single dequeue can be O(n), the average over many operations is constant.
&lt;h2&gt;Comparison Table&lt;/h2&gt;
&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
&lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;&lt;th&gt;Data Structure	&lt;/th&gt;&lt;th&gt;Operation	&lt;/th&gt;&lt;th&gt;Worst-Case	&lt;/th&gt;&lt;th&gt;Amortized&lt;/th&gt;	&lt;th&gt;Why?&lt;/th&gt;&lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Dynamic Array&lt;/th&gt;	&lt;th&gt;Append&lt;/th&gt;	&lt;th&gt;O(n)&lt;/th&gt;	&lt;th&gt;O(1)&lt;/th&gt;	&lt;th&gt;Doubling spreads resize cost &lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;th&gt;Hash Table	&lt;/th&gt;&lt;th&gt;Insert&lt;/th&gt;	&lt;th&gt;O(n)&lt;/th&gt;	&lt;th&gt;O(1)&lt;/th&gt;	&lt;th&gt;Rehashing is rare with geometric growth &lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;th&gt;Two-Stack Queue	&lt;/th&gt;&lt;th&gt;Dequeue&lt;/th&gt;	&lt;th&gt;O(n)&lt;/th&gt;	&lt;th&gt;O(1)&lt;/th&gt;	&lt;th&gt;Each element moved at most twice&lt;/th&gt;&lt;/tr&gt; 

&lt;tr&gt;&lt;th&gt;Disjoint Set (Union-Find)	&lt;/th&gt;&lt;th&gt;Find/Union&lt;/th&gt;	&lt;th&gt;O(log n)&lt;/th&gt;	&lt;th&gt;O(α(n)) ≈ O(1)&lt;/th&gt;	&lt;th&gt;Path compression + union by rank &lt;/th&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;Important Distinctions&lt;/h2&gt;
Concept	Definition	Applies To
Worst-case	Maximum time for a single operation	Any single operation
Average-case	Expected time over random inputs	Probabilistic analysis
Amortized	Average time over any sequence of operations	Sequence of operations on a data structure 

Crucial: Amortized analysis does not assume random inputs—it guarantees performance for the worst possible sequence of operations.
&lt;h2&gt;When Amortized Analysis Fails&lt;/h2&gt;
&lt;p&gt;Amortized O(1) relies on geometric growth (doubling). If a dynamic array grows by a fixed increment (e.g., +100 slots):&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Resizing occurs O(n) times for n insertions.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Each resize copies O(n) elements on average.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Total cost: O(n²) → Amortized cost: O(n), not O(1).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h2&gt;Takeaway&lt;/h2&gt;
&lt;p&gt;Amortized time complexity reveals that some data structures are far more efficient in practice than their worst-case per-operation analysis suggests. By analyzing sequences of operations rather than isolated steps, we can prove strong guarantees—like O(1) amortized time for dynamic arrays and hash tables—that make these structures indispensable in real-world software.&lt;/p&gt;

&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/58992538830553768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/amortized-time-complexity-definition-and-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/58992538830553768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/58992538830553768'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/amortized-time-complexity-definition-and-examples.html' title='Amortized Time Complexity: Definition and Examples'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLEjvXyw1C_FwHj1UP2YnmfvhKyQ6KsV_Q0olMG-M70qqR6iLZTFldyrjTQ-uzE2dqXmjoxbYYN8-WgpZMieTOJ25f5V13lHL_W2hKUNDkSbAUjVPTDINX2QRQ3X_wC5zW9U-YflD0jbQjR70pKNEiZ3aEfvENtu5UdUVuDWTARMorW2RpNurmu4a3_e5i/s72-w640-h350-c/Amortized%20Time%20Complexity%20Definition%20and%20Examples.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-6975235966236500065</id><published>2026-09-18T01:26:57.817+05:30</published><updated>2026-09-18T01:26:57.817+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures and Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Time Complexity"/><title type='text'>Time Complexity Practice Problems : A Comprehensive Guide</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;Time complexity analysis is a foundational skill for any programmer or computer science student, enabling you to predict how an algorithm&#39;s runtime scales with input size. Mastering this skill requires deliberate practice across a spectrum of problems—from simple loops to intricate recursive patterns.&lt;/p&gt;

&lt;h2&gt;Why Practice Time Complexity?&lt;/h2&gt;&lt;div&gt;&lt;p&gt;Understanding Big O notation theoretically is one thing; applying it fluently to unfamiliar code is another. Practice helps you:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Recognize common patterns instantly (e.g., nested loops = O(n²), halving = O(log n))&lt;/li&gt;&lt;li&gt;Avoid common pitfalls like miscounting triangular iterations or forgetting to drop constants&lt;/li&gt;&lt;li&gt;Build intuition for recursive algorithms and amortized analysis&lt;/li&gt;&lt;li&gt;Prepare confidently for technical interviews and exams&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h2&gt;Core Concepts Recap&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Before diving into problems, ensure you&#39;re comfortable with these rules:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Drop constants&lt;/strong&gt;: O(3n) = O(n), O(n²/2) = O(n²)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Keep the dominant term&lt;/strong&gt;: O(n² + n) = O(n²)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Sequential blocks add&lt;/strong&gt;: O(n) + O(n) = O(n)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Nested blocks multiply&lt;/strong&gt;: O(n) × O(n) = O(n²)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Halving/doubling loops&lt;/strong&gt;: O(log n)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Graph algorithms&lt;/strong&gt;: Typically O(V + E), where V = vertices, E = edges&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg04J_BGqF3Xq9dEjXFEovsem59b-zCnbqxgXlgUE_8jwr4LsNvEm8TeqSHGTXvHv8XFBE74M23qr3kz-gDCXJ72wS7TYFpoEkjUPL0oRNJFTIyCnZ96wMwMd8ObRBYHa57xdVfVGk3bDRbGjdCY9AWIBMZhQthxBTeMLniyTQbULPik5Xy0TamvpP8JSE/s1024/Time-Complexity-Practice-Problems%201.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;559&quot; data-original-width=&quot;1024&quot; height=&quot;350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg04J_BGqF3Xq9dEjXFEovsem59b-zCnbqxgXlgUE_8jwr4LsNvEm8TeqSHGTXvHv8XFBE74M23qr3kz-gDCXJ72wS7TYFpoEkjUPL0oRNJFTIyCnZ96wMwMd8ObRBYHa57xdVfVGk3bDRbGjdCY9AWIBMZhQthxBTeMLniyTQbULPik5Xy0TamvpP8JSE/w640-h350/Time-Complexity-Practice-Problems%201.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;


&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2&gt;Practice Problems by Difficulty&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;Beginner Problems (Single Loops &amp;amp; Constants)&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;strong&gt;Problem 1: Constant-Time Loop&lt;/strong&gt;&lt;br /&gt;What is the time complexity?&lt;/p&gt;
  &lt;pre data-comment=&quot;python&quot;&gt;for i in range(1, 101):
    print(i)&lt;/pre&gt;
  &lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(1) — the loop runs a fixed 100 times, independent of input size.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 2: Linear Scan&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;for i in range(n):
    print(array[i])&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n) — one iteration per element.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 3: Two Sequential Loops&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;for x in array:
    print(x)
for x in array:
    print(x * 2)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n) — sequential loops add: O(n) + O(n) = O(2n) = O(n).&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 4: Loop with Step&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;for i in range(1, n, 2):
    print(i)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n) — still linear; the step size (2) is a constant factor that gets dropped.&lt;/p&gt;&lt;h3&gt;Intermediate Problems (Nested Loops &amp;amp; Logarithms)&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Problem 5: Full Nested Loops&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;for i in range(n):
    for j in range(n):
        print(i, j)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n²) — n × n iterations.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 6: Triangular Nested Loops&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;for i in range(n):
    for j in range(i + 1, n):
        print(i, j)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n²) — total iterations = n(n-1)/2, but constants are dropped.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 7: Logarithmic Loop&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;i = n
while i &amp;gt; 0:
    i = i // 2
    print(i)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(log n) — the variable halves each iteration.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 8: Linear × Logarithmic&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;for i in range(n):
    j = 1
    while j &amp;lt; n:
        j *= 2&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n log n) — outer loop runs n times, inner loop log n times.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 9: Different Input Sizes&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;for x in array_a:      # length m
    for y in array_b:  # length n
        print(x, y)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(m × n) — use separate variables for distinct input sizes.&lt;/p&gt;&lt;h3&gt;Advanced Problems (Recursion &amp;amp; Complex Patterns)&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Problem 10: Naive Fibonacci&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;def fib(n):
    if n &amp;lt;= 1:
        return n
    return fib(n-1) + fib(n-2)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(2ⁿ) — each call branches into two more calls; recursion tree depth ≈ n.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 11: Memoized Fibonacci&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;def fib_memo(n, memo={}):
    if n in memo:
        return memo[n]
    if n &amp;lt;= 1:
        return n
    memo[n] = fib_memo(n-1, memo) + fib_memo(n-2, memo)
    return memo[n]&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n) — each unique subproblem (0 to n) is solved once.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 12: Merge Sort&lt;/strong&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;def merge_sort(arr):
    if len(arr) &amp;lt;= 1:
        return arr
    mid = len(arr) // 2
    left = merge_sort(arr[:mid])
    right = merge_sort(arr[mid:])
    return merge(left, right)  # O(n)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n log n) — recurrence T(n) = 2T(n/2) + O(n).&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 13: Tower of Hanoi&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;def hanoi(n, source, target, aux):
    if n == 1:
        move(source, target)
        return
    hanoi(n-1, source, aux, target)
    move(source, target)
    hanoi(n-1, aux, target, source)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(2ⁿ) — recurrence T(n) = 2T(n-1) + 1.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 14: All Subsets (Power Set)&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;def subsets(arr, i=0, current=[]):
    if i == len(arr):
        print(current)
        return
    subsets(arr, i+1, current + [arr[i]])  # include
    subsets(arr, i+1, current)             # exclude&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(n × 2ⁿ) — 2ⁿ subsets, each taking O(n) to copy/print.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem 15: BFS on a Graph&lt;/strong&gt;&lt;/p&gt;&lt;pre data-comment=&quot;python&quot;&gt;&lt;code&gt;from collections import deque
def bfs(graph, start):
    visited = {start}
    queue = deque([start])
    while queue:
        node = queue.popleft()
        for neighbor in graph[node]:
            if neighbor not in visited:
                visited.add(neighbor)
                queue.append(neighbor)&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; O(V + E) — each vertex and edge is processed at most once.&lt;/p&gt;
  &lt;h2&gt;Quick Reference Table&lt;/h2&gt;&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
 &lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Pattern&lt;/th&gt;&lt;th&gt;Complexity&lt;/th&gt;&lt;th&gt;Example&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Single loop over n&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;td&gt;Linear search&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
   nested loops over n&lt;/td&gt;&lt;td&gt;O(n²)&lt;/td&gt;&lt;td&gt;Bubble sort&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Triple nested loops&lt;/td&gt;&lt;td&gt;O(n³)&lt;/td&gt;&lt;td&gt;Naive matrix multiply&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Loop halving/doubling&lt;/td&gt;&lt;td&gt;O(log n)&lt;/td&gt;&lt;td&gt;Binary search&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Loop + inner halving&lt;/td&gt;&lt;td&gt;O(n log n)&lt;/td&gt;&lt;td&gt;Merge sort, heap sort&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Recursive, halves input&lt;/td&gt;&lt;td&gt;O(log n)&lt;/td&gt;&lt;td&gt;Binary search (recursive)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Recursive, two calls on n/2 + O(n)&lt;/td&gt;&lt;td&gt;O(n log n)&lt;/td&gt;&lt;td&gt;Merge sort&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Recursive, two calls on n-1&lt;/td&gt;&lt;td&gt;O(2ⁿ)&lt;/td&gt;&lt;td&gt;Naive Fibonacci, Hanoi&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Memoized recursion&lt;/td&gt;&lt;td&gt;O(unique states)&lt;/td&gt;&lt;td&gt;DP Fibonacci&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;All subsets&lt;/td&gt;&lt;td&gt;O(n × 2ⁿ)&lt;/td&gt;&lt;td&gt;Power set&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;All permutations&lt;/td&gt;&lt;td&gt;O(n × n!)&lt;/td&gt;&lt;td&gt;Permutation generation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Graph BFS/DFS&lt;/td&gt;&lt;td&gt;O(V + E)&lt;/td&gt;&lt;td&gt;Traversal&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
  
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h2&gt;How to Practice Effectively&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Start simple&lt;/strong&gt;: Master single and nested loops before tackling recursion.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Trace small inputs&lt;/strong&gt;: Manually count iterations for n = 3 or 4 to build intuition.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Identify the pattern&lt;/strong&gt;: Ask: Is it sequential or nested? Does the variable halve? Are there recursive calls?&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Write the recurrence&lt;/strong&gt; (for recursion): Express T(n) in terms of smaller subproblems, then solve using a recursion tree or Master Theorem.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Check edge cases&lt;/strong&gt;: What if input sizes differ (m vs. n)? What if a loop runs a constant number of times?&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWZtXGwxts_BigYVAZNXmzCpYxDUN8tGKdiHuOUCwLEhvVaRw0iIbP3fVJGvqUhvmx_H5rK-YtJucvf8RJXUzRy0faTelY8bRB35sV-VGNKe3bclezQlggd0R4PXEpaxnMufHCCKGfbLeFLrCrw-1GL3Uv1p3yvh8hkrbJsGSgaZ7udmd5twvz8hP7Pwg/s1024/Time-Complexity-Practice-Problems%202.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;559&quot; data-original-width=&quot;1024&quot; height=&quot;350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWZtXGwxts_BigYVAZNXmzCpYxDUN8tGKdiHuOUCwLEhvVaRw0iIbP3fVJGvqUhvmx_H5rK-YtJucvf8RJXUzRy0faTelY8bRB35sV-VGNKe3bclezQlggd0R4PXEpaxnMufHCCKGfbLeFLrCrw-1GL3Uv1p3yvh8hkrbJsGSgaZ7udmd5twvz8hP7Pwg/w640-h350/Time-Complexity-Practice-Problems%202.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;Common Mistakes to Avoid&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Forgetting to drop constants&lt;/strong&gt;: O(n²/2) is still O(n²).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Miscounting triangular loops&lt;/strong&gt;: j starting at i+1 still yields O(n²).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Assuming all recursion is exponential&lt;/strong&gt;: Halving the input (like in merge sort) gives O(n log n), not O(2ⁿ).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Ignoring different input sizes&lt;/strong&gt;: Nested loops over arrays of length m and n give O(mn), not O(n²).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Overlooking amortized analysis&lt;/strong&gt;: Some loops with inner while-loops are still O(n) if each element is processed a bounded number of times.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Next Steps&lt;/h2&gt;&lt;p&gt;Once comfortable with these problems, challenge yourself with:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Space complexity analysis&lt;/strong&gt;: How much extra memory does the algorithm use?&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Best, average, and worst-case analysis&lt;/strong&gt;: When does an algorithm perform optimally or poorly?&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Amortized analysis&lt;/strong&gt;: Understand why some seemingly expensive operations average out to O(1).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Master Theorem&lt;/strong&gt;: A powerful tool for solving recurrences of the form T(n) = aT(n/b) + f(n).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Practice consistently, and soon you&#39;ll be able to glance at any code snippet and instantly determine its time complexity.&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/6975235966236500065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/Time-Complexity-Practice-Problems-a-Comprehensive-Guide.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6975235966236500065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6975235966236500065'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/Time-Complexity-Practice-Problems-a-Comprehensive-Guide.html' title='Time Complexity Practice Problems : A Comprehensive Guide'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg04J_BGqF3Xq9dEjXFEovsem59b-zCnbqxgXlgUE_8jwr4LsNvEm8TeqSHGTXvHv8XFBE74M23qr3kz-gDCXJ72wS7TYFpoEkjUPL0oRNJFTIyCnZ96wMwMd8ObRBYHa57xdVfVGk3bDRbGjdCY9AWIBMZhQthxBTeMLniyTQbULPik5Xy0TamvpP8JSE/s72-w640-h350-c/Time-Complexity-Practice-Problems%201.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5388135308720741229</id><published>2026-09-06T02:29:23.622+05:30</published><updated>2026-09-06T03:22:30.095+05:30</updated><title type='text'>Big O Notation Practice Problems with Solutions</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
Big O notation describes how the running time or space requirements of an algorithm grow as the input size n increases. This guide contains Big O practice problems ranging from beginner to advanced, with step-by-step solutions and explanations.&lt;div&gt;&lt;br /&gt;&amp;nbsp;
  
  &lt;p class=&quot;alert info outline&quot;&gt;&lt;b&gt;Big O notation?&lt;/b&gt;
Big O notation describes how the running time or space requirements of an algorithm grow as the input size n increases. This guide contains Big O practice problems ranging from beginner to advanced, with step-by-step solutions and explanations.
&lt;/p&gt;

&lt;!--[ Table ]--&gt;&lt;div class=&quot;table sticky bordered stripped hovered&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Complexity&lt;/th&gt;
        &lt;th&gt;Common example&lt;/th&gt;
      
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
  &lt;tr&gt;
    &lt;td&gt;O(1)&lt;/td&gt;
    &lt;td&gt;Array access&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O(log n)&lt;/td&gt;
    &lt;td&gt;Binary search&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O(n)&lt;/td&gt;
    &lt;td&gt;Linear search&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O(n log n)&lt;/td&gt;
    &lt;td&gt;Merge sort&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O(n²)&lt;/td&gt;
    &lt;td&gt;Nested loops&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;O(2ⁿ)&lt;/td&gt;
    &lt;td&gt;Some recursive algorithms&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;

  &lt;/table&gt;
&lt;/div&gt;

&lt;!--BIG O INTERACTIVE VISUALIZER--&gt;
&lt;div class=&quot;op-bigo&quot; id=&quot;opBigO&quot;&gt;

  &lt;div class=&quot;op-bigo-chart&quot;&gt;

    &lt;!--Legend--&gt;
    &lt;div class=&quot;op-bigo-legend&quot;&gt;
      &lt;span&gt;&lt;i class=&quot;c1&quot;&gt;&lt;/i&gt;O(1)&lt;/span&gt;
      &lt;span&gt;&lt;i class=&quot;c2&quot;&gt;&lt;/i&gt;O(log n)&lt;/span&gt;
      &lt;span&gt;&lt;i class=&quot;c3&quot;&gt;&lt;/i&gt;O(n)&lt;/span&gt;
      &lt;span&gt;&lt;i class=&quot;c4&quot;&gt;&lt;/i&gt;O(n log n)&lt;/span&gt;
      &lt;span&gt;&lt;i class=&quot;c5&quot;&gt;&lt;/i&gt;O(n²)&lt;/span&gt;
      &lt;span&gt;&lt;i class=&quot;c6&quot;&gt;&lt;/i&gt;O(2ⁿ)&lt;/span&gt;
    &lt;/div&gt;

    &lt;canvas id=&quot;opBigOCanvas&quot;&gt;&lt;/canvas&gt;

  &lt;/div&gt;

  &lt;!--Equation / values--&gt;
  &lt;div class=&quot;op-bigo-info&quot;&gt;

    &lt;div class=&quot;op-bigo-equation&quot;&gt;
      &lt;span class=&quot;math-n&quot;&gt;n&lt;/span&gt;
      &lt;span&gt;=&lt;/span&gt;
      &lt;strong id=&quot;opN1&quot;&gt;64&lt;/strong&gt;
      &lt;span&gt;:&lt;/span&gt;

      &lt;span&gt;
        (1, log₂n, n)
        =
        (1,
        &lt;span id=&quot;opLog&quot;&gt;6&lt;/span&gt;,
        &lt;span id=&quot;opLinear&quot;&gt;64&lt;/span&gt;)
      &lt;/span&gt;
    &lt;/div&gt;

    &lt;div class=&quot;op-bigo-equation&quot;&gt;
      (n log₂n, n²)
      =
      (&lt;span id=&quot;opNLog&quot;&gt;384&lt;/span&gt;,
      &lt;span id=&quot;opSquare&quot;&gt;4,096&lt;/span&gt;)
    &lt;/div&gt;

    &lt;div class=&quot;op-bigo-equation&quot;&gt;
      2&lt;sup&gt;n&lt;/sup&gt;
      =
      &lt;span id=&quot;opExp&quot;&gt;1.84 × 10&lt;sup&gt;19&lt;/sup&gt;&lt;/span&gt;
    &lt;/div&gt;

  &lt;/div&gt;

  &lt;!--Slider--&gt;
  &lt;div class=&quot;op-bigo-slider-area&quot;&gt;

    &lt;span class=&quot;op-bigo-n&quot;&gt;n&lt;/span&gt;

    &lt;div class=&quot;op-bigo-slider-wrap&quot;&gt;

      &lt;div class=&quot;op-bigo-slider-labels&quot;&gt;
        &lt;span&gt;4&lt;/span&gt;
        &lt;span&gt;8&lt;/span&gt;
        &lt;span&gt;16&lt;/span&gt;
        &lt;span&gt;32&lt;/span&gt;
        &lt;span&gt;64&lt;/span&gt;
      &lt;/div&gt;

      &lt;input id=&quot;opBigOSlider&quot; max=&quot;64&quot; type=&quot;range&quot; value=&quot;64&quot; /&gt;

    &lt;/div&gt;

  &lt;/div&gt;

&lt;/div&gt;


&lt;style&gt;

#opBigO {
  width:100%;
  max-width:900px;
  margin:25px auto;
  background:#fff;
  border:1px solid #ddd;
  border-radius:20px;
  overflow:hidden;
  font-family:Arial,Helvetica,sans-serif;
  color:#222;
  box-sizing:border-box;
}

#opBigO * {
  box-sizing:border-box;
}

.op-bigo-chart {
  position:relative;
  width:100%;
  height:470px;
  padding:55px 10px 0 10px;
}

#opBigOCanvas {
  width:100%;
  height:100%;
  display:block;
}

/* LEGEND */

.op-bigo-legend {
  position:absolute;
  top:18px;
  left:0;
  right:0;

  display:flex;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
  gap:22px;

  font-family:Georgia,&quot;Times New Roman&quot;,serif;
  font-size:17px;
  color:#555;
}

.op-bigo-legend span {
  display:flex;
  align-items:center;
  white-space:nowrap;
}

.op-bigo-legend i {
  display:inline-block;
  width:27px;
  height:4px;
  border-radius:5px;
  margin-right:7px;
}

.c1 { background:#4caf50; }
.c2 { background:#f5c84c; }
.c3 { background:#3b82f6; }
.c4 { background:#c4a8f7; }
.c5 { background:#f26b32; }
.c6 { background:#bd9999; }


/* INFORMATION */

.op-bigo-info {
  background:#fafafa;
  border-top:1px solid #ddd;
  text-align:center;
  padding:20px 10px 14px;

  font-family:Georgia,&quot;Times New Roman&quot;,serif;
  font-size:20px;
  line-height:1.9;
  color:#555;
}

.op-bigo-equation {
  margin:2px 0;
}

.math-n {
  font-style:italic;
}

.op-bigo-info strong {
  font-weight:normal;
}


/* SLIDER */

.op-bigo-slider-area {
  display:flex;
  align-items:center;
  gap:12px;

  padding:4px 28px 15px;

  font-family:Georgia,&quot;Times New Roman&quot;,serif;
}

.op-bigo-n {
  font-style:italic;
  font-size:18px;
}

.op-bigo-slider-wrap {
  position:relative;
  flex:1;
  padding-top:22px;
}

.op-bigo-slider-labels {
  position:absolute;
  left:0;
  right:0;
  top:0;

  display:flex;
  justify-content:space-between;

  color:#555;
  font-size:14px;
  pointer-events:none;
}


/* RANGE */

#opBigOSlider {
  width:100%;
  height:26px;
  appearance:none;
  -webkit-appearance:none;
  background:transparent;
  cursor:pointer;
}

#opBigOSlider::-webkit-slider-runnable-track {
  height:12px;
  background:#e4e4e4;
  border-radius:20px;
}

#opBigOSlider::-webkit-slider-thumb {
  appearance:none;
  -webkit-appearance:none;

  width:30px;
  height:30px;

  margin-top:-9px;

  border-radius:50%;
  border:2px solid #ddd;

  background:white;

  box-shadow:0 1px 4px rgba(0,0,0,.15);
}

#opBigOSlider::-moz-range-track {
  height:12px;
  background:#e4e4e4;
  border-radius:20px;
}

#opBigOSlider::-moz-range-thumb {
  width:30px;
  height:30px;

  border-radius:50%;
  border:2px solid #ddd;

  background:white;
}


/* MOBILE */

@media(max-width:600px){

  .op-bigo-chart {
    height:390px;
    padding-top:80px;
  }

  .op-bigo-legend {
    gap:9px 14px;
    font-size:13px;
    padding:0 8px;
  }

  .op-bigo-legend i {
    width:20px;
  }

  .op-bigo-info {
    font-size:16px;
    line-height:1.8;
  }

  .op-bigo-slider-area {
    padding-left:15px;
    padding-right:15px;
  }

}

&lt;/style&gt;


&lt;script&gt;

(function(){

  const canvas =
    document.getElementById(&quot;opBigOCanvas&quot;);

  const ctx =
    canvas.getContext(&quot;2d&quot;);

  const slider =
    document.getElementById(&quot;opBigOSlider&quot;);


  const nText =
    document.getElementById(&quot;opN1&quot;);

  const logText =
    document.getElementById(&quot;opLog&quot;);

  const linearText =
    document.getElementById(&quot;opLinear&quot;);

  const nlogText =
    document.getElementById(&quot;opNLog&quot;);

  const squareText =
    document.getElementById(&quot;opSquare&quot;);

  const expText =
    document.getElementById(&quot;opExp&quot;);


  /*
   * Complexity definitions
   */

  const functions = [

    {
      name:&quot;O(1)&quot;,
      color:&quot;#4caf50&quot;,
      fn:n =&gt; 1
    },

    {
      name:&quot;O(log n)&quot;,
      color:&quot;#f5c84c&quot;,
      fn:n =&gt; Math.log2(n)
    },

    {
      name:&quot;O(n)&quot;,
      color:&quot;#3b82f6&quot;,
      fn:n =&gt; n
    },

    {
      name:&quot;O(n log n)&quot;,
      color:&quot;#c4a8f7&quot;,
      fn:n =&gt; n * Math.log2(n)
    },

    {
      name:&quot;O(n²)&quot;,
      color:&quot;#f26b32&quot;,
      fn:n =&gt; n * n
    },

    {
      name:&quot;O(2ⁿ)&quot;,
      color:&quot;#bd9999&quot;,
      fn:n =&gt; Math.pow(2,n)
    }

  ];


  /*
   * Resize canvas correctly for
   * high-resolution screens.
   */

  function resizeCanvas(){

    const rect =
      canvas.getBoundingClientRect();

    const ratio =
      window.devicePixelRatio || 1;

    canvas.width =
      rect.width * ratio;

    canvas.height =
      rect.height * ratio;

    ctx.setTransform(
      ratio,
      0,
      0,
      ratio,
      0,
      0
    );

    draw();

  }


  /*
   * Format exponential values
   */

  function scientific(value){

    if(value &lt; 1000000){

      return Math.round(value)
        .toLocaleString();

    }

    const exponent =
      Math.floor(Math.log10(value));

    const mantissa =
      value / Math.pow(10,exponent);

    return mantissa.toFixed(2)
      + &quot; × 10&quot;
      + &quot;&lt;sup&gt;&quot;
      + exponent
      + &quot;&lt;/sup&gt;&quot;;

  }


  /*
   * Update numbers below graph
   */

  function updateValues(){

    const n =
      Number(slider.value);

    nText.textContent = n;

    logText.textContent =
      Math.round(Math.log2(n));

    linearText.textContent =
      n;

    nlogText.textContent =
      Math.round(n * Math.log2(n))
      .toLocaleString();

    squareText.textContent =
      (n*n).toLocaleString();

    expText.innerHTML =
      scientific(Math.pow(2,n));

  }


  /*
   * Draw graph
   */

  function draw(){

    const width =
      canvas.clientWidth;

    const height =
      canvas.clientHeight;


    ctx.clearRect(
      0,
      0,
      width,
      height
    );


    /*
     * Graph boundaries
     */

    const left = 45;
    const right = 12;
    const top = 5;
    const bottom = 45;

    const graphWidth =
      width - left - right;

    const graphHeight =
      height - top - bottom;


    /*
     * Maximum Y value.
     *
     * We intentionally clip the graph at
     * 260 so all curves remain useful visually.
     */

    const maxY = 260;

    const maxX = 64;


    /*
     * Background
     */

    ctx.fillStyle = &quot;#ffffff&quot;;

    ctx.fillRect(
      0,
      0,
      width,
      height
    );


    /*
     * Horizontal grid
     */

    ctx.strokeStyle = &quot;#e6e6e6&quot;;
    ctx.lineWidth = 1;

    for(let y=0;y&lt;=200;y+=50){

      const py =
        top +
        graphHeight -
        (y/maxY)*graphHeight;

      ctx.beginPath();

      ctx.moveTo(left,py);

      ctx.lineTo(
        width-right,
        py
      );

      ctx.stroke();


      /*
       * Y labels
       */

      ctx.fillStyle = &quot;#999&quot;;

      ctx.font = &quot;16px Arial&quot;;

      ctx.textAlign = &quot;right&quot;;

      ctx.fillText(
        y,
        left-8,
        py+5
      );

    }


    /*
     * Vertical grid
     */

    for(let x=0;x&lt;=60;x+=10){

      const px =
        left +
        (x/maxX)*graphWidth;

      ctx.strokeStyle =
        &quot;#eeeeee&quot;;

      ctx.beginPath();

      ctx.moveTo(
        px,
        top
      );

      ctx.lineTo(
        px,
        top+graphHeight
      );

      ctx.stroke();


      ctx.fillStyle = &quot;#999&quot;;

      ctx.font = &quot;16px Arial&quot;;

      ctx.textAlign = &quot;center&quot;;

      if(x &gt; 0){

        ctx.fillText(
          x,
          px,
          top+graphHeight+27
        );

      }

    }


    /*
     * Axis
     */

    ctx.strokeStyle = &quot;#444&quot;;

    ctx.lineWidth = 2;

    ctx.beginPath();

    ctx.moveTo(
      left,
      top
    );

    ctx.lineTo(
      left,
      top+graphHeight
    );

    ctx.lineTo(
      width-right,
      top+graphHeight
    );

    ctx.stroke();


    /*
     * Y axis title
     */

    ctx.fillStyle = &quot;#111&quot;;

    ctx.font =
      &quot;bold 18px Arial&quot;;

    ctx.textAlign = &quot;left&quot;;

    ctx.fillText(
      &quot;Ops&quot;,
      left+10,
      top+20
    );


    /*
     * X axis title
     */

    ctx.textAlign = &quot;center&quot;;

    ctx.fillText(
      &quot;Input size n&quot;,
      left + graphWidth/2,
      height-5
    );


    /*
     * Draw complexity curves
     */

    functions.forEach(function(complexity){

      ctx.beginPath();

      ctx.strokeStyle =
        complexity.color;

      ctx.lineWidth = 2.5;

      let started = false;


      for(let n=1;n&lt;=64;n++){

        let value =
          complexity.fn(n);


        /*
         * Clip values above graph.
         */

        if(value &gt; maxY){

          value = maxY;

        }


        const x =
          left +
          ((n-1)/(maxX-1))
          * graphWidth;


        const y =
          top +
          graphHeight -
          (value/maxY)
          * graphHeight;


        if(!started){

          ctx.moveTo(x,y);

          started = true;

        }else{

          ctx.lineTo(x,y);

        }

      }

      ctx.stroke();

    });


    /*
     * Selected n
     */

    const selected =
      Number(slider.value);


    const markerX =
      left +
      ((selected-1)/(maxX-1))
      * graphWidth;


    /*
     * Vertical dotted line
     */

    ctx.save();

    ctx.strokeStyle =
      &quot;#aaaaaa&quot;;

    ctx.lineWidth = 1;

    ctx.setLineDash([4,4]);

    ctx.beginPath();

    ctx.moveTo(
      markerX,
      top
    );

    ctx.lineTo(
      markerX,
      top+graphHeight
    );

    ctx.stroke();

    ctx.restore();


    /*
     * Draw selected points
     */

    functions.forEach(function(complexity){

      let value =
        complexity.fn(selected);


      if(value &gt; maxY){

        value = maxY;

      }


      const y =
        top +
        graphHeight -
        (value/maxY)
        * graphHeight;


      ctx.beginPath();

      ctx.fillStyle =
        complexity.color;

      ctx.arc(
        markerX,
        y,
        3.5,
        0,
        Math.PI*2
      );

      ctx.fill();

    });

  }


  /*
   * Slider
   */

  slider.addEventListener(
    &quot;input&quot;,
    function(){

      updateValues();

      draw();

    }
  );


  /*
   * Resize
   */

  window.addEventListener(
    &quot;resize&quot;,
    resizeCanvas
  );


  /*
   * Initial render
   */

  updateValues();

  resizeCanvas();

})();

&lt;/script&gt;&lt;/div&gt;


&lt;h2&gt;Problem 1: Constant Time O(1)&lt;/h2&gt;

&lt;!--[ Multi-tabs Code Block Highlighter ]--&gt;
&lt;div class=&#39;pre tabs&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;preT1-1&#39; type=&#39;radio&#39; name=&#39;preTab1&#39; checked/&gt;
  &lt;input id=&#39;preT1-2&#39; type=&#39;radio&#39; name=&#39;preTab1&#39;/&gt;
  &lt;!--[ Header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace title ]--&gt;
    &lt;label for=&#39;preT1-1&#39; data-text=&#39;C++&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;preT1-2&#39; data-text=&#39;Phython&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;

  &lt;!--[ Content ]--&gt;
  &lt;pre class=&#39;preC1-1&#39; data-source=&#39;src/main.cpp&#39;&gt;&lt;code&gt;bool checkEven(int n) {
    return n % 2 == 0;
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;pre class=&#39;preC1-2&#39; data-source=&#39;src/main.py&#39;&gt;&lt;code&gt;def check_even(n):
  return n % 2 == 0
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Question: What is the time complexity?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution: O(1)&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Explanation: “Inside the function, a constant number of operations is performed: the modulus operation (% 2) and a comparison (== 0). The number of operations does not depend on the size of the input numbum (n).&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Problem 2: Linear Time O(n)&lt;/h2&gt;
&lt;!--[ Multi-tabs Code Block Highlighter ]--&gt;
&lt;div class=&#39;pre tabs&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;preT21-1&#39; type=&#39;radio&#39; name=&#39;preTab1&#39; checked/&gt;
  &lt;input id=&#39;preT21-2&#39; type=&#39;radio&#39; name=&#39;preTab1&#39;/&gt;
  &lt;!--[ Header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace title ]--&gt;
    &lt;label for=&#39;preT21-1&#39; data-text=&#39;C++&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;preT21-2&#39; data-text=&#39;Phython&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;

  &lt;!--[ Content ]--&gt;
  &lt;pre class=&#39;preC21-1&#39; data-source=&#39;src/main.cpp&#39;&gt;&lt;code&gt;#include &lt;iostream&gt;
#include &lt;vector&gt;

void printItems(const std::vector&lt;int&gt;&amp; arr) {
    for (int item : arr) {
        std::cout &lt;&lt; item &lt;&lt; &quot;\n&quot;;
    }
    for (int item : arr) {
        std::cout &lt;&lt; item &lt;&lt; &quot;\n&quot;;
    }
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;pre class=&#39;preC21-2&#39; data-source=&#39;src/main.py&#39;&gt;&lt;code&gt;def print_items(arr):
  for item in arr:
    print(item)
  for item in arr:
    print(item)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Question: What is the time complexity?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution: O(n)&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Explanation: The function loops through the list of n elements twice. This gives 2n steps. Big O notation drops constant coefficients, so 2n simplifies to O(n).&lt;/b&gt;&lt;/p&gt; 

&lt;h2&gt;Problem 3: Logarithmic Time (O(log n))&lt;/h2&gt;

&lt;!--[ Multi-tabs Code Block Highlighter ]--&gt;
&lt;div class=&#39;pre tabs&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;preT31-1&#39; type=&#39;radio&#39; name=&#39;preTab1&#39; checked/&gt;
  &lt;input id=&#39;preT31-2&#39; type=&#39;radio&#39; name=&#39;preTab1&#39;/&gt;
  &lt;!--[ Header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace title ]--&gt;
    &lt;label for=&#39;preT31-1&#39; data-text=&#39;C++&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;preT31-2&#39; data-text=&#39;Phython&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;

  &lt;!--[ Content ]--&gt;
  &lt;pre class=&#39;preC31-1&#39; data-source=&#39;src/main.cpp&#39;&gt;&lt;code&gt;int i = 1;
while (i &lt; n) {
    i = i * 2;
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;pre class=&#39;preC31-2&#39; data-source=&#39;src/main.py&#39;&gt;&lt;code&gt;i = 1
while i &lt; n:
  i = i * 2
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Question: What is the time complexity?

&lt;p&gt;&lt;b&gt;Solution: \(O(\log n)\)&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Explanation: The complexity is \(O(\log n)\) because the variable i doubles in each iteration, scaling logarithmically relative to n.&lt;/b&gt;&lt;/p&gt;
            &lt;h&gt;Problem 4: Quadratic Time O(n²)&lt;/h&gt;
&lt;!--[ Multi-tabs Code Block Highlighter ]--&gt;
&lt;div class=&#39;pre tabs&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;preT41-1&#39; type=&#39;radio&#39; name=&#39;preTab1&#39; checked/&gt;
  &lt;input id=&#39;preT41-2&#39; type=&#39;radio&#39; name=&#39;preTab1&#39;/&gt;
  &lt;!--[ Header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace title ]--&gt;
    &lt;label for=&#39;preT41-1&#39; data-text=&#39;C++&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;preT41-2&#39; data-text=&#39;Phython&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;

  &lt;!--[ Content ]--&gt;
  &lt;pre class=&#39;preC41-1&#39; data-source=&#39;src/main.cpp&#39;&gt;&lt;code&gt;#include &lt;vector&gt;

int findPairs(const std::vector&lt;int&gt;&amp; numbers, int target_sum) {
    int count = 0;
    int n = numbers.size();
    for (int i = 0; i &lt; n; i++) {
        for (int j = 0; j &lt; n; j++) {
            if (numbers[i] + numbers[j] == target_sum) {
                count++;
            }
        }
    }
    return count;
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;pre class=&#39;preC41-2&#39; data-source=&#39;src/main.py&#39;&gt;&lt;code&gt;def find_pairs(numbers, target_sum):
  count = 0
  for i in range(len(numbers)):
    for j in range(len(numbers)):
      if numbers[i] + numbers[j] == target_sum:
        count += 1
  return count
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
            &lt;p&gt;Question: What is the time complexity?&lt;/p&gt;
&lt;p&gt;Solution: O(n²)&lt;/p&gt;
&lt;p&gt;Explanation: Featuring nested loops where each individual loop runs n times, the total operations scale to \(n^{2}\) while constant-time work occurs inside&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5388135308720741229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/09/computer-sciencebig-o-notation-practice-problems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5388135308720741229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5388135308720741229'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/09/computer-sciencebig-o-notation-practice-problems.html' title='Big O Notation Practice Problems with Solutions'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5496051204911717443</id><published>2026-08-23T00:06:16.876+05:30</published><updated>2026-08-23T00:28:23.315+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="Toll Tax Collection"/><title type='text'>Toll Tax Collection Computer Graphics Project in OpenGL </title><content type='html'>&lt;p&gt;The &lt;strong&gt;Toll Tax Collection Booth Simulation&lt;/strong&gt; is a popular Computer Graphics mini-project developed using &lt;strong&gt;C/C++ with the GLUT/OpenGL library&lt;/strong&gt;. The project creates a simple interactive highway environment where vehicles move through toll booths, stop at barriers, and continue once the gates are opened.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhrWk2J5_lbd2tq7r5M14JtncGG-XfR9S9Hi-9-sXZSzfEOWDjga15hxpMGz9gumzVkAjLfwyDYyYNUi7E1qzLU4rQvhoVC9VI23fyPL8UY0nJbUpLH74bzUnJoH6EU9ov-CnwS3g6cpnJRzChie_I-hJ8qcie36diZt4Lv-tntehfNQ84M6zbnHMcudMIF&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Toll Tax Collection Computer Graphics Project in OpenGL&quot; data-original-height=&quot;901&quot; data-original-width=&quot;1204&quot; height=&quot;478&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhrWk2J5_lbd2tq7r5M14JtncGG-XfR9S9Hi-9-sXZSzfEOWDjga15hxpMGz9gumzVkAjLfwyDYyYNUi7E1qzLU4rQvhoVC9VI23fyPL8UY0nJbUpLH74bzUnJoH6EU9ov-CnwS3g6cpnJRzChie_I-hJ8qcie36diZt4Lv-tntehfNQ84M6zbnHMcudMIF=w640-h478&quot; title=&quot;Toll Tax Collection Computer Graphics Project in OpenGL&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;Key Project Features&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Welcome Screen:&lt;/strong&gt; Displays the project title, student details, and basic instructions for operating the simulation.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dual-Lane Highway:&lt;/strong&gt; Represents a two-way highway with separate lanes and toll booths for vehicles traveling in opposite directions.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive Barriers:&lt;/strong&gt; Vehicles automatically stop when they reach a toll booth. The user can manually raise the barrier to allow the vehicle to pass.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Vehicle Control:&lt;/strong&gt; Users can adjust vehicle speed and manage traffic using predefined keyboard controls.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive Environment:&lt;/strong&gt; Keyboard inputs make the simulation more engaging by allowing the user to control vehicle movement and toll barriers in real time.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Overall, the project demonstrates fundamental &lt;strong&gt;computer graphics concepts such as 2D object drawing, animation, transformations, user interaction, and keyboard-based controls&lt;/strong&gt; in an easy-to-understand highway toll booth simulation.&lt;/p&gt;

&lt;div class=&quot;controls-box&quot;&gt;
    &lt;h2&gt;🚧 Toll Tax Collection Computer Graphics Project User Controls&lt;/h2&gt;

    &lt;table style=&quot;border-collapse: collapse; border-radius: 10px; font-family: Arial, sans-serif; overflow: hidden; text-align: center; width: 100%;&quot;&gt;
        &lt;thead&gt;
            &lt;tr style=&quot;background: rgb(37, 99, 235); color: white;&quot;&gt;
                &lt;th style=&quot;padding: 14px;&quot;&gt;Action&lt;/th&gt;
                &lt;th style=&quot;padding: 14px;&quot;&gt;Left / Top Lane&lt;/th&gt;
                &lt;th style=&quot;padding: 14px;&quot;&gt;Right / Bottom Lane&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;

        &lt;tbody&gt;
            &lt;tr style=&quot;background: rgb(248, 250, 252);&quot;&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;&lt;strong&gt;Open Toll Barrier&lt;/strong&gt;&lt;/td&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;
                    &lt;span style=&quot;background: rgb(15, 23, 42); border-radius: 6px; color: white; padding: 6px 12px;&quot;&gt;L / l&lt;/span&gt;
                &lt;/td&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;
                    &lt;span style=&quot;background: rgb(15, 23, 42); border-radius: 6px; color: white; padding: 6px 12px;&quot;&gt;R / r&lt;/span&gt;
                &lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;&lt;strong&gt;Increase Speed&lt;/strong&gt;&lt;/td&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;
                    &lt;span style=&quot;background: rgb(15, 23, 42); border-radius: 6px; color: white; padding: 6px 12px;&quot;&gt;Z / z&lt;/span&gt;
                &lt;/td&gt;
                &lt;td style=&quot;padding: 14px;&quot;&gt;
                    &lt;span style=&quot;background: rgb(15, 23, 42); border-radius: 6px; color: white; padding: 6px 12px;&quot;&gt;V / v&lt;/span&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;
&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBIQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIEhAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;div aria-level=&quot;3&quot; class=&quot;otQkpb&quot; data-animation-nesting=&quot;&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(0, 29, 53);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; data-wiz-attrbind=&quot;aria-level=bqdNsf_2j/fLk2Md&quot; jsaction=&quot;&quot; jscontroller=&quot;a7qCn#ZxCkTb&quot; jsuid=&quot;bqdNsf_2j&quot; role=&quot;heading&quot; style=&quot;border-bottom: 0px rgb(0, 29, 53); font-size: 20px; font-weight: 600; margin: 24px 0px 12px;&quot;&gt;Complete Source Code Implementation&lt;!--TgQPHd|||[]--&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBQQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIFBAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;div class=&quot;n6owBd awi2gc&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBQQAQ&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;TDBkbc#Ml18Xb&quot; jsuid=&quot;bqdNsf_2k&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 12px 0px 16px;&quot;&gt;You can compile and run this full working program using CodeBlocks, Visual Studio, or a standard GCC/Clang compiler with GLUT linked.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBcQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIFxAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;div aria-level=&quot;3&quot; class=&quot;otQkpb&quot; data-animation-nesting=&quot;&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(0, 29, 53);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; data-wiz-attrbind=&quot;aria-level=bqdNsf_33/fLk2Md&quot; jsaction=&quot;&quot; jscontroller=&quot;a7qCn#ZxCkTb&quot; jsuid=&quot;bqdNsf_33&quot; role=&quot;heading&quot; style=&quot;border-bottom: 0px rgb(0, 29, 53); font-size: 20px; font-weight: 600; margin: 24px 0px 12px;&quot;&gt;Step-by-Step Execution Guide&lt;!--TgQPHd|||[]--&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBkQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIGRAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;div class=&quot;n6owBd awi2gc&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBkQAQ&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;TDBkbc#Ml18Xb&quot; jsuid=&quot;bqdNsf_34&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 12px 0px 16px;&quot;&gt;To run this project seamlessly on your computer, follow these setup stages:&lt;!--TgQPHd|||[]--&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol class=&quot;IaGLZe VimKh&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;xE4zce#N1SbDe&quot; jsuid=&quot;bqdNsf_3a&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 12px 0px 16px;&quot;&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIGhAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;li class=&quot;Z1qcYe&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 12px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQAQ&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;oSLmPe#HokZ0d&quot; jsuid=&quot;bqdNsf_3b&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px 0px 12px;&quot;&gt;&lt;span class=&quot;iNqyIf&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;KdQfFc#d5Qebf&quot; jsuid=&quot;bqdNsf_3c&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3d&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;Setup IDE:&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt; Open &lt;span class=&quot;iNqyIf&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;KdQfFc#d5Qebf&quot; jsuid=&quot;bqdNsf_3e&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;CodeBlocks&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt; or your environment of choice and start a new &lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3f&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;GLUT project&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt;.&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|||[]--&gt;&lt;/li&gt;&lt;/div&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQAg&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIGhAC&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;li class=&quot;Z1qcYe&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 12px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQAw&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;oSLmPe#HokZ0d&quot; jsuid=&quot;bqdNsf_3g&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px 0px 12px;&quot;&gt;&lt;span class=&quot;iNqyIf&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;KdQfFc#d5Qebf&quot; jsuid=&quot;bqdNsf_3h&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3i&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;Library Linking:&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt; Ensure your compiler options are linking the required dependencies: &lt;code class=&quot;KDcb0c&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: monospace; font-size: 14px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 1px solid rgb(243, 245, 246);&quot; data-sfc-root=&quot;ep&quot; dir=&quot;ltr&quot; jsaction=&quot;&quot; jscontroller=&quot;hNviFe#redMub&quot; jsuid=&quot;bqdNsf_3j&quot; style=&quot;border-bottom: 1px solid rgb(243, 245, 246); font-size: 14px; margin: 0px;&quot;&gt;-lglut -lGLU -lGL&lt;!--TgQPHd|||[]--&gt;&lt;/code&gt;.&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|||[]--&gt;&lt;/li&gt;&lt;/div&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQBA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIGhAE&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;li class=&quot;Z1qcYe&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 12px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQBQ&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;oSLmPe#HokZ0d&quot; jsuid=&quot;bqdNsf_3k&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px 0px 12px;&quot;&gt;&lt;span class=&quot;iNqyIf&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;KdQfFc#d5Qebf&quot; jsuid=&quot;bqdNsf_3l&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3m&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;Overwrite Main File:&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt; Replace all auto-generated code inside &lt;code class=&quot;KDcb0c&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: monospace; font-size: 14px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 1px solid rgb(243, 245, 246);&quot; data-sfc-root=&quot;ep&quot; dir=&quot;ltr&quot; jsaction=&quot;&quot; jscontroller=&quot;hNviFe#redMub&quot; jsuid=&quot;bqdNsf_3n&quot; style=&quot;border-bottom: 1px solid rgb(243, 245, 246); font-size: 14px; margin: 0px;&quot;&gt;main.cpp&lt;!--TgQPHd|||[]--&gt;&lt;/code&gt; with the script written above.&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|||[]--&gt;&lt;/li&gt;&lt;/div&gt;&lt;div class=&quot;WYczDe&quot; data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQBg&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIGhAG&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;li class=&quot;Z1qcYe&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 12px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBoQBw&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;oSLmPe#HokZ0d&quot; jsuid=&quot;bqdNsf_3o&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px 0px 12px;&quot;&gt;&lt;span class=&quot;iNqyIf&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;KdQfFc#d5Qebf&quot; jsuid=&quot;bqdNsf_3p&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); margin: 0px;&quot;&gt;&lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3q&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;Compile:&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt; Hit &lt;span class=&quot;rQesXe MPyX&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; jsaction=&quot;&quot; jscontroller=&quot;tP2kf#s32ZS&quot; jsuid=&quot;bqdNsf_3r&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-weight: 700; margin: 0px;&quot;&gt;Build and Run&lt;!--TgQPHd|||[]--&gt;&lt;/span&gt;. Tap &lt;code class=&quot;KDcb0c&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: monospace; font-size: 14px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 1px solid rgb(243, 245, 246);&quot; data-sfc-root=&quot;ep&quot; dir=&quot;ltr&quot; jsaction=&quot;&quot; jscontroller=&quot;hNviFe#redMub&quot; jsuid=&quot;bqdNsf_3s&quot; style=&quot;border-bottom: 1px solid rgb(243, 245, 246); font-size: 14px; margin: 0px;&quot;&gt;ENTER&lt;!--TgQPHd|||[]--&gt;&lt;/code&gt; on the welcome screen to launch into the toll layout!&lt;/span&gt;&lt;/li&gt;&lt;/div&gt;&lt;/ol&gt;&amp;nbsp;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdAM-mhZLor24zM3oxRV1kSfLHtkiXNBSJiuuKUZbIJHw1QqhC8HyvRhI4Tmll6wuHD6Lvb7zuFgkgA1fnmSsyxtQfHT0AXOxj4LI_hCGl2K5XhlTbVYYYkM4LOL_tRtn_tEiqDvjihl6vCB53EVBhekYtZKeeE9SewvhsF31DlpDL8SYIDhUUsjJbWwti&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Toll Tax Collection Computer Graphics Project in OpenGL&quot; data-original-height=&quot;627&quot; data-original-width=&quot;791&quot; height=&quot;507&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdAM-mhZLor24zM3oxRV1kSfLHtkiXNBSJiuuKUZbIJHw1QqhC8HyvRhI4Tmll6wuHD6Lvb7zuFgkgA1fnmSsyxtQfHT0AXOxj4LI_hCGl2K5XhlTbVYYYkM4LOL_tRtn_tEiqDvjihl6vCB53EVBhekYtZKeeE9SewvhsF31DlpDL8SYIDhUUsjJbWwti=w640-h507&quot; title=&quot;Toll Tax Collection Computer Graphics Project in OpenGL&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-bfc=&quot;&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);&quot; data-hveid=&quot;CAIIAAgBCBIQAA&quot; data-ved=&quot;2ahUKEwiFqvP56rSWAxXCe2wGHdmIKHoQi4wTegoIAggACAEIEhAA&quot; style=&quot;border-bottom: 0px rgb(10, 10, 10); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;div aria-level=&quot;3&quot; class=&quot;otQkpb&quot; data-animation-nesting=&quot;&quot; data-complete=&quot;true&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(0, 29, 53);&quot; data-sfc-cp=&quot;&quot; data-sfc-root=&quot;ep&quot; data-wiz-attrbind=&quot;aria-level=bqdNsf_2j/fLk2Md&quot; jsaction=&quot;&quot; jscontroller=&quot;a7qCn#ZxCkTb&quot; jsuid=&quot;bqdNsf_2j&quot; role=&quot;heading&quot; style=&quot;border-bottom: 0px rgb(0, 29, 53); font-size: 20px; font-weight: 600; margin: 24px 0px 12px;&quot;&gt;Full Source Code&amp;nbsp;&lt;/div&gt;
  
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
#include &lt;gl glut.h=&quot;&quot;&gt;
#include &lt;string .h=&quot;&quot;&gt;
#include &lt;stdio .h=&quot;&quot;&gt;

// Global State Variables
int screenMode = 0; // 0 = Welcome Screen, 1 = Toll Simulation
float car1X = -250.0f, car2X = 250.0f; 
float speed1 = 2.0f, speed2 = 2.0f;
bool gate1Open = false, gate2Open = false;
float gate1Angle = 0.0f, gate2Angle = 0.0f;

// Utility to render text strings
void renderText(float x, float y, void* font, const char* string) {
    glRasterPos2f(x, y);
    for (int i = 0; i &amp;lt; strlen(string); i++) {
        glutBitmapCharacter(font, string[i]);
    }
}

// Renders the initial introduction screen
void drawWelcomeScreen() {
    glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(1.0f, 1.0f, 1.0f);
    renderText(-120, 150, GLUT_BITMAP_HELVETICA_18, &quot;COMPUTER GRAPHICS MINI PROJECT&quot;);
    
    glColor3f(0.4f, 1.0f, 0.4f);
    renderText(-110, 100, GLUT_BITMAP_TIMES_ROMAN_24, &quot;TOLL COLLECTING BOOTH SIMULATION&quot;);

    glColor3f(0.9f, 0.9f, 0.3f);
    renderText(-200, 20, GLUT_BITMAP_HELVETICA_12, &quot;CONTROLS:&quot;);
    renderText(-200, 0, GLUT_BITMAP_HELVETICA_12, &quot;  &#39;L&#39; / &#39;l&#39; : Open Left Gate Barrier&quot;);
    renderText(-200, -20, GLUT_BITMAP_HELVETICA_12, &quot;  &#39;R&#39; / &#39;r&#39; : Open Right Gate Barrier&quot;);
    renderText(-200, -40, GLUT_BITMAP_HELVETICA_12, &quot;  &#39;Z&#39; / &#39;z&#39; : Speed up Left Car&quot;);
    renderText(-200, -60, GLUT_BITMAP_HELVETICA_12, &quot;  &#39;V&#39; / &#39;v&#39; : Speed up Right Car&quot;);

    glColor3f(0.3f, 0.8f, 1.0f);
    renderText(-90, -130, GLUT_BITMAP_HELVETICA_14, &quot;Press [ENTER] to Launch Simulation&quot;);
    
    glutSwapBuffers();
}

// Renders the main simulation scene
void drawSimulationScene() {
    glClearColor(0.2f, 0.5f, 0.2f, 1.0f); // Green background for fields
    glClear(GL_COLOR_BUFFER_BIT);

    // 1. Draw Two-Way Road Asphalt
    glColor3f(0.2f, 0.2f, 0.2f);
    glBegin(GL_QUADS);
        glVertex2f(-300, 80);
        glVertex2f(300, 80);
        glVertex2f(300, -80);
        glVertex2f(-300, -80);
    glEnd();

    // 2. Draw Yellow Center Divider Line
    glColor3f(1.0f, 1.0f, 0.0f);
    glLineWidth(3.0);
    glBegin(GL_LINES);
        glVertex2f(-300, 0);
        glVertex2f(300, 0);
    glEnd();

    // 3. Draw Toll Cabins
    // Left Cabin
    glColor3f(0.7f, 0.1f, 0.1f);
    glBegin(GL_QUADS);
        glVertex2f(-60, 120); glVertex2f(-20, 120);
        glVertex2f(-20, 80);  glVertex2f(-60, 80);
    glEnd();
    // Right Cabin
    glBegin(GL_QUADS);
        glVertex2f(20, -80);  glVertex2f(60, -80);
        glVertex2f(60, -120); glVertex2f(20, -120);
    glEnd();

    // 4. Draw Left Lane Gate Barrier
    glPushMatrix();
    glTranslatef(-20, 40, 0);
    glRotatef(gate1Angle, 0, 0, 1);
    glColor3f(1.0f, 0.5f, 0.0f);
    glLineWidth(6.0);
    glBegin(GL_LINES);
        glVertex2f(0, 0); glVertex2f(0, 40);
    glEnd();
    glPopMatrix();

    // 5. Draw Right Lane Gate Barrier
    glPushMatrix();
    glTranslatef(20, -40, 0);
    glRotatef(-gate2Angle, 0, 0, 1);
    glColor3f(1.0f, 0.5f, 0.0f);
    glLineWidth(6.0);
    glBegin(GL_LINES);
        glVertex2f(0, 0); glVertex2f(0, 40);
    glEnd();
    glPopMatrix();

    // 6. Render Car 1 (Moving Left to Right)
    glColor3f(0.1f, 0.4f, 0.8f);
    glBegin(GL_QUADS);
        glVertex2f(car1X, 60);  glVertex2f(car1X + 40, 60);
        glVertex2f(car1X + 40, 20); glVertex2f(car1X, 20);
    glEnd();

    // 7. Render Car 2 (Moving Right to Left)
    glColor3f(0.8f, 0.1f, 0.2f);
    glBegin(GL_QUADS);
        glVertex2f(car2X, -20); glVertex2f(car2X - 40, -20);
        glVertex2f(car2X - 40, -60); glVertex2f(car2X, -60);
    glEnd();

    glutSwapBuffers();
}

// Master display routing
void display() {
    if (screenMode == 0) {
        drawWelcomeScreen();
    } else {
        drawSimulationScene();
    }
}

// Handles frame state updates and simulation arithmetic
void update(int value) {
    if (screenMode == 1) {
        // Handle Left Car Stopping / Moving Logic
        if (!gate1Open &amp;amp;&amp;amp; (car1X + 40 &amp;gt;= -60) &amp;amp;&amp;amp; (car1X &amp;lt; -60)) {
            car1X = -100; // Force full stop at booth entry boundary
        } else {
            car1X += speed1;
            if (car1X &amp;gt; 300) { // Loop back around
                car1X = -300;
                gate1Open = false;
            }
        }

        // Handle Right Car Stopping / Moving Logic
        if (!gate2Open &amp;amp;&amp;amp; (car2X - 40 &amp;lt;= 60) &amp;amp;&amp;amp; (car2X &amp;gt; 60)) {
            car2X = 100; // Force full stop at booth entry boundary
        } else {
            car2X -= speed2;
            if (car2X &amp;lt; -300) { // Loop back around
                car2X = 300;
                gate2Open = false;
            }
        }

        // Smoothly animate gate positions
        if (gate1Open &amp;amp;&amp;amp; gate1Angle &amp;lt; 90.0f) gate1Angle += 5.0f;
        if (!gate1Open &amp;amp;&amp;amp; gate1Angle &amp;gt; 0.0f) gate1Angle -= 5.0f;
        
        if (gate2Open &amp;amp;&amp;amp; gate2Angle &amp;lt; 90.0f) gate2Angle += 5.0f;
        if (!gate2Open &amp;amp;&amp;amp; gate2Angle &amp;gt; 0.0f) gate2Angle -= 5.0f;
    }

    glutPostRedisplay();
    glutTimerFunc(16, update, 0); // Roughly 60 Frames Per Second
}

// Configures coordinate projections
void reshape(int w, int h) {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(-300, 300, -200, 200);
    glMatrixMode(GL_MODELVIEW);
}

// User Input Evaluator
void keyboard(unsigned char key, int x, int y) {
    switch (key) {
        case 13: // ENTER key
            screenMode = 1;
            break;
        case &#39;L&#39;: case &#39;l&#39;:
            gate1Open = true;
            break;
        case &#39;R&#39;: case &#39;r&#39;:
            gate2Open = true;
            break;
        case &#39;Z&#39;: case &#39;z&#39;:
            speed1 += 0.5f;
            break;
        case &#39;V&#39;: case &#39;v&#39;:
            speed2 += 0.5f;
            break;
        case 27: // ESC key
            exit(0);
            break;
    }
}

int main(int argc, char** argv) {
    glutInit(&amp;amp;argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(800, 600);
    glutCreateWindow(&quot;OpenGL Toll Booth Simulation&quot;);
    
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutKeyboardFunc(keyboard);
    glutTimerFunc(0, update, 0);
    
    glutMainLoop();
    return 0;
}

&lt;/stdio&gt;&lt;/string&gt;&lt;/gl&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5496051204911717443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/08/toll-tax-collection-computer-graphics-projects-in-opengl.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5496051204911717443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5496051204911717443'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/08/toll-tax-collection-computer-graphics-projects-in-opengl.html' title='Toll Tax Collection Computer Graphics Project in OpenGL '/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhrWk2J5_lbd2tq7r5M14JtncGG-XfR9S9Hi-9-sXZSzfEOWDjga15hxpMGz9gumzVkAjLfwyDYyYNUi7E1qzLU4rQvhoVC9VI23fyPL8UY0nJbUpLH74bzUnJoH6EU9ov-CnwS3g6cpnJRzChie_I-hJ8qcie36diZt4Lv-tntehfNQ84M6zbnHMcudMIF=s72-w640-h478-c" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4160398649736193444</id><published>2026-06-17T01:46:55.559+05:30</published><updated>2026-08-25T01:37:23.657+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="poke ball"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="rendering"/><title type='text'>OpenGL Python Program for Rendering Poké Ball</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://preview.redd.it/opengl-pok%C3%A9-ball-renderer-pixel-style-v0-f3l7lg3ms8lg1.png?width=1080&amp;amp;crop=smart&amp;amp;auto=webp&amp;amp;s=d42963ae217d7dd80750bfd4ea4a6c76ce683960&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;761&quot; data-original-width=&quot;1080&quot; height=&quot;282&quot; src=&quot;https://preview.redd.it/opengl-pok%C3%A9-ball-renderer-pixel-style-v0-f3l7lg3ms8lg1.png?width=1080&amp;amp;crop=smart&amp;amp;auto=webp&amp;amp;s=d42963ae217d7dd80750bfd4ea4a6c76ce683960&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;1. Render a Normal 3D Poké Ball&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The Poké
Ball itself is usually just a sphere mesh with:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l4 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A red upper hemisphere &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l4 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A white lower hemisphere &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l4 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A black center band &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l4 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A circular button on the
     front &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The
geometry can be:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l6 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A UV sphere &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l6 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;An icosphere &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l6 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A procedurally generated
     sphere &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The
fragment shader might assign colors based on position:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;if (worldPos.y &amp;gt; 0.0)&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;color = vec3(1.0, 0.0, 0.0); // red&lt;br /&gt;
else&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;color = vec3(1.0);&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// white&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The black
band can be created using latitude calculations or a separate mesh.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;2. Use Low-Resolution Rendering&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A common
pixel-art trick is rendering to a small framebuffer first.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;For
example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;320 x 180&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;instead
of:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;1920 x 1080&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The scene
is rendered into an off-screen texture (FBO).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Then that
texture is stretched to the screen using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;GL_NEAREST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;filtering.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;This
creates large visible pixels.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;glTexParameteri(&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GL_TEXTURE_2D,&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GL_TEXTURE_MIN_FILTER,&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GL_NEAREST&lt;br /&gt;
);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;3. Quantized Lighting&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Instead
of smooth lighting:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;float diffuse = max(dot(N, L), 0.0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;you
reduce it to a few discrete levels.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;float diffuse = max(dot(N, L), 0.0);&lt;br /&gt;
&lt;br /&gt;
diffuse = floor(diffuse * 4.0) / 4.0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;This produces
only 4 brightness levels.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Result:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l3 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Bright region &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l3 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Mid-bright &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l3 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Mid-dark &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l3 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Dark &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Very
similar to retro sprite shading.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;4. Palette Reduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Pixel-art
renderers often limit colors intentionally.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;vec3 color = baseColor * diffuse;&lt;br /&gt;
&lt;br /&gt;
color = floor(color * 8.0) / 8.0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;This
converts continuous colors into a small palette.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Instead
of thousands of shades, you might have:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l5 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;8 reds &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l5 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;8 grays &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l5 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;8 blacks &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;giving a
classic pixel-art appearance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;5. Pixel Grid Snapping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Many
projects quantize screen coordinates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;vec2 pixelSize = vec2(4.0);&lt;br /&gt;
&lt;br /&gt;
vec2 snappedUV =&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;floor(gl_FragCoord.xy / pixelSize)&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;* pixelSize;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;All
fragments within a block sample the same value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;This
creates chunky pixels even when rendering at higher resolutions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;6. Dithering&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;To fake
additional colors, retro-style renderers often use dithering.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Common
patterns:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Bayer Matrix&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;8&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;2 10&lt;br /&gt;
12 4 14 6&lt;br /&gt;
3 11 1&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;9&lt;br /&gt;
15 7 13 5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Shader:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;if(diffuse &amp;lt; threshold)&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;color *= 0.8;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;This
creates the checkerboard patterns often seen in pixel art.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;7. Outline Rendering&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Many
stylized renders add outlines.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Two
common methods:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Inverted Hull&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Render
the model twice:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l2 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Normal render &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l2 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Render enlarged backfaces in
     black &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;position += normal * 0.02;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Produces
a cartoon outline.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Edge Detection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Run a
post-process pass using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l1 level1 lfo6; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Depth buffer &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l1 level1 lfo6; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Normal buffer &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Detect
sharp changes and draw black edges.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;8. Shadow Quantization&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;If the
image has sharp, stylized shadows, they may use toon shading:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;if(diffuse &amp;gt; 0.7)&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;shade = 1.0;&lt;br /&gt;
else if(diffuse &amp;gt; 0.4)&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;shade = 0.7;&lt;br /&gt;
else&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;shade = 0.3;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Instead
of smooth gradients, you get discrete shadow bands.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;9. Specular Highlights&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The shiny
white highlight on the Poké Ball can be stylized:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;float spec =&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pow(max(dot(R, V), 0.0), 32.0);&lt;br /&gt;
&lt;br /&gt;
spec = step(0.5, spec);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Using &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;step()&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt; creates a hard-edged highlight instead of a
realistic glossy reflection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot; /&gt;

&lt;/span&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 18.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;10. Typical Rendering Pipeline&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;A common
pipeline would be:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sphere Mesh&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Vertex Shader&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Toon Lighting&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Palette Reduction&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Render to Low-Res FBO&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Nearest Neighbor Upscaling&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Dithering Pass&lt;br /&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;↓&lt;br /&gt;
Display&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;The
characteristic &quot;3D object that looks like pixel art&quot; usually comes
primarily from:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l0 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Rendering to a very
     low-resolution framebuffer &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l0 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Nearest-neighbor upscaling &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l0 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Quantized (toon) lighting &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l0 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Palette reduction &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
 &lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-list: l0 level1 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Optional dithering and
     outlines &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Those
five techniques together can make a smooth 3D OpenGL model look remarkably
similar to hand-drawn pixel art while still being fully real-time and
rotatable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;It can be generate via below mentioned stacks -&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;li data-end=&quot;314&quot; data-section-id=&quot;1gng5k9&quot; data-start=&quot;255&quot;&gt;&lt;strong data-end=&quot;277&quot; data-start=&quot;258&quot;&gt;PyOpenGL + GLFW&lt;/strong&gt; (closest to modern OpenGL tutorials)
&lt;/li&gt;&lt;li data-end=&quot;339&quot; data-section-id=&quot;1hveuub&quot; data-start=&quot;315&quot;&gt;
&lt;strong data-end=&quot;339&quot; data-start=&quot;318&quot;&gt;PyOpenGL + Pygame&lt;/strong&gt;
&lt;/li&gt;&lt;li data-end=&quot;390&quot; data-section-id=&quot;83thy8&quot; data-start=&quot;340&quot;&gt;
&lt;strong data-end=&quot;355&quot; data-start=&quot;343&quot;&gt;moderngl&lt;/strong&gt; (cleaner Python API, often easier)
&lt;/li&gt;&lt;li data-end=&quot;404&quot; data-section-id=&quot;1l21td8&quot; data-start=&quot;391&quot;&gt;
&lt;strong data-end=&quot;404&quot; data-start=&quot;394&quot;&gt;Pyglet&lt;/strong&gt;
&lt;/li&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;



&lt;/p&gt;&lt;li data-end=&quot;440&quot; data-section-id=&quot;sqqcld&quot; data-start=&quot;405&quot;&gt;
&lt;strong data-end=&quot;418&quot; data-start=&quot;408&quot;&gt;Ursina&lt;/strong&gt; (higher-level engine)&lt;/li&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/p&gt;

&lt;!--[ Download Box ]--&gt;
&lt;div class=&#39;dlBox&#39;&gt;
  &lt;!--[ Change data-text=&#39;...&#39; atribute to add new file type ]--&gt;
  &lt;span class=&#39;fT&#39; data-text=&#39;Doc&#39;&gt;&lt;/span&gt;
  &lt;div class=&#39;fN&#39;&gt;
    &lt;!--[ File name ]--&gt;
    &lt;span&gt;Google Doc&lt;/span&gt;
    &lt;span class=&#39;fS&#39;&gt;7 KB&lt;/span&gt;
  &lt;/div&gt;

  &lt;!--[ Download link (change href=&#39;...&#39; atribute to add link download) ]--&gt;
  &lt;a class=&#39;button&#39; aria-label=&#39;Download&#39; href=&#39;https://docs.google.com/document/d/1SDgkkOGE0i66-THoxS1G7-6pHYQwdstLewzz_czHjzM/edit?usp=sharing&#39; rel=&#39;nofollow noreferrer noopener&#39; target=&#39;_blank&#39;&gt;&lt;i class=&#39;icon dl&#39;&gt;&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4160398649736193444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/06/opengl-python-program-for-rendering-poke-ball.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4160398649736193444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4160398649736193444'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/06/opengl-python-program-for-rendering-poke-ball.html' title='OpenGL Python Program for Rendering Poké Ball'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-7115812019163201060</id><published>2026-05-16T01:42:09.679+05:30</published><updated>2026-05-16T01:52:46.503+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Artificial intelligence"/><title type='text'>Artificial intelligence and OpenGL </title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.khronos.org/assets/uploads/apis/ml-page-banner-v2.webp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Artificial intelligence and OpenGL&quot; border=&quot;0&quot; data-original-height=&quot;350&quot; data-original-width=&quot;1180&quot; height=&quot;190&quot; src=&quot;https://www.khronos.org/assets/uploads/apis/ml-page-banner-v2.webp&quot; title=&quot;Artificial intelligence and OpenGL&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&amp;nbsp;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Artificial intelligence and OpenGL work together to create graphics and interactive systems. OpenGL is a graphics tool that lets programs draw pictures by talking to the computers graphics card. Artificial intelligence adds intelligence by generating pictures improving how things are drawn and driving behavior in time.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;For someone who just graduated there are some examples. Artificial intelligence can generate textures, meshes and environments. This means you do not have to make every picture by hand. Artificial intelligence can produce high-quality textures. Suggest simpler meshes that still look good but are easier to make. When it comes to drawing pictures artificial intelligence techniques like denoising and superresolution help make clean pictures faster. Artificial intelligence removes noise from pictures. Makes them bigger and OpenGL shows the final picture efficiently.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Artificial intelligence also makes things more interactive. It can teach characters to move naturally in scenes that follow physics rules. Artificial intelligence can also create motion without needing to set lots of key frames. On the performance side artificial intelligence can predict which objects need to look really detailed and which can be simpler. This helps programs run smoothly on computers that&#39;re not very powerful.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;As someone who&#39;s new to this field you should focus on learning the basics of OpenGL, such as shaders, buffers and textures. You should also study how artificial intelligence is used in real-world applications like using neural networks for pictures and small models for real-time use. Some challenges you might face include managing latency and memory for models and making sure the artificial intelligence output looks the way you want it to. If you master both OpenGL and artificial intelligence you can have a career, in game engines, simulation and real-time graphics tools.&lt;/p&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;Advances in graphics and artificial intelligence (AI) are changing many parts of our lives—from how cars learn to drive, to how doctors see inside the body, to the games we play. OpenGL-style graphics APIs and modern GPU-based rendering create realistic visual worlds, while AI analyzes those visuals to make decisions, find patterns, or create new content. Below are five important ways these two technologies collaborate in the real world.&lt;/p&gt;&lt;h2 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;Self-Driving Car Simulation&lt;/h2&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Self-driving cars need huge amounts of visual experience to learn safe driving. Companies such as NVIDIA use GPU rendering similar to OpenGL to generate realistic 3D scenes that include roads, traffic, lighting, pedestrians, and weather. These simulated environments give AI systems—using computer vision and reinforcement learning—safe and repeatable places to practice. From these training sessions, AI learns tasks like lane detection, recognizing pedestrians, and understanding traffic signs. Key technologies behind this work include OpenGL or Vulkan for rendering, neural networks for perception and decision-making, and GPU acceleration tools such as CUDA and TensorRT for fast model training and inference.&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;AI-Powered Medical Imaging&lt;/h2&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Medical teams use powerful graphics and AI to improve diagnosis and planning. OpenGL-style rendering helps visualize MRI and CT scans as interactive 3D views of organs and tissues, making it easier for doctors to explore inside the body. AI analyzes those images to detect tumors, fractures, or other abnormalities automatically. Together, these tools support cancer detection, surgical planning, and organ reconstruction. Major companies working in this area include Siemens Healthineers and GE HealthCare, which combine advanced visualization with AI-driven image analysis.&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;Modern Video Games&lt;/h2&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Video games blend rendering and AI to create immersive, believable worlds. Graphics APIs render environments, shadows, particles, and animations, while AI controls non-player characters (NPCs), plans enemy tactics, generates landscapes procedurally, and improves visuals through real-time upscaling. This combination creates smarter enemies, AI-generated terrain, and better real-time lighting or ray-reconstruction effects. Popular engines and games that use these ideas include Unity, Unreal Engine, and titles like Minecraft that demonstrate procedural generation and AI-driven behaviors.&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;AI + OpenGL in Robotics&lt;/h2&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Robots must perceive and navigate complex spaces. OpenGL-style rendering is used to build virtual training environments where AI vision systems learn tasks such as navigation, object detection, and motion planning. Simulated practice helps robots prepare for real-world jobs like warehouse picking, drone navigation, and industrial automation without risking hardware. Companies such as Boston Dynamics and Open Robotics develop robotic systems that rely on simulation and AI to improve reliability and safety.&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;AI Face Filters &amp;amp; Augmented Reality Applications&lt;/h2&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Augmented reality (AR) apps combine graphics with AI to create fun and useful effects on mobile devices. OpenGL ES renders masks, makeup, and other visual effects in real time, while AI tracks facial landmarks and expressions to place those effects accurately. These systems power features like face filters, virtual makeup, AR gaming, and motion capture in apps such as Instagram and Snapchat, enabling smooth, responsive visuals that react to users’ movements.&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h1 style=&quot;border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; color: #27251e; font-family: pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif; font-size: 16px; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial; text-align: justify;&quot;&gt;Conclusion&lt;/h1&gt;&lt;p class=&quot;my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2&quot; style=&quot;--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: #3b82f680; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: color(srgb 0.980392 0.972549 0.960784); border-color: rgba(39, 26, 0, 0.14); border-style: solid; border-width: 0px; box-sizing: border-box; margin: 1rem 0px 0.5rem; scrollbar-color: initial; scrollbar-width: initial;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span face=&quot;pplxSerif, pplxSerif, ui-serif, Georgia, Cambria, &amp;quot;Hiragino Mincho ProN&amp;quot;, &amp;quot;Yu Mincho&amp;quot;, &amp;quot;Songti SC&amp;quot;, SimSun, &amp;quot;Songti TC&amp;quot;, PMingLiU, &amp;quot;Songti TC&amp;quot;, MingLiU_HKSCS, &amp;quot;Songti TC&amp;quot;, PMingLiU, AppleMyungjo, Batang, serif&quot; style=&quot;color: #27251e;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;OpenGL-style graphics and AI form a powerful partnership: rendering produces realistic visuals and simulations, while AI interprets or enhances those visuals to perform tasks, make decisions, or create new content. Together, they accelerate innovation in autonomous vehicles, healthcare, gaming, robotics, and augmented reality—fields that students interested in computer graphics, machine learning, or robotics might consider exploring.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;330&quot; src=&quot;https://www.youtube.com/embed/pVEqrVfgwEM&quot; width=&quot;577&quot; youtube-src-id=&quot;pVEqrVfgwEM&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/7115812019163201060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/05/artificial-intelligence-and-opengl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7115812019163201060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7115812019163201060'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/05/artificial-intelligence-and-opengl.html' title='Artificial intelligence and OpenGL '/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/pVEqrVfgwEM/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4331493042195063215</id><published>2026-05-16T01:23:25.725+05:30</published><updated>2026-08-26T02:36:58.282+05:30</updated><title type='text'>Animated University Campus Using OpenGL GLUT</title><content type='html'>&lt;!--[ Alert outlined ]--&gt;
&lt;div class=&#39;alert outline&#39;&gt;&lt;b&gt;
        &lt;/b&gt;
  Animated University Campus Using OpenGL &amp; C++.&lt;/br&gt;
  Learn Computer Graphics by Building a Real Animated Campus Scene.
&lt;/div&gt;


        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Project Introduction&lt;/h2&gt;
        &lt;p&gt;
           Computer Graphics is one of the most exciting areas of programming because it allows us to create visual worlds using code. In this project, we developed a fully animated university campus scene using OpenGL with GLUT in C++.

The project demonstrates how basic graphics primitives such as polygons, circles, and lines can be combined to create an interactive animated environment.

        &lt;/p&gt;

        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Project Overview&lt;/h2&gt;

        &lt;p&gt;
            In this project, we created a fully animated university campus using 
            &lt;strong&gt;OpenGL with GLUT in C++&lt;/strong&gt;.
        &lt;/p&gt;

        &lt;p&gt;
            The scene includes buildings, football ground, moving vehicles,
            animated students, birds, rain effects, day/night mode,
            and several interactive graphics features.
        &lt;/p&gt;
 &lt;!--[ Defer YouTube ]--&gt;
&lt;div class=&#39;videoYt&#39;&gt;
  &lt;iframe class=&#39;lazyload&#39; data-src=&#39;https://www.youtube.com/embed/J2d-SBR8cyU?si=CzaA5z2LJhX6CysX&#39; title=&#39;YouTube video player&#39; frameborder=&#39;0&#39; allow=&#39;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#39; referrerpolicy=&#39;strict-origin-when-cross-origin&#39; allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;   
   
        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Features Included&lt;/h2&gt;
      &lt;p&gt;The campus simulation includes:&lt;/p&gt;



        &lt;ul style=&quot;font-size:18px;&quot;&gt;

            &lt;li&gt;A large university building&lt;/li&gt;
            &lt;li&gt; Football Ground with Goal Posts&lt;/li&gt;
            &lt;li&gt; Animated Students&lt;/li&gt;
            &lt;li&gt;Moving Cars and Buses&lt;/li&gt;
            &lt;li&gt; Flying Airplane&lt;/li&gt;
            &lt;li&gt; Rain Effect&lt;/li&gt;
            &lt;li&gt; Day and Night Mode&lt;/li&gt;
            &lt;li&gt; Animated White Flag&lt;/li&gt;
         	 &lt;li&gt;Trees and park area&lt;/li&gt;
            &lt;li&gt; University Gate&lt;/li&gt;
            &lt;li&gt; Fountain Animation&lt;/li&gt;
            &lt;li&gt; Birds and Clouds&lt;/li&gt;
            &lt;li&gt; User interaction using keyboard controls&lt;/li&gt;

        &lt;/ul&gt;
      
      &lt;p&gt;  This project is ideal for beginners who want to learn:&lt;/p&gt;
 &lt;ul style=&quot;font-size:18px;&quot;&gt;
 &lt;li&gt;OpenGL fundamentals&lt;/li&gt;

 &lt;li&gt;2D graphics drawing&lt;/li&gt;

 &lt;li&gt;Animation techniques&lt;/li&gt;

 &lt;li&gt;Event handling&lt;/li&gt;

 &lt;li&gt;User interaction&lt;/li&gt;

 &lt;li&gt;Real-time rendering&lt;/li&gt;


        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Technologies Used&lt;/h2&gt;

        &lt;div style=&quot;display:flex; gap:20px; flex-wrap:wrap;&quot;&gt;

            &lt;div style=&quot;background:#eff6ff; padding:15px 25px; border-radius:8px;&quot;&gt;
                C++
            &lt;/div&gt;

            &lt;div style=&quot;background:#eff6ff; padding:15px 25px; border-radius:8px;&quot;&gt;
                OpenGL
            &lt;/div&gt;

            &lt;div style=&quot;background:#eff6ff; padding:15px 25px; border-radius:8px;&quot;&gt;
                GLUT  (OpenGL Utility Toolkit)
            &lt;/div&gt;

        &lt;/div&gt;



        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Understanding the Graphics Concepts&lt;/h2&gt;

        &lt;h3 style=&quot;color:#2563eb;&quot;&gt;1. Drawing Shapes&lt;/h3&gt;

        &lt;p&gt;
            OpenGL uses vertices to create graphics objects.
            Rectangles, polygons, and circles are combined
            to create buildings, roads, vehicles, and trees.
        &lt;/p&gt;

&lt;pre data-comment=&#39;C++&#39; data-source=&#39;main.cpp&#39;&gt;&lt;code&gt;glBegin(GL_QUADS);
glVertex2f(x,y);
glVertex2f(x+80,y);
glVertex2f(x+80,y+25);
glVertex2f(x,y+25);&lt;/code&gt;&lt;/pre&gt;


        &lt;h3 style=&quot;color:#2563eb;&quot;&gt;2. Animation&lt;/h3&gt;

        &lt;p&gt;
            Animation is achieved by updating object positions
            continuously using timer functions.
        &lt;/p&gt;

&lt;pre data-comment=&#39;C++&#39; data-source=&#39;main.cpp&#39;&gt;&lt;code&gt;planeMove += 1.5f;
carMove += 2.0f;
glutTimerFunc(16, update, 0);&lt;/code&gt;
&lt;/pre&gt;


        &lt;h3 style=&quot;color:#2563eb;&quot;&gt;3. Interactive Controls&lt;/h3&gt;

        &lt;p&gt;
            Keyboard controls allow users to interact with the scene.
        &lt;/p&gt;


&lt;pre data-comment=&#39;C++&#39; data-source=&#39;main.cpp&#39;&gt;&lt;code&gt;case &#39;n&#39;:
    nightMode = !nightMode;
    break;&lt;/code&gt;
&lt;/pre&gt;
&lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Keyboard Controls&lt;/h2&gt;
&lt;div class=&#39;table sticky bordered stripped hovered&#39;&gt;
        &lt;table style=&quot;width:100%; border-collapse:collapse;&quot;&gt;

            &lt;tr style=&quot;background:#1e3a8a; color:white;&quot;&gt;
                &lt;th style=&quot;padding:12px;&quot;&gt;Key&lt;/th&gt;
                &lt;th style=&quot;padding:12px;&quot;&gt;Action&lt;/th&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;N&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Toggle Night Mode&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;R&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Toggle Rain&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;B&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Toggle Bus&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;C&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Toggle Cars&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;P&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Toggle Plane&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;ESC&lt;/td&gt;
                &lt;td style=&quot;padding:12px; border:1px solid #ddd;&quot;&gt;Exit Program&lt;/td&gt;
            &lt;/tr&gt;

        &lt;/table&gt;
&lt;/div&gt;

        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Learning Outcomes&lt;/h2&gt;

        &lt;p&gt;
            After completing this project, students will learn:
        &lt;/p&gt;

        &lt;ul&gt;

            &lt;li&gt;2D Graphics Programming&lt;/li&gt;
            &lt;li&gt;OpenGL Rendering&lt;/li&gt;
            &lt;li&gt;Animation Techniques&lt;/li&gt;
            &lt;li&gt;Interactive Graphics&lt;/li&gt;
            &lt;li&gt;Keyboard Event Handling&lt;/li&gt;
            &lt;li&gt;Coordinate Systems&lt;/li&gt;
            &lt;li&gt;Scene Design&lt;/li&gt;

        &lt;/ul&gt;



        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Future Improvements&lt;/h2&gt;

        &lt;ul&gt;

            &lt;li&gt;3D Buildings&lt;/li&gt;
            &lt;li&gt;Traffic Lights&lt;/li&gt;
            &lt;li&gt;Sound Effects&lt;/li&gt;
            &lt;li&gt;Weather Systems&lt;/li&gt;
            &lt;li&gt;Character Controls&lt;/li&gt;
            &lt;li&gt;Texture Mapping&lt;/li&gt;
            &lt;li&gt;Lighting Effects&lt;/li&gt;

        &lt;/ul&gt;

&lt;h2 style=&quot;color:#1e3a8a;&quot;&gt; OpenGL Project Applications &lt;/h2&gt; &lt;p&gt; OpenGL is widely used in modern software development for: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Game Development&lt;/li&gt; &lt;li&gt;Simulation Systems&lt;/li&gt; &lt;li&gt;Scientific Visualization&lt;/li&gt; &lt;li&gt;Virtual Reality Applications&lt;/li&gt; &lt;li&gt;CAD Software&lt;/li&gt; &lt;li&gt;Animation Systems&lt;/li&gt; &lt;li&gt;Educational Simulations&lt;/li&gt; &lt;li&gt;Interactive User Interfaces&lt;/li&gt; &lt;/ul&gt; &lt;p&gt; By building this animated campus environment, students gain practical understanding of how real-world graphics applications are developed. &lt;/p&gt; &lt;/div&gt;



        &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt;Conclusion&lt;/h2&gt;

        &lt;p&gt;
            This OpenGL campus simulation project is a great way to learn
            computer graphics through practical implementation.
        &lt;/p&gt;

        &lt;p&gt;
            By combining shapes, animation, interaction, and rendering,
            students can build impressive graphical applications using C++.
        &lt;/p&gt;

        &lt;p&gt;
            Continue experimenting and improving the project to explore
            more advanced computer graphics concepts.
        &lt;/p&gt;

 
 &lt;h2 style=&quot;color:#1e3a8a;&quot;&gt; Best OpenGL Project for Beginners &lt;/h2&gt; &lt;p&gt; If you are searching for a beginner-friendly OpenGL project in C++, this animated campus simulation is an excellent choice. It combines graphics rendering, animation, interaction, and scene management into one practical project. &lt;/p&gt; &lt;p&gt; This project is especially useful for: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Computer Graphics Lab Projects&lt;/li&gt; &lt;li&gt;University Assignments&lt;/li&gt; &lt;li&gt;Final Year Projects&lt;/li&gt; &lt;li&gt;OpenGL Practice&lt;/li&gt; &lt;li&gt;C++ Animation Learning&lt;/li&gt; &lt;li&gt;Graphics Programming Portfolio&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; 
      &lt;h3 id=&quot;multi-tabs-code-block&quot;&gt;Frequently Asked Questions (FAQ)&lt;/h3&gt;    
      
 &lt;!--[ Accordion (FAQPage) ]--&gt;
&lt;div class=&#39;showH&#39; itemscope itemtype=&#39;https://schema.org/FAQPage&#39;&gt;
  &lt;details class=&#39;ac alt&#39; itemscope itemprop=&#39;mainEntity&#39; itemtype=&#39;https://schema.org/Question&#39;&gt;
    &lt;summary itemprop=&#39;name&#39;&gt;What is OpenGL?&lt;/summary&gt;
    &lt;div itemscope itemprop=&#39;acceptedAnswer&#39; itemtype=&#39;https://schema.org/Answer&#39;&gt;
      &lt;p itemprop=&#39;text&#39;&gt;OpenGL is a cross-platform graphics library used for developing 2D and 3D graphics applications.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/details&gt;
  &lt;details class=&#39;ac alt&#39; itemscope itemprop=&#39;mainEntity&#39; itemtype=&#39;https://schema.org/Question&#39;&gt;
    &lt;summary itemprop=&#39;name&#39;&gt;What is GLUT?&lt;/summary&gt;
    &lt;div itemscope itemprop=&#39;acceptedAnswer&#39; itemtype=&#39;https://schema.org/Answer&#39;&gt;
      &lt;p itemprop=&#39;text&#39;&gt;GLUT (OpenGL Utility Toolkit) helps developers create OpenGL windows and handle user interactions like keyboard and mouse events.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/details&gt;
  &lt;details class=&#39;ac alt&#39; itemscope itemprop=&#39;mainEntity&#39; itemtype=&#39;https://schema.org/Question&#39;&gt;
    &lt;summary itemprop=&#39;name&#39;&gt;Can beginners learn this project?&lt;/summary&gt;
    &lt;div itemscope itemprop=&#39;acceptedAnswer&#39; itemtype=&#39;https://schema.org/Answer&#39;&gt;
      &lt;p itemprop=&#39;text&#39;&gt;Yes. This project is beginner-friendly and helps students understand graphics programming step by step.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/details&gt;
  &lt;details class=&#39;ac alt&#39; itemscope itemprop=&#39;mainEntity&#39; itemtype=&#39;https://schema.org/Question&#39;&gt;
    &lt;summary itemprop=&#39;name&#39;&gt;Which language is used?&lt;/summary&gt;
    &lt;div itemscope itemprop=&#39;acceptedAnswer&#39; itemtype=&#39;https://schema.org/Answer&#39;&gt;
      &lt;p itemprop=&#39;text&#39;&gt;The project is developed using C++ with OpenGL and GLUT.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;     
      
 &lt;!--[ Note info ]--&gt;
&lt;p class=&#39;note&#39;&gt;&lt;b&gt;Info!&lt;/b&gt;&lt;br/&gt;
  OpenGL Campus Project Tutorial Learn OpenGL graphics programming with practical examples, animated projects, C++ tutorials, and interactive computer graphics concepts. 
&lt;/p&gt; 

&lt;!--[ Alert default ]--&gt;
&lt;div class=&#39;alert&#39;&gt;&lt;b&gt;Keywords:&lt;/b&gt;
 OpenGL project, computer graphics tutorial, GLUT animation, C++ graphics programming, OpenGL campus simulation, beginner OpenGL project.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4331493042195063215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/05/Animated-University-Campus-Using-OpenGL-GLUT.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4331493042195063215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4331493042195063215'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/05/Animated-University-Campus-Using-OpenGL-GLUT.html' title='Animated University Campus Using OpenGL GLUT'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4340931676464317916</id><published>2026-05-11T01:10:56.984+05:30</published><updated>2026-08-26T22:33:29.882+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Insurance"/><title type='text'>Importance of insurance - OpenGL Computer Graphics Projects</title><content type='html'>&lt;!--[ Text Indent paragraph ]--&gt;
&lt;p class=&#39;pIndent&#39;&gt;The Importance of Insurance – OpenGL Computer Graphics Project is a computer graphics-based project developed using OpenGL (Open Graphics Library) to visually demonstrate the concept and importance of insurance. The main purpose of the project is to combine programming and computer graphics to create an interactive and attractive representation of different insurance concepts.&lt;/p&gt;
&lt;!--[ Drop Cap paragraph ]--&gt;
&lt;p&gt;&lt;span class=&#39;dropCap&#39;&gt;I&lt;/span&gt;
nsurance is an important part of financial planning because it provides protection against unexpected risks such as accidents, health problems, property damage, and other unforeseen events. Instead of explaining these concepts only through text, this project presents them using 2D/3D graphical objects, animations, colors, text, and user interaction.&lt;/p&gt;
&lt;h3 id=&quot;paragraph-with-drop-cap&quot;&gt;Objective of the Project&lt;/h3&gt;


&lt;p&gt;The primary objective of this project is to develop an OpenGL-based graphical application that explains the importance of insurance in an easy-to-understand manner.&lt;/p&gt;

&lt;h3 id=&quot;paragraph-with-drop-cap&quot;&gt;The project aims to:&lt;/h3&gt;

&lt;p&gt;Demonstrate the concept of insurance through computer graphics.
Present different types of insurance using visual elements.
Show how insurance provides financial protection during unexpected situations.
Develop an interactive graphical application using OpenGL.
Apply fundamental computer graphics concepts such as shapes, transformations, colors, text rendering, and animation.
Improve understanding of OpenGL programming through a practical project.&lt;/p&gt;

&lt;h3 id=&quot;paragraph-with-drop-cap&quot;&gt;Project Description&lt;/h3&gt;

&lt;p&gt;The project consists of a graphical interface in which different insurance-related scenarios are represented visually. The application can display elements such as a house, car, hospital, family, money, documents, and protection symbols to represent various types of insurance.&lt;/p&gt;


&lt;!--[ Note info ]--&gt;
&lt;p class=&#39;note&#39;&gt;&lt;b&gt;Why Insurance Matters&lt;/b&gt;&lt;br/&gt;
  Insurance provides financial protection, peace of mind, and security for your family during uncertain times. It helps you stay prepared for life’s unexpected challenges.
&lt;/p&gt;

&lt;!--CONTENT--&gt;
&lt;div class=&quot;content&quot;&gt;

    &lt;!--SECTION 1--&gt;
    &lt;section class=&quot;section fade-up&quot;&gt;
        &lt;h2&gt;Benefits of Life Insurance&lt;/h2&gt;

        &lt;div class=&quot;image-card&quot;&gt;
            &lt;img alt=&quot;Life Insurance&quot; src=&quot;YOUR_IMAGE_URL_1&quot; /&gt;
        &lt;/div&gt;
&lt;/section&gt;
        &lt;p&gt;
            Life insurance protects your loved ones financially in case of emergencies.
            It provides income replacement, supports children’s education,
            and ensures your family can maintain their lifestyle.
        &lt;/p&gt;
    
  &lt;!--[ Tabs, remove classname &#39;stick&#39; to disable floating title ]--&gt;
&lt;div class=&#39;tabs stick&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;tabT-1&#39; type=&#39;radio&#39; name=&#39;postTabs&#39; checked=&#39;&#39;&gt;
  &lt;input id=&#39;tabT-2&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;
  &lt;input id=&#39;tabT-3&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;
  &lt;input id=&#39;tabT-4&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;

  &lt;!--[ Tabs header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace tabs title ]--&gt;
    &lt;label for=&#39;tabT-1&#39; data-text=&#39;Family Protection&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-2&#39; data-text=&#39;Financial Security&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-3&#39; data-text=&#39;Stress Reduction&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-4&#39; data-text=&#39;Legacy Planning&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-1&#39;&gt;
   Ensures your family remains financially secure after your absence.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-2&#39;&gt;
    Helps cover loans, expenses, and future commitments.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-3&#39;&gt;
  Reduces financial pressure during difficult moments.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-4&#39;&gt;
   Allows you to leave behind support for future generations.
  &lt;/div&gt;
&lt;/div&gt;

    &lt;!--SECTION 2--&gt;
    &lt;section class=&quot;section fade-up&quot;&gt;
        &lt;h2&gt;Who Needs Insurance?&lt;/h2&gt;

        &lt;div class=&quot;image-card&quot;&gt;
            &lt;img alt=&quot;Who Needs Insurance&quot; src=&quot;YOUR_IMAGE_URL_2&quot; /&gt;
        &lt;/div&gt;

        &lt;p&gt;
            Insurance is important for parents, homeowners, business owners,
            and anyone with financial responsibilities.
            It protects families, assets, and future goals.
        &lt;/p&gt;
    &lt;/section&gt;

    &lt;!--SECTION 3--&gt;
    &lt;section class=&quot;section fade-up&quot;&gt;
        &lt;h2&gt;Importance of Insurance for Everyone&lt;/h2&gt;

        &lt;div class=&quot;image-card&quot;&gt;
            &lt;img alt=&quot;Importance of Insurance&quot; src=&quot;YOUR_IMAGE_URL_3&quot; /&gt;
        &lt;/div&gt;

        &lt;p&gt;
            Insurance is not just a policy — it is a safety net that protects your dreams and hard work.
            From medical emergencies to financial planning,
            insurance secures a stable future.
        &lt;/p&gt;

        &lt;div class=&quot;quote&quot;&gt;
            &lt;h3&gt;“”&lt;/h3&gt;
            &lt;p&gt;
               
            &lt;/p&gt;
        &lt;/div&gt;
    &lt;/section&gt;
  
  &lt;!--[ Blockquote (Style 1) ]--&gt;
&lt;blockquote class=&#39;s2&#39;&gt;
  &lt;p&gt;Insurance is a small investment for a secure tomorrow. Protect yourself, your family, and your future with the right coverage.&lt;/p&gt;
  &lt;span&gt;Anonymous&lt;/span&gt;
&lt;/blockquote&gt;

    &lt;!--SECTION 4--&gt;
    &lt;section class=&quot;section fade-up&quot;&gt;
        &lt;h2&gt;Why Buy Term Insurance?&lt;/h2&gt;

        &lt;div class=&quot;image-card&quot;&gt;
            &lt;img alt=&quot;Term Insurance&quot; src=&quot;YOUR_IMAGE_URL_4&quot; /&gt;
        &lt;/div&gt;

        &lt;p&gt;
            Term insurance offers high coverage at affordable premiums.
            It protects dependents financially and safeguards your future goals.
        &lt;/p&gt;

        &lt;div class=&quot;benefits-grid&quot;&gt;

            &lt;div class=&quot;benefit-box&quot;&gt;
                &lt;h3&gt;Affordable Premiums&lt;/h3&gt;
                &lt;p&gt;Get large coverage at a lower cost.&lt;/p&gt;
            &lt;/div&gt;

            &lt;div class=&quot;benefit-box&quot;&gt;
                &lt;h3&gt;Protect Dependents&lt;/h3&gt;
                &lt;p&gt;Ensures your family can manage expenses after your loss.&lt;/p&gt;
            &lt;/div&gt;

            &lt;div class=&quot;benefit-box&quot;&gt;
                &lt;h3&gt;Asset Protection&lt;/h3&gt;
                &lt;p&gt;Helps preserve savings and investments.&lt;/p&gt;
            &lt;/div&gt;

            &lt;div class=&quot;benefit-box&quot;&gt;
                &lt;h3&gt;Life Goal Support&lt;/h3&gt;
                &lt;p&gt;Supports future goals like education and stability.&lt;/p&gt;
            &lt;/div&gt;

        &lt;/div&gt;
    &lt;/section&gt;

&lt;/div&gt;
&lt;!--[ Tabs, remove classname &#39;stick&#39; to disable floating title ]--&gt;
&lt;div class=&#39;tabs stick&#39;&gt;
  &lt;!--[ Active function ]--&gt;
  &lt;input id=&#39;tabT-1&#39; type=&#39;radio&#39; name=&#39;postTabs&#39; checked=&#39;&#39;&gt;
  &lt;input id=&#39;tabT-2&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;
  &lt;input id=&#39;tabT-3&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;
  &lt;input id=&#39;tabT-4&#39; type=&#39;radio&#39; name=&#39;postTabs&#39;&gt;

  &lt;!--[ Tabs header/title ]--&gt;
  &lt;div&gt;
    &lt;!--[ Change atribute data-text=&#39;...&#39; to replace tabs title ]--&gt;
    &lt;label for=&#39;tabT-1&#39; data-text=&#39;Affordable Premiums&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-2&#39; data-text=&#39;Protect Dependents&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-3&#39; data-text=&#39;Asset Protection&#39;&gt;&lt;/label&gt;
    &lt;label for=&#39;tabT-4&#39; data-text=&#39;Life Goal Support&#39;&gt;&lt;/label&gt;
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-1&#39;&gt;
   Get large coverage at a lower cost.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-2&#39;&gt;
    Ensures your family can manage expenses after your loss.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-3&#39;&gt;
   Helps preserve savings and investments.
  &lt;/div&gt;
  
  &lt;!--[ Tabs content ]--&gt;
  &lt;div class=&#39;tabC-4&#39;&gt;
    Supports future goals like education and stability.
  &lt;/div&gt;
&lt;/div&gt;
&lt;!--[ Alert variant success ]--&gt;
&lt;div class=&#39;alert success&#39;&gt;&lt;b&gt;End of Article&lt;/b&gt;
  OpenGL Computer Graphics Project
&lt;/div&gt;
&lt;!--[ Button with download icon ]--&gt;
&lt;a class=&#39;button&#39; href=&#39;https://drive.google.com/file/d/1uhkbGp48CJysRWuYB7hympiPdeBfxW02/view?usp=drive_link&#39;&gt;&lt;i class=&#39;icon dl&#39;&gt;&lt;/i&gt;Download Source Code&lt;/a&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4340931676464317916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/05/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4340931676464317916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4340931676464317916'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/05/blog-post.html' title='Importance of insurance - OpenGL Computer Graphics Projects'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-7862635539385251305</id><published>2026-05-11T00:52:45.385+05:30</published><updated>2026-05-11T00:52:45.385+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Batman"/><title type='text'>BATMAN OPENGL COMPUTER GRAPHICS PROJECT USING C++  | With Source Code and Report</title><content type='html'>&lt;p&gt;&amp;nbsp;OpenGL Project (C++ + GLUT)&lt;/p&gt;&lt;p data-end=&quot;126&quot; data-start=&quot;62&quot;&gt;This project is a simple &lt;strong data-end=&quot;114&quot; data-start=&quot;87&quot;&gt;2D graphics application&lt;/strong&gt; made using:&lt;/p&gt;&lt;ul data-end=&quot;185&quot; data-start=&quot;127&quot;&gt;
&lt;li data-end=&quot;136&quot; data-section-id=&quot;d66eyz&quot; data-start=&quot;127&quot;&gt;
&lt;strong data-end=&quot;136&quot; data-start=&quot;129&quot;&gt;C++&lt;/strong&gt;
&lt;/li&gt;
&lt;li data-end=&quot;149&quot; data-section-id=&quot;yzbmbb&quot; data-start=&quot;137&quot;&gt;
&lt;strong data-end=&quot;149&quot; data-start=&quot;139&quot;&gt;OpenGL&lt;/strong&gt;
&lt;/li&gt;
&lt;li data-end=&quot;185&quot; data-section-id=&quot;y3mkc2&quot; data-start=&quot;150&quot;&gt;
&lt;strong data-end=&quot;185&quot; data-start=&quot;152&quot;&gt;GLUT (OpenGL Utility Toolkit)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;h1 data-end=&quot;831&quot; data-section-id=&quot;zpkhl5&quot; data-start=&quot;820&quot;&gt;OBJECTIVE&lt;/h1&gt;&lt;p data-end=&quot;872&quot; data-start=&quot;833&quot;&gt;The main objectives of the project are:&lt;/p&gt;&lt;p data-end=&quot;1362&quot; data-start=&quot;1354&quot;&gt;

&lt;/p&gt;&lt;ul data-end=&quot;1078&quot; data-start=&quot;874&quot;&gt;
&lt;li data-end=&quot;917&quot; data-section-id=&quot;jee5s4&quot; data-start=&quot;874&quot;&gt;
To understand OpenGL graphics programming
&lt;/li&gt;
&lt;li data-end=&quot;954&quot; data-section-id=&quot;1fvencq&quot; data-start=&quot;918&quot;&gt;
To implement 2D graphics using C++
&lt;/li&gt;
&lt;li data-end=&quot;999&quot; data-section-id=&quot;fxeawy&quot; data-start=&quot;955&quot;&gt;
To create animations using timer functions
&lt;/li&gt;
&lt;li data-end=&quot;1040&quot; data-section-id=&quot;s3u0gv&quot; data-start=&quot;1000&quot;&gt;
To learn keyboard interaction handling
&lt;/li&gt;
&lt;li data-end=&quot;1078&quot; data-section-id=&quot;182j15j&quot; data-start=&quot;1041&quot;&gt;
To design multiple graphical scenes&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h1 data-end=&quot;1490&quot; data-section-id=&quot;j7j6n5&quot; data-start=&quot;1471&quot;&gt;TECHNOLOGIES USED&lt;/h1&gt;
&lt;h2 data-end=&quot;1501&quot; data-section-id=&quot;z04krd&quot; data-start=&quot;1492&quot;&gt;1. C++&lt;/h2&gt;
&lt;p data-end=&quot;1561&quot; data-start=&quot;1502&quot;&gt;Used for implementing program logic and graphics functions.&lt;/p&gt;
&lt;h2 data-end=&quot;1575&quot; data-section-id=&quot;e6uo2u&quot; data-start=&quot;1563&quot;&gt;2. OpenGL&lt;/h2&gt;
&lt;p data-end=&quot;1612&quot; data-start=&quot;1576&quot;&gt;Used for rendering graphics objects.&lt;/p&gt;
&lt;h2 data-end=&quot;1624&quot; data-section-id=&quot;1mtukaa&quot; data-start=&quot;1614&quot;&gt;3. GLUT&lt;/h2&gt;
&lt;p data-end=&quot;1634&quot; data-start=&quot;1625&quot;&gt;Used for:&lt;/p&gt;
&lt;ul data-end=&quot;1714&quot; data-start=&quot;1635&quot;&gt;
&lt;li data-end=&quot;1652&quot; data-section-id=&quot;1cdaf1n&quot; data-start=&quot;1635&quot;&gt;
Window handling
&lt;/li&gt;
&lt;li data-end=&quot;1675&quot; data-section-id=&quot;7n0o67&quot; data-start=&quot;1653&quot;&gt;
Keyboard interaction
&lt;/li&gt;
&lt;li data-end=&quot;1693&quot; data-section-id=&quot;fmtzxa&quot; data-start=&quot;1676&quot;&gt;
Timer functions
&lt;/li&gt;
&lt;li data-end=&quot;1714&quot; data-section-id=&quot;retrxd&quot; data-start=&quot;1694&quot;&gt;
Display management&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h1 data-end=&quot;2745&quot; data-section-id=&quot;frmztu&quot; data-start=&quot;2721&quot;&gt;WORKING OF THE PROJECT&lt;/h1&gt;
&lt;ol data-end=&quot;3042&quot; data-start=&quot;2747&quot;&gt;
&lt;li data-end=&quot;2798&quot; data-section-id=&quot;1kmaztp&quot; data-start=&quot;2747&quot;&gt;
The program starts with the introduction screen.
&lt;/li&gt;
&lt;li data-end=&quot;2842&quot; data-section-id=&quot;1scyr04&quot; data-start=&quot;2799&quot;&gt;
User presses &lt;code data-end=&quot;2818&quot; data-start=&quot;2815&quot;&gt;N&lt;/code&gt; to move between scenes.
&lt;/li&gt;
&lt;li data-end=&quot;2896&quot; data-section-id=&quot;ohv1oh&quot; data-start=&quot;2843&quot;&gt;
Gotham city scene displays animated moon movement.
&lt;/li&gt;
&lt;li data-end=&quot;2952&quot; data-section-id=&quot;dl7lzw&quot; data-start=&quot;2897&quot;&gt;
Batman scene displays Batman standing on a building.
&lt;/li&gt;
&lt;li data-end=&quot;2997&quot; data-section-id=&quot;1q0qnji&quot; data-start=&quot;2953&quot;&gt;
Logo scene displays rotating Batman logo.
&lt;/li&gt;
&lt;li data-end=&quot;3042&quot; data-section-id=&quot;4r2cxy&quot; data-start=&quot;2998&quot;&gt;
Thank you screen is displayed at the end.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyBU4TrR1w_47EzVtMXacMqHEj2c-RooJpxO9yoTpoBuOJTBJ0P7u_I_aYbNxGp6K8G6oWjD4mArB8AkTw1rGg_cA6F5WWpn_diRpRACuhqinHZcjLaH7itGqjD5KJ3De5bCGv-2-JoyidAa_-9PG2n3ZzgViUWxslQ0POfsKDWpsFinnL5qzXxPDs1ILI/s985/BATMAN%20OPENGL%20COMPUTER%20GRAPHICS%20PROJECT%20USING%20C%201.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;724&quot; data-original-width=&quot;985&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyBU4TrR1w_47EzVtMXacMqHEj2c-RooJpxO9yoTpoBuOJTBJ0P7u_I_aYbNxGp6K8G6oWjD4mArB8AkTw1rGg_cA6F5WWpn_diRpRACuhqinHZcjLaH7itGqjD5KJ3De5bCGv-2-JoyidAa_-9PG2n3ZzgViUWxslQ0POfsKDWpsFinnL5qzXxPDs1ILI/s320/BATMAN%20OPENGL%20COMPUTER%20GRAPHICS%20PROJECT%20USING%20C%201.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p data-end=&quot;1362&quot; data-start=&quot;1354&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;h1 data-end=&quot;3065&quot; data-section-id=&quot;9etkee&quot; data-start=&quot;3049&quot;&gt;OUTPUT SCREENS&lt;/h1&gt;&lt;h2 data-end=&quot;3077&quot; data-section-id=&quot;1t014oa&quot; data-start=&quot;3067&quot;&gt;Scene 1&lt;/h2&gt;&lt;p data-end=&quot;3098&quot; data-start=&quot;3078&quot;&gt;College Intro Screen&lt;/p&gt;&lt;h2 data-end=&quot;3110&quot; data-section-id=&quot;1t014o9&quot; data-start=&quot;3100&quot;&gt;Scene 2&lt;/h2&gt;&lt;p data-end=&quot;3131&quot; data-start=&quot;3111&quot;&gt;Animated Gotham City&lt;/p&gt;&lt;h2 data-end=&quot;3143&quot; data-section-id=&quot;1t014o8&quot; data-start=&quot;3133&quot;&gt;Scene 3&lt;/h2&gt;&lt;p data-end=&quot;3171&quot; data-start=&quot;3144&quot;&gt;Batman Standing on Building&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii5gyaxGpFf_1Ge-eJb6CMgCsTUmATCqTefIPBG2bqis99KER4QXGXT1zfhdIOawMO9aLKyl-WjiGe3p3yNE3DQ4d7jBxEJksAtvp7wK09Eri6WgFcs17YV8iPe0A1rVjfJ2McveTBuEz2tKUlKfXjnoXqKuU-CxC6f3gHV3XA3diliuUOkj648X-ZbLOS/s973/BATMAN%20OPENGL%20COMPUTER%20GRAPHICS%20PROJECT%20USING%20C%202.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;688&quot; data-original-width=&quot;973&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii5gyaxGpFf_1Ge-eJb6CMgCsTUmATCqTefIPBG2bqis99KER4QXGXT1zfhdIOawMO9aLKyl-WjiGe3p3yNE3DQ4d7jBxEJksAtvp7wK09Eri6WgFcs17YV8iPe0A1rVjfJ2McveTBuEz2tKUlKfXjnoXqKuU-CxC6f3gHV3XA3diliuUOkj648X-ZbLOS/s320/BATMAN%20OPENGL%20COMPUTER%20GRAPHICS%20PROJECT%20USING%20C%202.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 data-end=&quot;3183&quot; data-section-id=&quot;1t014of&quot; data-start=&quot;3173&quot;&gt;Scene 4&lt;/h2&gt;&lt;p data-end=&quot;3204&quot; data-start=&quot;3184&quot;&gt;Rotating Batman Logo&lt;/p&gt;&lt;h2 data-end=&quot;3216&quot; data-section-id=&quot;1t014oe&quot; data-start=&quot;3206&quot;&gt;Scene 5&lt;/h2&gt;&lt;p data-end=&quot;3233&quot; data-start=&quot;3217&quot;&gt;&lt;/p&gt;Thank You Screen&lt;p&gt;&lt;/p&gt;&lt;hr data-end=&quot;3238&quot; data-start=&quot;3235&quot; /&gt;&lt;h1 data-end=&quot;3252&quot; data-section-id=&quot;1mutcm6&quot; data-start=&quot;3240&quot;&gt;ADVANTAGES&lt;/h1&gt;&lt;ul data-end=&quot;3430&quot; data-start=&quot;3254&quot;&gt;
&lt;li data-end=&quot;3285&quot; data-section-id=&quot;1dif2l8&quot; data-start=&quot;3254&quot;&gt;
Simple and easy to understand
&lt;/li&gt;
&lt;li data-end=&quot;3314&quot; data-section-id=&quot;uodymd&quot; data-start=&quot;3286&quot;&gt;
Demonstrates OpenGL basics
&lt;/li&gt;
&lt;li data-end=&quot;3355&quot; data-section-id=&quot;1x43spk&quot; data-start=&quot;3315&quot;&gt;
Includes animation and transformations
&lt;/li&gt;
&lt;li data-end=&quot;3390&quot; data-section-id=&quot;uhv7hr&quot; data-start=&quot;3356&quot;&gt;
Interactive graphics application
&lt;/li&gt;
&lt;li data-end=&quot;3430&quot; data-section-id=&quot;13ozpt5&quot; data-start=&quot;3391&quot;&gt;
Useful for learning computer graphics
&lt;/li&gt;
&lt;/ul&gt;&lt;hr data-end=&quot;3435&quot; data-start=&quot;3432&quot; /&gt;&lt;h1 data-end=&quot;3450&quot; data-section-id=&quot;14ghrct&quot; data-start=&quot;3437&quot;&gt;LIMITATIONS&lt;/h1&gt;&lt;p data-end=&quot;1362&quot; data-start=&quot;1354&quot;&gt;















&lt;/p&gt;&lt;ul data-end=&quot;3536&quot; data-start=&quot;3452&quot;&gt;
&lt;li data-end=&quot;3475&quot; data-section-id=&quot;15w33tb&quot; data-start=&quot;3452&quot;&gt;
Uses only 2D graphics
&lt;/li&gt;
&lt;li data-end=&quot;3497&quot; data-section-id=&quot;1s9gnbp&quot; data-start=&quot;3476&quot;&gt;
Basic Batman design
&lt;/li&gt;
&lt;li data-end=&quot;3516&quot; data-section-id=&quot;gqw9se&quot; data-start=&quot;3498&quot;&gt;
No sound effects
&lt;/li&gt;
&lt;li data-end=&quot;3536&quot; data-section-id=&quot;6vv7yi&quot; data-start=&quot;3517&quot;&gt;
Limited animation&lt;/li&gt;&lt;/ul&gt;&lt;h1 data-end=&quot;3450&quot; data-section-id=&quot;14ghrct&quot; data-start=&quot;3437&quot;&gt;DESIGN AND IMPLEMENTATION&lt;/h1&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Batman&quot;&gt;Batman&lt;/a&gt; is &lt;mark class=&quot;HxTRcb&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 500; margin: 0px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_z&quot; jsaction=&quot;click:&amp;amp;ARuf3c_y|h5M12e;mouseenter:&amp;amp;ARuf3c_y|sbHm2b;mouseleave:&amp;amp;ARuf3c_y|Tx5Rb;rcuQ6b:&amp;amp;ARuf3c_y|npT2md&quot; jscontroller=&quot;DfH0l&quot; jsuid=&quot;ARuf3c_y&quot; style=&quot;border-bottom: 0px rgb(238, 240, 255); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; margin: 0px;&quot;&gt;&lt;!--qkimaf ARuf3c_y/HugV6--&gt;&lt;!--cqw1tb ARuf3c_y/HugV6--&gt;one of the world&#39;s most iconic fictional superheroes, appearing in American comic books published by &lt;span class=&quot;Yjhzub&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; jsaction=&quot;&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;ARuf3c_10&quot; style=&quot;border-bottom: 0px rgb(238, 240, 255); font-weight: 600; margin: 0px;&quot;&gt;&lt;span data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_12&quot; jsaction=&quot;rcuQ6b:&amp;amp;ARuf3c_11|npT2md&quot; jscontroller=&quot;CCvEPd&quot; jsuid=&quot;ARuf3c_11&quot; style=&quot;border-bottom: 0px rgb(238, 240, 255); margin: 0px;&quot;&gt;DC Comics&lt;!--TgQPHd|[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|[]--&gt;&lt;/mark&gt;. Created by artist &lt;span class=&quot;Yjhzub&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; jsaction=&quot;&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;ARuf3c_13&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px;&quot;&gt;&lt;span data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_15&quot; jsaction=&quot;rcuQ6b:&amp;amp;ARuf3c_14|npT2md&quot; jscontroller=&quot;CCvEPd&quot; jsuid=&quot;ARuf3c_14&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); margin: 0px;&quot;&gt;Bob Kane&lt;!--TgQPHd|[]--&gt;&lt;/span&gt;&lt;!--TgQPHd|[]--&gt;&lt;/span&gt; and writer &lt;span class=&quot;Yjhzub&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; jsaction=&quot;&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;ARuf3c_16&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px;&quot;&gt;&lt;span data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_18&quot; jsaction=&quot;rcuQ6b:&amp;amp;ARuf3c_17|npT2md&quot; jscontroller=&quot;CCvEPd&quot; jsuid=&quot;ARuf3c_17&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); margin: 0px;&quot;&gt;Bill Finger.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Yjhzub&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; jsaction=&quot;&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;ARuf3c_16&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px;&quot;&gt;&lt;span data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_18&quot; jsaction=&quot;rcuQ6b:&amp;amp;ARuf3c_17|npT2md&quot; jscontroller=&quot;CCvEPd&quot; jsuid=&quot;ARuf3c_17&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Yjhzub&quot; data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; jsaction=&quot;&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;ARuf3c_16&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); margin: 0px;&quot;&gt;&lt;span data-copy-service-computed-style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);&quot; data-sfc-cb=&quot;&quot; data-sfc-root=&quot;c&quot; data-wiz-uids=&quot;ARuf3c_18&quot; jsaction=&quot;rcuQ6b:&amp;amp;ARuf3c_17|npT2md&quot; jscontroller=&quot;CCvEPd&quot; jsuid=&quot;ARuf3c_17&quot; style=&quot;border-bottom: 0px rgb(230, 232, 240); margin: 0px;&quot;&gt;&lt;h1 data-end=&quot;356&quot; data-section-id=&quot;833lg3&quot; data-start=&quot;339&quot; style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600;&quot;&gt;Header Files&lt;/h1&gt;&lt;div style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600;&quot;&gt;Headaer Files used in for desing and implementation of&amp;nbsp;BATMAN OPENGL COMPUTER GRAPHICS PROJECT USING C++&amp;nbsp; are -&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Google Sans&amp;quot;, Arial, sans-serif; font-size: 16px; font-weight: 600;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Google Sans, Arial, sans-serif;&quot;&gt;&lt;b&gt;1.#include &amp;lt;GL/glut.h&amp;gt; - For&amp;nbsp;&lt;/b&gt;&lt;/span&gt;OpenGL functions and graphics creation and user interations&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Google Sans, Arial, sans-serif;&quot;&gt;&lt;b&gt;2. #include &amp;lt;cmath&amp;gt; -&amp;nbsp;&lt;/b&gt;&lt;/span&gt;Used for:&lt;/div&gt;
&lt;ul data-end=&quot;602&quot; data-start=&quot;583&quot;&gt;
&lt;li data-end=&quot;592&quot; data-section-id=&quot;1lk25gd&quot; data-start=&quot;583&quot;&gt;
&lt;code data-end=&quot;592&quot; data-start=&quot;585&quot;&gt;sin()&lt;/code&gt;
&lt;/li&gt;
&lt;li data-end=&quot;602&quot; data-section-id=&quot;1b63a2e&quot; data-start=&quot;593&quot;&gt;
&lt;code data-end=&quot;602&quot; data-start=&quot;595&quot;&gt;cos()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-end=&quot;636&quot; data-start=&quot;604&quot;&gt;Needed for circles and rotation.&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-family: Google Sans, Arial, sans-serif;&quot;&gt;&lt;b&gt;3. #include &amp;lt;cstring&amp;gt;&amp;nbsp; -&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p data-end=&quot;672&quot; data-start=&quot;663&quot;&gt;Used for:&lt;/p&gt;
&lt;ul data-end=&quot;685&quot; data-start=&quot;673&quot;&gt;
&lt;li data-end=&quot;685&quot; data-section-id=&quot;1i4eb17&quot; data-start=&quot;673&quot;&gt;
&lt;code data-end=&quot;685&quot; data-start=&quot;675&quot;&gt;strlen()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-end=&quot;731&quot; data-start=&quot;687&quot;&gt;Needed to print text character by character.&lt;/p&gt;&lt;p data-end=&quot;731&quot; data-start=&quot;687&quot;&gt;Global Variables :&amp;nbsp;&lt;/p&gt;&lt;h3 data-end=&quot;876&quot; data-section-id=&quot;tnpy0&quot; data-start=&quot;865&quot;&gt;&lt;span role=&quot;text&quot;&gt;&lt;code data-end=&quot;876&quot; data-start=&quot;869&quot;&gt;scene is used a global varaiable for&amp;nbsp;Controls current screen. with keyboard functions assigned for user to shift between the screense&lt;/code&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 data-end=&quot;876&quot; data-section-id=&quot;tnpy0&quot; data-start=&quot;865&quot;&gt;&lt;span role=&quot;text&quot;&gt;&lt;code data-end=&quot;876&quot; data-start=&quot;869&quot;&gt;scene&lt;/code&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p data-end=&quot;901&quot; data-start=&quot;877&quot;&gt;Controls current screen.&lt;/p&gt;&lt;/div&gt;&lt;p data-end=&quot;208&quot; data-start=&quot;187&quot;&gt;The program displays:&lt;/p&gt;&lt;p&gt;


&lt;/p&gt;&lt;ol data-end=&quot;332&quot; data-start=&quot;209&quot;&gt;
&lt;li data-end=&quot;232&quot; data-section-id=&quot;3njspf&quot; data-start=&quot;209&quot;&gt;
College intro screen
&lt;/li&gt;
&lt;li data-end=&quot;257&quot; data-section-id=&quot;1iqjits&quot; data-start=&quot;233&quot;&gt;
Gotham city animation
&lt;/li&gt;
&lt;li data-end=&quot;288&quot; data-section-id=&quot;5mskqe&quot; data-start=&quot;258&quot;&gt;
Batman standing on building
&lt;/li&gt;
&lt;li data-end=&quot;312&quot; data-section-id=&quot;wgspq5&quot; data-start=&quot;289&quot;&gt;
Rotating Batman logo
&lt;/li&gt;
&lt;li data-end=&quot;332&quot; data-section-id=&quot;15wceax&quot; data-start=&quot;313&quot;&gt;
Thank you screen&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Value&lt;/th&gt;&lt;th&gt;Scene&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;Intro&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Gotham City&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Batman&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Logo&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Thank You&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p data-end=&quot;1362&quot; data-start=&quot;1354&quot;&gt;Changes:&lt;/p&gt;&lt;ul data-end=&quot;1392&quot; data-start=&quot;1363&quot;&gt;&lt;li data-end=&quot;1377&quot; data-section-id=&quot;i4ix4h&quot; data-start=&quot;1363&quot;&gt;true → false&lt;/li&gt;&lt;li data-end=&quot;1392&quot; data-section-id=&quot;1esojpt&quot; data-start=&quot;1378&quot;&gt;false → true&lt;/li&gt;&lt;/ul&gt;&lt;p data-end=&quot;1417&quot; data-start=&quot;1394&quot;&gt;Used for blinking text.&amp;nbsp;&lt;/p&gt;&lt;p data-end=&quot;1417&quot; data-start=&quot;1394&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p data-end=&quot;1417&quot; data-start=&quot;1394&quot;&gt;Drawing Circle&lt;/p&gt;&lt;p data-end=&quot;1417&quot; data-start=&quot;1394&quot;&gt;void drawCircle(float cx, float cy, float r)&lt;/p&gt;&lt;p data-end=&quot;1867&quot; data-start=&quot;1858&quot;&gt;Used for:&lt;/p&gt;&lt;p data-end=&quot;1417&quot; data-start=&quot;1394&quot;&gt;
&lt;/p&gt;&lt;ul data-end=&quot;1895&quot; data-start=&quot;1868&quot;&gt;
&lt;li data-end=&quot;1874&quot; data-section-id=&quot;1j3zte3&quot; data-start=&quot;1868&quot;&gt;
Moon
&lt;/li&gt;
&lt;li data-end=&quot;1888&quot; data-section-id=&quot;18ocuol&quot; data-start=&quot;1875&quot;&gt;
Batman head
&lt;/li&gt;
&lt;li data-end=&quot;1895&quot; data-section-id=&quot;1j45xs2&quot; data-start=&quot;1889&quot;&gt;
Eyes&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Creates city buildings using rectangles.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and similarly other polygons are use to create building logo and batman body etc.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Timer Function (Animation)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;void timer(int)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; moonX += 0.002f;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if (moonX &amp;gt; 1.2f)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moonX = -1.2f;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; logoAngle += 2.0f;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if (logoAngle &amp;gt; 360)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logoAngle = 0;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; blink = !blink;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(30, timer, 0);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;glutTimerFunc(30, timer, 0);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p data-end=&quot;1505&quot; data-start=&quot;1465&quot;&gt;Calls timer again every 30 milliseconds.&lt;/p&gt;
&lt;p data-end=&quot;1530&quot; data-start=&quot;1507&quot;&gt;This creates animation.&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IMPORTANT OPENGL FUNCTIONS&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Purpose&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;glBegin()&lt;/td&gt;&lt;td&gt;Start drawing&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glEnd()&lt;/td&gt;&lt;td&gt;End drawing&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glVertex2f()&lt;/td&gt;&lt;td&gt;Define point&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glColor3f()&lt;/td&gt;&lt;td&gt;Set color&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glClear()&lt;/td&gt;&lt;td&gt;Clear screen&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glFlush()&lt;/td&gt;&lt;td&gt;Show drawing&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glRotatef()&lt;/td&gt;&lt;td&gt;Rotate object&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glTranslatef()&lt;/td&gt;&lt;td&gt;Move object&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glPushMatrix()&lt;/td&gt;&lt;td&gt;Save position&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;glPopMatrix()&lt;/td&gt;&lt;td&gt;Restore position&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;h1 data-end=&quot;3755&quot; data-section-id=&quot;a1gw3p&quot; data-start=&quot;3743&quot;&gt;User Interactions&amp;nbsp;&lt;/h1&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Keyboard Function&amp;nbsp;&lt;span class=&quot;ͼm&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;ͼm&quot;&gt;keyboard&lt;/span&gt;(&lt;span class=&quot;ͼm&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;ͼm&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;ͼm&quot;&gt;key&lt;/span&gt;, &lt;span class=&quot;ͼm&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;ͼm&quot;&gt;x&lt;/span&gt;, &lt;span class=&quot;ͼm&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;ͼm&quot;&gt;y&lt;/span&gt;) is used as user interations with scence as said above -&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Key&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;Interaction&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;n&#39;&amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; Next Scene&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;p&#39; -&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Previous Scene&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ESC -&amp;gt;&amp;nbsp; Exit&lt;/div&gt;&lt;h1 data-end=&quot;3755&quot; data-section-id=&quot;a1gw3p&quot; data-start=&quot;3743&quot;&gt;CONCLUSION&lt;/h1&gt;&lt;h1 data-end=&quot;5117&quot; data-section-id=&quot;beilsy&quot; data-start=&quot;5093&quot;&gt;
&lt;p data-end=&quot;3894&quot; data-start=&quot;3757&quot;&gt;The project successfully demonstrates the implementation of computer graphics concepts using OpenGL and C++.&lt;br data-end=&quot;3868&quot; data-start=&quot;3865&quot; /&gt;
It helps in understanding:&lt;/p&gt;
&lt;ul data-end=&quot;3965&quot; data-start=&quot;3895&quot;&gt;
&lt;li data-end=&quot;3915&quot; data-section-id=&quot;ezys5z&quot; data-start=&quot;3895&quot;&gt;
Graphics rendering
&lt;/li&gt;
&lt;li data-end=&quot;3927&quot; data-section-id=&quot;8wggla&quot; data-start=&quot;3916&quot;&gt;
Animation
&lt;/li&gt;
&lt;li data-end=&quot;3946&quot; data-section-id=&quot;w28l6t&quot; data-start=&quot;3928&quot;&gt;
Scene management
&lt;/li&gt;
&lt;li data-end=&quot;3965&quot; data-section-id=&quot;nj5p7n&quot; data-start=&quot;3947&quot;&gt;
User interaction
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-end=&quot;4052&quot; data-start=&quot;3967&quot;&gt;The project is useful for beginners to learn OpenGL programming concepts practically.&lt;/p&gt;&lt;/h1&gt;&lt;h1 data-end=&quot;5117&quot; data-section-id=&quot;beilsy&quot; data-start=&quot;5093&quot;&gt;HOW TO IMPROVE PROJECT&lt;/h1&gt;
&lt;h1 data-end=&quot;5142&quot; data-section-id=&quot;18cyegr&quot; data-start=&quot;5119&quot;&gt;1. Add More Animation&lt;/h1&gt;
&lt;h2 data-end=&quot;5152&quot; data-section-id=&quot;xj0htr&quot; data-start=&quot;5144&quot;&gt;Ideas&lt;/h2&gt;
&lt;ul data-end=&quot;5233&quot; data-start=&quot;5153&quot;&gt;
&lt;li data-end=&quot;5169&quot; data-section-id=&quot;18utm24&quot; data-start=&quot;5153&quot;&gt;
Batman walking
&lt;/li&gt;
&lt;li data-end=&quot;5183&quot; data-section-id=&quot;1gmxb6z&quot; data-start=&quot;5170&quot;&gt;
Moving cape
&lt;/li&gt;
&lt;li data-end=&quot;5205&quot; data-section-id=&quot;4jb9pt&quot; data-start=&quot;5184&quot;&gt;
Flashing bat signal
&lt;/li&gt;
&lt;li data-end=&quot;5219&quot; data-section-id=&quot;9lbp8r&quot; data-start=&quot;5206&quot;&gt;
Rain effect
&lt;/li&gt;
&lt;li data-end=&quot;5233&quot; data-section-id=&quot;14ggv5r&quot; data-start=&quot;5220&quot;&gt;
Flying bats
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;5238&quot; data-start=&quot;5235&quot; /&gt;
&lt;h1 data-end=&quot;5254&quot; data-section-id=&quot;130iuc8&quot; data-start=&quot;5240&quot;&gt;2. Add Sound&lt;/h1&gt;
&lt;p data-end=&quot;5273&quot; data-start=&quot;5256&quot;&gt;Use Batman music.&lt;/p&gt;
&lt;p data-end=&quot;5283&quot; data-start=&quot;5275&quot;&gt;Windows:&lt;/p&gt;
&lt;pre class=&quot;overflow-visible! px-0!&quot; data-end=&quot;5342&quot; data-start=&quot;5284&quot;&gt;&lt;div class=&quot;relative w-full mt-4 mb-1&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl&quot;&gt;&lt;div class=&quot;h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback&quot;&gt;&lt;div class=&quot;pointer-events-none absolute inset-x-4 top-12 bottom-4&quot;&gt;&lt;div class=&quot;pointer-events-none sticky z-40 shrink-0 z-1!&quot;&gt;&lt;div class=&quot;sticky bg-token-border-light&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative z-0 flex max-w-full&quot;&gt;&lt;div class=&quot;q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr&quot; dir=&quot;ltr&quot; id=&quot;code-block-viewer&quot;&gt;&lt;div class=&quot;cm-scroller&quot;&gt;&lt;pre class=&quot;cm-content q9tKkq_readonly m-0&quot;&gt;&lt;code&gt;&lt;span class=&quot;ͼm&quot;&gt;PlaySound&lt;/span&gt;(&lt;span class=&quot;ͼm&quot;&gt;TEXT&lt;/span&gt;(&lt;span class=&quot;ͼk&quot;&gt;&quot;batman.wav&quot;&lt;/span&gt;), &lt;span class=&quot;ͼj&quot;&gt;NULL&lt;/span&gt;, &lt;span class=&quot;ͼm&quot;&gt;SND_ASYNC&lt;/span&gt;);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;hr data-end=&quot;5347&quot; data-start=&quot;5344&quot; /&gt;
&lt;h1 data-end=&quot;5363&quot; data-section-id=&quot;1g7d7x9&quot; data-start=&quot;5349&quot;&gt;3. Add Stars&lt;/h1&gt;
&lt;p data-end=&quot;5390&quot; data-start=&quot;5365&quot;&gt;Draw small white circles.&lt;/p&gt;
&lt;p data-end=&quot;5420&quot; data-start=&quot;5392&quot;&gt;Creates realistic night sky.&lt;/p&gt;
&lt;hr data-end=&quot;5425&quot; data-start=&quot;5422&quot; /&gt;
&lt;h1 data-end=&quot;5451&quot; data-section-id=&quot;1eik41h&quot; data-start=&quot;5427&quot;&gt;4. Add Color Gradients&lt;/h1&gt;
&lt;p data-end=&quot;5481&quot; data-start=&quot;5453&quot;&gt;Instead of plain background:&lt;/p&gt;
&lt;ul data-end=&quot;5512&quot; data-start=&quot;5482&quot;&gt;
&lt;li data-end=&quot;5497&quot; data-section-id=&quot;douokh&quot; data-start=&quot;5482&quot;&gt;
Dark blue top
&lt;/li&gt;
&lt;li data-end=&quot;5512&quot; data-section-id=&quot;hf5y3k&quot; data-start=&quot;5498&quot;&gt;
Black bottom
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-end=&quot;5533&quot; data-start=&quot;5514&quot;&gt;Looks professional.&lt;/p&gt;
&lt;hr data-end=&quot;5538&quot; data-start=&quot;5535&quot; /&gt;
&lt;h1 data-end=&quot;5565&quot; data-section-id=&quot;1og816l&quot; data-start=&quot;5540&quot;&gt;5. Improve Batman Shape&lt;/h1&gt;
&lt;p data-end=&quot;5571&quot; data-start=&quot;5567&quot;&gt;Add:&lt;/p&gt;
&lt;ul data-end=&quot;5616&quot; data-start=&quot;5572&quot;&gt;
&lt;li data-end=&quot;5578&quot; data-section-id=&quot;1j435l1&quot; data-start=&quot;5572&quot;&gt;
Arms
&lt;/li&gt;
&lt;li data-end=&quot;5587&quot; data-section-id=&quot;1xfofe4&quot; data-start=&quot;5579&quot;&gt;
Gloves
&lt;/li&gt;
&lt;li data-end=&quot;5594&quot; data-section-id=&quot;1j4266v&quot; data-start=&quot;5588&quot;&gt;
Belt
&lt;/li&gt;
&lt;li data-end=&quot;5602&quot; data-section-id=&quot;16xvyml&quot; data-start=&quot;5595&quot;&gt;
Boots
&lt;/li&gt;
&lt;li data-end=&quot;5616&quot; data-section-id=&quot;7u8s8p&quot; data-start=&quot;5603&quot;&gt;
Better face
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;5621&quot; data-start=&quot;5618&quot; /&gt;
&lt;h1 data-end=&quot;5646&quot; data-section-id=&quot;1h1o6rz&quot; data-start=&quot;5623&quot;&gt;6. Add More Buildings&lt;/h1&gt;
&lt;p data-end=&quot;5677&quot; data-start=&quot;5648&quot;&gt;Currently only few buildings.&lt;/p&gt;
&lt;p data-end=&quot;5683&quot; data-start=&quot;5679&quot;&gt;Add:&lt;/p&gt;
&lt;ul data-end=&quot;5739&quot; data-start=&quot;5684&quot;&gt;
&lt;li data-end=&quot;5697&quot; data-section-id=&quot;jujf11&quot; data-start=&quot;5684&quot;&gt;
More towers
&lt;/li&gt;
&lt;li data-end=&quot;5708&quot; data-section-id=&quot;t5bz44&quot; data-start=&quot;5698&quot;&gt;
Antennas
&lt;/li&gt;
&lt;li data-end=&quot;5739&quot; data-section-id=&quot;hfzcvu&quot; data-start=&quot;5709&quot;&gt;
Windows with blinking lights
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;5744&quot; data-start=&quot;5741&quot; /&gt;
&lt;h1 data-end=&quot;5771&quot; data-section-id=&quot;dd5gkp&quot; data-start=&quot;5746&quot;&gt;7. Use Double Buffering&lt;/h1&gt;
&lt;p data-end=&quot;5781&quot; data-start=&quot;5773&quot;&gt;Current:&lt;/p&gt;
&lt;pre class=&quot;overflow-visible! px-0!&quot; data-end=&quot;5804&quot; data-start=&quot;5782&quot;&gt;&lt;div class=&quot;relative w-full mt-4 mb-1&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl&quot;&gt;&lt;div class=&quot;h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback&quot;&gt;&lt;div class=&quot;pointer-events-none absolute inset-x-4 top-12 bottom-4&quot;&gt;&lt;div class=&quot;pointer-events-none sticky z-40 shrink-0 z-1!&quot;&gt;&lt;div class=&quot;sticky bg-token-border-light&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative z-0 flex max-w-full&quot;&gt;&lt;div class=&quot;q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr&quot; dir=&quot;ltr&quot; id=&quot;code-block-viewer&quot;&gt;&lt;div class=&quot;cm-scroller&quot;&gt;&lt;pre class=&quot;cm-content q9tKkq_readonly m-0&quot;&gt;&lt;code&gt;GLUT_SINGLE&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;p data-end=&quot;5813&quot; data-start=&quot;5806&quot;&gt;Better:&lt;/p&gt;
&lt;pre class=&quot;overflow-visible! px-0!&quot; data-end=&quot;5836&quot; data-start=&quot;5814&quot;&gt;&lt;div class=&quot;relative w-full mt-4 mb-1&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl&quot;&gt;&lt;div class=&quot;h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback&quot;&gt;&lt;div class=&quot;pointer-events-none absolute inset-x-4 top-12 bottom-4&quot;&gt;&lt;div class=&quot;pointer-events-none sticky z-40 shrink-0 z-1!&quot;&gt;&lt;div class=&quot;sticky bg-token-border-light&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative z-0 flex max-w-full&quot;&gt;&lt;div class=&quot;q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr&quot; dir=&quot;ltr&quot; id=&quot;code-block-viewer&quot;&gt;&lt;div class=&quot;cm-scroller&quot;&gt;&lt;pre class=&quot;cm-content q9tKkq_readonly m-0&quot;&gt;&lt;code&gt;GLUT_DOUBLE&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;p data-end=&quot;5843&quot; data-start=&quot;5838&quot;&gt;Then:&lt;/p&gt;
&lt;pre class=&quot;overflow-visible! px-0!&quot; data-end=&quot;5873&quot; data-start=&quot;5844&quot;&gt;&lt;div class=&quot;relative w-full mt-4 mb-1&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;h-full min-h-0 min-w-0&quot;&gt;&lt;div class=&quot;border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl&quot;&gt;&lt;div class=&quot;h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback&quot;&gt;&lt;div class=&quot;pointer-events-none absolute inset-x-4 top-12 bottom-4&quot;&gt;&lt;div class=&quot;pointer-events-none sticky z-40 shrink-0 z-1!&quot;&gt;&lt;div class=&quot;sticky bg-token-border-light&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;relative&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;relative z-0 flex max-w-full&quot;&gt;&lt;div class=&quot;q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr&quot; dir=&quot;ltr&quot; id=&quot;code-block-viewer&quot;&gt;&lt;div class=&quot;cm-scroller&quot;&gt;&lt;pre class=&quot;cm-content q9tKkq_readonly m-0&quot;&gt;&lt;code&gt;&lt;span class=&quot;ͼm&quot;&gt;glutSwapBuffers&lt;/span&gt;();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;&quot;&gt;&lt;div class=&quot;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;p data-end=&quot;5884&quot; data-start=&quot;5875&quot;&gt;Benefits:&lt;/p&gt;
&lt;ul data-end=&quot;5919&quot; data-start=&quot;5885&quot;&gt;
&lt;li data-end=&quot;5903&quot; data-section-id=&quot;tyfmho&quot; data-start=&quot;5885&quot;&gt;
Smooth animation
&lt;/li&gt;
&lt;li data-end=&quot;5919&quot; data-section-id=&quot;1h8apat&quot; data-start=&quot;5904&quot;&gt;
No flickering
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;5924&quot; data-start=&quot;5921&quot; /&gt;
&lt;h1 data-end=&quot;5952&quot; data-section-id=&quot;1570fe&quot; data-start=&quot;5926&quot;&gt;8. Add Mouse Interaction&lt;/h1&gt;
&lt;p data-end=&quot;5962&quot; data-start=&quot;5954&quot;&gt;Example:&lt;/p&gt;
&lt;ul data-end=&quot;6017&quot; data-start=&quot;5963&quot;&gt;
&lt;li data-end=&quot;5987&quot; data-section-id=&quot;qwdt2a&quot; data-start=&quot;5963&quot;&gt;
Click to switch scenes
&lt;/li&gt;
&lt;li data-end=&quot;6017&quot; data-section-id=&quot;y7wxvc&quot; data-start=&quot;5988&quot;&gt;
Click logo to rotate faster
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;6022&quot; data-start=&quot;6019&quot; /&gt;
&lt;h1 data-end=&quot;6047&quot; data-section-id=&quot;1ptb730&quot; data-start=&quot;6024&quot;&gt;9. Add Day/Night Mode&lt;/h1&gt;
&lt;p data-end=&quot;6055&quot; data-start=&quot;6049&quot;&gt;Press:&lt;/p&gt;
&lt;ul data-end=&quot;6077&quot; data-start=&quot;6056&quot;&gt;
&lt;li data-end=&quot;6065&quot; data-section-id=&quot;fd9lz6&quot; data-start=&quot;6056&quot;&gt;
D → Day
&lt;/li&gt;
&lt;li data-end=&quot;6077&quot; data-section-id=&quot;jbeydk&quot; data-start=&quot;6066&quot;&gt;
N → Night
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-end=&quot;6082&quot; data-start=&quot;6079&quot; /&gt;
&lt;h1 data-end=&quot;6103&quot; data-section-id=&quot;7bf874&quot; data-start=&quot;6084&quot;&gt;10. Add 3D OpenGL&lt;/h1&gt;
&lt;p data-end=&quot;6126&quot; data-start=&quot;6105&quot;&gt;Advanced improvement:&lt;/p&gt;
&lt;ul data-end=&quot;6182&quot; data-start=&quot;6127&quot;&gt;
&lt;li data-end=&quot;6143&quot; data-section-id=&quot;nw5fhd&quot; data-start=&quot;6127&quot;&gt;
3D Batman logo
&lt;/li&gt;
&lt;li data-end=&quot;6154&quot; data-section-id=&quot;1ltr4ja&quot; data-start=&quot;6144&quot;&gt;
Lighting
&lt;/li&gt;
&lt;li data-end=&quot;6164&quot; data-section-id=&quot;1s22rbx&quot; data-start=&quot;6155&quot;&gt;
Shadows
&lt;/li&gt;
&lt;li data-end=&quot;6182&quot; data-section-id=&quot;mby3te&quot; data-start=&quot;6165&quot;&gt;
Camera movement&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;h1 data-end=&quot;6401&quot; data-section-id=&quot;35vdoo&quot; data-start=&quot;6371&quot;&gt;Recommended Viva Explanation&lt;/h1&gt;
&lt;p data-end=&quot;6446&quot; data-start=&quot;6403&quot;&gt;If teacher asks:&lt;br /&gt;
“How does animation work?”&lt;/p&gt;
&lt;p data-end=&quot;6455&quot; data-start=&quot;6448&quot;&gt;Answer:&lt;/p&gt;
&lt;blockquote data-end=&quot;6620&quot; data-start=&quot;6456&quot;&gt;
&lt;p data-end=&quot;6620&quot; data-start=&quot;6458&quot;&gt;Animation is created using &lt;code data-end=&quot;6502&quot; data-start=&quot;6485&quot;&gt;glutTimerFunc()&lt;/code&gt;.&lt;br data-end=&quot;6506&quot; data-start=&quot;6503&quot; /&gt;
It repeatedly updates variables like moon position and logo rotation angle, then redraws the scene continuously.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr data-end=&quot;6625&quot; data-start=&quot;6622&quot; /&gt;
&lt;p data-end=&quot;6666&quot; data-start=&quot;6627&quot;&gt;If teacher asks:&lt;br /&gt;
“How is Batman drawn?”&lt;/p&gt;
&lt;p data-end=&quot;6675&quot; data-start=&quot;6668&quot;&gt;Answer:&lt;/p&gt;
&lt;blockquote data-end=&quot;6767&quot; data-start=&quot;6676&quot;&gt;
&lt;p data-end=&quot;6767&quot; data-start=&quot;6678&quot;&gt;Batman is created using basic OpenGL primitives such as polygons, triangles, and circles.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr data-end=&quot;6772&quot; data-start=&quot;6769&quot; /&gt;
&lt;p data-end=&quot;6823&quot; data-start=&quot;6774&quot;&gt;If teacher asks:&lt;br /&gt;
“How does scene switching work?”&lt;/p&gt;
&lt;p data-end=&quot;6832&quot; data-start=&quot;6825&quot;&gt;Answer:&lt;/p&gt;
&lt;blockquote data-end=&quot;6995&quot; data-start=&quot;6833&quot;&gt;
&lt;p data-end=&quot;6995&quot; data-start=&quot;6835&quot;&gt;A global variable called &lt;code data-end=&quot;6867&quot; data-start=&quot;6860&quot;&gt;scene&lt;/code&gt; stores the current scene number. Keyboard input changes the value, and the display function draws different scenes accordingly.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Source Code Downloads&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&quot;https://docs.google.com/document/d/1NRk13q85ObS1O1LfQOFiKYAsG70w7gjN5i_28OR_ojg/edit?usp=sharing&quot; target=&quot;_blank&quot;&gt;BATMAN OPENGL COMPUTER GRAPHICS PROJECT USING C++&amp;nbsp; Free Source code download&amp;nbsp;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/7862635539385251305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/05/batman-opengl-computer-graphics-project-using-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7862635539385251305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7862635539385251305'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/05/batman-opengl-computer-graphics-project-using-c.html' title='BATMAN OPENGL COMPUTER GRAPHICS PROJECT USING C++  | With Source Code and Report'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyBU4TrR1w_47EzVtMXacMqHEj2c-RooJpxO9yoTpoBuOJTBJ0P7u_I_aYbNxGp6K8G6oWjD4mArB8AkTw1rGg_cA6F5WWpn_diRpRACuhqinHZcjLaH7itGqjD5KJ3De5bCGv-2-JoyidAa_-9PG2n3ZzgViUWxslQ0POfsKDWpsFinnL5qzXxPDs1ILI/s72-c/BATMAN%20OPENGL%20COMPUTER%20GRAPHICS%20PROJECT%20USING%20C%201.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-1939455536235107480</id><published>2026-03-14T18:55:00.002+05:30</published><updated>2026-03-14T19:01:30.952+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="PI Day"/><title type='text'>Pi Day: Where Math Meets a Slice of Fun</title><content type='html'>&lt;p&gt;Every year on &lt;strong data-end=&quot;80&quot; data-start=&quot;61&quot;&gt;March 14 (3/14)&lt;/strong&gt;, all the math lovers around the world celebrate &lt;strong data-end=&quot;131&quot; data-start=&quot;121&quot;&gt;Pi Day&amp;nbsp;&lt;/strong&gt;—as a tribute to the mathematical constant &lt;strong data-end=&quot;181&quot; data-start=&quot;171&quot;&gt;π (pi). &lt;/strong&gt;The Value of Pi is&amp;nbsp;&lt;strong data-end=&quot;227&quot; data-start=&quot;219&quot;&gt;3.14&lt;/strong&gt;. upto two decimal place. As these may be slipt to 3 and 14 represeting 3 as march month and 14 as date, hence PI DAY.&amp;nbsp;This quirky holiday blends geeky fun with delicious pies, making math feel less intimidating and more indulgent.&lt;/p&gt;&lt;p&gt;Also the Value of Pi is long ending with each mathematician has cacluate to some extent of decimal places. The&amp;nbsp;Pi represents the ratio of a circle’s circumference to its diameter and appears in countless formulas, theorem, thesis etc and used in various feilds including science, engineering, and technology. PI being an infinite and non-repeating number, it has become one of the most famous constants in mathematics.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN5j7WJDkBIRffx6OD956NsKPGdOiiw5bSSpfFqVLa4yBF7d3lbzubQCTcPDyijsjo2O5g0G-IHAMIWp5mXnbWAtrKKFk_wS99qQgdvTrpCbt24ULUxnz58Yjkd2N8FE1ZIW-q0Vo0fg-1u7M1FjePxMi1HeOW8Hbir7fDgDeHCbGvaa-8DobqIY_Ift0s/s1024/PI%20DAY.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;1024&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN5j7WJDkBIRffx6OD956NsKPGdOiiw5bSSpfFqVLa4yBF7d3lbzubQCTcPDyijsjo2O5g0G-IHAMIWp5mXnbWAtrKKFk_wS99qQgdvTrpCbt24ULUxnz58Yjkd2N8FE1ZIW-q0Vo0fg-1u7M1FjePxMi1HeOW8Hbir7fDgDeHCbGvaa-8DobqIY_Ift0s/s320/PI%20DAY.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;When it statrtd PI DAY?&lt;/h2&gt;
&lt;p data-end=&quot;811&quot; data-start=&quot;533&quot; style=&quot;text-align: justify;&quot;&gt;Today is Pi Day, celebrated on March 14 (or 3.14) to honor the mathematical constant π.&amp;nbsp;&lt;/p&gt;&lt;p data-end=&quot;811&quot; data-start=&quot;533&quot; style=&quot;text-align: justify;&quot;&gt;Interestingly, Pi Day began in&amp;nbsp;&lt;strong data-end=&quot;1324&quot; data-start=&quot;1278&quot;&gt;1988 at the Exploratorium in San Francisco&lt;/strong&gt;, where physicist Larry Shaw organized the first celebration. Over time, the tradition spread worldwide and even gained official recognition in the United States in 2009.&lt;/p&gt;&lt;p data-end=&quot;811&quot; data-start=&quot;533&quot; style=&quot;text-align: justify;&quot;&gt;The Story of Origin: 1988 At the San Francisco Exploratorium, Pi Day was first officially observed. It was created by Larry Shaw, a physicist known as the &quot;Prince of Pi.&quot; Shaw selected March 14 (3/14) as the date because it corresponds to the first three digits of the mathematical constant: 3.14. The Ritual: Shaw and his employees marched around one of the museum&#39;s circular areas as part of the first celebration, after which they ate a lot of fruit pies.The Logistics: Shaw discovered that &quot;pi&quot; and &quot;pie&quot; are homophones in addition to pies are—conveniently—circular in a flash of insight (or maybe just hunger).The Celebration&#39;s Development What was once a specialized staff party swiftly became a worldwide sensation.&lt;/p&gt;&lt;p data-end=&quot;811&quot; data-start=&quot;533&quot;&gt;Today, enthusiasts recite its endless digits, bake π-themed pies, and share memes poking fun at its irrational nature. In 2026, social media buzzes with crypto twists and cat-in-chef-hat antics, turning classrooms into pie parties.&lt;/p&gt;&lt;p data-end=&quot;1245&quot; data-start=&quot;865&quot;&gt;One of the reasons Pi Day is so popular is the &lt;strong data-end=&quot;954&quot; data-start=&quot;912&quot;&gt;endless supply of math jokes and memes&lt;/strong&gt;. After all, when a mathematical constant sounds exactly like a dessert, the internet can’t resist. You’ll often see jokes like: &lt;em data-end=&quot;1126&quot; data-start=&quot;1083&quot;&gt;“It’s okay, Pi Day is all about the pie!”&lt;/em&gt;—a reminder that sometimes learning math can be both educational and delicious.&lt;/p&gt;&lt;p data-end=&quot;1708&quot; data-start=&quot;1536&quot;&gt;So whether you’re a mathematician, a student, or just someone who enjoys dessert, Pi Day is a perfect reminder that &lt;strong data-end=&quot;1705&quot; data-start=&quot;1652&quot;&gt;math can be fun, creative, and surprisingly tasty&lt;/strong&gt;.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Google PI Day Doodle&lt;/h2&gt;&lt;p data-end=&quot;1708&quot; data-start=&quot;1536&quot;&gt;Google has dedicate 14/03/2026 PI Day with a good mathematical Doodle as given -&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.google.com/logos/doodles/2026/pi-day-2026-6753651837111068.2-2xa.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;400&quot; data-original-width=&quot;1000&quot; height=&quot;160&quot; src=&quot;https://www.google.com/logos/doodles/2026/pi-day-2026-6753651837111068.2-2xa.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p data-end=&quot;1708&quot; data-start=&quot;1536&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p data-end=&quot;1708&quot; data-start=&quot;1536&quot;&gt;Google created a unique interactive Doodle in celebration of the ancient Greek mathematician Archimedes and his groundbreaking technique for determining the limits of pi in commemoration of Pi Day in 2026.&lt;/p&gt;&lt;p data-end=&quot;811&quot; data-start=&quot;533&quot;&gt;


&lt;/p&gt;&lt;p data-end=&quot;1822&quot; data-start=&quot;1710&quot;&gt;And remember: if anyone asks why you’re eating pie on March 14, just say it’s for &lt;strong data-end=&quot;1816&quot; data-start=&quot;1792&quot;&gt;educational purposes&lt;/strong&gt;. 😄&lt;/p&gt;&lt;p data-end=&quot;1822&quot; data-start=&quot;1710&quot;&gt;Why not join in? Grab a slice of apple pie, ponder infinity, and remember: even Einstein would approve. Pi reminds us circles are endless—and so is the joy in a good pun. Happy Pi Day! (198 words) PI Day Video for you -https://www.youtube.com/shorts/ZWlDDm_R_HQ&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/1939455536235107480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/03/pi-day-where-math-meets-slice-of-fun.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1939455536235107480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1939455536235107480'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/03/pi-day-where-math-meets-slice-of-fun.html' title='Pi Day: Where Math Meets a Slice of Fun'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN5j7WJDkBIRffx6OD956NsKPGdOiiw5bSSpfFqVLa4yBF7d3lbzubQCTcPDyijsjo2O5g0G-IHAMIWp5mXnbWAtrKKFk_wS99qQgdvTrpCbt24ULUxnz58Yjkd2N8FE1ZIW-q0Vo0fg-1u7M1FjePxMi1HeOW8Hbir7fDgDeHCbGvaa-8DobqIY_Ift0s/s72-c/PI%20DAY.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5706640564736930916</id><published>2026-03-05T03:13:00.002+05:30</published><updated>2026-03-05T03:25:24.961+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Engineering Students"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenGL Projects"/><title type='text'>Top 20 OpenGL Projects for Engineering Students</title><content type='html'>&lt;h1 style=&quot;text-align: justify;&quot;&gt;ABSTRACT&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Computer graphics plays an important role in fields such as gaming, simulation, visualization, and scientific computing. OpenGL is one of the most widely used graphics APIs for building cross-platform graphics applications. Through practical projects, engineering students can gain a deeper understanding of rendering pipelines, GPU programming, shaders, and 3D mathematics.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;This report presents &lt;strong&gt;twenty OpenGL project ideas&lt;/strong&gt; categorized by difficulty level, including beginner, intermediate, and advanced projects. Each project is designed to strengthen practical skills in modern graphics programming using C++ and OpenGL. The goal of these projects is to help students develop the ability to design and implement real-time graphics applications.&lt;/p&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;TABLE OF CONTENTS&lt;/h1&gt;&lt;ol&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Introduction&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Objectives&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Development Tools and Technologies&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Beginner-Level OpenGL Projects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Intermediate-Level OpenGL Projects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Advanced-Level OpenGL Projects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Applications of OpenGL Projects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Conclusion&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;References&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh93YvxElpMHy6EK8oYZOP8aHgA_X07xJbC7Chtff3Or3MG9Rtp7qX6wWzyxNvJKZD5oVcUrq78MTaX2Ys8uBO-9hu0afNLAphIyyfYlgs6ifaFZbw242L5xJ5f44AodnGGaxe4L0CL6EKSYgYUkIvHF4fQR5lRo0Q11s-KBTqLBc6I_VfDAX8l1zaP-LW2/s1600/Top%2020%20OpenGL%20Projects%20for%20Engineering%20Students.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;896&quot; data-original-width=&quot;1600&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh93YvxElpMHy6EK8oYZOP8aHgA_X07xJbC7Chtff3Or3MG9Rtp7qX6wWzyxNvJKZD5oVcUrq78MTaX2Ys8uBO-9hu0afNLAphIyyfYlgs6ifaFZbw242L5xJ5f44AodnGGaxe4L0CL6EKSYgYUkIvHF4fQR5lRo0Q11s-KBTqLBc6I_VfDAX8l1zaP-LW2/w640-h358/Top%2020%20OpenGL%20Projects%20for%20Engineering%20Students.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;1. INTRODUCTION&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;OpenGL (Open Graphics Library) is an industry-standard graphics API used for developing two-dimensional and three-dimensional graphics applications. It provides developers with the tools needed to control the GPU and implement efficient rendering pipelines.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;In modern computer graphics education, practical implementation is essential. Students must understand how rendering works through real projects that demonstrate concepts such as:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Vertex processing&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Lighting models&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Texture mapping&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Shader programming&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Real-time rendering techniques&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;The following project list is structured to help engineering students progressively build their skills from fundamental graphics programming to advanced rendering systems.&lt;/p&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;2. OBJECTIVES&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;The objectives of these OpenGL projects are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;To understand the fundamentals of computer graphics.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;To develop practical experience with OpenGL programming.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;To explore GPU-based rendering techniques.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;To implement interactive graphics applications.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;To prepare students for careers in graphics programming, game development, and simulation.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;3. DEVELOPMENT TOOLS AND TECHNOLOGIES&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;The following tools are commonly used for OpenGL development.&lt;/p&gt;&lt;table style=&quot;text-align: justify;&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Tool&lt;/th&gt;&lt;th&gt;Purpose&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;OpenGL&lt;/td&gt;&lt;td&gt;Graphics rendering API&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;C++&lt;/td&gt;&lt;td&gt;Primary programming language&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GLFW&lt;/td&gt;&lt;td&gt;Window creation and input handling&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GLAD / GLEW&lt;/td&gt;&lt;td&gt;OpenGL function loading&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GLM&lt;/td&gt;&lt;td&gt;Mathematics library&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;stb_image&lt;/td&gt;&lt;td&gt;Texture loading&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Assimp&lt;/td&gt;&lt;td&gt;3D model loading&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Dear ImGui&lt;/td&gt;&lt;td&gt;User interface for debugging&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;These libraries simplify the development of modern OpenGL applications.&lt;/p&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;4. BEGINNER-LEVEL OPENGL PROJECTS&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;These projects introduce the fundamental concepts of rendering and graphics programming.&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;4.1 2D Shape Drawing Application&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;This project allows users to draw basic geometric shapes such as:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Lines&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Triangles&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Rectangles&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Circles&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Vertex buffers&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Rendering primitives&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;User input handling&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;4.2 Interactive Solar System Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;This project simulates planetary motion where planets revolve around the sun.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Features:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Orbital motion&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Planet rotation&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Keyboard-controlled camera&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Hierarchical transformations&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Rotation matrices&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;4.3 3D Cube Viewer&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;A simple program displaying a cube that can be rotated, scaled, and translated.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Model, View, Projection matrices&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Basic camera system&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;4.4 Texture Mapping Demonstration&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Render textured objects such as cubes or spheres.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;UV coordinates&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Texture sampling&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Texture filtering&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;4.5 Basic 3D Model Viewer&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Load and render a 3D model file.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Features:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Model loading&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Lighting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Camera control&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Mesh structures&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Model rendering pipeline&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;5. INTERMEDIATE-LEVEL OPENGL PROJECTS&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;These projects introduce more advanced graphics techniques.&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.1 Real-Time Terrain Generator&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Generate terrain using procedural methods such as noise functions.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Heightmaps&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Procedural generation&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.2 3D Maze Navigation Game&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;A small game where the player navigates through a maze using a first-person camera.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Collision detection&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Camera systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Game logic&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.3 Particle System Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Simulate visual effects such as fire, smoke, or rain.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Particle systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;GPU instancing&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.4 Shadow Mapping&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Implement dynamic shadows in a scene.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Depth maps&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Framebuffer objects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.5 Physics-Based Bouncing Ball Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Simulate objects bouncing under gravity.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Motion equations&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Collision response&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.6 First-Person Camera System&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Develop a camera system similar to those used in FPS games.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Features:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Mouse look&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Keyboard movement&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Perspective projection&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;5.7 Water Rendering Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Render animated water surfaces.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Reflection&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Refraction&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Wave animation&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;6. ADVANCED-LEVEL OPENGL PROJECTS&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;These projects involve complex rendering algorithms and system design.&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.1 Real-Time Ray Tracing (Hybrid)&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Implement basic ray tracing techniques using shaders.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Ray-object intersection&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Reflection and shadow calculations&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.2 Deferred Rendering Engine&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Build a rendering pipeline capable of handling multiple lights efficiently.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;G-buffer rendering&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Deferred shading&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.3 Procedural City Generator&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Automatically generate buildings and urban layouts.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Procedural modeling&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Scene generation&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.4 Cloth Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Simulate cloth movement using physics models.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Mass-spring systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Real-time simulation&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.5 GPU Fluid Simulation&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Create a real-time fluid or smoke simulation.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Numerical simulation&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Compute shaders&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.6 OpenGL Mini Game Engine&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Develop a basic rendering engine supporting:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Scene management&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Lighting systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Model loading&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Camera control&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.7 Augmented Reality Viewer&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Integrate computer vision with OpenGL rendering.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Camera calibration&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Marker tracking&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;3D overlay rendering&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;6.8 Virtual Reality Scene Viewer&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Render stereoscopic scenes for VR headsets.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Concepts learned:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Stereo rendering&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Head tracking integration&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;7. APPLICATIONS OF OPENGL PROJECTS&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;OpenGL-based systems are widely used in many industries:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Video game development&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Scientific visualization&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;CAD and engineering software&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Virtual reality systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Simulation and training environments&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Medical imaging visualization&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Developing OpenGL projects prepares students for careers in these fields.&lt;/p&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;8. CONCLUSION&lt;/h1&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;OpenGL projects provide engineering students with hands-on experience in computer graphics programming. By implementing progressively complex projects, students can develop a deep understanding of rendering pipelines, shader programming, and real-time graphics techniques.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;These twenty projects offer a structured pathway from beginner concepts to advanced graphics development, helping students build a strong foundation in modern graphics programming.&lt;/p&gt;&lt;hr style=&quot;text-align: justify;&quot; /&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;9. REFERENCES&lt;/h1&gt;&lt;ol&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;OpenGL Architecture Review Board. &lt;em&gt;OpenGL Programming Guide&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Shreiner, Dave et al. &lt;em&gt;OpenGL SuperBible&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Akenine-Möller, Tomas et al. &lt;em&gt;Real-Time Rendering&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;OpenGL Official Documentation.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Graphics programming tutorials and educational resources.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5706640564736930916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2026/03/top-20-opengl-projects-for-engineering-students.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5706640564736930916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5706640564736930916'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2026/03/top-20-opengl-projects-for-engineering-students.html' title='Top 20 OpenGL Projects for Engineering Students'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh93YvxElpMHy6EK8oYZOP8aHgA_X07xJbC7Chtff3Or3MG9Rtp7qX6wWzyxNvJKZD5oVcUrq78MTaX2Ys8uBO-9hu0afNLAphIyyfYlgs6ifaFZbw242L5xJ5f44AodnGGaxe4L0CL6EKSYgYUkIvHF4fQR5lRo0Q11s-KBTqLBc6I_VfDAX8l1zaP-LW2/s72-w640-h358-c/Top%2020%20OpenGL%20Projects%20for%20Engineering%20Students.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-1297154354431016757</id><published>2025-12-26T00:44:00.003+05:30</published><updated>2025-12-26T00:45:49.885+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Games"/><category scheme="http://www.blogger.com/atom/ns#" term="Space Shooter"/><title type='text'>Space Shooter game built with OpenGL -18CSL67/21CSL66</title><content type='html'>&lt;p&gt;Students &lt;span class=&quot;red&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;blue&quot;&gt;Visvesvaraya Technological University (VTU) &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;frequently&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;engage&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; OpenGL mini-projects as &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; of the Computer Graphics and Visualization (18CSL67/21CSL66) course&lt;/span&gt;. The &lt;span class=&quot;red&quot;&gt;newest&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;initiatives&lt;/span&gt; for 2025 &lt;span class=&quot;red&quot;&gt;focus&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; interactive simulations and &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;visual&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;representations&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;algorithms.&lt;/span&gt;&lt;/p&gt;&lt;div data-pm-slice=&quot;2 1 []&quot;&gt;&lt;span class=&quot;blue&quot;&gt;A&amp;nbsp;&lt;span class=&quot;Yjhzub&quot; data-processed=&quot;true&quot; face=&quot;&amp;quot;Google Sans&amp;quot;, Arial, sans-serif&quot; jscontroller=&quot;zYmgkd&quot; jsuid=&quot;QL8uxb_a&quot; style=&quot;background-color: white; color: #0a0a0a; font-size: 16px; font-weight: bolder;&quot;&gt;Space Shooter game built with OpenGL&lt;/span&gt;&amp;nbsp;is a &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;typical&lt;/span&gt; project for &lt;span class=&quot;red&quot;&gt;understanding&lt;/span&gt; computer graphics, &lt;span class=&quot;red&quot;&gt;usually&lt;/span&gt; developed &lt;span class=&quot;red&quot;&gt;in&lt;/span&gt; C++ language and &lt;span class=&quot;red&quot;&gt;utilizing&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;well-known&lt;/span&gt; libraries &lt;span class=&quot;red&quot;&gt;such&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; GLFW, GLUT, and GLEW&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;blue&quot;&gt;These games are &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;typically&lt;/span&gt; 2D &lt;span class=&quot;red&quot;&gt;featuring&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;traditional&lt;/span&gt; arcade-style &lt;span class=&quot;red&quot;&gt;mechanics&lt;/span&gt; and are &lt;span class=&quot;red&quot;&gt;frequently&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;presented&lt;/span&gt; as &lt;span class=&quot;red&quot;&gt;assignments&lt;/span&gt; for courses &lt;span class=&quot;red&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; computer graphics and visualization&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://camo.githubusercontent.com/0e279f06a563138f995e8eb0e5c5343f62096f6e90aa0fa9f4c8ab526d65cd52/68747470733a2f2f696d6775722e636f6d2f51657a396e76782e706e67&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;747&quot; data-original-width=&quot;1493&quot; height=&quot;320&quot; src=&quot;https://camo.githubusercontent.com/0e279f06a563138f995e8eb0e5c5343f62096f6e90aa0fa9f4c8ab526d65cd52/68747470733a2f2f696d6775722e636f6d2f51657a396e76782e706e67&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Typical&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;Attributes&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;blue&quot;&gt;2D Graphics: The game &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;mainly&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;employs&lt;/span&gt; 2D rendering, &lt;span class=&quot;red&quot;&gt;leveraging&lt;/span&gt; OpenGL to &lt;span class=&quot;red&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; points, lines, and polygons, which are &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;subsequently&lt;/span&gt; textured to &lt;span class=&quot;red&quot;&gt;depict&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; spaceships, bullets, and backgrounds&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Game&lt;/span&gt; Mechanics:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The &lt;span class=&quot;red&quot;&gt;gamer&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;navigates&lt;/span&gt; a &lt;span class=&quot;red&quot;&gt;spacecraft&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;around&lt;/span&gt; the &lt;span class=&quot;red&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;(typically&lt;/span&gt; using&lt;span class=&quot;blue&quot;&gt; &#39;W&#39;, &#39;S&#39;, &#39;A&#39;, &#39;D&#39; or &#39;I&#39;, &#39;K&#39;, &#39;J&#39;, &#39;L&#39; &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;buttons)&lt;/span&gt; and &lt;span class=&quot;red&quot;&gt;fires&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;foes&lt;/span&gt; with &lt;span class=&quot;red&quot;&gt;designated&lt;/span&gt; keys.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Enemies &lt;span class=&quot;red&quot;&gt;may&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;consist&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;standard&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; minions and bosses &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;that&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;have&lt;/span&gt; health bars.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;blue&quot;&gt;Collision detection is &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;an&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;essential&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;aspect,&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;frequently&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;employing&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; Axis-Aligned Bounding Boxes (AABB) or &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;circular/spherical&lt;/span&gt; detection, to &lt;span class=&quot;red&quot;&gt;identify&lt;/span&gt; when projectiles &lt;span class=&quot;red&quot;&gt;strike&lt;/span&gt; enemies or when the player &lt;span class=&quot;red&quot;&gt;takes&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;damage&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Power-ups, &lt;span class=&quot;red&quot;&gt;like&lt;/span&gt; those that &lt;span class=&quot;red&quot;&gt;enhance&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; fire rate or &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;reduce&lt;/span&gt; boss health, &lt;span class=&quot;red&quot;&gt;might&lt;/span&gt; be &lt;span class=&quot;red&quot;&gt;obtainable&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Technical &lt;span class=&quot;red&quot;&gt;Execution:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The games &lt;span class=&quot;red&quot;&gt;frequently&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; a game loop for &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;ongoing&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; updates and rendering&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Libraries &lt;span class=&quot;red&quot;&gt;like&lt;/span&gt; stb_image are &lt;span class=&quot;red&quot;&gt;utilized&lt;/span&gt; for loading &lt;span class=&quot;red&quot;&gt;textures,&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;while&lt;/span&gt; OpenAL is &lt;span class=&quot;red&quot;&gt;often&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;selected&lt;/span&gt; for audio.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Fundamental&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; shaders (color, texture, font) are &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;generally&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;applied&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Elements&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;such&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;as&lt;/span&gt; score &lt;span class=&quot;red&quot;&gt;trackers,&lt;/span&gt; health &lt;span class=&quot;red&quot;&gt;indicators,&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;primary&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; menus, and game over screens are also &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;included&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; the user experience&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Coding&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;Materials&lt;/span&gt; and &lt;span class=&quot;red&quot;&gt;Educational&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;Tools&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Many&lt;/span&gt; open-source &lt;span class=&quot;red&quot;&gt;projects&lt;/span&gt; can &lt;span class=&quot;red&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;found&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; on GitHub, which can &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;act&lt;/span&gt; as &lt;span class=&quot;red&quot;&gt;great&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;educational&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;tools&lt;/span&gt; or &lt;span class=&quot;red&quot;&gt;foundations&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; for your own &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;initiative&lt;/span&gt;&lt;span class=&quot;red&quot;&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also See&amp;nbsp;&amp;nbsp;&lt;span style=&quot;background-color: white; color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;, Trebuchet, Verdana, sans-serif; font-size: 22px;&quot;&gt;&lt;a href=&quot;https://www.openglprojects.in/2018/02/space-invaders-freeglut-project.html#gsc.tab=0&quot;&gt;Space Invaders Freeglut Project&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Basic 2D Game: &lt;span class=&quot;red&quot;&gt;An&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;uncomplicated&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;execution&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; in C++ and OpenGL for &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;fundamental&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;understanding&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;red&quot;&gt;Contemporary&lt;/span&gt; OpenGL &lt;span class=&quot;red&quot;&gt;Method:&lt;/span&gt; A more &lt;span class=&quot;red&quot;&gt;intricate&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;endeavor&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;focused&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;on&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;tidy&lt;/span&gt; code and &lt;span class=&quot;red&quot;&gt;contemporary&lt;/span&gt; OpenGL &lt;span class=&quot;red&quot;&gt;capabilities,&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;featuring&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;an&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;extensive&lt;/span&gt; roadmap &lt;span class=&quot;red&quot;&gt;that&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;includes&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;elements&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;such&lt;/span&gt; &lt;span class=&quot;red&quot;&gt;as&lt;/span&gt; collision detection, &lt;span class=&quot;red&quot;&gt;sound,&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; and state machines&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Multiplayer &lt;span class=&quot;red&quot;&gt;Edition:&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt; A project that &lt;/span&gt;&lt;span class=&quot;red&quot;&gt;features&lt;/span&gt; a &lt;span class=&quot;red&quot;&gt;two-player&lt;/span&gt; game &lt;span class=&quot;red&quot;&gt;along&lt;/span&gt; with a menu and introductory system&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://camo.githubusercontent.com/65bcf624c6b197b0f92bb67beff6e41f1f16046e6213c03b8867a486a10de933/68747470733a2f2f696d6775722e636f6d2f4473354a4f364f2e706e67&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;597&quot; data-original-width=&quot;1198&quot; height=&quot;319&quot; src=&quot;https://camo.githubusercontent.com/65bcf624c6b197b0f92bb67beff6e41f1f16046e6213c03b8867a486a10de933/68747470733a2f2f696d6775722e636f6d2f4473354a4f364f2e706e67&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/imanojg/Space-Shooter-Using-OpenGL/raw/main/images/Game.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;670&quot; data-original-width=&quot;1242&quot; height=&quot;345&quot; src=&quot;https://github.com/imanojg/Space-Shooter-Using-OpenGL/raw/main/images/Game.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/imanojg/Space-Shooter-Using-OpenGL/main/images/Winning.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;797&quot; data-original-width=&quot;1513&quot; height=&quot;337&quot; src=&quot;https://raw.githubusercontent.com/imanojg/Space-Shooter-Using-OpenGL/main/images/Winning.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Game Description&lt;/p&gt;&lt;p&gt;Keybord control for PLAYER 1 :&lt;/p&gt;&lt;p&gt;W - UP&lt;/p&gt;&lt;p&gt;S - DOWN&lt;/p&gt;&lt;p&gt;A - LEFT&lt;/p&gt;&lt;p&gt;D - RIGHT&lt;/p&gt;&lt;p&gt;C - to shoot, Use &#39;w&#39; and &#39;s&#39; to change direction.&lt;/p&gt;&lt;p&gt;Keybord control for PLAYER 2 :&lt;/p&gt;&lt;p&gt;I - UP&lt;/p&gt;&lt;p&gt;K - DOWN&lt;/p&gt;&lt;p&gt;J - LEFT&lt;/p&gt;&lt;p&gt;L - RIGHT&lt;/p&gt;&lt;p&gt;M - to shoot, Use &#39;I&#39; and &#39;K&#39; to change direction.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://camo.githubusercontent.com/c710ffebb5fa7447b28ce514c9e44c6d53057a1cc24858c05f5c5072eeda4c9a/68747470733a2f2f696d6775722e636f6d2f48574f35616f5a2e706e67&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;597&quot; data-original-width=&quot;1197&quot; height=&quot;319&quot; src=&quot;https://camo.githubusercontent.com/c710ffebb5fa7447b28ce514c9e44c6d53057a1cc24858c05f5c5072eeda4c9a/68747470733a2f2f696d6775722e636f6d2f48574f35616f5a2e706e67&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Objective&lt;/p&gt;&lt;p&gt;kill your opponent.&lt;/p&gt;&lt;p&gt;Each time a player gets shot, LIFE decreases by 5 points.&lt;/p&gt;&lt;p&gt;Source Code - 1. &lt;a href=&quot;https://github.com/rajathpi/space-shooter&quot; target=&quot;_blank&quot;&gt;Download Free&lt;/a&gt;&amp;nbsp;2. &lt;a href=&quot;https://github.com/imanojg/Space-Shooter-Using-OpenGL&quot; target=&quot;_blank&quot;&gt;Alternate Download Source Code link&lt;/a&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/1297154354431016757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/12/Space-Shooter-game-built-with-OpenGL-18CSL67-21CSL66.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1297154354431016757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1297154354431016757'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/12/Space-Shooter-game-built-with-OpenGL-18CSL67-21CSL66.html' title='Space Shooter game built with OpenGL -18CSL67/21CSL66'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-7760410829942775252</id><published>2025-07-26T03:09:00.003+05:30</published><updated>2025-10-12T00:50:11.550+05:30</updated><title type='text'>Drawing Mountains in OpenGL Using Bitmap Loaders</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;Using the OpenGL Glut library, we have created numerous straightforward and intricate programs, but none of them have used texturing or image loading. We tried to find how to load image in the Opengl? &lt;a href=&quot;https://stackoverflow.com/questions/14173320/loading-images-in-opengl&quot; target=&quot;_blank&quot;&gt;The stackoverflow question pertaining to &quot;Loading images in openGL&quot;&lt;/a&gt;&amp;nbsp;yielded the best response.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Images Loading in OpenGL Graphics Programming&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;We can claim that working with OpenGL graphics programmiong, the image loading is seems to be difficult task. External libraries such as stb_image.h, DevIL (Developer&#39;s Image Library), FreeImage, and SOIL (Simple OpenGL Image Library) are used to read and decode images into raw pixel data; OpenGL does not import image files directly. This data is then sent to the GPU as a texture using OpenGL methods such as glGenTextures, glBindTexture, and glTexImage2D for rendering.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;In addition to images/photos/pictures, textures can be used to contain a sizable collection of arbitrary data that can be sent to the shaders for rendering the object.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Drawing Mountains in OpenGL&lt;/h2&gt;&lt;p&gt;In this Computer graphics Open project we are going to generate the mountains using the image texture with use of bitmap loaders.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTUFKxYXohMe9CwHB8QG4eIfHrP-oQPjAqHg5I-dYfy9Gzo3e5c_JG8k5B4-_ToBI4nLsuLvUdKY4T8PWWuX9kTVRnsLH8PX28ClQyEACuvW0JG6xTb67Ai7Ta5ZlVQPBsCEuc4qJE2bdsPIOIVachS_qRMty4wWclefcZF74ySd5fTV-AIwc_F5OzlcXp/s783/Mountains%20in%20OpenGL%20Using%20Bitmap%20Loaders.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;754&quot; data-original-width=&quot;783&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTUFKxYXohMe9CwHB8QG4eIfHrP-oQPjAqHg5I-dYfy9Gzo3e5c_JG8k5B4-_ToBI4nLsuLvUdKY4T8PWWuX9kTVRnsLH8PX28ClQyEACuvW0JG6xTb67Ai7Ta5ZlVQPBsCEuc4qJE2bdsPIOIVachS_qRMty4wWclefcZF74ySd5fTV-AIwc_F5OzlcXp/s16000/Mountains%20in%20OpenGL%20Using%20Bitmap%20Loaders.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;1. Grass Like Texture to Mountains&lt;/h4&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;We are randomly generating the mountains using a normalized pseudo-random number generator and fractal techniques. The windows are displayed differently each time you resize them or start the project program application.&amp;nbsp;&lt;span style=&quot;text-align: left;&quot;&gt;This application relies on GLUT and uses a bitmap for the grass texture. Therefore, they were loaded into the program for use using BitmapLoader.h.&lt;/span&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;2. Random Number for (Gaussian) distribution&lt;/h4&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Let first define the randomNormal utility function, which uses the central limit theorem approximation (sum of uniform random variables) to produce a random number with a normal (Gaussian) distribution.&lt;/p&gt;
&lt;pre&gt;double randomNormal (double mu, double sigma)
{
double sum = 0;
for(int i = 0; i &amp;lt; 12; i++)
sum = sum + (double)rand()/RAND_MAX;
sum -= 6;
return sigma*sum + mu;
}&amp;nbsp;&lt;/pre&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;3. Texture Creation and Circle Drawing Functions&lt;/h4&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Using raw bitmap data, createTexture1 loads a texture into OpenGL and sets its filtering mode to nearest neighbor (pixelated look) and wrapping mode to clamp.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Draw_circle uses a polygon of 36 vertices (one every 10 degrees) to approximate a 2D filled circle. This might stand in for the sun or another round object in the picture.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;See Also - &lt;a href=&quot;https://www.openglprojects.in/2014/03/draw-circle-opengl.html#gsc.tab=0&quot;&gt;How to draw circle in OpenGL&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: justify;&quot;&gt;4.&amp;nbsp;Fractal Mountain Generation Function&lt;/h4&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div&gt;By periodically splitting a quadrilateral and applying a random height displacement, this recursive program creates fractal landscape.&lt;/div&gt;&lt;div&gt;Lighting effects are used to draw the quad once it is sufficiently small (perim &amp;lt;= tolerance). Using the Lambertian model, the lighting simulates diffuse light by shading the polygon according to its normal and light positions.&lt;/div&gt;&lt;div&gt;In order to produce four smaller quads recursively and add height perturbations for realistic terrain detail, it computes a displaced midpoint if it is not small enough.&lt;/div&gt;&lt;h4&gt;5. Initialization of OpenGL and Textures&lt;/h4&gt;&lt;div&gt;&lt;div&gt;Uses the external method LoadBitmapFile to load the grass bitmap texture from the file. The program exits and prints an error if loading is unsuccessful. Specifies the scene&#39;s clipping volume and sets up the OpenGL projection matrix with an orthographic projection (no perspective). transforms the clean background into a dark gray.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;Running the Program to get Desire Result&lt;/h2&gt;&lt;div&gt;Before compiling the program place the grass image in the source folder, let the program load and run pefectly. If the grass image not present then comiplation will be error free but non loading of image lead to failure of outcome.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Downloads&lt;/h3&gt;&lt;div&gt;Source code will be provie for both main program and header file including the bitmap image on request by you to our email id openglprojects@gmail.com&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/7760410829942775252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/07/Drawing-Mountains-in-OpenGL-Using-Bitmap-Loaders.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7760410829942775252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/7760410829942775252'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/07/Drawing-Mountains-in-OpenGL-Using-Bitmap-Loaders.html' title='Drawing Mountains in OpenGL Using Bitmap Loaders'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTUFKxYXohMe9CwHB8QG4eIfHrP-oQPjAqHg5I-dYfy9Gzo3e5c_JG8k5B4-_ToBI4nLsuLvUdKY4T8PWWuX9kTVRnsLH8PX28ClQyEACuvW0JG6xTb67Ai7Ta5ZlVQPBsCEuc4qJE2bdsPIOIVachS_qRMty4wWclefcZF74ySd5fTV-AIwc_F5OzlcXp/s72-c/Mountains%20in%20OpenGL%20Using%20Bitmap%20Loaders.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-1567782612329895065</id><published>2025-06-18T02:30:00.004+05:30</published><updated>2025-06-22T01:50:39.199+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Solar"/><title type='text'>Opengl Computer Graphics Projects on Solar Energy Solar Power</title><content type='html'>&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;We are going to get started Opengl Computer Graphics Projects on Solar Power/Solar Energy.&lt;div&gt;&lt;br /&gt;&amp;nbsp;&lt;h2&gt;Abstract&lt;/h2&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The Main aim of this Mini OpenGL Project is to illustrate/demonstrate the working principle of Solar power/Solar Energy using the concepts and usage of pre-built functions in OpenGL.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this we are going to demo Solar power using OpenGL. During day electricity is generated through solar panels which are set in fields called as solar farms and is transmitted to near by homes and excess is stored in a power station. During night the power station supplies the stored power to homes. We have used input devices like mouse and key board to interact with in the OpenGL C/C++ program.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Solar Power&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Solar power is the power or say energy generated by conversion of sunlight into electricity using solar panels. For Generating energy or power these panels (Solar Panels), uses the photovoltaic cells in them which, convert light into direct current (DC). The DC, afterwards converted to alternating current (AC) for further use in electricity supply or to grid connection, or for storage in batteries. This is&amp;nbsp; a renewable, green, clean energy source, with many advantages , helps in minimizing greenhouse gas emissions during operation and save plane from &lt;a href=&quot;https://www.britannica.com/science/global-warming&quot; target=&quot;_blank&quot;&gt;Global warming&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn_mOvVmQWWVxtSoDVDSGBW3OAC1Yww8vV7n8aCRft9nIbBOIOKW4TXEhQ7oOFIzm31wVnlf7AtmfnQkBR6d1ITMOA3_oQvFGimxl1EZGdfVnqKwunlPtFpTbHEEG5H0tpPLoQogO8H4QLqgaKCOfNFi-l8UHijQpYkHIUuM-FGRGsJ-PypzL7Ey2bhpsh/s729/Opengl%20Computer%20Graphics%20Projects%20on%20Solar%20Energy%20Solar%20Power.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;389&quot; data-original-width=&quot;729&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn_mOvVmQWWVxtSoDVDSGBW3OAC1Yww8vV7n8aCRft9nIbBOIOKW4TXEhQ7oOFIzm31wVnlf7AtmfnQkBR6d1ITMOA3_oQvFGimxl1EZGdfVnqKwunlPtFpTbHEEG5H0tpPLoQogO8H4QLqgaKCOfNFi-l8UHijQpYkHIUuM-FGRGsJ-PypzL7Ey2bhpsh/s320/Opengl%20Computer%20Graphics%20Projects%20on%20Solar%20Energy%20Solar%20Power.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #16161a; font-family: &amp;quot;Open Sans&amp;quot;, Arial, sans-serif; font-size: 23px; line-height: 1.3em; margin: 0px 0px 20px; outline: none; padding: 0px; text-align: start; vertical-align: baseline;&quot;&gt;1. The Basics&lt;/h2&gt;&lt;div&gt;We are going to code this OpenGL C/C++ program using MS Visual Studio, you are free to use other IDE like Code Block, Dev C++ etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First we are going to develop front page where user will input their interaction to start the program. A help screen will also create for getting the information or usage. User will have choice and program will accordingly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We will implement various primitive functions for creating the square, rectangle and circle shape for create the diagram require for the demo of this&amp;nbsp;Opengl Computer Graphics Projects on Solar Energy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #16161a; font-family: &amp;quot;Open Sans&amp;quot;, Arial, sans-serif; font-size: 23px; line-height: 1.3em; margin: 0px 0px 20px; outline: none; padding: 0px; text-align: start; vertical-align: baseline;&quot;&gt;2. Implementation&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;2. 1 Various functions used in this program.&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutInit() : interaction between the windowing system and OPENGL is&lt;/div&gt;&lt;div&gt;initiated&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutInitDisplayMode() : used when double buffering is required and depth&lt;/div&gt;&lt;div&gt;information is required&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutCreateWindow() : this opens the OPENGL window and displays the title&lt;/div&gt;&lt;div&gt;at top of the window&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutInitWindowSize() : specifies the size of the window&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutInitWindowPosition() : specifies the position of the window in screen&lt;/div&gt;&lt;div&gt;co-ordinates&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutKeyboardFunc() : handles normal ascii symbols&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutSpecialFunc() : handles special keyboard keys&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutReshapeFunc() : sets up the callback function for reshaping the window&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutIdleFunc() : this handles the processing of the background&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutDisplayFunc() : this handles redrawing of the window&lt;/div&gt;&lt;div&gt;&amp;nbsp;glutMainLoop() : this starts the main loop, it never returns&lt;/div&gt;&lt;div&gt;&amp;nbsp;glViewport() : used to set up the viewport&lt;/div&gt;&lt;div&gt;&amp;nbsp;glVertex3fv() : used to set up the points or vertices in three dimensions&lt;/div&gt;&lt;div&gt;&amp;nbsp;glColor3fv() : used to render color to faces&lt;/div&gt;&lt;div&gt;&amp;nbsp;glFlush() : used to flush the pipeline&lt;/div&gt;&lt;div&gt;glutPostRedisplay() : used to trigger an automatic redrawal of the object&lt;/div&gt;&lt;div&gt;&amp;nbsp;glMatrixMode() : used to set up the required mode of the matrix&lt;/div&gt;&lt;div&gt;&amp;nbsp;glLoadIdentity() : used to load or initialize to the identity matrix&lt;/div&gt;&lt;div&gt;&amp;nbsp;glTranslatef() : used to translate or move the rotation centre from one&lt;/div&gt;&lt;div&gt;point to another in three dimensions&lt;/div&gt;&lt;div&gt;glRotatef() : used to rotate an object through a specified rotation angle&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; text-align: start;&quot;&gt;&lt;span face=&quot;Open Sans, Arial, sans-serif&quot; style=&quot;color: #16161a;&quot;&gt;&lt;div&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; line-height: 1.3em; margin: 0px 0px 20px; outline: none; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;div&gt;Also See -&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a href=&quot;https://www.openglprojects.in/2020/03/electromagnetic-induction-demo-opengl-program.html&quot; target=&quot;_blank&quot;&gt;Electromagnetic induction demo with opengl graphic program&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.openglprojects.in/2015/04/mini-solar-system-computer-graphics-programs.html&quot; target=&quot;_blank&quot;&gt;Mini Solar System Computer Graphics Programs&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.openglprojects.in/2015/05/3d-solar-system-opengl-graphics-program.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;3D Solar System OpenGL graphics program&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.openglprojects.in/2015/04/wind-mill-cplusplus-projects-download.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;Wind Mill C++ Projects Download&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; line-height: 1.3em; margin: 0px 0px 20px; outline: none; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-size: 23px;&quot;&gt;3. User Interaction&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;This program Opengl Computer Graphics Projects on Solar Energy Solar Power includes following interaction through keyboard.&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;S-&amp;gt;&amp;nbsp; Toggle Day or night&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: 15px; text-align: start;&quot;&gt;&lt;span face=&quot;Open Sans, Arial, sans-serif&quot; style=&quot;color: #16161a;&quot;&gt;&lt;div&gt;H-&amp;gt; Get Help Menu&lt;/div&gt;&lt;div&gt;Q-&amp;gt; Quit&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #16161a; font-family: &amp;quot;Open Sans&amp;quot;, Arial, sans-serif; font-size: 23px; line-height: 1.3em; margin: 0px 0px 20px; outline: none; padding: 0px; text-align: start; vertical-align: baseline;&quot;&gt;4. Source Code&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;The complete Source code of this&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;Open Sans, Arial, sans-serif&quot; style=&quot;color: #16161a;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;Opengl Computer Graphics&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;&amp;nbsp;project can be found in the below&lt;/span&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;. Please Let Us know about your opinion, feedback, question, doubt or any other&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;queries&lt;/span&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;&amp;nbsp;in the comments section below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; font-size: 15px; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;&amp;quot;Open Sans&amp;quot;, Arial, sans-serif&quot; style=&quot;background-color: white; color: #16161a; text-align: start;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;void draw(){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(day){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glClearColor(0.9,0.9,0.9,0.0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}else{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glClearColor(0.3,0.3,0.3,0.0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glRotatef(angle,1,0,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(-10,20,-155);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,1,0.6);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(day){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}else{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidSphere(5,100,100);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(0,-10,5);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(500,10,1000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(0.8,0.7,0.7);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;drawHouse(-3,0,-55);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;drawHouse(-4,0,-35);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;drawHouse(-5,0,-15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;drawHouse(-10,0,-15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;//Solar Panels&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;for(int i=-1;i&amp;lt;3;i++)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;for(int j=5;j&amp;gt;-2;j--)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;drawSolarPanel(i*2,1,j);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;//draw power station.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;stroke_output(0.8,1.8,&quot;Power Station&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;// transformer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(15,5,-100);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;//glScaled(0,2,0.2);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,0.3,0.3);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;//Transformer Power levels&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;// y axis from 5 to 18 and show growth in one second delay&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(day){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;lt;=15000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;grow++;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;angle+=0.002;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;else{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;=0){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;grow--;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;angle-=0.002;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;1000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,-2,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;2000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,-1,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;3000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,0,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;4000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,1,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;5000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,2,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;6000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,3,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;7000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,4,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;8000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,5,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;9000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,6,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;10000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,7,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;11000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,8,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;12000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,9,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;13000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,10,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;14000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPushMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(14.8,11,-99.8);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glScaled(1,0.05,1);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glColor3f(1,1,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSolidCube(15);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glPopMatrix();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(grow&amp;gt;15000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;void doDisplay()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLoadIdentity();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glTranslatef(0.0f,0.0f,-13.0f);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;// Write your Own Code Here&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(help1){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;help();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;draw();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat mat_ambient[]={0.0f,1.0f,2.0f,1.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat mat_diffuse[]={0.0f,1.5f,.5f,1.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat mat_specular[]={5.0f,1.0f,1.0f,1.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat mat_shininess[]={100.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;/*GLfloat lightIntensity[]={3.7f,0.7f,0.7f,1.0f}; Orange&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position[]={2.0f,5.0f,3.0f,1.0f};*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;/*light source properties*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;//if(day){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat lightIntensity[]={1.7f,1.7f,1.7f,1.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position[]={2.0f,0.0f,0.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position2[]={0.0f,0.0f,8.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position2);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position3[]={0.0f,5.0f,15.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position3);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;/*}else{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat lightIntensity[]={0.7f,0.7f,0.7f,0.5f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position[]={2.0f,0.0f,0.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position2[]={0.0f,0.0f,8.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position2);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;GLfloat light_position3[]={0.0f,2.0f,2.0f,0.0f};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_POSITION,light_position3);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glFlush();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutSwapBuffers();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;void mykey(unsigned char key,int x,int y)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(key==&#39;q&#39;||key==&#39;Q&#39;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;exit(0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(key==&#39;h&#39;||key==&#39;H&#39;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;help1=!help1;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutPostRedisplay();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(key==&#39;s&#39; || key==&#39;S&#39;){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;if(day){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;day=false;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}else{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;day=true;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutPostRedisplay();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutIdleFunc(doDisplay);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;int main(int argc, char *argv[])&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutInit(&amp;amp;argc, argv);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutInitWindowSize(640,480);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutInitWindowPosition(0,0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutCreateWindow(&quot;Solar power&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutDisplayFunc(doDisplay);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glEnable(GL_LIGHTING);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glEnable(GL_LIGHT0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glShadeModel(GL_SMOOTH);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glEnable(GL_DEPTH_TEST);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glEnable(GL_NORMALIZE);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutKeyboardFunc(mykey);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;doInit();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;glutMainLoop();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;return 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;alert-message alert-info&quot;&gt;We have so many good programs in OpenGL.  &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/1567782612329895065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/06/Opengl-Computer-Graphics-Projects-on-Solar-Energy-Solar-Power.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1567782612329895065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/1567782612329895065'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/06/Opengl-Computer-Graphics-Projects-on-Solar-Energy-Solar-Power.html' title='Opengl Computer Graphics Projects on Solar Energy Solar Power'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn_mOvVmQWWVxtSoDVDSGBW3OAC1Yww8vV7n8aCRft9nIbBOIOKW4TXEhQ7oOFIzm31wVnlf7AtmfnQkBR6d1ITMOA3_oQvFGimxl1EZGdfVnqKwunlPtFpTbHEEG5H0tpPLoQogO8H4QLqgaKCOfNFi-l8UHijQpYkHIUuM-FGRGsJ-PypzL7Ey2bhpsh/s72-c/Opengl%20Computer%20Graphics%20Projects%20on%20Solar%20Energy%20Solar%20Power.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4601554936931675922</id><published>2025-04-27T03:53:00.013+05:30</published><updated>2025-04-27T04:24:59.171+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Communication"/><category scheme="http://www.blogger.com/atom/ns#" term="Networking Based Project"/><title type='text'>Create OpenGL CG Projects on Networking Data Communication</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;We have developed Selective Repeat ARQ a networking based Create OpenGL CG Projects with C/C++. In this post we are going to create new networking based project. As well aware of Internet which help us communicate through various means including mail, chat and social media. We are going to create OpenGL Project on Networking Data Communication.
Let&#39;s get started with some basics information.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: justify;&quot;&gt;Abstract -&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Our Aim is to Create, design and the illustrate the concepts and usage of Data Communication over Internet Using OpenGL C/C++.

The Communication between two devices begins with a message/information of which one send the message and other receive it. The first device is called source, or sender while the second device i is the destination/receiver, of the message. The destination receives the message and interprets it. Another element involved in the process is called channel, which consists of the media that provides the pathway over which the message can travel from source to destination.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNYQd6vvD_A2fjXT1IGI8a6ttjyX4Mxp8id6XO0-uFXcFKqTvGIoX6BuAyZzGoozdYMFPFRH6-yWOSHgzJnSj14UhFP4DDD1WH-qX6i9iEsSYA9-BzX7lBhUuXPncWHvVdg_zWX_2pQHnQfeGKlY7GlVIknWQBC2I61TCJb3NLABenToPd8qEVTLxPVHAT/s1366/CG%20Projects%20on%20Networking%20Data%20Communication1.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;723&quot; data-original-width=&quot;1366&quot; height=&quot;169&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNYQd6vvD_A2fjXT1IGI8a6ttjyX4Mxp8id6XO0-uFXcFKqTvGIoX6BuAyZzGoozdYMFPFRH6-yWOSHgzJnSj14UhFP4DDD1WH-qX6i9iEsSYA9-BzX7lBhUuXPncWHvVdg_zWX_2pQHnQfeGKlY7GlVIknWQBC2I61TCJb3NLABenToPd8qEVTLxPVHAT/s320/CG%20Projects%20on%20Networking%20Data%20Communication1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

This program is implemented using various OpenGL functions which are shown below&lt;/div&gt;&lt;div class=&quot;download_code&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;download_code&quot;&gt;Various functions used in this program.&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;glutInit() : interaction between the windowing system and OPENGL is initiated&lt;/li&gt;&lt;li&gt;glutInitDisplayMode() : used when double buffering is required and depth information is required&lt;/li&gt;&lt;li&gt;glutCreateWindow() : this opens the OPENGL window and displays the title at top of the window&lt;/li&gt;&lt;li&gt;glutInitWindowSize() : specifies the size of the window&lt;/li&gt;&lt;li&gt;glutInitWindowPosition() : specifies the position of the window in screen co-ordinates&lt;/li&gt;&lt;li&gt;glutKeyboardFunc() : handles normal ASCII symbols&lt;/li&gt;&lt;li&gt;glutSpecialFunc() : handles special keyboard keys&lt;/li&gt;&lt;li&gt;glutReshapeFunc() : sets up the callback function for reshaping the window&lt;/li&gt;&lt;li&gt;glutIdleFunc() : this handles the processing of the background&lt;/li&gt;&lt;li&gt;glutDisplayFunc() : this handles redrawing of the window&lt;/li&gt;&lt;li&gt;glutMainLoop() : this starts the main loop, it never returns&lt;/li&gt;&lt;li&gt;glViewport() : used to set up the viewport&lt;/li&gt;&lt;li&gt;glVertex3fv() : used to set up the points or vertices in three dimensions&lt;/li&gt;&lt;li&gt;glColor3fv() : used to render color to faces&lt;/li&gt;&lt;li&gt;glFlush() : used to flush the pipeline&lt;/li&gt;&lt;li&gt;glutPostRedisplay() : used to trigger an automatic redrawal of the object&lt;/li&gt;&lt;li&gt;glMatrixMode() : used to set up the required mode of the matrix&lt;/li&gt;&lt;li&gt;glLoadIdentity() : used to load or initialize to the identity matrix&lt;/li&gt;&lt;li&gt;glTranslatef() : used to translate or move the rotation centre from one point to another in three dimensions&lt;/li&gt;&lt;li&gt;glRotatef() : used to rotate an object through a specified rotation angle&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Interactions&lt;/h3&gt;Interaction with program We can have an interaction with this project using popular input device like mouse and key board are used to interact with this program. Some keys of key board have specific function, we mentioned them below,&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;‘s/S’ - Start&lt;/li&gt;&lt;li&gt;‘n/N’ – Network&lt;/li&gt;&lt;li&gt;‘a/A’ – About Project&lt;/li&gt;&lt;/ol&gt;With these above mentioned keys, we can interact with the program. Also we can interact with this program by using mouse (input device), By click on right and left button On right click of mouse menu will occur. Select the option by left click of mouse.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgekYSsHHh8N-cY4TYz0W67xEqXhKhat8yeIZke0m14JsSxIK__52rxdP1E7_brOLKruXFbu2p_omdFacd5Cb6k2yiT0fc2Np-B0NSgF9gyEKfZ10uzWo5eP7NRbWKLEJk2-h9B8uXjYr_9Jhn7RN5r28wGzsQIfmjgck2XF-7URPXAY1Rxw5ocIjX1xx8z/s1366/CG%20Projects%20on%20Networking%20Data%20Communication2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;725&quot; data-original-width=&quot;1366&quot; height=&quot;170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgekYSsHHh8N-cY4TYz0W67xEqXhKhat8yeIZke0m14JsSxIK__52rxdP1E7_brOLKruXFbu2p_omdFacd5Cb6k2yiT0fc2Np-B0NSgF9gyEKfZ10uzWo5eP7NRbWKLEJk2-h9B8uXjYr_9Jhn7RN5r28wGzsQIfmjgck2XF-7URPXAY1Rxw5ocIjX1xx8z/s320/CG%20Projects%20on%20Networking%20Data%20Communication2.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5cBGRqZKYfBKhN1prXtqIpN5XCXZR32PoooE4Sgtm2j6UDDytbaoIahywnrViTa6eg8dsu_LejPJtkmKEIS_5tVkEZiv553m1Czhd8OLhZglGFy6TX1BpcKgD_L9IUYX8FHTrFzWvUD20fWzTYcA3Jl5h55V93_3a_IgVUsCPWNLHKDKunzNcdy6LXsvU/s1366/CG%20Projects%20on%20Networking%20Data%20Communication3.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;718&quot; data-original-width=&quot;1366&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5cBGRqZKYfBKhN1prXtqIpN5XCXZR32PoooE4Sgtm2j6UDDytbaoIahywnrViTa6eg8dsu_LejPJtkmKEIS_5tVkEZiv553m1Czhd8OLhZglGFy6TX1BpcKgD_L9IUYX8FHTrFzWvUD20fWzTYcA3Jl5h55V93_3a_IgVUsCPWNLHKDKunzNcdy6LXsvU/s320/CG%20Projects%20on%20Networking%20Data%20Communication3.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
 
&lt;div class=&quot;code-container&quot;&gt;
&lt;div class=&quot;code-header&quot;&gt;
&lt;span class=&quot;file-name&quot;&gt;&lt;/span&gt;
        &lt;button class=&quot;copy-btn&quot;&gt;Copy&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;hljs language-kotlin&quot; data-highlighted=&quot;yes&quot;&gt;#include&lt;stdlib .h=&quot;&quot;&gt;
#include&lt;windows .h=&quot;&quot;&gt;
#include&lt;string .h=&quot;&quot;&gt;
#include&lt;stdarg .h=&quot;&quot;&gt;
#include&lt;stdio .h=&quot;&quot;&gt;
#include &lt;gl glut.h=&quot;&quot;&gt;
static double x=0.0,x1=-3.0,x2=3.0,y1=0.0,y2=0;
static double x8=-4.0,x9=4.0,y8=1.0,y9=1;
static double move=-60;
static bool pca2pcb=false,pca2rt=false,rt2pca=false, pcb2pca=false, local=false,
dubai=false;
void P();
void d();
void *font;
void *currentfont;
void setFont(void *font)
{
currentfont=font;
}
void drawstring(float x,float y,float z,char *string)
{
char *c;
glRasterPos3f(x,y,z);
for(c=string;*c!=&#39;\0&#39;;c++)
{ glColor3f(0.0,1.0,1.0);
glutBitmapCharacter(currentfont,*c);
}
}
void stroke_output(GLfloat x, GLfloat y, char *format,...)
{ va_list args;
char buffer[200], *p;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
glPushMatrix();
DATA COMMUNICATION over INTERNET
11 Dept. of Computer Science &amp;amp; Engineering.
glTranslatef(-2.5, y, 0);
glScaled(0.003, 0.005, 0.005);
for (p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
}
//Windows
void window(float x4, float y4)
{
glLoadIdentity();
glColor3f(1.0,1.5,0.5);
glTranslatef(0.0f,0.0f,-11.0f);
for(float j=-2;j&lt;1 .5=&quot;&quot; 12=&quot;&quot; change=&quot;&quot; color=&quot;&quot; communication=&quot;&quot; computer=&quot;&quot; computers=&quot;&quot; condition=&quot;&quot; data=&quot;&quot; dept.=&quot;&quot; engineering.=&quot;&quot; f=&quot;&quot; float=&quot;&quot; for=&quot;&quot; glcolor3f=&quot;&quot; glloadidentity=&quot;&quot; glpopmatrix=&quot;&quot; glpushmatrix=&quot;&quot; glrotatef=&quot;&quot; glscaled=&quot;&quot; gltranslatef=&quot;&quot; glutsolidcube=&quot;&quot; glutsolidtorus=&quot;&quot; i=&quot;&quot; if=&quot;&quot; indows=&quot;&quot; internet=&quot;&quot; j=&quot;&quot; of=&quot;&quot; ondition=&quot;&quot; outer=&quot;&quot; over=&quot;&quot; pc=&quot;&quot; pca=&quot;&quot; pcb2pca=&quot;&quot; pcb=&quot;&quot; router=&quot;&quot; science=&quot;&quot; to=&quot;&quot; void=&quot;&quot; window1=&quot;&quot; x5=&quot;&quot; x6=&quot;&quot; x7=&quot;=5)&quot; x9=&quot;&quot; y5=&quot;&quot; y6=&quot;&quot; y7=&quot;&quot; z7=&quot;&quot;&gt;=-5 &amp;amp;&amp;amp; x9&amp;lt;=-4 &amp;amp;&amp;amp; x7==-5)
glColor3f(1,0,0);
glScaled(.7,.7,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
DATA COMMUNICATION over INTERNET
13 Dept. of Computer Science &amp;amp; Engineering.
glutSolidCube(.85);
glPopMatrix();
glPopMatrix();
}
//PC
void cpu(float x7, float y7, float z7)
{ glLoadIdentity();
glColor3f(0.5,0.5,.5);
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glPushMatrix();
glScaled(1,.3,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glColor3f(1,1,1);
glScaled(1,.3,0);
glRotatef(95,1.0f,0.0f,0.0f);
glTranslatef(x7,y7,z7);
glutSolidCube(.4);
glPopMatrix();
glPopMatrix();
}
//Draw LAN/WAN
void lan(double x8,double y8)
{
glClearColor(0.6,0.5,.5,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
router(0,-1);
//Data Media (connected to Router)
glPushMatrix();
DATA COMMUNICATION over INTERNET
14 Dept. of Computer Science &amp;amp; Engineering.
glTranslatef(0.0,1.0,-2.0);
glScaled(0.1,5.0,0.1);
glColor3f(1,1,1);
glutWireCube(1.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.0,-2.0);
glScaled(5.1,0.1,0.1);
glColor3f(1,1,1);
glutWireCube(1.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.0,-2.0);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(1,3.5,-1.0,&quot;ROUTER&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-4.6,.5,-1.0,&quot;PC-A&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-.5,.5,-1.0,&quot;SWITCH&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(4,.5,-1.0,&quot;PC-B&quot;);
glPopMatrix();
//Data Transfer
if(pca2pcb){
// data
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
if(x8&amp;gt;=4){
DATA COMMUNICATION over INTERNET
15 Dept. of Computer Science &amp;amp; Engineering.
pcb2pca=true;
pca2pcb=false;
} }
//Ack
if(pcb2pca){
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
}
if(pca2rt)
{
glPushMatrix();
glTranslatef(x8,y8,-2.0);
glScaled(0.1,0.1,0.1);
glColor3f(x8,0,1);
glutSolidCube(1);
glPopMatrix();
}
// move the packet out of LAN
if(pca2rt &amp;amp;&amp;amp; rt2pca==false &amp;amp;&amp;amp; y8&amp;gt;=6)
{
glutIdleFunc(P);
}
//switch
glPushMatrix();
glColor3f(0.5,0.5,1.5);
glTranslatef(0.0,0,1.0);
glRotatef(15,1.0f,0.0f,0.0f);
glScaled(1.2,0.2,1.0);
glutSolidCube(1);
glPopMatrix();
pc(-5,1,0);
cpu(-3.5,7,1.5);
DATA COMMUNICATION over INTERNET
16 Dept. of Computer Science &amp;amp; Engineering.
pc(5,1,0);
cpu(3.5,7,1.5);
pc(0,20,2);
cpu(0,105,1.5);
glFlush();
glutSwapBuffers();
}
// Draw Network
void network(double ang,double x1,double x2,double y1,double y2)
{
glClearColor(0.0,0.85,1,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
glBegin(GL_POLYGON);
glColor3f(0.0,1.8,0.0);
glVertex2f(-10,0);
glVertex2f(10,0);
glVertex2f(-10,-10);
glVertex2f(-10,10);
glEnd();
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-4.2,2.65,0.0,&quot;LOCAL BUILDING&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-1.5,3.2,0.0,&quot;EARTH Connected with Fibric Wires&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(2.5,2.65,0.0,&quot;DUBAI BUILDING&quot;);
//Earth
glPushMatrix();
glColor3f(0.5,0.5,1.5);
glScaled(0.8,1,0.8);
glTranslatef(0.0,2.2,0.0);
glRotatef(ang,0.0f,-1.0f,0.0f);
DATA COMMUNICATION over INTERNET
17 Dept. of Computer Science &amp;amp; Engineering.
glutSolidSphere(1,20,20);
glPopMatrix();
//Building A
glLoadIdentity();
glTranslatef(0.0f,0.0f,-12.0f);
glPushMatrix();
glTranslatef(-3,-0.5,0.0);
glScaled(0.8,2.2,0.8);
glutSolidCube(1.8);
glPopMatrix();
window(-2.6, 1);
//Building B
glLoadIdentity();
glTranslatef(0.0f,0.0f,-12.0f);
glPushMatrix();
glTranslatef(3,-0.5,0.0);
glScaled(0.8,2.2,0.8);
glutSolidCube(1.8);
glPopMatrix();
window1(3.3, 1);
// Line 1
glPushMatrix();
glTranslatef(-3.0,1.0,-2.0);
glScaled(0.1,3.0,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(-1.45,2.4,-2.0);
glScaled(3.0,0.2,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
//Line 2
glPushMatrix();
DATA COMMUNICATION over INTERNET
18 Dept. of Computer Science &amp;amp; Engineering.
glTranslatef(3.0,1.0,-2.0);
glScaled(0.1,3.0,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(1.45,2.4,-2.0);
glScaled(3.0,0.2,0.1);
glColor3f(1,1,1);
glutWireCube(1);
glPopMatrix();
// Transmission of Datapackets
glPushMatrix();
// Send Packets
if(local){
if(x1==-3 &amp;amp;&amp;amp; y1&amp;lt;=2.38)
glTranslatef(-3,y1,-2.0);
if(y1&amp;gt;=2.38 &amp;amp;&amp;amp; x1&amp;lt;=3)
glTranslatef(x1,2.38,-2.0);
if(x1&amp;gt;=3 &amp;amp;&amp;amp; y1&amp;gt;=0)
glTranslatef(3,y1,-2.0);
if(x1&amp;gt;=3 &amp;amp;&amp;amp; y1&amp;lt;=0.0)
{
dubai=true;
local=false;
} }
// Ack packets
if(dubai)
{
if(x2&amp;gt;=3 &amp;amp;&amp;amp; y2&amp;lt;=2.38)
glTranslatef(3,y2,-2.0);
if(y2&amp;gt;=2.38 &amp;amp;&amp;amp; x2&amp;gt;=-3)
glTranslatef(x2,2.38,-2.0);
if(x2&amp;lt;=-3 &amp;amp;&amp;amp; y2&amp;gt;=0.0)
glTranslatef(-3,y2,-2.0);
if(x2&amp;lt;=-3 &amp;amp;&amp;amp; y2&amp;lt;=0.0)
DATA COMMUNICATION over INTERNET
19 Dept. of Computer Science &amp;amp; Engineering.
{
dubai=false;
local=true;
rt2pca=true;
x8=0;
y8=6;
glutIdleFunc(d);
} }
glScaled(0.1,0.1,0.1);
glColor3f(1,1,1);
glutSolidCube(1);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void building(double ang)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
glPushMatrix();
glScaled(0.3,1.5,0.3);
glRotatef(90,1.0f,0.0f,0.0f);
glTranslatef(8.5,0,-0.5);
glutSolidTorus(0.2,1.0,40,40);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void about()
{
glClearColor(0.0,0.85,1,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
DATA COMMUNICATION over INTERNET
20 Dept. of Computer Science &amp;amp; Engineering.
glColor3f(0,0,0);
drawstring(-4.2,2,0.0,&quot;About Data Communication&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0,0,0);
drawstring(-3.5,1.5,0.0,&quot;1. Data Communications refers to the exchange of
data between two devices via some&quot;);
glColor3f(0,0,0);
drawstring(-3.5,1,0.0,&quot; form of transmission medium such as a wire
cable.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,.5,0.0,&quot;2. Similarly data and information from one computer
system can be transmitted to&quot;);
glColor3f(0,0,0);
drawstring(-3.5,0.0,0.0,&quot; other systems across geographical areas.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-0.5,0.0,&quot;3. Thus data transmission is the movement of
information using some standard methods.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-1,0.0,&quot;4. The effectiveness of a data communications
system depends on&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-1.5,0.0,&quot; four fundamental characteristics: delivery,
accuracy, timeliness, and jitter.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-2,0.0,&quot;5. A network is two or more devices connected
through links.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-2.5,0.0,&quot;6. A link is a communications pathway that
transfers data from one device to another.&quot;);
glColor3f(0,0,0);
drawstring(-3.5,-3,0.0,&quot;7. Type of Connection : Point-to-Point &amp;amp;
Multipoint.&quot;);
glFlush();
glutSwapBuffers();
}
void s()
DATA COMMUNICATION over INTERNET
21 Dept. of Computer Science &amp;amp; Engineering.
{
lan(-4,1);
}
void n()
{
x-=0.07;
network(x,0,0,0,0);
}
void P()
{
if(local)
{
if(x1==-3 &amp;amp;&amp;amp; y1&amp;lt;=2.38){
y1+=0.01;
}
if(y1&amp;gt;=2.38 &amp;amp;&amp;amp; x1&amp;lt;=3.0)
{ x1+=0.01;
}
if(x1&amp;gt;=3 &amp;amp;&amp;amp; y1&amp;gt;=0.0){
y1-=0.01;
}
x+= .07;
network(x,x1,x2,y1,y2);
}
//Dubai to local
if(dubai)
{
if(x2&amp;gt;=3 &amp;amp;&amp;amp; y2&amp;lt;=2.38)
y2+=0.01;
if(y2&amp;gt;=2.38 &amp;amp;&amp;amp; x2&amp;gt;=-3)
x2-=0.01;
if(x2&amp;lt;=-3 &amp;amp;&amp;amp; y2&amp;gt;=0.0)
y2-=0.01;
x+= .07;
network(x,x1,x2,y1,y2);
} }
DATA COMMUNICATION over INTERNET
22 Dept. of Computer Science &amp;amp; Engineering.
void d()
{
if(pca2pcb)
{ if(x8&amp;gt;=-4 &amp;amp;&amp;amp; x8&amp;lt;=4){
x8+=0.01;
}
lan(x8,0);
}
if(pcb2pca)
{
if(x9&amp;lt;=4 &amp;amp;&amp;amp; x9&amp;gt;=-4){
x9-=0.01;
}
lan(x9,0);
}
// To Dubai
if(pca2rt &amp;amp; rt2pca==false)
{
if(x8&amp;gt;=-4 &amp;amp;&amp;amp; y8&amp;lt;=6){
if(x8&amp;lt;=0)
{x8+=0.01;
}
if(x8&amp;gt;=0 &amp;amp;&amp;amp; y8&amp;lt;=6)
{
y8+=0.01;
}
}
lan(x8,y8);
}
if(rt2pca)
{
if(x8&amp;lt;=0 &amp;amp;&amp;amp; y8&amp;lt;=6){
if(y8&amp;gt;=0)
{y8-=0.01;
}
if(x8&amp;gt;=-4 &amp;amp;&amp;amp; y8&amp;lt;=0)
DATA COMMUNICATION over INTERNET
23 Dept. of Computer Science &amp;amp; Engineering.
{
x8-=0.01;
} }
lan(x8,y8);
} }
void doInit()
{
/* Background and foreground color */
glClearColor(0.0,0.0,0.0,0);
glViewport(0,0,640,480);
/* Select the projection matrix and reset it then
setup our view perspective */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0f,(GLfloat)640/(GLfloat)480,0.1f,200.0f);
/* Select the modelview matrix, which we alter with rotatef() */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearDepth(2.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
}
void display()
{
glClearColor(0.1,0.1,0.5,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(3.0,1.0,1.0);
drawstring(-1.5,3.0,0.0,&quot;DEPARTMENT OF COMPUTER SCIENCE&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-3.0,2.5,0.0,&quot;Computer Graphics Mini Project on DATA
COMMUNICATION IN NETWORK&quot;);
DATA COMMUNICATION over INTERNET
24 Dept. of Computer Science &amp;amp; Engineering.
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-1,2,0,&quot;Using OPENGL&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-0.5,1.5,0,&quot;By&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-2,1,0,&quot;BUSHRA JABEEN (USN : 3KB10CS022)&quot;);
setFont(GLUT_BITMAP_TIMES_ROMAN_24);
glColor3f(0.0,1.0,1.0);
drawstring(-2,.5,0,&quot;BUSHRA SULTANA (USN : 3KB10CS023)&quot;);
stroke_output(-2.0, -1, &quot;s --&amp;gt; Start&quot;);
stroke_output(-2.0, -1.75, &quot;A --&amp;gt; About&quot;);
stroke_output(-2.0, -3,&quot;q --&amp;gt; Quit&quot;);
GLfloat mat_ambient[]={0.0f,1.0f,2.0f,1.0f};
GLfloat mat_diffuse[]={0.0f,1.5f,.5f,1.0f};
GLfloat mat_specular[]={5.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[]={50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
GLfloat lightIntensity[]={1.7f,1.7f,1.7f,1.0f};
GLfloat light_position3[]={0.0f,5.0f,5.0f,0.0f};
glLightfv(GL_LIGHT0,GL_POSITION,light_position3);
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glEnable(GL_COLOR_MATERIAL);
glFlush();
glutSwapBuffers();
}
void menu(int id)
{
switch(id)
{
case 1:glutIdleFunc(about);
DATA COMMUNICATION over INTERNET
25 Dept. of Computer Science &amp;amp; Engineering.
break;
case 2:glutIdleFunc(s);
break;
case 3:glutIdleFunc(d);
break;
case 4:glutIdleFunc(P);
break;
case 5:glutIdleFunc(n);
break;
case 6:
pca2pcb=true;
x8=-4;
glutIdleFunc(d);
break;
case 7:
local=true;
dubai=false;
pca2rt=true;
x8=-4.0;x9=4.0;y8=0.0; y9=0;
pca2pcb=false;
pcb2pca=false;
glutIdleFunc(d);
break;
case 8: pca2rt=false;
pca2pcb=false;
x8=-4.0;x9=4.0;y8=1.0; y9=0;
x=0.0;x1=-3.0;x2=3.0;y1=0.0;y2=2.38;
pca2pcb=false;pca2rt=false; pcb2pca=false;
glutIdleFunc(s);
break;
case 9:exit(0);
break;
}
glFlush();
glutSwapBuffers();
glutPostRedisplay();
DATA COMMUNICATION over INTERNET
26 Dept. of Computer Science &amp;amp; Engineering.
}
void mykey(unsigned char key,int x,int y)
{
if(key==&#39;s&#39;)
{
glutIdleFunc(s);
}
if(key==&#39;n&#39;)
{
glutIdleFunc(n);
}
if(key==&#39;P&#39;)
{
glutIdleFunc(P);
}
if(key==&#39;A&#39;)
{
glutIdleFunc(about);
}
if(key==&#39;q&#39;||key==&#39;Q&#39;)
{
exit(0);
}
}
void main(int argc, char *argv[])
{
glutInit(&amp;amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(1000,480);
glutInitWindowPosition(0,0);
glutCreateWindow(&quot;Data Communication in Network&quot;);
glutDisplayFunc(display);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
DATA COMMUNICATION over INTERNET
27 Dept. of Computer Science &amp;amp; Engineering.
glEnable(GL_NORMALIZE);
glutKeyboardFunc(mykey);
glutCreateMenu(menu);
glutAddMenuEntry(&quot;About Project &#39;A&#39;&quot;,1);
glutAddMenuEntry(&quot;Local Area Network(LAN) &#39;s&#39;&quot;,2);
glutAddMenuEntry(&quot;Local Area Network(LAN) &#39;n&#39;&quot;,3);
glutAddMenuEntry(&quot;Wide Area Network(WAN) &#39;P&#39;&quot;,5);
glutAddMenuEntry(&quot;Transfer data from PC-A to PC-B &#39;1&#39;&quot;,6);
glutAddMenuEntry(&quot;Transfer data from PC-A to Company B --&amp;gt;&#39;2&#39;&quot;,7);
glutAddMenuEntry(&quot;Reset &#39;r&#39;&quot;,8);
glutAddMenuEntry(&quot;Quit &#39;q&#39;&quot;,9);
glutAttachMenu(GLUT_RIGHT_BUTTON);
doInit();
glutMainLoop();
}
&lt;/1&gt;&lt;/gl&gt;&lt;/stdio&gt;&lt;/stdarg&gt;&lt;/string&gt;&lt;/windows&gt;&lt;/stdlib&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
  
 &lt;div class=&quot;download_code&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;download_code&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;download_code&quot;&gt;&lt;a class=&quot;btn_left&quot; href=&quot;https://drive.google.com/file/d/1tpBPr_jS4OkUIKwYA3dItK5n4UdoZUPG/view?usp=share_link&quot; target=&quot;_blank&quot;&gt;Download source code&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4601554936931675922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/04/create-opengl-cg-projects-on-networking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4601554936931675922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4601554936931675922'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/04/create-opengl-cg-projects-on-networking.html' title='Create OpenGL CG Projects on Networking Data Communication'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNYQd6vvD_A2fjXT1IGI8a6ttjyX4Mxp8id6XO0-uFXcFKqTvGIoX6BuAyZzGoozdYMFPFRH6-yWOSHgzJnSj14UhFP4DDD1WH-qX6i9iEsSYA9-BzX7lBhUuXPncWHvVdg_zWX_2pQHnQfeGKlY7GlVIknWQBC2I61TCJb3NLABenToPd8qEVTLxPVHAT/s72-c/CG%20Projects%20on%20Networking%20Data%20Communication1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5586055010079604660</id><published>2025-02-26T20:56:00.003+05:30</published><updated>2025-02-26T20:57:48.990+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="IC engine"/><title type='text'>Internal combustion engine - IC engine - OpenGL Computer Graphics Project</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;In this post we are going to referring to a project that involves computer graphics related to an internal combustion (IC) engine in particular petrol engine.We are going to focus on the design of engine components, simulations of the engine cycle and will going to show visualizations of how the internal combustion (IC) engine&amp;nbsp;works.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;An &lt;strong data-end=&quot;39&quot; data-start=&quot;3&quot;&gt;internal combustion engine (IC Engine)&lt;/strong&gt; is a type of heat engine that generates power by burning (using oxidizer usually air) fuel (typically gasoline(petrol), diesel, or natural gas etc) inside a combustion chamber. IC&amp;nbsp;&lt;strong data-end=&quot;39&quot; data-start=&quot;3&quot;&gt;engines&lt;/strong&gt;&amp;nbsp;are used in many vehicles, including cars, motorcycles, trucks, and airplanes. Below is Figure of an Typical&amp;nbsp;&amp;nbsp;IC engine.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Four_stroke_engine_diagram.jpg/220px-Four_stroke_engine_diagram.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;248&quot; data-original-width=&quot;220&quot; height=&quot;320&quot; src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Four_stroke_engine_diagram.jpg/220px-Four_stroke_engine_diagram.jpg&quot; width=&quot;284&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;p data-end=&quot;372&quot; data-start=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;Before going to &lt;a href=&quot;https://github.com/prasannakusugal/Computer-Graphics-Project&quot; target=&quot;_blank&quot;&gt;OpenGL Computer Graphics Project for IC engine&lt;/a&gt; let us know some more information about&amp;nbsp;Internal combustion engine.&lt;/p&gt;&lt;p data-end=&quot;436&quot; data-start=&quot;374&quot; style=&quot;text-align: justify;&quot;&gt;Here’s a breakdown of how an internal combustion engine works:&lt;/p&gt;&lt;ol data-end=&quot;1033&quot; data-start=&quot;438&quot;&gt;&lt;li data-end=&quot;527&quot; data-start=&quot;438&quot;&gt;&lt;p data-end=&quot;527&quot; data-start=&quot;441&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;452&quot; data-start=&quot;441&quot;&gt;Intake:&lt;/strong&gt; The engine draws in a mixture of fuel and air into the combustion chamber.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;697&quot; data-start=&quot;529&quot;&gt;&lt;p data-end=&quot;697&quot; data-start=&quot;532&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;548&quot; data-start=&quot;532&quot;&gt;Compression:&lt;/strong&gt; The intake valve closes, and the piston moves upwards, compressing the fuel-air mixture. This increases the pressure and temperature of the mixture.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;905&quot; data-start=&quot;699&quot;&gt;&lt;p data-end=&quot;905&quot; data-start=&quot;702&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;723&quot; data-start=&quot;702&quot;&gt;Power/Combustion:&lt;/strong&gt; A spark plug ignites the compressed fuel-air mixture, causing a controlled explosion. This explosion pushes the piston down, which creates the mechanical energy to power the engine.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;1033&quot; data-start=&quot;907&quot;&gt;&lt;p data-end=&quot;1033&quot; data-start=&quot;910&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;922&quot; data-start=&quot;910&quot;&gt;Exhaust:&lt;/strong&gt; The exhaust valve opens, and the piston moves upwards again to expel the combustion gases out of the cylinder.&lt;/p&gt;&lt;/li&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/4StrokeEngine_Ortho_3D_Small.gif/220px-4StrokeEngine_Ortho_3D_Small.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;293&quot; data-original-width=&quot;220&quot; height=&quot;293&quot; src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/4StrokeEngine_Ortho_3D_Small.gif/220px-4StrokeEngine_Ortho_3D_Small.gif&quot; width=&quot;220&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/ol&gt;&lt;p data-end=&quot;1220&quot; data-start=&quot;1035&quot; style=&quot;text-align: justify;&quot;&gt;The cycle repeats continuously, with pistons moving up and down, creating the power needed to drive a vehicle or perform work. There are two common types of internal combustion engines:&lt;/p&gt;&lt;ul data-end=&quot;1432&quot; data-start=&quot;1221&quot;&gt;&lt;li data-end=&quot;1323&quot; data-start=&quot;1221&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;1246&quot; data-start=&quot;1223&quot;&gt;Two-stroke engines:&lt;/strong&gt; Complete a power cycle with two strokes of the piston (one up and one down).&lt;/li&gt;&lt;li data-end=&quot;1432&quot; data-start=&quot;1324&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;1350&quot; data-start=&quot;1326&quot;&gt;Four-stroke engines:&lt;/strong&gt; Complete a power cycle in four strokes (intake, compression, power, and exhaust).&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Usages :&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;Keyboard:&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&#39;Space&#39; :&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;stop/start Engine&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&#39;+&#39; :&amp;nbsp; Speed up Engine&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&#39;-&#39; :&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;Speed&lt;/span&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&amp;nbsp;down Engine&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/prasannakusugal/Computer-Graphics-Project/refs/heads/master/ic_engine_screenshot.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;965&quot; data-original-width=&quot;1920&quot; height=&quot;322&quot; src=&quot;https://raw.githubusercontent.com/prasannakusugal/Computer-Graphics-Project/refs/heads/master/ic_engine_screenshot.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;Code :&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;overflow-wrap: break-word;&quot;&gt;&lt;div style=&quot;text-align: justify; text-wrap-mode: wrap;&quot;&gt;//Simple Program:&lt;/div&gt;&lt;div style=&quot;text-align: justify; text-wrap-mode: wrap;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify; text-wrap-mode: wrap;&quot;&gt;#include&amp;lt;GL/glut.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify; text-wrap-mode: wrap;&quot;&gt;#include &amp;lt;math.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-wrap-mode: wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;text-wrap-mode: wrap;&quot;&gt;void *font = GLUT_BITMAP_TIMES_ROMAN_24;
char buff[10];
void *fonts[] =
{
  GLUT_BITMAP_9_BY_15,
  GLUT_BITMAP_TIMES_ROMAN_10,
  GLUT_BITMAP_TIMES_ROMAN_24
};
int cc=25,cb=65,s=0,speed=30,status=1;
float pointer=25;
typedef struct
{ GLfloat x,y;} Pt;
Pt  q1, q2,q3,q4;
GLfloat colors[][3] = {{0.5,0.5,0.5},{0.5,0.5,0.5},{0.8,0.8,0.8},{0.8,0.8,0.8},{0.8,0.8,0.8},{0.4,0.4,0.4}};
void init()
{
	glClearColor(0.0,0,0,0.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0,499.0,0.0,499.0);
    glutPostRedisplay();
}

void DrawLine(Pt n1, Pt n2)
     {

        glBegin(GL_LINES);
 for (int i=0;i&amp;lt;3;i++){
       glVertex2f(n1.x+i, n1.y+i);
       glVertex2f(n2.x+i, n2.y+i);
 }
       glEnd();
  //     glFlush();

     }
void point (float x,float y){
   glPointSize(10.0f);
	glBegin(GL_POINTS);
	glVertex2f(x,y);
glEnd();
//glFlush();

}
void rect(Pt n1, Pt n2,Pt n3, Pt n4){
    glBegin(GL_QUADS);        // Draw The Cube Using quads
//    glColor3f(0.0f,1.0f,0.0f);    // Color Blue
    glVertex2f(n1.x, n1.y);
    glVertex2f(n2.x, n2.y);
    glVertex2f(n3.x, n3.y);
    glVertex2f(n4.x, n4.y);
    glEnd();            // End Drawing The Cube
//glFlush();
}

void Circle(float cx, float cy, float r, int num_segments,int h) {
    //glColor3f(0.0,0.0,1.0);
    float xx,yy,n;
    if(h==1)
    glBegin(GL_LINE_LOOP);//  for not filled circle
    else
    glBegin(GL_TRIANGLE_FAN);

    for (int ii = 0; ii &amp;lt; num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        glVertex2f(x + cx, y + cy);//output vertex

      }
    glEnd();

}
void quad(Pt n1, Pt n2,int i){
    glBegin(GL_QUADS);        // Draw The Cube Using quads
 //   glColor3f(0.0f,1.0f,0.0f);    // Color Blue
    glVertex2f(n1.x-i, n1.y);
    glVertex2f(n1.x+i, n1.y);
    glVertex2f(n2.x+i, n2.y);
    glVertex2f(n2.x-i, n2.y);
    glEnd();            // End Drawing The Cube
//glFlush();
}

void quadd(Pt n1, Pt n2){
    glBegin(GL_QUADS);        // Draw The Cube Using quads
    //glColor3f(0.0f,1.0f,0.0f);    // Color Blue
    glVertex2f(n1.x, n1.y-5);
    glVertex2f(n1.x, n1.y+5);
    glVertex2f(n2.x, n2.y+5);
    glVertex2f(n2.x, n2.y-5);
    glEnd();            // End Drawing The Cube
//glFlush();
}

void rectangle(Pt n1, Pt n2,int i){
	glBegin(GL_QUADS);        // Draw The Cube Using quads
    //glColor3f(0.0f,1.0f,0.0f);    // Color Blue
    glVertex2f(n1.x-i, n1.y);
    glVertex2f(n2.x+i, n1.y);
    glVertex2f(n2.x+i, n2.y);
    glVertex2f(n1.x-i, n2.y);
    glEnd();            // End Drawing The Cube
//glFlush();
}
void outlet(float x,float y){
    glColor3fv(colors[3]);
glBegin(GL_TRIANGLE_FAN);
if(s==1 )
{   if(cc&amp;gt;=75 &amp;amp;&amp;amp; cc&amp;lt;100 || cc&amp;gt;=0 &amp;amp;&amp;amp; cc&amp;lt;=25)
    glColor3f(0.9,0.96,0.96);

}
if(s==0){
   if(cc&amp;gt;25 &amp;amp;&amp;amp; cc&amp;lt;=50){
        float r=(cc-25)*0.006;
        glColor3f(0.9-(r),0.95-(r),0.95-(r));
    }}

        float cx=x+50,cy=y+225,r=32;
    for (int ii = 0; ii &amp;lt; 100; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=25 &amp;amp;&amp;amp; ii&amp;lt;=50)
        glVertex2f(x + cx, y + cy);//output vertex

      } r=10;
    for (int ii = 100; ii &amp;gt;=0; ii--)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=25 &amp;amp;&amp;amp; ii&amp;lt;=50)
        glVertex2f(x + cx, y + cy);//output vertex

      }
        glEnd();
        glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x+100, y+234);
        glVertex2f(x+100, y+256);
        glVertex2d(x+41, y+256);
        glVertex2f(x+41, y+234);
        glEnd();

}

void outletcover(float x,float y){
glColor3fv(colors[1]);
//glColor3f(0,0,0);
glBegin(GL_TRIANGLE_FAN);

        float cx=x+50,cy=y+225,r=34;
    for (int ii = 0; ii &amp;lt; 100; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=25 &amp;amp;&amp;amp; ii&amp;lt;=50)
        glVertex2f(x + cx, y + cy);//output vertex

      } r=8;
    for (int ii = 100; ii &amp;gt;=0; ii--)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=25 &amp;amp;&amp;amp; ii&amp;lt;=50)
        glVertex2f(x + cx, y + cy);//output vertex

      }
        glEnd();
        glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x+100, y+232);
        glVertex2f(x+100, y+259);
        glVertex2d(x+42, y+259);
        glVertex2f(x+42, y+232);
        glEnd();

}
void Crank(float cx, float cy, float r, int num_segments) {
    glColor3f(0.0,0.0,1.0);
    float xx,yy,n;
    glBegin(GL_LINE_LOOP);//  for not filled circle
    //glBegin(GL_TRIANGLE_FAN);
    for (int ii = 0; ii &amp;lt; num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
      if(ii==cc){
       xx=x+ cx;
                yy=y+ cy;    }
      }
    glEnd();
    if(cc&amp;gt;=0 &amp;amp;&amp;amp; cc&amp;lt;25)
    {n=cy+125+(cc*1.4);}
    else if(cc&amp;gt;=25 &amp;amp;&amp;amp; cc&amp;lt;=75)
        {n=cy+160-((cc-25)*1.4);}
     else if(cc&amp;gt;75 &amp;amp;&amp;amp; cc&amp;lt;100)
    {n=cy+90+((cc-75)*1.4);}


    glColor3f(0.0f,1.0f,0.0f);
    q1.x=xx;
    q1.y=yy;
                    /*glColor3f(0.0f,0.0f,1.0f);
                    q2.x=cx;
                    q2.y=cy;
                    quad(q1,q2,5);
                    q2.x=cx;
                    q2.y=cy;
                    quadd(q1,q2);*/
    glColor3f(0.4f,0.4f,0.4f);
    q2.x=cx;
    q2.y=n;
    quad(q1,q2,5);
    q1.x=cx;
    q1.y=n;
    q2.x=cx;
    q2.y=n+40;
    //glColor3f(0.0f,0.0f,1.0f);
    glColor3fv(colors[0]);
    quad(q1,q2,45);
    glColor3f(0.4f,0.4f,0.4f);


    glColor3f(0.4f,0.4f,0.4f);
    q1.x=cx;
    q1.y=n+18;
    q2.x=cx;
    q2.y=n+28;
    //quad(q1,q2,45);
    q1.x=cx;
    q1.y=n+30;
    q2.x=cx;
    q2.y=n+39;
    //quad(q1,q2,45);
    Circle(xx,yy,10,100,0);//crank connector
    Circle(cx,n+10,10,100,0);//piston connecting rod


}

void Crankrod(float cx, float cy, float r, int num_segments) {
    float xx,yy,n,xxx,yyy,flg=0;
    glBegin(GL_TRIANGLE_FAN);
    for (int ii = 0; ii &amp;lt; num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component

      if(ii&amp;gt;=cb &amp;amp;&amp;amp; ii&amp;lt;=(cb+20)){
                glVertex2f(x + cx, y + cy);//output vertex
                if(flg!=1)
                {xxx=x+cx;
                yyy=y+cy;}
    }
     if(cb&amp;gt;=80 &amp;amp;&amp;amp; ii&amp;lt;=(20-(100-cb))){
                glVertex2f(x + cx, y + cy);//output vertex
                xxx=x+cx;
                yyy=y+cy;
                flg=1;
    }
    if(ii==cb){
                xx=x+ cx;
                yy=y+ cy;
    }
    }
    glEnd();

    q1.x=xx;
    q1.y=yy;
    q2.x=xxx;
    q2.y=yyy;
    q3.x=cx;
    q3.y=cy;
    q4.x=cx;
    q4.y=cy;

    rect(q1,q2,q3,q4);


    //glColor3f(0.0,0.0,0.0);

    //Circle(xx,yy,3,100,0);

}void valve(float x,float y){

   float p=0;
    if(s==0){
     if(cc&amp;gt;=25 &amp;amp;&amp;amp; cc&amp;lt;=50)
        p=-(cc-25)*0.6;
     else if(cc&amp;gt;50 &amp;amp;&amp;amp; cc&amp;lt;75)
        p=-15+(cc-50)*0.6;
    }
                    //glColor3f(1.0f,0.0f,0.0f);
                    glColor3fv(colors[5]);
                    q1.x=x-30;
                    q1.y=y+225+p;
                    q2.x=x-30;
                    q2.y=y+220+p;
                    quad(q1,q2,10);
                    q1.x=x-30;
                    q1.y=y+225+p;
                    q2.x=x-30;
                    q2.y=y+276+p;
                    quad(q1,q2,2);


     p=0;
     if(s==1){
  if(cc&amp;gt;=0 &amp;amp;&amp;amp; cc&amp;lt;25)
        p=-15+(cc)*0.6;
    if(cc&amp;gt;=75 &amp;amp;&amp;amp; cc&amp;lt;100)
    p=-(cc-75)*0.6;

    }               q1.x=x+30;
                    q1.y=y+225+p;
                    q2.x=x+30;
                    q2.y=y+220+p;
                    quad(q1,q2,10);
                    q1.x=x+30;
                    q1.y=y+225+p;
                    q2.x=x+30;
                    q2.y=y+276+p;
                    quad(q1,q2,2);


}
void cover(float x,float y){// x=900;y=500;
//glColor3f(1.0,1.0,0.0);
glBegin(GL_TRIANGLE_FAN);
glVertex2d(x-120,y+60);
glVertex2d(x-55,y+125);
glVertex2d(x+55,y+125);
glVertex2d(x+120,y+60);
glVertex2d(x+120,y-120);
glVertex2d(x-120,y-120);
glEnd();

glBegin(GL_TRIANGLE_FAN);
//glVertex2d(780,560);
glVertex2d(x-55,y+125);
glVertex2d(x-55,y+225);
glVertex2d(x-20,y+250);
glVertex2d(x+20,y+250);
glVertex2d(x+55,y+225);
glVertex2d(x+55,y+125);
glEnd();

}
void innlet(float x,float y){
    glColor3fv(colors[3]);

glBegin(GL_TRIANGLE_FAN);
if(s==0 )
{   if(cc&amp;gt;=27 &amp;amp;&amp;amp; cc&amp;lt;75)
    glColor3f(0.0,0.5,1.0);
    if(cc&amp;gt;=75 &amp;amp;&amp;amp; cc&amp;lt;100){
        float r=(cc-75)*0.032;
        glColor3f(0.0+r,0.5+(r/2.66),1.0-(r/4));
    }
}
        float cx=x-50,cy=y+225,r=32;
    for (int ii = 0; ii &amp;lt; 100; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=0 &amp;amp;&amp;amp; ii&amp;lt;=25)
        glVertex2f(x + cx, y + cy);//output vertex

      }r=10;
    for (int ii = 100; ii &amp;gt;=0; ii--)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=0 &amp;amp;&amp;amp; ii&amp;lt;=25)
        glVertex2f(x + cx, y + cy);//output vertex

      }
    glEnd();
        glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x-100, y+256);
        glVertex2f(x-100, y+235);
        glVertex2d(x-49,y+235);
        glVertex2f(x-49, y+256);
        glEnd();

}
void innletcover(float x,float y){
    glColor3fv(colors[1]);

glBegin(GL_TRIANGLE_FAN);
        float cx=x-50,cy=y+225,r=34;
    for (int ii = 0; ii &amp;lt; 100; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=0 &amp;amp;&amp;amp; ii&amp;lt;=25)
        glVertex2f(x + cx, y + cy);//output vertex

      }r=8;
    for (int ii = 100; ii &amp;gt;=0; ii--)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=0 &amp;amp;&amp;amp; ii&amp;lt;=25)
        glVertex2f(x + cx, y + cy);//output vertex

      }
    glEnd();

        glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x-100, y+259);
        glVertex2f(x-100, y+232);
        glVertex2d(x-47,y+232);
        glVertex2f(x-47, y+259);
        glEnd();

}
void spark(float x,float y){
glColor3f(1,1,0.1);
glBegin(GL_TRIANGLE_FAN);
//glBegin(GL_LINE_LOOP);
//glVertex2f(x-5,y+220);
glVertex2f(x+3,y+220);
glVertex2f(x+16,y+225);
glVertex2f(x+10,y+220);
glVertex2f(x+17,y+215);
glVertex2f(x-3,y+220);
glVertex2f(x-16,y+225);
glVertex2f(x-11,y+220);
glVertex2f(x-17,y+215);
glVertex2f(x+3,y+220);
glVertex2f(x+5,y+220);
glVertex2f(x,y+210);
glVertex2f(x-5,y+220);
glEnd();
}
void plug(float x,float y){ //float x=217,y=301;
   glColor3f(0.3,0.3,0.3);
 glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x-2, y+19);
        glVertex2f(x+3, y+19);
        glVertex2f(x+3, y+24);
        glVertex2f(x-2, y+24);
    glEnd();
    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x-7, y+19);
        glVertex2f(x+8, y+19);
        glVertex2f(x+8, y+1);
        glVertex2f(x-7, y+1);
    glEnd();
glColor3f(0.0,0.0,0.0);

    glBegin(GL_QUADS);
        glVertex2f(x-17, y-1);
        glVertex2f(x+19, y-1);
        glVertex2f(x+19, y+1);
        glVertex2f(x-17, y+1);
    glEnd();
    glColor3f(1.8,1.8,1.0);
glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x-9, y-1);
        glVertex2f(x+10, y-1);
        glVertex2f(x+10, y-31);
        glVertex2f(x-9, y-31);
    glEnd();
     glColor3f(0.0,0.0,0.0);
    glBegin(GL_LINES);
        for(int i=0;i&amp;lt;5;i++)
   {
            glVertex2f(x+10, (y-1)-(5*i));
            glVertex2f(x-9, (y-6)-(5*i));
   }
    glEnd();
     glColor3f(1.8,1.8,1.0);

    glPointSize(7.0f);
    glBegin(GL_POINTS);
    glVertex2d(x+1,y-31);
    glEnd();
    glBegin(GL_LINES);
    glVertex2d(x+6,y-32);
    glVertex2d(x+6,y-41);
    glEnd();
    glBegin(GL_LINES);

    glVertex2d(x-2,y-41);
    glVertex2d(x+6,y-41);

    glEnd();
 glColor3f(0.3,0.3,0.3);
  glBegin(GL_LINES);
        float cx=x+25,cy=y+24,r=25;
        for (int ii = 0; ii &amp;lt; 100; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(100);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=25 &amp;amp;&amp;amp; ii&amp;lt;=50)
        glVertex2f(x + cx, y + cy);//output vertex

         }
    glEnd();
}


void fuel(float x,float y){
    float j,i=x,k=y+227,l,flag=0;
    if(s==0){k=y+224;
            if( cc&amp;gt;25 &amp;amp;&amp;amp; cc&amp;lt;=75){
    l=y+170-((cc-25)*1.4);
    flag=1;

    glColor3f(0.0,0.5,1.0);//fuel color
            }
            if( cc&amp;gt;75 &amp;amp;&amp;amp; cc&amp;lt;100){
    l=y+100+((cc-75)*1.4);
    flag=1;
    float rr=(cc-75)*0.02;
    glColor3f(rr,0.5-(rr/2),1-rr);//fuel color
            }
            if( cc&amp;gt;=0 &amp;amp;&amp;amp; cc&amp;lt;25){
    l=y+135+(cc*1.4);
    flag=1;

    float rr=(cc)*0.02;

    glColor3f(rr+0.5,0.25-(rr/2),0.5-rr);//fuel color
            }
    }


     if(s==1){
            k=(y+225);
        if(cc&amp;gt;=25 &amp;amp;&amp;amp; cc&amp;lt;=75){
    l=y+170-((cc-25)*1.4);
    flag=1;
    float rr=(cc-25)*0.02;
    if(rr&amp;gt;=0.95)
        rr=0.95;
    glColor3f(1-(rr*0.1),0+rr,0+rr);

        }
            if( cc&amp;gt;75 &amp;amp;&amp;amp; cc&amp;lt;100){ l=y+100+((cc-75)*1.4);
            flag=1;
 glColor3f(0.9,0.95,0.95);

            }
            if( cc&amp;gt;=0 &amp;amp;&amp;amp; cc&amp;lt;=25){ l=y+135+(cc*1.4);
            flag=1;

 glColor3f(0.9,0.95,0.95);//gas color
 }

    }

    if(flag==1){
    glBegin(GL_LINES);
    for(j=k;j&amp;gt;l;j--)
    {
        glVertex2f(i-43,j);
        glVertex2f(i+44,j);
    }
    glEnd();
    }

}

void board(float x,float y){
//glColor3f(0.0,1.0,1.0);
glColor3f(0.95,1,1);

glBegin(GL_QUADS);
glVertex2f(x-450,y-250);
glVertex2f(x+450,y-250);
glVertex2f(x+450,y+450);
glVertex2f(x-450,y+450);
glEnd();
//glColor3f(0.85,1,1);
glColor3f(0.2,.8,.5);

glBegin(GL_QUADS);
glVertex2f(x-400,y-200);
glVertex2f(x+400,y-200);
glVertex2f(x+400,y+400);
glVertex2f(x-400,y+400);
glEnd();

}

void smallboard(float x,float y){
//glColor3f(0.0,1.0,1.0);
glColor3f(0.95,1,1);

glBegin(GL_QUADS);
glVertex2f(x-200,y-200);
glVertex2f(x+200,y-200);
glVertex2f(x+200,y+200);
glVertex2f(x-200,y+200);
glEnd();
//glColor3f(0.85,1,1);
glColor3f(0.2,.8,.5);

glBegin(GL_QUADS);
glVertex2f(x-160,y-160);
glVertex2f(x+160,y-160);
glVertex2f(x+160,y+160);
glVertex2f(x-160,y+160);
glEnd();

}
/*void board(float x,float y){
glColor3f(0.3,0.3,0.3);
//glColor3f(0.95,1,1);

glBegin(GL_QUADS);
glVertex2f(x-550,y-250);
glVertex2f(x+550,y-250);
glVertex2f(x+550,y+450);
glVertex2f(x-550,y+450);
glEnd();
glColor3f(1.0,1.0,1.0);
//glColor3f(0.2,.8,.5);

glBegin(GL_QUADS);
glVertex2f(x-500,y-200);
glVertex2f(x+500,y-200);
glVertex2f(x+500,y+400);
glVertex2f(x-500,y+400);
glEnd();

}*/

void text(int x, int y, char *string,int j)
{
  int len, i;

  glRasterPos2f(x, y);
  len = (int) strlen(string);
  for (i = 0; i &amp;lt; len; i++) {
    glutBitmapCharacter(fonts[j], string[i]);
  }
}
void indicator(float cx, float cy, float r, int num_segments,int h) {
    //glColor3f(0.0,0.0,1.0);
    float xx,yy,n;
    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(cx, cy);//output vertex

    for (int ii = 0; ii &amp;lt;= num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii&amp;gt;=h &amp;amp;&amp;amp; ii&amp;lt;=(h+25))
        glVertex2f(x + cx, y + cy);//output vertex

      }
    glEnd();


}
void kk(float cx, float cy, float r, int num_segments){
    for (int ii = 0; ii &amp;lt;= num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        if(ii==pointer || ii==(pointer-0.5))
        glVertex2f(x + cx, y + cy);//output vertex

      }

}
void tip(float cx, float cy, float r, int num_segments){
    float xx,yy,n;
    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(cx-5, cy-5);//output vertex
        kk(cx,cy,r,num_segments);
      glVertex2f(cx+5, cy-5);//output vertex


    glEnd();

    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(cx-5, cy-5);//output vertex
kk(cx,cy,r,num_segments);
      glVertex2f(cx-5, cy+5);//output vertex


    glEnd();

    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(cx-5, cy+5);//output vertex
kk(cx,cy,r,num_segments);
      glVertex2f(cx+5, cy+5);//output vertex


    glEnd();

    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(cx+5, cy-5);//output vertex
kk(cx,cy,r,num_segments);
      glVertex2f(cx+5, cy+5);//output vertex


    glEnd();




}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//glClear(GL_COLOR_BUFFER_BIT);

int x=800,y=500;

    //Circle(x, y, 100, 100,0);
 glColor3f(0.0,1.0,1.0);
    board(x,y);
    glColor3fv(colors[1]);
    cover(x,y);
    glColor3f(0.8,0.8,0.8);
    innletcover(x,y);
    innlet(x,y);
    outletcover(x,y);
    outlet(x,y);
   // glColor3f(1.0,1.0,1.0);
    glColor3fv(colors[4]);
    Circle(x, y, 110, 100,0);


    q1.x=x-44;
    q1.y=y+100;
    q2.x=x-44;
    q2.y=y+225;
    q3.x=x+44;
    q3.y=y+225;
    q4.x=x+44;
    q4.y=y+100;

    rect(q1,q2,q3,q4); //inner cylinder
     fuel(x,y);
    glColor3f(0.0,0.0,1.0);

    //reectangle();
    //point(x,y+325);

 glColor3fv(colors[0]);
	//Crankrod(x, y, 65, 100);
    Circle(x, y, 50, 100,0);
  glColor3fv(colors[2]);
    Crank(x, y, 35, 100);
    glColor3f(0.0,0.0,1.0);
    valve(x,y);
    plug(x,y+253);
    if(s==0 &amp;amp;&amp;amp; cc&amp;gt;=22 &amp;amp;&amp;amp; cc&amp;lt;=25  )
        spark(x+1,y-2);
    if(s==1 &amp;amp;&amp;amp; cc&amp;lt;=28 &amp;amp;&amp;amp; cc&amp;gt;=25  )
        spark(x+1,y-2);
// title
    glColor3f(0.0,0.0,1.0);
    text(x-115,y+415,&quot;IC Petrol Engine&quot;,2);
 y+=150;
    smallboard(x+700,y);
    glColor3f(0.3,0.3,0.3);
    Circle(x+700, y, 145, 100,0);
        glColor3f(0.9,0.95,0.95);
        indicator(x+700, y, 140, 100,0); //exhaust
    glColor3f(0.0,0.5,1.0);
     indicator(x+700, y, 140, 100,25); //suction
    glColor3f(0.8,0.5,0.5);
        indicator(x+700, y, 140, 100,50);//compression
    glColor3f(0.9,1.0,0.5);
        indicator(x+700, y, 140, 100,75);// working
    glColor3f(0.3,0.3,0.3);
    Circle(x+700, y, 15, 100,0);
    //glColor3f(0.0,0.0,0.0);

    tip(x+700, y, 100, 100);

    glColor3f(0.0,0.0,1.0);
    text(x+600,y+170,&quot;Stroke Indicator&quot;,2);

    //lables
    glColor3f(0.0,0.5,1.0);
     point(x+520,y-240);

    glColor3f(0.5,0.9,1.0);
    text(x+540,y-245,&quot;Suction Stroke&quot;,0);

    glColor3f(0.8,0.5,0.5);
     point(x+520,y-260);

    glColor3f(0.5,0.9,1.0);
    text(x+540,y-265,&quot;Compression Stroke&quot;,0);

    glColor3f(0.9,1.0,0.5);
     point(x+520,y-280);

    glColor3f(0.5,0.9,1.0);
    text(x+540,y-285,&quot;Working Stroke&quot;,0);

    glColor3f(0.9,0.95,0.95);
     point(x+520,y-300);

    glColor3f(0.5,0.9,1.0);
    text(x+540,y-305,&quot;Exhaust Stroke&quot;,0);
    text(x-510,y-450,&quot;Press &#39;space&#39; to start/stop    Press &#39;+&#39; to speedup engine    Press &#39;-&#39; to slowdown engine&quot;,0);


    glFlush();

    //quad();



}
void start(){
    if(status==1)
{   cb++;
    cc++;
    pointer+=0.5;
    }
    if(cc==100)
    {
        cc=0;

    }
    if(pointer==100)
    {
        pointer=0;

    }
    if(cb==100) cb=0;
    display();

      //Game title

    if(cc==25){
        if(s==0)
            s=1;
        else
            s=0;
    }

    Sleep(speed);

}

void keypress(unsigned char key, int x,int y){
       if (key==&#39;+&#39;) {speed--;
                                if(speed&amp;lt;=0) speed=0;}
       if (key==&#39;-&#39;) {speed++;if(speed&amp;gt;=500) speed=500;}
       if(key==&#39; &#39;) {if(status==0) status=1; else status=0; }}
void myReshape(int w,int h)
{

	glViewport(0,0,w,h);
	glMatrixMode(GL_PROJECTION);
    glOrtho(-2.0,2.0,-2.0*(GLfloat)h/(GLfloat)w,2.0*(GLfloat)h/(GLfloat)w,-10.0,10.0);
	glMatrixMode(GL_PROJECTION);
}


int main(int argc,char **argv)
{
	glutInit(&amp;amp;argc,argv);
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
	glutInitWindowSize (600, 600);
	glutCreateWindow(&quot;Introduction to Open GL&quot;);
	glutReshapeFunc(myReshape);
	glutKeyboardFunc(keypress);
	glutDisplayFunc(display);
	glutIdleFunc(start);
	init();
    glutMainLoop();
&lt;div style=&quot;text-align: justify;&quot;&gt;}&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;p data-end=&quot;417&quot; data-start=&quot;347&quot; style=&quot;text-align: justify;&quot;&gt;Here are a few common components that could be part of such the OpenGL Computer Graphics Project:&lt;/p&gt;&lt;ol data-end=&quot;1114&quot; data-start=&quot;419&quot;&gt;&lt;li data-end=&quot;562&quot; data-start=&quot;419&quot;&gt;&lt;p data-end=&quot;562&quot; data-start=&quot;422&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;442&quot; data-start=&quot;422&quot;&gt;3D Visualization&lt;/strong&gt;: Creating a detailed 3D model of a petrol engine, showing key parts like the pistons, crankshaft, valves, and camshaft.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;708&quot; data-start=&quot;564&quot;&gt;&lt;p data-end=&quot;708&quot; data-start=&quot;567&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;596&quot; data-start=&quot;567&quot;&gt;Animation of Engine Cycle&lt;/strong&gt;: Simulating and animating the stages of the engine cycle, like intake, compression, power, and exhaust strokes.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;909&quot; data-start=&quot;710&quot;&gt;&lt;p data-end=&quot;909&quot; data-start=&quot;713&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;762&quot; data-start=&quot;713&quot;&gt;Computational Fluid Dynamics (CFD) Simulation&lt;/strong&gt;: Visualizing airflow and combustion processes inside the engine, potentially showing how fuel and air mix, ignite, and exhaust gases are expelled.&lt;/p&gt;&lt;/li&gt;&lt;li data-end=&quot;1114&quot; data-start=&quot;911&quot;&gt;&lt;p data-end=&quot;1114&quot; data-start=&quot;914&quot; style=&quot;text-align: justify;&quot;&gt;&lt;strong data-end=&quot;940&quot; data-start=&quot;914&quot;&gt;Performance Simulation&lt;/strong&gt;: Using computer graphics to illustrate how engine performance (such as horsepower, torque, fuel consumption) changes with different variables (e.g., RPM, throttle position).&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5586055010079604660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/02/internal-combustion-engine-ic-engine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5586055010079604660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5586055010079604660'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/02/internal-combustion-engine-ic-engine.html' title='Internal combustion engine - IC engine - OpenGL Computer Graphics Project'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-5570385793269253585</id><published>2025-01-29T16:37:00.004+05:30</published><updated>2025-01-29T16:37:51.878+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Astronomer"/><category scheme="http://www.blogger.com/atom/ns#" term="Solar system"/><category scheme="http://www.blogger.com/atom/ns#" term="Sun"/><title type='text'>OpenGL Solar System Simulator </title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;In OpenGL projects blog we are going to demonstrate&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #1f2328;&quot;&gt;solar system simulator with Verlet. Here we are using OpenGL for displaying coded and compiled in Visual Studio. We have used&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #1f2328;&quot;&gt;glm and glew in this project with&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #1f2328;&quot;&gt;MS XML Parser.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;a href=&quot;https://img.youtube.com/vi/nO0xolnW4Jg/0.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;360&quot; data-original-width=&quot;480&quot; height=&quot;360&quot; src=&quot;https://img.youtube.com/vi/nO0xolnW4Jg/0.jpg&quot; width=&quot;480&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: #1f2328;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;&quot; style=&quot;background-color: white; color: #1f2328; font-size: 16px;&quot;&gt;We are going to see the important concepts used in this project -&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Object oriented programming use the Concept of Class hence here we are going to demonstrate the same. First we are using classes which are getting generated in this application and get done by compiler.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;#SolarSystem&lt;/p&gt;&lt;p&gt;Others programs -&lt;/p&gt;&lt;p&gt;1.&amp;nbsp;&lt;span face=&quot;&amp;quot;Trebuchet MS&amp;quot;, Trebuchet, Verdana, sans-serif&quot; style=&quot;background-color: white; color: #666666; font-size: 24.48px;&quot;&gt;&lt;a href=&quot;https://www.openglprojects.in/2015/04/mini-solar-system-computer-graphics-programs.html&quot; target=&quot;_blank&quot;&gt;Mini Solar System Computer Graphics Programs&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;2. &lt;a href=&quot;https://www.openglprojects.in/2011/05/solar-system.html?&quot; target=&quot;_blank&quot;&gt;sol&lt;span face=&quot;&amp;quot;Trebuchet MS&amp;quot;, Trebuchet, Verdana, sans-serif&quot; style=&quot;background-color: white; color: #666666; font-size: 24.48px;&quot;&gt;ar System Mini-Project in OpenGL&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;3.&lt;a href=&quot;https://www.openglprojects.in/2015/05/3d-solar-system-opengl-graphics-program.html?m=1&quot; style=&quot;font-family: &amp;quot;Trebuchet MS&amp;quot;, Trebuchet, Verdana, sans-serif; font-size: 24.48px;&quot; target=&quot;_blank&quot;&gt;3D Solar System OpenGL graphics progra&lt;/a&gt;m&lt;/p&gt;&lt;div _ngcontent-ng-c459698851=&quot;&quot; class=&quot;main-content ng-trigger ng-trigger-routeChangeAnimation&quot;&gt;&lt;div _ngcontent-ng-c459698851=&quot;&quot; class=&quot;content-container&quot;&gt;&lt;chat-window _nghost-ng-c2879136452=&quot;&quot; class=&quot;ng-tns-c2879136452-1 mobile-device ng-star-inserted&quot;&gt;&lt;div _ngcontent-ng-c2879136452=&quot;&quot; class=&quot;chat-container ng-tns-c2879136452-1 ng-trigger ng-trigger-chatHistoryImmersiveTransitions&quot; jslog=&quot;173898;track:impression&quot;&gt;&lt;chat-window-content _ngcontent-ng-c2879136452=&quot;&quot; _nghost-ng-c2479520514=&quot;&quot; class=&quot;ng-tns-c2879136452-1 ui-improvements-phase-1&quot;&gt;&lt;div _ngcontent-ng-c2479520514=&quot;&quot; class=&quot;chat-history-scroll-container&quot; id=&quot;chat-history&quot;&gt;&lt;infinite-scroller _ngcontent-ng-c2479520514=&quot;&quot; _nghost-ng-c3325606809=&quot;&quot; class=&quot;chat-history response-optimization&quot; data-test-id=&quot;chat-history-container&quot;&gt;&lt;div _ngcontent-ng-c2479520514=&quot;&quot; class=&quot;conversation-container message-actions-hover-boundary response-optimization tts-removed ng-star-inserted&quot; id=&quot;bc4011a80e60cc2f&quot; style=&quot;min-height: 618px;&quot;&gt;&lt;model-response _ngcontent-ng-c2479520514=&quot;&quot; _nghost-ng-c1790302082=&quot;&quot; class=&quot;ng-star-inserted&quot;&gt;&lt;div _ngcontent-ng-c1790302082=&quot;&quot;&gt;&lt;response-container _ngcontent-ng-c1790302082=&quot;&quot; _nghost-ng-c2299864928=&quot;&quot; class=&quot;ng-tns-c2299864928-8 reduced-bottom-padding ng-star-inserted&quot; jslog=&quot;188576;track:impression;BardVeMetadataKey:[[&amp;quot;r_bc4011a80e60cc2f&amp;quot;,&amp;quot;c_891aa419e8f19618&amp;quot;,null,null,null,null,null,null,1,null,null,null,0]];mutable:true&quot;&gt;&lt;div _ngcontent-ng-c2299864928=&quot;&quot; class=&quot;response-container ng-tns-c2299864928-8 response-optimization response-container-with-gpi is-mobile tts-removed ng-star-inserted response-container-has-multiple-responses&quot; jslog=&quot;173900;track:impression&quot;&gt;&lt;div _ngcontent-ng-c2299864928=&quot;&quot; class=&quot;response-container-header ng-tns-c2299864928-8 ng-star-inserted&quot;&gt;&lt;div _ngcontent-ng-c2299864928=&quot;&quot; class=&quot;response-container-header-controls ng-tns-c2299864928-8&quot;&gt;&lt;tts-control _ngcontent-ng-c2299864928=&quot;&quot; _nghost-ng-c2878255793=&quot;&quot; class=&quot;ng-tns-c2299864928-8 ng-trigger ng-trigger-singleResponseEnter ng-animate-disabled ng-star-inserted&quot;&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;response-tts-container hidden-tts ng-star-inserted&quot; data-test-draft-id=&quot;rc_926d48ba83561117&quot; style=&quot;height: 1294px;&quot;&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot;&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button--disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;For this Opengl programming project we need to have the supporting liabrary ie&amp;nbsp; glm and glew. We can download the mentioned liablrary and have to installed them LIBs folder of PC. According to the directory/destination of the glu/gl/ other supporting filles we need to adjust our project settings accordingly.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;Download the above libraries from the link provided below -&amp;nbsp;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;glm : &lt;a href=&quot;http://glm.g-truc.net/0.9.7/index.html&quot;&gt;http://glm.g-truc.net/0.9.7/index.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;glew: &lt;a href=&quot;http://glew.sourceforge.net/&quot;&gt;http://glew.sourceforge.net/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;mfc: This will be already included in the Visual Studio package, if not there kindly check Visual Studio installation guide.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;Download Source code&amp;nbsp; -&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://github.com/aromanro/SolarSystem&quot;&gt;https://github.com/aromanro/SolarSystem&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div _ngcontent-ng-c2878255793=&quot;&quot; class=&quot;mat-mdc-tooltip-trigger tts-button-container mat-mdc-tooltip-disabled&quot; data-test-id=&quot;disabled-tooltip&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;Video&amp;nbsp; -&amp;nbsp;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;327&quot; src=&quot;https://www.youtube.com/embed/nO0xolnW4Jg&quot; width=&quot;531&quot; youtube-src-id=&quot;nO0xolnW4Jg&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/tts-control&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/response-container&gt;&lt;/div&gt;&lt;/model-response&gt;&lt;/div&gt;&lt;/infinite-scroller&gt;&lt;/div&gt;&lt;/chat-window-content&gt;&lt;/div&gt;&lt;/chat-window&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/5570385793269253585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2025/01/Opengl-solar-system-simulator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5570385793269253585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/5570385793269253585'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2025/01/Opengl-solar-system-simulator.html' title='OpenGL Solar System Simulator '/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/nO0xolnW4Jg/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-8879630995709130382</id><published>2024-01-16T01:33:00.004+05:30</published><updated>2024-01-16T01:46:09.677+05:30</updated><title type='text'>New Village Scenery Computer Graphics Project in OpenGL Source Code</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;Many of the University including VTU have &#39;The Department of Computer Science and Engineering&#39; which have Lab projects for students to show thier learning skill which got during thier course study.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;https://www.msec.ac.in/files/vlab/CG%20Lab%20Manual.pdf&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;VTU Computer Graphics and Visualization Laboratory [15CSL68]&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;Above mentioned link have the lab programs prescribed by VTU under it course id mentioned have computer graphics project in OpenGL. Under this program students use thier learning ability to show of thier excellence, what they learnt in the course. Many students keeping in focus special efforts to impart&amp;nbsp; thier knowledge to give best projects.&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;We in this article we are going to show one of the best project in&amp;nbsp;Computer Graphics Project in OpenGL with free source code. The name of the Project is&amp;nbsp;New Village Scenery.&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;h3 class=&quot;wp-block-heading&quot; style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #3a3a3a; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 1.5625rem; font-weight: inherit; line-height: 1.3em; margin: 30px 0px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Project Description:&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;In this&amp;nbsp;Computer Graphics Project in OpenGL with free Source Code are going to draw sun, clouds, sky, river, boats, fence, trees, huts. In this projects we demonstrate the moving clouds in the sky and moving boats in the river,&amp;nbsp; Above is achived by using circle, lines traingle and spheres.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifdnhF3j3Okak7ka6D7a98DYAfurujMIERqvkc4BD6b4MEnO4I1ry3D3DZAacaKFiDM9ACES1Ucl-2UP7cH5I8HtxDWExTOuA_tBy_h5wEwFHDsohupfKfptcUJ5U-auQg6oxDXX9XChOud5TvtgJf-ylAL94_PA-ahqlkIQSzdiiYOa8iszV-4S6if8u2/s1016/New%20Village%20Scenery%20Computer%20Graphics%20Project%20in%20OpenGL%20Source%20Code.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;718&quot; data-original-width=&quot;1016&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifdnhF3j3Okak7ka6D7a98DYAfurujMIERqvkc4BD6b4MEnO4I1ry3D3DZAacaKFiDM9ACES1Ucl-2UP7cH5I8HtxDWExTOuA_tBy_h5wEwFHDsohupfKfptcUJ5U-auQg6oxDXX9XChOud5TvtgJf-ylAL94_PA-ahqlkIQSzdiiYOa8iszV-4S6if8u2/s320/New%20Village%20Scenery%20Computer%20Graphics%20Project%20in%20OpenGL%20Source%20Code.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Draw Sky&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;///sky///&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_POLYGON);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glColor3ub(112,160,228);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0,3.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0,14.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,14.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,3.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Draw the Sun&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; /// Sun&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,0,0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glTranslatef(1.0, 7.0, 0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(1.0, 750, 300);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;See Also&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;1.&amp;nbsp;&lt;a href=&quot;https://www.openglprojects.in/2022/07/simple-city-scenery-opengl-computer.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;Simple City Scenery Opengl Computer Graphics Project&lt;/a&gt;&lt;/div&gt;&lt;p&gt;2. &lt;a href=&quot;https://www.openglprojects.in/2021/05/transformers-opengl-computer-graphics-projects.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;Transformers - Free OpenGL Source code&lt;/a&gt;&lt;/p&gt;&lt;p&gt;3. &lt;a href=&quot;https://www.openglprojects.in/2016/03/day-night-color.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;Day and Night OpenGL Computer graphics Project&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Implementation&amp;nbsp;&lt;/h2&gt;&lt;div&gt;We use GL_QUADS with tranlation in opengl to draw most of the scenery in this new village scenery opengl projects program. As name suggested quads means fourt vertices. We use the glvertex in opengl to join the vertices and make the objects. Below is how vertices are used in opengl.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.dgp.toronto.edu/~ah/csc418/fall_2001/tut/Image22.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;192&quot; data-original-width=&quot;348&quot; height=&quot;192&quot; src=&quot;https://www.dgp.toronto.edu/~ah/csc418/fall_2001/tut/Image22.gif&quot; width=&quot;348&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Draw Components&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this project we are going to use the different functions to implement the different object like sun in the program.&amp;nbsp;void DrawAllComponents() functions is used to draw all the mentioned objects required in this program. After we draw all the objects and then we call them in the display function -&amp;nbsp;void display(void)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;After above functions are implemented we call the keyboard and mouse functions to implement the user interactions and call all of them in main functions.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;User Interaction&lt;/h3&gt;&lt;p&gt;In this opengl project below is user interactions&lt;/p&gt;&lt;p&gt;&lt;b&gt;Mouse interactions&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Left Mouse button - Increase the Movement of clouds and boats&lt;/p&gt;&lt;p&gt;Right Mouse button - Decrease the Movement of clouds and boats&lt;/p&gt;&lt;p&gt;&lt;b&gt;Key Interactions&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;s - &lt;/b&gt;to stop the boat&lt;/p&gt;&lt;p&gt;r -&amp;nbsp; to run the boat again&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Source code and Reports Computer Graphics Project in OpenGL&amp;nbsp;&lt;/h2&gt;&lt;p&gt;Here you can download computer graphics projects with source code and reports.&lt;/p&gt;&lt;p&gt;Below is soure code -&lt;/p&gt;&lt;p&gt;#include&amp;lt;windows.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;iostream&amp;gt;&lt;/p&gt;&lt;p&gt;#include&amp;lt;GL/gl.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;GL/glut.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;math.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include&amp;lt;windows.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;float moveC = 0.0f;&lt;/p&gt;&lt;p&gt;float moveB1 = 0.0f;&lt;/p&gt;&lt;p&gt;float moveB2 = 0.0f;&lt;/p&gt;&lt;p&gt;float speed = 0.02f;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void DrawAllComponents()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glClearColor(1.0f,1.0f,1.0f,1.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glClear(GL_COLOR_BUFFER_BIT);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(1,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glLoadIdentity();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; gluOrtho2D(-12,38,-19,14);//range&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glMatrixMode(GL_MODELVIEW);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///sky///&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_POLYGON);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(112,160,228);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0,3.0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0,14.0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,14.0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,3.0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /// Sun&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(1.0, 7.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(1.0, 750, 300);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///Cloud-01&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(moveC,0.0f,0.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(1.0, 6.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(1.0, 7.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(2.0, 7.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(2.0, 6.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(0.0, 6.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(3.0, 6.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.7, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///cloud-02&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(moveC,0.0f,0.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(15.0, 9.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(15.0, 8.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(16.0, 8.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(16.0, 9.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(14.0, 8.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(17.0, 8.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.8, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///cloud-03&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(moveC,0.0f,0.0f);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(22.0, 8.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(22.0, 7.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(23.0, 8.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(23.0, 7.0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(24.0, 7.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3d(255,255,255);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(21.0, 7.5, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSolidSphere(0.75, 250, 250);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///See portion&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_POLYGON);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(65,105,225);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(40.0,-19.0);&amp;nbsp; /// right-down&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0,-11.0); /// right-top&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,-11.0); /// left-top&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0,-19.0);&amp;nbsp; /// left-down&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///Ground portion&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_POLYGON);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(25,128,0);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(90.0f, -12.5f); /// angle&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0f,-12.0f);&amp;nbsp; /// right-down&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.0f,3.0f); /// right-top&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0f,3.0f); /// left-top&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.0f,-11.0f);&amp;nbsp; /// left-down&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /// House Drawing&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///1st House&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /// FEG&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(162, 116, 36);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-8, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-6, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-4, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /// FGIH&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(214, 42, 50);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-8.023, -5.184);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-8, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-4, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.999, -7.219);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///ROPQ&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(19, 105, 51);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-6.73, -5.67);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-6.76, -3.58);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-5.19, -3.58);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-5.19, -6.62);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///EGKJ&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(124, 85, 17);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-6, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(4, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(6, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-4, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///GLMI&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(156, 9, 16);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-4, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(5.22, -2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(5.26, -5.11);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.99, -7.22);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///VSTU&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(216, 215, 111);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-0.39, -6.40);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-0.42, -3.62);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.95, -3.58);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.97, -5.86);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///SZA1V&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(19, 105, 51);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-0.42, -3.62);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(0.38, -4.38);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(0.38, -5.53);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-0.39, -6.40);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///TB1C1U&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(19, 105, 51);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.95, -3.58);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.21, -4.38);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.21, -5.46);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.97, -5.86);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///2nd House&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///S1R1W1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(8.09,-5.01);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(10.96,-2.02);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(14.10, -5.01);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///U1V1Z1W1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(145, 0, 12);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(9.15, -5.01);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(9.14, -9.02);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(12.85, -9.04);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(12.84, -5.01);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///A2B2C2D2&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(245, 10, 49);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(10.36, -6.79);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(10.35, -8.91);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(11.59, -8.99);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(11.58, -6.79);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///1st Tree&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(22, 208, 70);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(14.88, -6.00);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(20, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(24.98, -6.16);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(21.05, -4.96);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.09, -4.95);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///NWJ1H1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(191, 158, 24);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.02, -6.06);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(20.96, -6.09);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(21, -10.08);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.01, -10.08);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /// 2nd Tree&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///L1K1M1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(17, 218, 45);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(27.02, -6.16);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(30, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(32.93, -6);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///E1F1P1Q1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(191, 158, 24);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(29.09, -6.10);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(31.03, -6.05);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(31.05, -10.03);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(29.06, -9.97);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///Rail Line&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///N1B&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(155, 29, 29);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12, 2);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38, 3);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(37.98, 2.69);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-11.98, 1.71);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(155, 29, 29);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.07, 0.72);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-12.07, 0.48);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38.02, 1.52);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(38, 1.70);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-8, 2.08);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-7.64, 2.08);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-7.63, 0.63);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-8, 0.62);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(0.97, 2.31);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.28, 2.27);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.34, 0.76);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(0.97, 0.75);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(11.98, 2.48);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(12.48, 2.49);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(12.5, 1);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(11.98, 0.98);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(25.45, 2.75);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(26.09, 2.76);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(26.09, 1.27);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(25.45, 1.26);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(33.99, 2.92);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(34.48, 2.93);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(34.58, 1.45);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(34.03, 1.44);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0, 0, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.39, 2.69);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.16, 2.62);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.18, 1.13);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.42, 1.11);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///boat-1 speed left to right&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(moveB1, 0.0f, 0.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(139,69,19);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.50f, -13.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-2.0f, -13.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(2.0f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(2.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.0f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.0f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-3.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(-4.5f, -13.7f);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(2.0f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(3.5f, -13.7f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(2.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(2.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.5f, -13.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(1.0f, -14.0f);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ///boat-2 motion right to left&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPushMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glTranslatef(moveB2, 0.0f, 0.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(139,69,19);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(22.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(21.0f, -16.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.50f, -16.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(22.0f, -18.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(22.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.0f, -18.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(255,99,71);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(20.5f, -16.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(21.0f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.5f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.0f, -16.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_QUADS);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(139,69,19);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.8f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.8f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.7f, -14.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(19.7f, -14.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.0f, -18.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(15.5f, -17.2f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(22.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(22.0f, -18.0f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(23.5f, -17.2f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_TRIANGLES);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glColor3ub(0,0,0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(18.0f, -17.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glVertex2f(17.5f, -16.5f);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //end&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glPopMatrix();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutSwapBuffers();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void updateC(int value)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; if(moveC &amp;gt; +36)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moveC = -38;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; moveC += 0.15;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(20, updateC, 0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void updateB1(int value)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; moveB1 += speed;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; if(moveB1 &amp;gt; 38)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moveB1 = -38;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//&amp;nbsp; &amp;nbsp;moveB1 += 0.17;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(20, updateB1, 0); //Notify GLUT to call update again in 25 milliseconds&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void updateB2(int value)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; if(moveB2 &amp;lt; -36)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moveB2 = +38;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //Notify GLUT that the display has changed&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; moveB2 -= 0.13;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(20, updateB2, 0); //Notify GLUT to call update again in 25 milliseconds&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void handleKeypress(unsigned char key, int x, int y)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; switch (key)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; case &#39;s&#39;://stops&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; speed = 0.0f;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; case &#39;r&#39;://runs&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; speed = 0.02f;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void handleMouse(int button, int state, int x, int y)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; if (button == GLUT_LEFT_BUTTON)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; speed += 0.05f;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; else if (button == GLUT_RIGHT_BUTTON)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; speed -= 0.05f;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutPostRedisplay();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void display(void)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; DrawAllComponents();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glFlush ();&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void init()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glClearColor(0.0f, 0.0f, 0.0f, 0.0f);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main(int argc, char** argv)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutInit(&amp;amp;argc, argv);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutInitWindowSize(1300, 700);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutInitWindowPosition(100,100);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutCreateWindow(&quot; Village Scenery &quot;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; init();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(100, updateC, 1);&amp;nbsp; &amp;nbsp; // cloud speed&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(100, updateB1, 0); //Boat 1&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutTimerFunc(100, updateB2, 0); //boat 2&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutKeyboardFunc(handleKeypress);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutMouseFunc(handleMouse);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutDisplayFunc(display);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; glutMainLoop();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/8879630995709130382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2024/01/New-Village-Scenery-Computer-Graphics-Project-in-OpenGL-Source-Code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/8879630995709130382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/8879630995709130382'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2024/01/New-Village-Scenery-Computer-Graphics-Project-in-OpenGL-Source-Code.html' title='New Village Scenery Computer Graphics Project in OpenGL Source Code'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifdnhF3j3Okak7ka6D7a98DYAfurujMIERqvkc4BD6b4MEnO4I1ry3D3DZAacaKFiDM9ACES1Ucl-2UP7cH5I8HtxDWExTOuA_tBy_h5wEwFHDsohupfKfptcUJ5U-auQg6oxDXX9XChOud5TvtgJf-ylAL94_PA-ahqlkIQSzdiiYOa8iszV-4S6if8u2/s72-c/New%20Village%20Scenery%20Computer%20Graphics%20Project%20in%20OpenGL%20Source%20Code.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-6605537871085338711</id><published>2023-03-12T02:58:00.001+05:30</published><updated>2023-03-12T03:11:42.133+05:30</updated><title type='text'>Satellites Launch Mini Projects OpenGL Computer graphics</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;ISRO has made our county proud. They have lauched so many sattelites into the sapce for tele communication,&amp;nbsp; sciencetific discovery, defence, remote sensing, meteorolog etc. In this article we are going to code satellite launch mini projects using opengl computer graphcis in c/c++.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We launch satellites into space by putting them on rockets. The rockets carrying satellites launch via a luching station through tons of propellants (fules of rocket). The propellants provide energy to the rocket to get out of Earth gravity &#39;s pull (Speed is called escape velocity). Rocket with even thrust get into space at mutliple stages. The final stage of the rocket is to place the satellite into it orbit.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzApOTQUQUDaGGRW3bSl9DWL9NsIIvG2x3FzIdo9k95OpvCTjoYNWENk3sI3W4S9bHdz0Dzjg0EWLPoYR1GaJeC3OcoQYvJ7RhKtd1l7uLZPmZzGhGxVE73vORNrQbEB4MkHLG2PUju5E5TJvyr5c2nIsAtIlUnphaaQ6LorDbVYBfCPFl4h3oC2tWig/s1279/Satellites%20Launch%20Mini%20Projects%20OpenGL%20Computer%20graphics.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Satellites Launch Mini Projects OpenGL Computer graphics&quot; border=&quot;0&quot; data-original-height=&quot;725&quot; data-original-width=&quot;1279&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzApOTQUQUDaGGRW3bSl9DWL9NsIIvG2x3FzIdo9k95OpvCTjoYNWENk3sI3W4S9bHdz0Dzjg0EWLPoYR1GaJeC3OcoQYvJ7RhKtd1l7uLZPmZzGhGxVE73vORNrQbEB4MkHLG2PUju5E5TJvyr5c2nIsAtIlUnphaaQ6LorDbVYBfCPFl4h3oC2tWig/w400-h226/Satellites%20Launch%20Mini%20Projects%20OpenGL%20Computer%20graphics.jpg&quot; title=&quot;Satellites Launch Mini Projects OpenGL Computer graphics&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;Aim of the&amp;nbsp;Mini Projects&lt;/h1&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The aim of this&amp;nbsp;Satellites Launch Mini Projects&amp;nbsp; with OpenGL Computer graphics is to simulate the lauch if satellites using the opengl functions and codes. We are going to create the Earth, rocket, satellites using opengl and simulate the actual lauching of satellites.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;Design and Implementation&amp;nbsp;&lt;/h1&gt;&lt;div&gt;1. Drawing of Earth -&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. Drawing of Rocket-&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. Drawing of Satellite -&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Do You Know?&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ISRO have &lt;a href=&quot;https://www.isro.gov.in/Student_Program_Satellite.html&quot; target=&quot;_blank&quot;&gt;student satellite program&lt;/a&gt;. 
Students who want to working in space technology may develope the payload for satellites with the help of ISRO through thier university.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;User Interaction in the program&lt;/h1&gt;&lt;div&gt;The&amp;nbsp;Satellites Launch Mini Projects OpenGL Computer graphics program includes interaction through keyboard as mentioned below -&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;P - Launch the rocket&lt;/div&gt;&lt;div&gt;Q- Quit&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;Download the source of&amp;nbsp;Mini Projects OpenGL&lt;/h1&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/6605537871085338711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2023/03/satellites-launch-mini-projects-opengl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6605537871085338711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/6605537871085338711'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2023/03/satellites-launch-mini-projects-opengl.html' title='Satellites Launch Mini Projects OpenGL Computer graphics'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzApOTQUQUDaGGRW3bSl9DWL9NsIIvG2x3FzIdo9k95OpvCTjoYNWENk3sI3W4S9bHdz0Dzjg0EWLPoYR1GaJeC3OcoQYvJ7RhKtd1l7uLZPmZzGhGxVE73vORNrQbEB4MkHLG2PUju5E5TJvyr5c2nIsAtIlUnphaaQ6LorDbVYBfCPFl4h3oC2tWig/s72-w400-h226-c/Satellites%20Launch%20Mini%20Projects%20OpenGL%20Computer%20graphics.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-3984400188557615570</id><published>2023-02-18T23:15:00.005+05:30</published><updated>2023-02-18T23:15:52.718+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Pendulum"/><title type='text'>Create Pendulum in OpenGL Computer Graphics Program</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;We have created many simple programs using OpenGL C/C++ in this blog. In this post we are going to create another simple opengl program. We are creating a simple pendulum. You can use these code as base to create a project particlualry based on the use of pendulum.&lt;/div&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;Introduction&amp;nbsp;&lt;/h1&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A pendulum can be define as a certain mass of object tied from a pivot that can swings back and forth due to force of gravity. The Pendulum swing at the same distance in both the directions. The angle made by pendulum from the centre on bothe side are equal and called amplitude of pendulum.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h1 style=&quot;text-align: justify;&quot;&gt;Design and Code&lt;/h1&gt;&lt;div&gt;This simple pendulum opengl graphics program we are going to code will have two things - circle and lines. We are going to create a simple circle as clock and attache thread to it with a small circle to it. We will swing the circle right and left from the center point of it attachement with thread.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://www.openglprojects.in/2014/03/draw-circle-opengl.html#gsc.tab=0&quot; target=&quot;_blank&quot;&gt;Learn how to draw a circle in opengl&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;First in this computer graphics program we are going to write a function for coding circles. We are goint to name this functions as drawcircle. The function will have four arguments segments, radius, x, y. As name suggest these are angle (segments), radius of thread, x and y coordinates.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div&gt;float drawCircle(float segments,float radius,float sx,float sy)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_LINE_LOOP);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;segments;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; float theta=2.0*3.142*float(i)/float(segments); //get the current angle&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; float x=radius*cos(theta);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; float y=radius*sin(theta);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; glVertex2f(x+sx,y+sy);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we are going to draw the pendulum with the help of draw functions which looks like -&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;void draw(float x1,float y1,float angle)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; float segments=100;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; float radius=6.0;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; //Drawing Clock main Circle&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glLineWidth(4);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glColor3f(1,0,0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; drawCircle(segments,radius,x1,y1);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; //Drawing Minute Line&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glColor3f(1,1,0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glLineWidth(2);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_LINES);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(x1,y1);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(x1,(radius/3.0)*2.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; //Drawing Hour Line&lt;/div&gt;&lt;div&gt;&amp;nbsp; glColor3f(1,0,0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glLineWidth(2);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_LINES);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(x1,y1);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(radius/3.0,radius/3.0);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; //Drawing Pendulum Circle&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; double radians=angle*3.142/180;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; float x2=(radius*3.4)*cos(radians);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; float y2=(radius*3.4)*sin(radians);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; float radius2=radius/3.0;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glColor3f(0,0,1);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; //glLineWidth(2);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; drawCircle(segments,radius2,x2,y2);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glBegin(GL_LINES);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(x1,-1*(radius)+0.2);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glVertex2f(x2,y2);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; glEnd();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In above opengl computer graphics program code we have drawn a &lt;a href=&quot;https://www.openglprojects.in/2012/04/mini-project-on-clock-using-opengl.html#gsc.tab=0&quot;&gt;simple clock&lt;/a&gt; with hour and minute hands.You may skip therse as they are just to make this program look realstic and more sensible. In last few line we were able to draw the pendulum circle and the thread with the help of circle functions above and GL_LINES.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As we have the draw function we applying the below logic to make the right and left movment of pendulum and thread.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;if(angle&amp;gt;315)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;angle=315;&lt;/div&gt;&lt;div&gt;inc=-inc;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;if(angle&amp;lt;225)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;angle=225;&lt;/div&gt;&lt;div&gt;inc=-inc;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We are going to place all the code in display function and then create the main functions. You can see the output below.&lt;/div&gt;&lt;h1&gt;Outpu Pendulum OpenGL Program&lt;/h1&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI8QBF7CEgFlFluirFYSUtSf_7jLbKVxevEMKRVqcd07WzIUvegvGN-yfhd_8zOh85D397UoOvRr4qmApDieVWUsl098c82ZaCnQuvLhOWqxTwXXuafymciCQWbGBOiIwTwraO6GHiFg-voPxDeN6YAii6lx2-Qj9z6O5TaxlPPsPEH3YwEoDXBEzLqA/s561/Pendulum%20in%20OpenGL%20Computer%20Graphics%20Program.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;521&quot; data-original-width=&quot;561&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI8QBF7CEgFlFluirFYSUtSf_7jLbKVxevEMKRVqcd07WzIUvegvGN-yfhd_8zOh85D397UoOvRr4qmApDieVWUsl098c82ZaCnQuvLhOWqxTwXXuafymciCQWbGBOiIwTwraO6GHiFg-voPxDeN6YAii6lx2-Qj9z6O5TaxlPPsPEH3YwEoDXBEzLqA/s320/Pendulum%20in%20OpenGL%20Computer%20Graphics%20Program.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;Projects Suggestion&lt;/h1&gt;&lt;div&gt;1. Simple Old Mechanical &lt;a href=&quot;https://www.openglprojects.in/2015/03/time-zone-opengl-c-graphics-projects.html#gsc.tab=0&quot;&gt;Clock&lt;/a&gt;&lt;/div&gt;&lt;div&gt;2. Clock tower with long pendulam Clock&lt;/div&gt;&lt;div&gt;3. Different kinds of swings&lt;/div&gt;&lt;div&gt;4. Circus swings with jokers&lt;/div&gt;&lt;div&gt;5. Amusment park with swings&amp;nbsp;&lt;/div&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;Download&amp;nbsp;&lt;/h1&gt;&lt;div&gt;Get the full code of the&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;download_code&quot;&gt;&lt;a class=&quot;btn_left&quot; href=&quot;https://drive.google.com/file/d/1tpBPr_jS4OkUIKwYA3dItK5n4UdoZUPG/view?usp=share_link&quot; target=&quot;_blank&quot;&gt;Download source code&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/3984400188557615570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2023/02/create-pendulum-in-opengl-computer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/3984400188557615570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/3984400188557615570'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2023/02/create-pendulum-in-opengl-computer.html' title='Create Pendulum in OpenGL Computer Graphics Program'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI8QBF7CEgFlFluirFYSUtSf_7jLbKVxevEMKRVqcd07WzIUvegvGN-yfhd_8zOh85D397UoOvRr4qmApDieVWUsl098c82ZaCnQuvLhOWqxTwXXuafymciCQWbGBOiIwTwraO6GHiFg-voPxDeN6YAii6lx2-Qj9z6O5TaxlPPsPEH3YwEoDXBEzLqA/s72-c/Pendulum%20in%20OpenGL%20Computer%20Graphics%20Program.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2020194800836807725.post-4085618032389521495</id><published>2023-02-05T23:53:00.002+05:30</published><updated>2023-02-05T23:53:23.616+05:30</updated><title type='text'>Atom Simulation - computer graphics projects with source code</title><content type='html'>&lt;p&gt;Download the project&amp;nbsp;Atom Simulation - computer graphics projects with source code file. The Atom simulation is OpenGL computer graphics projects uses a single window.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #202020; font-family: &amp;quot;Nunito Sans&amp;quot;, sans-serif; font-size: 14px;&quot;&gt;OpenGL (Open Graphics Library) is a cross-platform, industry-standard graphics API used for creating 3D applications and games. It provides a set of commands for drawing 2D and 3D objects, as well as managing the rendering pipeline, lighting, shading, and texturing.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #202020; font-family: &amp;quot;Nunito Sans&amp;quot;, sans-serif; font-size: 14px;&quot;&gt;One of the advantages of using OpenGL is that it provides a low-level interface to the graphics hardware, which means that it can be used on a variety of platforms, including Windows, macOS, Linux, and mobile devices. It also allows developers to take advantage of the latest hardware advancements and performance optimizations.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This is the Atom simulation: This window contains all content that is the menu bar and display of the simulation.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://user-images.githubusercontent.com/70787887/128596742-17ab830e-ea83-4afc-acfd-183c370d7486.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;723&quot; data-original-width=&quot;800&quot; height=&quot;723&quot; src=&quot;https://user-images.githubusercontent.com/70787887/128596742-17ab830e-ea83-4afc-acfd-183c370d7486.png&quot; width=&quot;800&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This window is used for all events and for this project.&lt;/p&gt;&lt;p&gt;In this window, we display the simulation of the 10 atoms of the periodic table.&lt;/p&gt;&lt;p&gt;And all mouse and keyboard events triggered in window.&lt;/p&gt;&lt;p&gt;All labels and information about the model displayed on this window.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.openglprojects.in/feeds/4085618032389521495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.openglprojects.in/2023/02/atom-simulation-computer-graphics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4085618032389521495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2020194800836807725/posts/default/4085618032389521495'/><link rel='alternate' type='text/html' href='http://www.openglprojects.in/2023/02/atom-simulation-computer-graphics.html' title='Atom Simulation - computer graphics projects with source code'/><author><name>Rajeev</name><uri>http://www.blogger.com/profile/03147189487850777395</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>