Build Taj Mahal mini projects in OpenGL Computer Graphics

Rajeev
Taj Mahal (ताज महल), is the symbol of love. It  is a white Marble mausoleum located in Agra, INDIA. It was built by Mughal emperor Shah Jahan in memory of his third wife, Mumtaz Mahal. For more info read wikipedia.

Here, we are going to develop basic structure of Taj Mahal in computer graphics. In this tutorial I will tell how to make Taj like structure using the OpenGL. We will develop simple structure, not exactly same as it looks in real but some what idealistic. This project is mainly mean for the VTU Computer Graphics mini-projects.

Taj Mahal is basically a structure with many minars and gumbazz. We will use the simple objects like spheres and cubes to build these units. First for the main part we use box or a large cube and then point small sphere over them. Thereafter, we place a small cubical structure with very low height, a egg like sphere is also placed over it. Similarly,we going to place four long minars over each four corners.

We are also developing the wired framed structure of the Taj as well. In the wired framed Taj, the large cube block will go transparent and the two tombs will be place in the middle with small cubes.

In this mini-project, we will create a simplified 3D model of the Taj Mahal using OpenGL and GLUT. The model is not intended to be an exact replica of the real monument. Instead, basic OpenGL primitives such as cubes and spheres are combined, scaled, and translated to create an idealized Taj Mahal-like structure.

This type of project is useful for understanding the fundamentals of Computer Graphics, 3D transformations, OpenGL primitives, and hierarchical modeling, and can be used as a VTU Computer Graphics mini-project.

1. Project Objective

The main objectives of this mini project in OpenGL are:

  • To learn how OpenGL primitive objects can be combined to form a larger model, use translation and scaling transformations, understand hierarchical modeling using glPushMatrix() and glPopMatrix(). 

  • To understand basic modeling using OpenGL and  demonstrate the use of GLUT solid primitives such as cubes and spheres

  • Use above concept to create a simple representation of the Taj Mahal.

2. Software Requirements

The project can be implemented using:

3. Explanation

3.1. Creating the Bottom Base

The first component is the large bottom platform.

/* Draw the bottom box */
glPushMatrix();

glScaled(0.8, 0.04, 0.8);
glTranslatef(0.0, -30.2, 0.0);

glutSolidCube(7.0);

glPopMatrix();

A cube of size 7.0 is initially created. It is then scaled heavily along the Y-axis using: glScaled(0.8, 0.04, 0.8); This converts the cube into a thin rectangular platform. Then use translation with: glTranslatef(0.0, -30.2, 0.0); places the platform below the main structure. Thus, the cube acts as the large base/platform of the Taj Mahal.

3.2. Creating the Main Building

The main central building is represented using a cubeglutSolidCube(2.0); which creates the main body. The translation glTranslatef(0.0, -0.6, 0.0); moves the building slightly downward along the Y-axis. The cube provides the basic central structure on which the dome is placed.

3.3 Creating the Main Dome

The main dome is created using a scaled sphere.

// main gumbaz
glPushMatrix();

glScaled(0.8, 1.0, 0.8);
glTranslatef(0.0, 1.5, 0.0);

glutSolidSphere(0.8, 80, 120);

glPopMatrix();

The sphere is scaled with glScaled(0.8, 1.0, 0.8); so that it forms a dome-like shape reduces the width of the sphere relative to its height. The translation: glTranslatef(0.0, 1.5, 0.0); moves it above the main building. The sphere is therefore used as a simple approximation of the central gumbaz (dome).

3.4. Dome Base

A small cube is placed underneath the dome.

glTranslatef(0.0, 1.0, 0.0);
glScaled(1.2, 0.25, 1.2);

glutSolidCube(0.9);

The cube is scaled in the Y direction to make it short and wide. This creates a small platform between the main building and the dome.

3.5. Dome Pointer or Spire

The top portion of the dome is represented using another scaled sphere.

// gumbaz pointer
glPushMatrix();

glScaled(0.03, 0.5, 0.03);
glTranslatef(0.0, 10.8, 0.0);

glutSolidSphere(0.4, 80, 120);

glPopMatrix();

The sphere is extremely narrow in the X and Z directions with scaling usingglScaled(0.03, 0.5, 0.03); which makes it appear like a thin vertical pointer. The result acts as the spire on top of the central dome.

3.6. Creating the Four Main Minarets

The Taj Mahal mini projects in OpenGL contains four large minarets positioned around the central building. They are placed approximately at: (+2, -1.9, +2)- (-2, -1.9, +2)- (-2, -1.9, -2)- (+2, -1.9, -2)- This gives the structure a symmetrical appearance.

3.6.1 First Minaret

glPushMatrix();

glTranslated(2, -1.9, 2);
glScaled(.2, 10.5, .2);

glutSolidSphere(0.4, 80, 120);

glPopMatrix();

The sphere is heavily scaled along the Y-axis, making it look like a tall cylindrical tower. Although a cylinder would normally be a more natural primitive for a minaret, the project uses a scaled sphere as a simple modeling technique.

3.6.2 Minaret Top

A second scaled sphere is placed near the top.

glPushMatrix();

glTranslated(2, 0.8, 2);
glScaled(0.3, 1.5, 0.3);

glutSolidSphere(0.4, 80, 120);

glPopMatrix();

This produces a decorative section near the top of the minaret.

3.6.3. Remaining Three Main Minarets

The same technique is repeated for the remaining three corners.

Second Minaret

glTranslated(-2, -1.9, 2);

Third Minaret

glTranslated(-2, -1.9, -2);

Fourth Minaret

glTranslated(2, -1.9, -2);

Changing the signs of the X and Z coordinates places the towers at the four corners.

This demonstrates an important concept in 3D graphics: symmetry can be created by changing the coordinates of repeated objects rather than designing every object independently.

3.7. Creating the Short Inner Minarets

The program also creates four smaller towers closer to the center. The first is positioned at:

glTranslated(0.6, -0.5, 0.6);

Another is positioned at:

glTranslated(0.6, -0.5, -0.6);

The remaining two are:

glTranslated(-0.6, -0.5, -0.6);

and:

glTranslated(-0.6, -0.5, 0.6);

Each tower is created using:

glScaled(.2, 11.5, .2);
glutSolidSphere(0.2, 80, 120);

The smaller radius makes these towers thinner than the four external minarets. 

3.8. Decorative Spheres on the Short Minarets

Each short minaret also contains a decorative upper section.

For example:

glPushMatrix();

glTranslated(0.6, 0.5, 0.6);
glScaled(0.3, 1.5, 0.3);

glutSolidSphere(0.4, 80, 120);

glPopMatrix();

The same design is repeated at the other three positions.

This produces symmetry and gives the model additional architectural detail.

4. Important OpenGL Functions Used

FunctionPurpose
glPushMatrix()Saves the current transformation matrix
glPopMatrix()Restores the previous transformation matrix
glTranslatef()Moves an object
glTranslated()Moves an object using double-precision parameters
glScaled()Changes the size of an object
glutSolidCube()Creates a solid cube
glutSolidSphere()Creates a solid sphere

5. Conclusion

The Taj Mahal OpenGL mini-project demonstrates how basic geometric objects can be combined to create a recognizable 3D architectural structure.

Using cubes and spheres along with transformations such as glTranslatef(), glTranslated(), and glScaled(), we can construct the major components of the Taj Mahal, including its central building, dome, spire, platform, and minarets.

The project is an example of hierarchical modeling in OpenGL, where each component is independently transformed using glPushMatrix() and glPopMatrix().

Although the resulting model is a simplified representation rather than an exact architectural reconstruction, it effectively demonstrates the fundamental concepts required for a Computer Graphics / OpenGL mini-project.

Project Summary

Project Title: Taj Mahal
Technology: OpenGL + GLUT
Language: C/C++

/* Draw the bottom box */
 glPushMatrix();
 glScaled(0.8,0.04,0.8);
 glTranslatef(0.0,-30.2,0.0);
 glutSolidCube(7.0);
 glPopMatrix();

 //main cube
 glTranslatef(0.0,-.6,0.0);
 glutSolidCube(2.0);

 //main gumbazz 
 glPushMatrix();
 glScaled(0.8,1.0,0.8);
 glTranslatef(0.0,1.5,0.0);
 glutSolidSphere(0.8,80,120);
 glPopMatrix();
 
 glTranslatef(0.0,1.0,0.0);
 glScaled(1.2,0.25,1.2);
 glutSolidCube(0.9);

 //gumbaz pointer

 glPushMatrix();
 glScaled(0.03,0.5,0.03);
 glTranslatef(0.0,10.8,0.0);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();
 
 //Minars
 glPushMatrix();
 glTranslated(2,-1.9,2);
 glScaled(.2,10.5,.2);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //minar's sphere
 glPushMatrix();
 glTranslated(2,0.8,2);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //Minars
 glPushMatrix();
 glTranslated(-2,-1.9,2);
 glScaled(.2,10.5,.2);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //minar's sphere
 glPushMatrix();
 glTranslated(-2,0.8,2);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();
 

 //Minars
 glPushMatrix();
 glTranslated(-2,-1.9,-2);
 glScaled(.2,10.5,.2);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //minar's sphere
 glPushMatrix();
 glTranslated(-2,0.8,-2);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //Minars
 glPushMatrix();
 glTranslated(2,-1.9,-2);
 glScaled(.2,10.5,.2);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();
 
 //minar's sphere
 glPushMatrix();
 glTranslated(2,0.8,-2);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();
 
 //short Minars
 glPushMatrix();
 glTranslated(0.6,-0.5,0.6);
 glScaled(.2,11.5,.2);
 glutSolidSphere(0.2,80,120);
 glPopMatrix();

 //short minar's sphere
 glPushMatrix();
 glTranslated(0.6,0.5,0.6);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //short Minars
 glPushMatrix();
 glTranslated(0.6,-0.5,-0.6);
 glScaled(.2,11.5,.2);
 glutSolidSphere(0.2,80,120);
 glPopMatrix();

 //short minar's sphere
 glPushMatrix();
 glTranslated(0.6,0.5,-0.6);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //short Minars
 glPushMatrix();
 glTranslated(-0.6,-0.5,-0.6);
 glScaled(.2,11.5,.2);
 glutSolidSphere(0.2,80,120);
 glPopMatrix();

 //short minar's sphere
 glPushMatrix();
 glTranslated(-0.6,0.5,-0.6);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

 //short Minars
 glPushMatrix();
 glTranslated(-0.6,-0.5,0.6);
 glScaled(.2,11.5,.2);
 glutSolidSphere(0.2,80,120);
 glPopMatrix();

 //short minar's sphere
 glPushMatrix();
 glTranslated(-0.6,0.5,0.6);
 glScaled(0.3,1.5,0.3);
 glutSolidSphere(0.4,80,120);
 glPopMatrix();

49 comments

  1. namratha
    sir i need the updation of the project memory blocks sir....the updations are
    1) inspite of geometrical obejcts i want to add numbers.
    2) While displaying the score i want the time also to be displayed..(How much time we took to solve that puzzel)
  2. Uttam
    hi nice wrk dear, cn u plz email me d full source code of dis tajmahal program for my mini project...
     
  3. Rajeev Kumar Singh
    You can get the Taj Project from this blog, but you can make it your own as structure has been given with code. All you have to do is to post some display and keyboard, mouse interactions functions.

    Subscribe to email news letter to get the updates as soon it will be on the board.
    1. Anonymous
      can you tell when it will be avialabel to download the code
  4. hussain123
    awesome please send me code and all files of it
  5. Rajeev Kumar Singh
    source code is mentioned here but there is need to add up some other functions so, get the code and work out in display your self...............
  6. Sultanahusna
    Rajeev sir,could you please send me the complete source code of this project...please do the needful
  7. Rajeev Kumar Singh
     Since almost all codes are there, u can develop ur self if problem persist have a comment here
  8. Shilpa13 Shree05
    sir plz send me complete code and files of it................
    shilpa13.shree05@gmail:disqus .com
  9. Prajna k s
    plz gv us source code
  10. Rajeev Kumar Singh
    sent to u
  11. Rajeev Kumar Singh
     code  has been sent 2 u
  12. Arshfrndz
    can u pls post complete code of tajmahal
  13. karishma
    can i plsss get complete source code for tis  program.....
  14. Ajayjagdale66
    can u pls post complete code of tajmahal
  15. Rajeev Kumar Singh
     the whole projects is here , you just need to code the main function and a display function that's it!
  16. Deepthi
    can u plz put put the entire code?
  17. Rajeev Kumar Singh
     already said just put main function and run it.........
  18. Knshwetha9
    can i get some new topics of cg project
  19. Ballesh
    Plz send full code of taj mahal
  20. Anithaboomiraj
    open gl means what that is one language??
    can u give me full code
  21. Rajeev Kumar Singh
    as i said b4 everthing is here u just need to call main function nothing else.....
  22. Rajeev Kumar Singh
    opengl is platform for coding the graphics and it can be implemented on c, c++ as well as java. you can see it on the apple's products like of iphone. also counter striker is made from this.
  23. TanB
    pls gv d main function.....
  24. Rajeev Kumar Singh
    as usual add the things that u add in normal programs that's it
  25. kalai
    Plz send full code of taj mahal
  26. Harika P
    can u plzzz send me the source code for rendering "RAVAN with FIRE" as output in opengl...to ma email...i.i...."harika.87p@gmail.com
  27. sithara nair
    pls send the source code
  28. hasini
    send me complete source code of tajmahal
  29. ayeshu
    hai iam ayeshu can u send complete project code of taj mahal for my mini project.i need it.please.alon with main function.i will be waiting.
  30. ayeshu
    rajeev sir,can u give me a 3d project,fo me.idont wich project i select.so please help me.
  31. ayeshu
    sir,iwant a 3d project in opengl please provide me with tat type of project,i selected taj mahal but it is not in 3d.please help.iam waiting.please send project to my mail.
  32. kalai
    sir can u plz send me taj mahal's coding to my mail

    kalaiselvi5mjkpr5@gmail.com
  33. praveen
    praveenchaudhary3@gmail.com Please send the code
  34. akshatha
    hello Rajeev Kumar Singh,

    can u send me complete code of this mini project with lighting effects....
  35. arslan bilal
    can u plz mail me the complete project at sheikh.abm@gmail.com
  36. akshatha
    can we do this project in visualstuido2005 version...?
  37. nemish kamath
    sir can u please send me the entire code

    nemish.kamath@gmail.com
    thank you
  38. Pavan Sudhindra
    sir can u please mail me the source code

    pavan_sudhindra@ymail.com

    thank you
  39. auvy
    please send me the complete code.............please
    my e-mail address "auvyauvy@gmail.com"
  40. ripunjay
    sir plzz mail me full code of taj mahal ..please at ripun0145@gmail.com
    please @Rajeevkumarsingh
  41. Rajeev Kumar Singh
    sent u...........
  42. ☺☻Surbhi☻☺
    sir..,Can you please send me complete code ....

    surbhi.09.c@gmail.com
  43. zeba
    hello sir,hope you r seeing this text..plz send the main function of this code sir...i tried it,bt itz nt working ...so plz i request u to mail at zeba14rocks@gmail.com
  44. faisal ahmed
    can u send this project plz bro faisal.ahmedbcse@gmail.com
  45. Arpitha B
    pls send dis taj mahal project to my mail arpithab92@gmail.com
  46. Arpitha B
    sir can u send me project topic nd coding to my mail arpithab92@gmail.com
  47. sanjay singh
    cn u plz email me d full source code of dis tajmahal program for my mini project...
  48. Anonymous
    Please send the complete source code to anjithaalila@gmail.com
    Plz.....plz..sir

Join the conversation