Fractal Tree Project
Fractal Tree Project
We are thankful to our principal who has given us the opportunity science
department & our company guide & all the friends who have always have been a
great source of inspiration for us.
We would also like to give our sincere gratitude to Prof. Joshi G.R. (Head of
Department, Computer Science) who guided us to develop the system “Fractal
Tree”.
INDEX
Sr.No Topic Page No
1 Computer graphics concepts used in project. 6
2 OpenGL library and methods used in project. 7
3 Code. 9
4 Output Screen. 21
5 Bibliography. 22
Computer graphics concepts used in project
1.Pixel or point:
2.Resolution:
3.Curves:
OpenGL library:
GL utility toolkit-provides function for opening windows, managing
,menus and managing events.
1. glClear Basic GL:
OpenGL methods:
1. glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,ch[i]):-
2. glLoadIdentity():- Reset The Projection Matrix
3. ghRasterPos2f(xpos,ypos):-
4. glClearColor():-set display window color
5. glBegin(GL_QUADS):-Start draw a polygon
6. glColor3f():- Set ball color
7. glVertex2f():- Define the vertex
8. glClear():-Clear display window.
9. glEnd():-We are done polygon
10. glTranslatef():-Move an object.
11. glPointSize():-
12. glutPostRedisplay():-
13. glMatrixMode(GL_PROJECTION):-Specifies the weather projection will modify
using argument GL_PROJECTION for mode. Subsequent command affect the
specified matrix.
14. glOrtho2D():-
15. glMatrixMode(GL_MODELVIEW):-
16. glutSwapBuffer():-
17. glutInit():-Initialise OpenGL
18. glutInitDisplayMode(GLUT_RGB/GLUT_DOUBLE):-Set display mode.
19. glutInitWindowPosition():- Set window position.
20. glutWindowSize():- Set window size.
21. glutCreateWindow():-open screen window with the specified previously
specified size position & other properties.
22. glutDisplayFunc():-Image to be drawn initially.
23. glutSpecialFunc(2specialkey):-
24. glutKeyboardFunc():-When Keyboard Is pressed.
25. glutIdleFunc(display):-Even if there are no events, redraw our gl scene.
26. glutMainLoop():-Start Event Processing Engine
Code
#include<windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include<GL/glu.h>
#endif
#include <stdlib.h>
int flag=1;
GLfloat angle,angle2;
int moving,startx,starty;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLUquadricObj *qobj;
qobj = gluNewQuadric();
glPushMatrix();
glRotatef(-90,1.0f,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
float angle;
makecylinder(height, Base);
glTranslatef(0.0f, height,0.0f);
height-=height*0.2f;
Base-=Base*0.31;
angle = 20+((rand()%50));
if(angle >48)
angle=-(20+((rand()%50)));
if (height > 1)
glPushMatrix();
if (flag)
else
flag = !flag;
glPopMatrix();
else
//Glut.glutSwapBuffers();
glPopMatrix();
srand(GLUT_ELAPSED_TIME);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(angle,0,1,0);
glRotatef(angle2,0,0,1);
maketree(4.0f,0.1f);
glutSwapBuffers();
glFlush();
switch (key)
case 27 :
case 'q':
exit(0);
break;
glutPostRedisplay();
moving=1;
startx=x;
starty=y;
moving=0;
if(moving)
angle=angle+(x-startx);
angle2=angle2+(y-starty);
startx=x;
starty=y;
glutPostRedisplay();
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glClearColor(1,1,1,1);
glEnable(GL_DEPTH_TEST);
glutMainLoop();
return EXIT_SUCCESS;
}
Bibliography
For the completion of our project documentation we have referred the following book.
1.Computer Graphics.
-Poonam Ponde.
2.www.graphicsminiproject.com