100% found this document useful (1 vote)
142 views40 pages

CG Report WIND MILL

wind mill report

Uploaded by

Shilpa Vasista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
142 views40 pages

CG Report WIND MILL

wind mill report

Uploaded by

Shilpa Vasista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Village wind mill Using OpenGL

CHAPTER 1
INTRODUCTION
1.1 About Computer Graphics
The term computer graphics has been used in a broad sense to describe almost everything on
computers that is not text or sound. Typically, the term computer graphics refers to several
different things:
 The representation and manipulation of image data by a computer
 The various technologies used to create and manipulate images
 The sub-field of Computer Science which studies methods for digitally synthesizing
and manipulating visual content.
Today, computer graphics is widespread. Such imagery is found in and on television,
newspapers, weather reports, and in a variety of medical investigations and surgical
procedures. A well-constructed graph can present complex statistics in a form that is easier to
understand and interpret. In the media such graphs are used to illustrate papers, reports and
other presentation material.
Graphics provides one of the most natural means of communicating with a computer,
since our highly developed 2D and 3D pattern-recognition abilities allow us to perceive and
process pictorial data rapidly and efficiently. Interactive computer graphics is the most
important means of producing pictures since the invention of photography and television. It
has the added advantage that, with the computer, we can make pictures not only of concrete
real-world objects but also of abstract, synthetic objects, such as mathematical surfaces and of
data that have no inherent geometry, such as survey results.
Using this editor you can draw and paint using the mouse. It can also perform a host of
other functions like drawing lines, circles, and polygons and so on. Interactive picture
construction techniques such as basic positioning methods, rubber-band methods, dragging
and drawing are used. Block operations like cut, copy and paste are supported to edit large
areas of the workspace simultaneously. It is user friendly and intuitive to use.
Graphics provides one of the most natural means of communicating with a computer,
since our highly developed 2D Or 3D pattern-recognition abilities allow us to perceive and
process pictorial data rapidly. Computers have become a powerful medium for the rapid and
economical production of pictures. Graphics provide a so natural means of communicating
with the computer that they have become widespread. Interactive graphics is the most

Department of CSE, CEC 2021-2022 Page 1


Village wind mill Using OpenGL

important means of producing pictures since the invention of photography and television. We
can make pictures of not only the real-world objects but also of abstract objects such as
mathematical surfaces on 4D and of data that have no inherent geometry. A computer
graphics system is a computer system with all the components of the general-purpose
computer system. There are five major elements in system: input devices, processor,
memory, frame buffer and output devices.
There are different types of Graphics architectures which are:
 Display processors: The earliest attempts to build special purpose graphics system were
concerned primarily with relieving the general-purpose computer from the task of
refreshing the display continuously. These display processors had conventional
architecture but included instructions to display primitives on the CRT.
 Pipeline architectures: The availability of inexpensive solid-state memory led to the
universality of raster display. For computer graphics applications, the most important use
of custom VLSI circuits has been in creating pipeline architectures.
 Graphics pipeline: Each object comprises a set of graphical primitives. Each primitive
comprises set of vertices.
 Vertex processing: The assignment of vertex color scan as simple as program specifying
a color or as complex as computation of a color from a physically realistic lightning
model that incorporates the surface properties of the object and the characteristic light
sources in the scene.
 Clipping and primitive assembly: We must do clipping because of the limitations of that
no imaging system can see the whole world at once. The human retina has a limited size
corresponding to an approximately 90-degreed field of view.

1.2 History of Computer Graphics


William fetter was credited with coning the term Computer Graphics in 1960, to describe his
work at Boeing. One of the first displays of computer animation was future world (1976),
which included an animation of a human face and hand-produced by Carmel and Fred Parle at
the university of Utah.
There are several international conferences and journals where the most significant
results in computer graphics are published, among them are the SIGGRAPH and Euro
graphics conferences and the association for computing machinery (ACM) transaction on
graphics journals.

Department of CSE, CEC 2021-2022 Page 2


Village wind mill Using OpenGL

1.3 About OpenGL:


OpenGL (open graphics library) is a standard specification defining a cross language cross
platform API for writing applications that produce 2D and 3D computer graphics. The
interface consists of over 250 different function calls which can be used to draw complex 3D
scenes from simple primitives. OpenGL was developed by silicon graphics Inc.(SGI) in 1992
and is widely used in CAD ,virtual reality , scientific visualization , information visualization
and flight simulation. It is also used in video games, where it competes with direct 3D on
Microsoft Windows platforms. OpenGL is managed by the non-profit technology consortium,
the khronos group, Inc.
OpenGL serves two main purposes:
 To hide the complexities of interfacing with different 3D accelerators, by presenting
programmer with a single, uniform API.
 To hide the differing capabilities of hardware platforms, by requiring that all
Implementations support the full OpenGL, feature set.

OpenGL has historically been influential on the development of 3D accelerator, promoting a


base level of functionality that is now common in consumer level hardware:

 Rasterized points, lines and polygons are basic primitives.


 A transform and lighting pipeline.
 Z buffering.
 Texture Mapping.
 Alpha.
 Blending.

OpenGL is the premier environment for developing portable, interactive 2D and 3D


graphics applications. Since its introduction in 1992, OpenGL has become the industry's most
widely used and supported 2D and 3D graphics application programming interface (API),
bringing thousands of applications to a wide variety of computer platforms.
OpenGL fosters innovation and speeds application development by incorporating a broad
set of rendering, texture mapping, special effects, and other powerful visualization functions.
Developers can leverage the power of OpenGL across all popular desktop and workstation
platforms, ensuring wide application deployment.

Department of CSE, CEC 2021-2022 Page 3


Village wind mill Using OpenGL

OpenGL Available Everywhere: Supported on all UNIX® workstations, and shipped standard
with every Windows 95/98/2000/NT and Mac OS PC, no other graphics API operates on a
wider range of hardware platforms and software environments.
OpenGL runs on every major operating system including Mac OS, OS/2, UNIX,
Windows 95/98, Windows 2000, Windows NT, Linux, Open Step, and BeOS; it also works
with every major windowing system, including Win32, Mac OS, Presentation Manager, and
X-Window System. OpenGL is callable from Ada, C, C++, FORTRAN, Python, Perl and
Java and offers complete independence from network protocols and topologies.
The OpenGL interface: Our application will be designed to access OpenGL directly
through functions in three libraries namely-

 GL
 GLU
 glut

GLU

GL

OpenGL Frame
GLUT
application Buffer
program
Xlib,Xtk

GLX

Figure 1.1: Library Organization

Department of CSE, CEC 2021-2022 Page 4


Village wind mill Using OpenGL

1.4 Applications of Computer Graphics:


(1) Video games:
 These games requires human interaction with the User Interface for making nice visual
result on the Video Device
(2) Education Field:
 In the learning process, acquiring knowledge and skills required for better career path CG
is needed. So Computer generated models in economic, financial and physical systems are
often used.
 We regularly love to have computerized model to understand any topic easily. Equipment,
Physiological systems, physical systems are coded using CG.
(3) Computer Aided Design (CAD):
 Most of engineering and Architecture students are concerned with Design. CAD is used to
design various structures such as Computers, Aircrafts, Building, in almost all kinds of
Industries (where designing is necessary)
 After making a full diagram, we can even see its animation (Operation and working of a
Product)
(4) Computer Arts:
 If we are intelligent enough, we can rock by making creative arts using these Graphics
tools. For making these arts we generally use CAD packages, paint and Paint brush
programs and in animation too
 Computer Arts Examples include Logo design (for companies, college, Industries,
Institutions), Cartoon drawing, Product advertisements and many.
(5) Simulation:
 Using CG graphics reproduction or duplicating already existing thing will be done. For
Instance, if we go for the Flight simulators, these computer generated images are very
much needed for training pilots to understand easily (learning standard methods)
(6) Entertainment:
 When we talk about Entertainment, immediately movies and games get in to picture.CG
are mostly used in music videos, motion pictures, cartoon animation films. For finding out
tricks to be used in Games, for its interactivity we often use CG
(7) Image Processing: (Medical)
 In Medical field, concerning Image Processing CG is used to various technologies to
interpret already existing pictures and is useful to modify Photographs and TV scans.

Department of CSE, CEC 2021-2022 Page 5


Village wind mill Using OpenGL

Basically, CG is used to improve the picture quality, and visualizing effects. Some of its
applications includes-
i). Tomography
ii). Ultrasonic medical scanners
iii). Picture enhancements
(8) User Interfaces (Graphical User Interfaces):
 CG is effectively used to make Menus, Icons (Graphical Symbols),to make window
manager(multiple windows).And Some of the Graphic packages includes PHIGS,
Graphics Kernel System, Painting and drawing.
Some of the other applications are: -
 Scientific and Business Visualization
 Graphic Presentation
 Graphic Design
 Web Designing
 Computational Physics
 Information Visualization
 Display of Information
 Information Architecture
 Genetics, Molecular Biology, Neuroscience, Animation, Statistics
 Desktop Publishing.

1.5 Built-In Functions:


(1) glColor3f (float, float, float):-
This function will set the current drawing color.
(2) gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top):-
Which defines a two-dimensional viewing rectangle in the plane z=0.
(3) glClear ( ):-
Takes a single argument that is the bitwise OR of several values indicating which buffer is to
be cleared.
(4) glClearColor ():-
Specifies the red, green, blue, and alpha values used by glClear to clear the color buffers.

Department of CSE, CEC 2021-2022 Page 6


Village wind mill Using OpenGL

(5) glLoadIdentity ( ):-


Sets the current matrix to an identity matrix.
(6) glMatrixMode (mode):-
Sets the current matrix mode, mode can be GL_MODELVIEW, GL_PROJECTION or
GL_TEXTURE.
(7) glutInit (int *argc, char**argv):-
Initializes GLUT, the arguments from main are passed in and can be used by the application.
(8) glutInitDisplayMode (unsigned int mode):-
Request a display with the properties in mode. The value of mode is determined by the logical
OR of options including the color model and buffering.
(9) glutInitWindowSize (int width, int height):-
Specifies the initial position of the top-left corner of the window in pixels
(10) glutCreateWindow (char *title):-
A window on the display. The string title can be used to label the window. The return value
provides references to the window that can be used when there are multiple windows.
(11) glutMouseFunc(void *f(int button, int state, int x, int y):-
Register the mouse callback function f. The callback function returns the button, the state of
button after the event and the position of the mouse relative to the top-left corner of the
window.
(12) Void glutKeyboardFunc(void(*func) (void)):-
This function is called every time when you press enter key to resume the game or when you
press ‘b’ or ‘B’ key to go back to the initial screen or when you press esc key to exit from the
application.
(13) glutDisplayFunc (void (*func) (void)):-
Register the display function that is executed when the window needs to be redrawn.
(14) glutSpecialFunc(void(*func)( void)):-
This function is called when you press the special keys in the keyboard like arrow keys,
function keys etc. In our program, the function is invoked when the up arrow or down arrow
key is pressed for selecting the options in the main menu and when the left or right arrow key
is pressed for moving the object(car) accordingly.
(15) glut PostReDisplay ( ) :-
Which requests that the display callback be executed after the current callback returns.

Department of CSE, CEC 2021-2022 Page 7


Village wind mill Using OpenGL

(16) Void MouseFunc (void (*func) void)):-


This function is invoked when mouse keys are pressed. This function is used as an alternative
to the previous function i.e., it is used to move the object(car) to right or left in our program
by clicking left and right button respectively.
(17) glutMainLoop() :-
Cause the program to enter an event-processing loop. It should be the last statement in main
function.

1.6 Mouse Functions:


Right button: controls the below options.
 No wind option: wind mills doesn’t rotate.
 Wind CW option: wind mills move in clockwise direction.
 Wind ACW option: wind mills move in anticlockwise direction.
 Fast wind CW option: moves faster in clockwise direction.
 Fast wind ACW option: moves faster in anticlockwise direction.
 Fast wind ACW option: moves faster in anticlockwise direction.
 Quit option: used to quit the above operations.
When the project is made to run, we can initially start the wind mills in clockwise
direction by selecting Wind CW option. We have to select Wind ACW option for
anticlockwise moving, and then we have to select Fast Wind CW for faster moving with
clockwise direction and Fast Wind ACW foe faster moving with anticlockwise direction and
finally for quit that operation we have to select Quit option and end the project

Department of CSE, CEC 2021-2022 Page 8


Village wind mill Using OpenGL

CHAPTER 2
LITERATURE SURVEY
 Computer graphics started with the display of data on hardcopy plotters and cathode ray
tube (CRT) screens soon after the introduction of computers.
 Computer graphics today largely interactive, the user controls the contents, structure, and
appearance of objects and of displayed images by using input devices, such as keyboard,
mouse, or touch-sensitive panel on the screen. Graphics based user interfaces allow
millions of new users to control simple, low- cost application programs, such as
spreadsheets, word processors, and drawing programs.
 OpenGL (Open Graphics Library) is a standard specification defining a cross-language,
cross-platform API for writing applications that produce 2D and 3D computer graphics.
The interface consists of over 250 different function calls which can be used to draw
complex three-dimensional scenes from simple primitives. OpenGL was developed by
Silicon Graphics Inc. (SGI) in 1992 and is widely used in CAD, virtual reality, scientific
visualization, information visualization, and flight simulation. It is also used in video
games, where it competes with Direct3D on Microsoft Windows platforms (see Direct3D
vs. OpenGL). OpenGL is managed by the non-profit technology consortium, the Khronos
Group.
 In the 1980s, developing software that could function with a wide range of graphics
hardware was a real challenge. By the early 1990s, Silicon Graphics (SGI) was a leader in
3D graphics for workstations. SGI's competitors (including Sun Microsystems, Hewlett-
Packard and IBM) were also able. In addition, SGI had a large number of software
customers; by changing to the OpenGL API they planned to keep their customers locked
onto SGI (and IBM) hardware for a few years while market support for OpenGL matured
to bring to market 3D hardware, supported by extensions made to the PHIGS standard. In
1992, SGI led the creation of the OpenGL architectural review board (OpenGL ARB), the
group of companies that would maintain.
 OpenGL specification took for years to come. On 17 December 1997, Microsoft and SGI
initiated the Fahrenheit project, which was a joint effort with the goal of unifying the
OpenGL and Direct3D interfaces (and adding a scene-graph API too). In 1998 Hewlett-
Packard joined the project. It initially showed some promise of bringing order to the
world of interactive 3D computer graphics APIs, but on account of financial constraints at
SGI, strategic reasons at Microsoft, and general lack of industry support, it was

Department of CSE, CEC 2021-2022 Page 9


Village wind mill Using OpenGL

abandoned in 1999.
 Many openGL functions are used for rendering and transformation purposes.
Transformations functions like glRotate (), glTranslate (), glScaled () can be used.
 OpenGL provides a powerful but primitive set of rendering command, and all higher-level
drawing must be done in terms of these commands. There are several libraries that allow
you to simplify your programming tasks, including the following:
 OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL
commands to perform such tasks as setting up matrices for specific viewing orientations
and projections and rendering surfaces.
 OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by
Mark Kill guard, to hide the complexities of differing window APIs.
 To achieve the objective of the project, information related to the light sources is required
with OpenGL we can manipulate the lighting and objects in a scene to create many
different kinds of effects. It explains how to control the lighting in a scene, discusses the
OpenGL conceptual model of lighting, and describes in detail how to set the numerous
illumination parameters to achieve certain effects and this concept is being obtained.
 To demonstrate the transformation and lightening, effects, different polygons have to be
used. Polygons are typically drawn by filling in all the pixels enclosed within the
boundary, but we can also draw them as outlined polygons or simply as points at the
vertices. This concept is obtained from.
 The properties of a light source like its material, diffuse, emissive, has to mention in the
project. So to design the light source and the objects, programming guide of an OpenGL is
used.

Department of CSE, CEC 2021-2022 Page 10


Village wind mill Using OpenGL

CHAPTER 3
SYSTEM REQUIREMENT SPECIFICATION
3.1 Hardware Requirements:
Minimum hardware specification-
 Microprocessor: Intel® Pentium® CPU [email protected]*4
 Main memory: 3.8GiB
 Hard Disk: 20GB (approx)
 Hard disk speed in RPM:5400 RPM
 Keyboard: QWERTY Keyboard
 Mouse :2 or 3 Button mouse
 Monitor: 1024 x 768 display resolution

3.2 Software Requirements:


Minimum software specification-
 Operating system: WINDOWS 10/11
 Tool Used: OpenGL
 Compiler: Eclipse idle
 X86
 X64(WOW)
 Mouse Driver
 Graphics Driver
 C/C++ Language

Department of CSE, CEC 2021-2022 Page 11


Village wind mill Using OpenGL

CHAPTER 4
DESIGN
4.1 FLOW CHART

START

MAIN()

INIT()

DISPLAY

MOUSE()

LEFT BUTTONL RIGHT BUTTON

HOUSE
CONTROLS

STOP

Figure 4.1: Flow chart

Department of CSE, CEC 2021-2022 Page 12


Village wind mill Using OpenGL

4.2 PROPOSED SYSTEM:


To achieve three dimensional effects, open GL software is proposed. It is software which
provides a graphical interface. It is a interface between application program and graphics
hardware.
The advantages are: -

1. Open GL is designed as a streamlined.


2. It’s a hardware independent interface i.e., it can be implemented on many different
hardware platforms.
3. With OpenGL we can draw a small set of geometric primitives such as points, lines and
polygons etc.
4. It provides double buffering which is vital in providing transformations.
5. It is event driven software.
6. It provides call back function.
OpenGL (Open Graphics Library) is the computer industry's standard application
program interface (API) for defining 2-D and 3-D graphic images. Prior to OpenGL, any
company developing a graphical application typically had to rewrite the graphics part of it for
each operating system platform and had to be cognizant of the graphics hardware as well.
With OpenGL, an application can create the same effects in any operating system using any
OpenGL-adhering graphics adapter.
OpenGL specifies a set of "commands" immediately executed functions. Each
command directs a drawing action or causes special effects. A list of these commands can be
created for repetitive effects. OpenGL is independent of the windowing characteristics of
each operating system, but provides special "glue" routines for each operating system that
enable OpenGL to work in that system's windowing environment. OpenGL comes with a
large number of built-in capabilities requestable through the API.

Department of CSE, CEC 2021-2022 Page 13


Village wind mill Using OpenGL

4.3 LOW LEVEL DESIGN:

START

MAINMAIN

glutReshapeFunc(myReshape)

glutMouseFunc(mouse)

glutKeyboardFunc(keys))

0 DISPLAY 0

END

Figure 4.2: Design of the low level

Department of CSE, CEC 2021-2022 Page 14


Village wind mill Using OpenGL

4.4 User Defined Functions:


 myinit():
This function initializes light source for ambient, diffuse and specular types.
 display():
This function creates and translates all the objects in a specified location in a particular
order and also rotates the objects in different axes.
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
 timerfunc():
This function starts a timer in the event loop that delays the event loop for delay miiliseconds.
 MainLoop():
This function whose execution will cause the program to begin an event processing loop.
 PushMatrix():
Save the present values of attributes and matrices placing ,or pushing on the top of the stack.
 PopMatrix():
We can recover them by removing them from stack.
 Translated():
In translate function the variables are components of the displacement vector.
 main():
The execution of the program starts from this function. It initializes the graphics system
and includes many callback functions.
 PostRedisplay():
It ensures that the display will be drawn only once each time the program goes through the
event loop.

Department of CSE, CEC 2021-2022 Page 15


Village wind mill Using OpenGL

CHAPTER 5
IMPLEMENTATION

5.1 Implementation of data structures concepts

DATA STRUCTURE:
Data structures are a specific way of organizing data in a specialized format on a computer so
that the information can be organized, processed, stored, and retrieved quickly and
effectively. They are a means of handling information, rendering the data for easy use.
THE DIFFERENT TYPES OF DATA STRUCTURES: Array, List. Linked List,
Queue, Graphs. Hash Tables, Tree and STACKS
STACK: t store collections of items in a linear order and are used when applying the
operations. For example, the order could be "first in, first out" (FIFO) or "last in, first out"
(LIFO).

STACK OPERATIONS:
 Push Operation Algorithm
Step 1 Checks Stack Has Some Space Or Stack Is Full.
Step 2-If The Stack Has No Space Then Display "Overflow" And Exit
Step 3-If The Stack Has Space Then Increase Top By 1 To Point Next Empty Space. -
Step 4-Adds Item To The Newly Stack Location, Where Top Is Pointing.
Step 5-Push Operation Performed Successfully.

 Pop Operation Algorithm


Step 1- Checks Stack Has Some Element Or Stack Is Empty.
Step 2-If The Stack Has No Element Means It Is Empty Then Display "Underflow"
Step 3-If The Stack Has Element Some Element. Accesses The Data Element At Which Top
Is Pointing.
Step 4-Decreases The Value Of Top By 1.
Step 5-Pop Operation Performed Successfully.

Department of CSE, CEC 2021-2022 Page 16


Village wind mill Using OpenGL

STACK OPERATION IN VILLAGE WIND MILL:


OpenGL keeps a stack of matrices to quickly apply and remove transformations,
glPushMatrix copies the top matrix and pushes it onto the stack, while glPopMatrix pops the
top matrix off the stack. All transformation functions (glScaled, etc.) function on the top
matrix, and the top matrix is what all rendering commands use to transform their data. By
pushing and popping matrices, you can control what transformations apply to which objects,
as well as apply transformations to groups of objects, and easily reverse the transformations
so that they don't affect other objects,

5.2 OpenGL Primitives


The term Primitive in OpenGL is used to refer to two similar but separate concepts. The first
meaning of "Primitive" refers to the interpretation scheme used by OpenGL to determine what
a stream of vertices represents when being rendered ex: "GL_POINTS". Such sequences of
vertices can be arbitrarily long.[7]
1. Point Primitive:
There is only one kind of point primitive:
 GL_POINTS: This will cause OpenGL to interpret each individual vertex in the stream as
a point. Points that have a Texture mapped onto them are often called "point sprites".
2. Line Primitive:
There are 3 kinds of line primitives, based on different interpretations of a vertex stream.
 GL_LINES: Vertices 0 and 1 are considered a line. Vertices 2 and 3 are considered a line.
And so on. If the user specifies a non-even number of vertices, then the extra vertex is
ignored.
 GL_LINE_STRIP: The adjacent vertices are considered lines. Thus, if you pass n
vertices, you will get n-1 lines. If the user only specifies 1 vertex, the drawing command is
ignored.
 GL_LINE_LOOP: As line strips, except that the first and last vertices are also used as a
line. Thus, you get n lines for n input vertices. If the user only specifies 1 vertex, the
drawing command is ignored. The line between the first and last vertices happens after all
of the previous lines in the sequence.
3. Triangle Primitives:
A triangle is a primitive formed by 3 vertices. It is the 2D shape with the smallest
number of vertices, so renderers are typically designed to render them. Since it is created from

Department of CSE, CEC 2021-2022 Page 17


Village wind mill Using OpenGL

only 3 vertices, it is also guaranteed to be planar. There are 3 kinds of triangle primitives,
based again on different interpretations of the vertex stream:

 GL_TRIANGLES: Vertices 0, 1, and 2 form a triangle. Vertices 3, 4, and 5 form a


triangle. And so on.
 GL_TRIANGLE_STRIP: Every group of 3 adjacent vertices forms a triangle. The face
direction ofthe strip is determined by the winding of the first triangle.
Each successive triangle will have its effective face order reversed, so the system compensates for
that by testing it in the opposite way. A vertex stream of n length will generate n-2 triangles.
 GL_TRIANGLE_FAN: The first vertex is always held fixed. From there on, every group
of 2 adjacent vertices form a triangle with the first.
4. Quads:
A quad is a 4-vertex quadrilateral primitive. The four vertices are expected to be
coplanar; failure to do so can lea1d to undefined results. A quad is typically rasterized as a
pair of triangles. This is not defined by the GL specification, but it is allowed by it. This can
lead to some artifacts due to how vertex/geometry shader outputs are interpolated over the 2
generated triangles.
 GL_QUADS: Vertices 0-3 form a quad, vertices 4-7 form another, and so on. The vertex
stream must be a number of vertices divisible by 4 to work.
 GL_QUAD_STRIP: Similar to triangle strips, a quad strip uses adjacent edges to form the
next quad. In the case of quads, the third and fourth vertices of one quad are used as the
edge of the next quad.

5.3 Header Files:


The headers that are used are as follows:
 #include<GL/glut.h>: To include glut library files.
 #include<stdio.h>: To include standard input and output files.
 #include<math.h>: To include various mathematical functions.

5.4 Main Function:


 void glScalef(TYPE sx, TYPE sy, TYPE sz) alters the current matrix by a scaling of (sx,
sy, sz). TYPE here is GLfloat. Here in the above considered example we use scaling to
minimize the length of the curve at each iteration. Forthis curve we use the scale factor to

Department of CSE, CEC 2021-2022 Page 18


Village wind mill Using OpenGL

be 3 units because we substitute a line by 4 lines in each iteration.


 void glRotatef(TYPE angle, TYPE dx, TYPE dy, TYPE dz) alters the current matrix by
a rotation of angle degrees about the axis(dx, dy, dz). TYPE heris GLfloat. For a Koch
curve we rotate by 60° about the z-axis.
 void glTranslatef(TYPE x, TYPE y, TYPE z) alters the current matrix by a displacement
of (x, y, z). TYPE here is GLfloat. We need to translate to display the new position of the
line from the old position and also to go out to thebeginning of the next side while
drawing.

 void glLoadIdentity() sets the current transformation matrix to an identity matrix.

 void glPushMatrix() pushes to the matrix stack corresponding to the current matrix mode.

 void glPopMatrix() pops from the matrix stack corresponding to the current matrix mode.

 void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top)


defines a two- dimensional viewing rectangle in the plane z=0.

 void glutMouseFunc(myMouse) refers to the mouse callback function. Here mouse


interface is given to increase a level of recursion by clicking mouse button and also to
decrease a level of recursion by doing the same holding the shift on the keyboard.

 void glutKeyboardFunc(myKey) refers to the keyboard callback function. Here keyboard


interface is given to quit, the user can quit by pressing ‘q’ and to see next example of the
implementation, the user should press ‘n’.

 void glutSwapBuffers() swaps the front and back buffers.


User defined functions are used to color the curves in a standard cycle rainbow manner which
becomes veryeasy for the user to identify the levels of recursion for the curves.

 void glutInit(int *argc, char**argv) Initializes GLUT< the arguments from main are
passed in and can by the application.

 void glutCreateWindow(char *title) Creates a window on the display. The string title can
Department of CSE, CEC 2021-2022 Page 19
Village wind mill Using OpenGL

be used to label the window. The return value provides a reference to the window that can
be used when there are multiple windows.

 void glutInitDisplaymode(unsigned int mode) Requests a display with the properties in


mode. The value of mode is determined by the logical OR of options including the color
model(GLUT_RGB<GLUT_INDEX) an buffering (GLUT_SINGLE<GLUT_DOUBLE).

 void glutInitWindowSize(int width,int heights) Specifies the initial height and width of
the window in pixels.

 void glutInitWindowPosition(int x,int y) Specifies the initial position of the top-left


corner of the window in pixels.

 void glViewport(int x,int y,GLsizei width,GLsizei height) Specifies a width * height


viewport in pixels whose lower-left corner is at (x,y) measured fromhe origin of the
window.

 void glutMainLoop() Cause the program to enter an event –processing loop.it should be
the statement in main.

 void glutPostRedisplay() Requests that the display callback be executed after the
current callback returns.

 void gluLookAt(GLdouble eyex,GLdouble eyey, GLdouble eyez, GLdouble atx,


GLdouble aty, GLdoubleatz, GLdouble upx, GLdouble upy, GLdouble upz)
Postmultiplies the current matrix determined by the viewer at the eye point looking at the
pointwith specified up direction.

 void gluPerscpective(GLdouble fov, GLdouble aspect, GLdouble near, GLdouble


far) Defines a perspective viewing volume using the y direction field of view fov
measured indegree,the aspect ratio of the front clipping plane, and the near and far
distance.

Department of CSE, CEC 2021-2022 Page 20


Village wind mill Using OpenGL

CHAPTER 6
SNAPSHOTS

Figure 6.1 Shows this is the first scene which appear when the program is executed

Figure 6.2 Shows the wind mill functions list on pressing right button on mouse

Department of CSE, CEC 2021-2022 Page 21


Village wind mill Using OpenGL

Figure 6.3 Wind mill is not blowing

Figure 6.4 Wind turbines are rotating in clockwise direction

Department of CSE, CEC 2021-2022 Page 22


Village wind mill Using OpenGL

Figure 6.5 Wind turbines are rotating in clockwise direction

Figure 6.6 Wind turbines are rotating more faster in clockwise direction

Department of CSE, CEC 2021-2022 Page 23


Village wind mill Using OpenGL

Figure 6.7 Wind turbines are rotating more faster in anticlockwise direction

Figure 6.8 Final view

Department of CSE, CEC 2021-2022 Page 24


Village wind mill Using OpenGL

APPENDIX
#include<stdlib.h> #include<stdio.h> #include<math.h> #include<Gl/glut.h>
static GLfloat spin = 360.0;/*fan rotation variable*/ static GLfloat u = 0.45; static GLfloat v
= 0.45; static GLfloat w = 0.45; static GLfloat b = 0.45; static GLfloat c = 0.00; static
GLfloat d = 0.00; static GLfloat e = 0.00;
static GLfloat a = -40; /*clouds translation variable*/ static int z = 0;GLfloat x = 0; GLfloat
y = 0; int m, n;
void output(char* string)
{
while (*string)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *string++);
}
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glShadeModel(GL_FLAT);
}
void text()
{
glColor3f(u, v, w); glRasterPos2f(0, 13);printf ("POWER HOUSE");
glRasterPos2f(20, 13); printf("STREET LIGHT");
}
void front()
{
glColor3f(0.0, 0.0, 1.0);
glRasterPos2f(-22, 25);
printf("ELECTRIC POWER GENERATION THROUGH WIND MILL");
glColor3f(0.3, 0.1, 0.4);
glRasterPos2f(-15, 0.0); printf("Your Name Here");
}
void streetlight()
{

Department of CSE, CEC 2021-2022 Page 25


Village wind mill Using OpenGL

glPushMatrix();/*1st street light*/ glLoadIdentity();


glColor3f(0.2, 0.2, 0.2); glBegin(GL_POLYGON); glVertex3f(28.0, -20.0, 2.0);
glVertex3f(29.0, -20.0, 3.0);
glVertex3f(29.0, 10.0, 4.0);
glVertex3f(28.0, 10.0, 2.0);
glEnd(); glPopMatrix(); glPushMatrix();glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON); glVertex3f(26.0, 6.0, 2.0);
glVertex3f(31.0, 7.0, 3.0);
glVertex3f(31.0, 6.0, 4.0);
glVertex3f(26.0, 7.0, 2.0); glEnd();
glPopMatrix(); glPushMatrix(); glColor3f(b, b, b); glTranslatef(24.5, 4.0, 1.0);
glRotatef(260, 0, 0, 1);
glScalef(1, 3.5, 1); glutSolidCube(2); glPopMatrix(); glPushMatrix();/*2nd street light*/
glLoadIdentity();
glColor3f(0.2, 0.2, 0.2); glBegin(GL_POLYGON); glVertex3f(16.1, -10.0, 2.0);
glVertex3f(16.9, -10.0, 3.0);
glVertex3f(16.9, 14.0, 4.0);
glVertex3f(16.1, 14.0, 2.0); glEnd();glPopMatrix(); glPushMatrix();
glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON); glVertex3f(14.5, 12.0, 2.0);
glVertex3f(18.5, 13.0, 3.0);
glVertex3f(18.5, 12.0, 4.0);
glVertex3f(14.5, 13.0, 2.0); glEnd(); glPopMatrix(); glPushMatrix(); glColor3f(b, b, b);
glTranslatef(13.5, 10.5, 1.0);
glRotatef(260, 0, 0, 1);
glScalef(1, 3.5, 1); glutSolidCube(1.5); glPopMatrix();
}

void background()
{
glColor3f(0.0, 0.1, 0.0);
glBegin(GL_POLYGON);//green ground glVertex2i(-250.0, -250.0);

Department of CSE, CEC 2021-2022 Page 26


Village wind mill Using OpenGL

glVertex2i(250.0, -250.0);
glVertex2i(250.0, 0.0);
glVertex2i(-250.0, 0.0);
glEnd();
glColor3f(0.1, 0.1, 0.1);
glBegin(GL_POLYGON);//mid night blue sky glVertex2i(-250.0, 0.0);
glVertex2i(-250.0, 250.0);
glVertex2i(250.0, 250.0);
glVertex2i(250.0, 0.0);
glEnd();
}
void fan1()
{
glPushMatrix(); glLoadIdentity(); glColor3f(1, 1, 1);
glTranslatef(-8.0, 20.0, 2.0);/*rotation about fixed point*/ glRotatef(spin, 0.0,0.0, 1.0);
glTranslatef(8.0, -20.0, -2.0); glBegin(GL_TRIANGLES);/*1st fan*/ glVertex3f(-8.0,
20.0, 2.0);
glVertex3f(-12.0, 16.0, 3.0);
glVertex3f(-12.0, 18.0, 4.0);
glVertex3f(-8.0, 20.0, 2.0);
glVertex3f(-4.0, 24.0, 3.0);
glVertex3f(-4.0, 22.0, 4.0); glEnd();glPopMatrix();
}

void fan2()
{
glPushMatrix(); glLoadIdentity();
glTranslatef(-20.0, 20.0, 2.0);/*rotation about fixed point*/ glRotatef(spin, 0.0,0.0, 1.0);
glTranslatef(20.0, -20.0, -2.0);
glColor3f(1, 1, 1); glBegin(GL_TRIANGLES);/*2nd fan*/ glVertex3f(-20.0, 20.0, 2.0);
glVertex3f(-25.0, 17.0, 3.0);
glVertex3f(-25.0, 19.0, 4.0);

Department of CSE, CEC 2021-2022 Page 27


Village wind mill Using OpenGL

glVertex3f(-20.0, 20.0, 2.0);


glVertex3f(-15.0, 23.0, 3.0);
glVertex3f(-15.0, 21.0, 4.0);
glEnd(); glPopMatrix();
}
void fan3()
{
glPushMatrix(); glLoadIdentity();
glTranslatef(-32.0, 20.0, 2.0);/*rotation about fixed point*/ glRotatef(spin, 0.0,0.0, 1.0);
glTranslatef(32.0, -20.0, -2.0);
glColor3f(1, 1, 1); glBegin(GL_TRIANGLES);/*2nd fan*/ glVertex3f(-32.0, 20.0, 2.0);
glVertex3f(-36.0, 16.0, 3.0);
glVertex3f(-36.0, 18.0, 4.0);
glVertex3f(-32.0, 20.0, 2.0);
glVertex3f(-28.0, 24.0, 3.0);
glVertex3f(-28.0, 22.0, 4.0);
glEnd(); glPopMatrix();
}
void fan4()
{
glPushMatrix(); glLoadIdentity(); glColor3f(1, 1, 1);
glTranslatef(28.0, 25.0, 2.0);/*rotation about fixed point*/ glRotatef(spin, 0.0,0.0, 1.0);
glTranslatef(-28.0, -25.0, -2.0); glBegin(GL_TRIANGLES);/*4th fan*/ glVertex3f(28.0,
25.0, 2.0);
glVertex3f(24.0, 21.0, 3.0);
glVertex3f(24.0, 23.0, 4.0);
glVertex3f(28.0, 25.0, 2.0);
glVertex3f(32.0, 29.0, 3.0);
glVertex3f(32.0, 27.0, 4.0); glEnd();glPopMatrix();
}

Department of CSE, CEC 2021-2022 Page 28


Village wind mill Using OpenGL

void wires()
{
glColor3f(.7, .5, .7); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x00FF);
glBegin(GL_LINES); glVertex2f(-8.0, 7.0);
glVertex2f(-32.0, 7.0);
glVertex2f(-8.0, 10.0);
glVertex2f(1.5, 10.0);
glVertex2f(26.5, 7.0);
glVertex2f(14.5, 12.0);
glVertex2f(31.0, 7.0);
glVertex2f(18.0, 12.0); glEnd(); glDisable(GL_LINE_STIPPLE);
}
void powerstation()
{
GLint ax = 1.5, ay = 8; glColor3f(1.0, 0.25, 0.1);
glBegin(GL_POLYGON);//from tip(anti clkwise) glVertex2i(ax, ay);//a
glVertex2i(ax - 2, ay - 2);//b glVertex2i(ax - 2, ay - 8);//c glVertex2i(ax + 2, ay
- 8);//d glVertex2i(ax + 2, ay - 2);//e glEnd();
glColor3f(0.7, 0.5, 0.3); glBegin(GL_POLYGON);//roof (from a) glVertex2i(ax, ay + 3);//a
glVertex2i(ax - 3, ay - 3);//b glVertex2i(ax + 3, ay - 3);//e
glEnd(); glColor3f(v, v, w);
glBegin(GL_POLYGON);/* door */ glVertex2i(ax - 1, ay - 5.0);//top left glVertex2i(ax
- 1.0, ay - 8.0);//bottom left glVertex2i(ax + 1.0, ay - 8.0);// bottom right glVertex2i(ax + 1.0,
ay - 5.0);//top right
glEnd();
}
void road()
{
glColor3f(0.0, 0.0, 0.0); glBegin(GL_POLYGON); glVertex2f(-1, 0);
glVertex2f(4, 0);
glVertex2f(43, -39);
glVertex2f(37, -40); glEnd();

Department of CSE, CEC 2021-2022 Page 29


Village wind mill Using OpenGL

}
void clouds()
{
glPushMatrix(); glColor3f(0.4, 0.7, 0.9);
glLoadIdentity(); /* clear the matrix */
/* viewing transformation */ glTranslatef(a + 1, 40.0, -9.0);
glScalef(2.0, 1.0, 1.0); /* modeling transformation */ glutSolidSphere(2.0, 50, 56);
glLoadIdentity(); glTranslatef(a - 2.0, 40.0, -9.0);
glScalef(2.0, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 7.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56);
glLoadIdentity(); glTranslatef(a - 7.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 18.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 25.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 36.0, 40.0, -9.0);
glScalef(3.0, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 50.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glLoadIdentity();
glTranslatef(a + 56.0, 40.0, -9.0);
glScalef(2, 1.0, 1.0);
glutSolidSphere(2.0, 50, 56); glPopMatrix();
}

Department of CSE, CEC 2021-2022 Page 30


Village wind mill Using OpenGL

void roof(GLint rux, GLint ruy, GLint rdx, GLint rdy)


{
glPushMatrix();
glColor3f(1, 0.25, 0.1); glBegin(GL_LINE_STRIP); glVertex2i(rux, ruy);//roof up
glVertex2i(rdx, rdy);//roof down glEnd();
glPopMatrix();
}
void hut(GLint rux, GLint ruy, GLint rdx, GLint rdy)
{
GLint blx = rdx, bly = rdy - 9, brx = rdx + 10, bry = rdy - 9, kx = rdx - 8, ky =rdy + 1;
GLfloat i;
for (i = 0; i < 440; i = i + 1)
roof(rux + i / 40, ruy, rdx + i / 40, rdy);/* draw straws */ glColor3f(0.3, 0.25,0.1);
glBegin(GL_POLYGON);/* front wall */ glVertex2i(rdx, rdy);//roof left glVertex2i(rdx
+ 10, rdy);//roof right glVertex2i(brx, bry);//base right glVertex2i(blx,bly);//base left
glEnd();
glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON);/* side wall */ glVertex2i(rux, ruy);//roof up glVertex2i(kx,
ky);//bacK glVertex2i(kx, ky - 6);//bacK base glVertex2i(blx, bly); glVertex2i(rdx, rdy);
glEnd();
glColor3f(v, v, w);
glBegin(GL_POLYGON);/* window */ glVertex2i(kx + 2, ky - 2.5);//top left glVertex2i(kx
+ 2, ky - 5.5);//bottom left glVertex2i(blx - 3, bly + 3.5);//bottomright glVertex2i(blx - 3, bly
+ 6.9);//top right glEnd();
glColor3f(v, v, w); glBegin(GL_POLYGON);/* door */ glVertex2i(blx + 3.5, bly + 5);//top
left glVertex2i(blx + 3.5, bly);//bottom left glVertex2i(brx - 3.5, bry);//bottom right
glVertex2i(brx - 3.5, bry + 5);//top right glEnd();
}
void fanpole1()
{
glColor3f(1.0, 1.0, 1.0); glBegin(GL_TRIANGLE_STRIP);
glVertex2f(-8.1, 20.0);

Department of CSE, CEC 2021-2022 Page 31


Village wind mill Using OpenGL

glVertex2f(-7.9, 20.0);
glVertex2f(-8.5, 0.0);
glVertex2f(-7.5, 0.0); glEnd();
}
void fanpole2()
{
glColor3f(1.0, 1.0, 1.0); glBegin(GL_TRIANGLE_STRIP);
glVertex2f(-20.1, 20.0);
glVertex2f(-19.9, 20.0);
glVertex2f(-20.5, 0.0);
glVertex2f(-19.5, 0.0); glEnd();
}
void fanpole3()
{
glColor3f(1.0, 1.0, 1.0); glBegin(GL_TRIANGLE_STRIP);
glVertex2f(-32.1, 20.0);
glVertex2f(-31.9, 20.0);
glVertex2f(-32.5, 0.0);
glVertex2f(-31.5, 0.0); glEnd();
}
void fanhouse()
{
GLint ax = 28, ay = 30; glColor3f(0.7, 0.5, 0.3);
glBegin(GL_POLYGON);//from tip(anti clkwise) glVertex2i(ax, ay);//a
glVertex2i(ax - 3, ay - 2);//b glVertex2i(ax - 3, ay - 9);//c glVertex2i(ax + 3, ay
- 9);//d glVertex2i(ax + 3, ay - 2);//e glEnd();
glColor3f(0.0, 0.3, 0.3); glBegin(GL_POLYGON);//roof (from a) glVertex2i(ax, ay +3);//a
glVertex2i(ax - 4, ay - 3);//b glVertex2i(ax + 4, ay - 3);//e glEnd();
glColor3f(0.3, 0.15, 0.1); glBegin(GL_TRIANGLE_STRIP);
glVertex2f(30.1, 21.0);
glVertex2f(29.9, 21.0);
glVertex2f(30.5, 0.0);

Department of CSE, CEC 2021-2022 Page 32


Village wind mill Using OpenGL

glVertex2f(29.5, 0.0);
glEnd();
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(26.1, 21.0);
glVertex2f(25.9, 21.0);
glVertex2f(26.5, 0.0);
glVertex2f(25.5, 0.0);
glEnd();
glColor3f(0.0, 0.3, 0.3);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(30.0, 22.0);
glVertex2f(29.5, 22.0);
glVertex2f(29.0, 19.0);
glVertex2f(28.5, 19.0);
glEnd();
glBegin(GL_TRIANGLE_STRIP);glVertex2f(26.5, 22.0);
glVertex2f(26.0, 22.0);
glVertex2f(25.5, 19.0);
glVertex2f(25.0, 19.0);
glEnd();
glColor3f(0, 0, d); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x00FF);
glBegin(GL_LINES); glVertex2f(25.5, 19.0);
glVertex2f(25.5, -1.0);
glVertex2f(25.0, 19.0);
glVertex2f(25.0, -1.0);
glVertex2f(25.25, 19.0);
glVertex2f(25.25, -1.0); glEnd();
glColor3f(0, 0, e); glBegin(GL_LINES); glVertex2f(28.5, 19.0);
glVertex2f(28.5, -1.0);
glVertex2f(29.0, 19.0);
glVertex2f(29.0, -1.0);
glVertex2f(28.75, 19.0);

Department of CSE, CEC 2021-2022 Page 33


Village wind mill Using OpenGL

glVertex2f(28.75, -1.0);
glEnd(); glDisable(GL_LINE_STIPPLE);
glColor3f(0, 0, 1);
glBegin(GL_POLYGON); glVertex2f(25.0, -1.0);
glVertex2f(29.5, -1.0);
glVertex2f(29.5, -2.0);
glVertex2f(25.0, -2.0); glEnd();
glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON); glVertex2f(24.5, -1.0);
glVertex2f(25.0, -1.0);
glVertex2f(25.0, -2.0);
glVertex2f(24.5, -2.0); glEnd();
glBegin(GL_POLYGON); glVertex2f(24.5, -2.0);
glVertex2f(30.0, -2.0);
glVertex2f(30.0, -3.0);
glVertex2f(24.5, -3.0); glEnd();
glBegin(GL_POLYGON); glVertex2f(29.5, -1.0);
glVertex2f(30.0, -1.0);
glVertex2f(30.0, -2.0);
glVertex2f(29.5, -2.0); glEnd();
}
void woman()
{
glClearColor(0.48, 0.5, 0.5, 0.0);
glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON);//veil glVertex2f(21.0 + x, -17.0 + y);
glVertex2f(22.0 + x, -17.0 + y); glVertex2f(22.5 + x, -20.0 + y); glVertex2f(20.5 + x, -20.0 +
y); glEnd();
glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON);//face glVertex2f(21.0 + x, -18.0 + y); glVertex2f(21.0 + x, - 17.0
+ y); glVertex2f(22.0 + x, -17.0 + y); glVertex2f(22.0 + x, -18.0 + y); glEnd();
glBegin(GL_POLYGON);//neck glVertex2f(21.5 + x, -17.0 + y); glVertex2f(21.6
+ x, -17.0 + y); glVertex2f(21.6 + x, -18.5 + y); glVertex2f(21.5 + x, -18.5 + y);glEnd();

Department of CSE, CEC 2021-2022 Page 34


Village wind mill Using OpenGL

glColor3f(0.97, 0.45, 0.84);


glBegin(GL_POLYGON);//body glVertex2f(21.0 + x, -18.5 + y); glVertex2f(22.1 + x, - 18.5
+ y); glVertex2f(22.1 + x, -20.0 + y); glVertex2f(21.0 + x, -20.0 + y); glEnd();
glColor3f(0.59, 0.137, 0.985);
glBegin(GL_POLYGON);//skirt glVertex2f(21.0 + x, -20.0 + y); glVertex2f(22.1 + x, -20.0 +
y); glVertex2f(22.7 + x, -21.0 + y); glVertex2f(20.5 + x, -21.0 + y); glEnd();
glColor3f(0.0, 0.0, 0.0); glPointSize(1.4);
glBegin(GL_POINTS);//eyes glVertex2f(21.3 + x, -17.30 + y); glVertex2f(21.8 + x, -
17.30 + y); glEnd(); glBegin(GL_LINES);//nose glVertex2f(21.6 + x, -17.6 + y);
glVertex2f(21.6 + x, -17.3 + y); glEnd(); glBegin(GL_LINES);//smile glVertex2f(21.5
+ x, -17.8 + y); glVertex2f(21.8 + x, -17.8 + y); glEnd();
glColor3f(0.3, 0.15, 0.1);
glBegin(GL_POLYGON);//hand 1 glVertex2f(21.0 + x, -18.5 + y); glVertex2f(20.5 + x, -
20.0 + y); glVertex2f(21.0 + x, -19.0 + y); glEnd(); glBegin(GL_POLYGON);//hand 2
glVertex2f(22.1 + x, -18.5 + y); glVertex2f(22.7 + x, -19.0 + y); glVertex2f(22.1 + x, -19.0 +
y); glEnd();
glColor3f(1, 1, 0.4); glBegin(GL_POLYGON);//torch glVertex2f(22.7 + x, -19.0 + y);
glVertex2f(22.4 + x, -19.0 + y); glVertex2f(22.5 + x, -19.7 + y); glVertex2f(23.0 + x, -19.7 +
y);
glEnd(); glColor3f(c, c, c);
glBegin(GL_POLYGON);//torch light glVertex2f(22.7 + x, -19.2 + y); glVertex2f(22.4 + x, -
19.2 + y); glVertex2f(22.5 + x, -19.7 + y); glVertex2f(23.0 + x, -19.7 + y); glEnd();
glColor3f(c, c, c); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x00FF);
glBegin(GL_LINES); glVertex2f(22.5 + x, -19.2 + y); glVertex2f(24.0 + x, -25.0 + y);
glVertex2f(22.6 + x, -19.2 + y); glVertex2f(25.5 + x, -25.0 + y); glVertex2f(22.7 + x, -19.2
+ y); glVertex2f(27.0 + x, -25.0 + y); glEnd();
}
void mykey(unsigned char key, int m, int n)
{
if (key == 'w') y += .1, x -= 0.1;
if (key == 's') y -= .1, x += 0.1;
glutPostRedisplay();
}

Department of CSE, CEC 2021-2022 Page 35


Village wind mill Using OpenGL

void display(void)
{
int b = 0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (z < 50)
{
for (z = 0; z <= 1500; z++)
{
}
}
else
{
front(); glutPostRedisplay(); glutSwapBuffers(); glFlush();
background(); fanhouse(); text();road();
hut(-29, -23, -24, -33);
hut(0, -11, 5, -21);
hut(-21, -1, -14, -11);
clouds(); powerstation(); wires(); streetlight(); woman(); fanpole1(); fanpole2(); fanpole3();
fan1();
fan2();
fan3();
fan4(); glutSwapBuffers(); glFlush();
}
}
void spinclockwise(void)
{
w = 0.3; u = 0; v = 1; b = 0.5; c = 1; d = 1; e = 0; a = a + 0.1;
if (a > 40)a -= 100.0;
spin = spin - 1.0;
if (spin < 0)
spin = spin + 360.0;

Department of CSE, CEC 2021-2022 Page 36


Village wind mill Using OpenGL

glutPostRedisplay();
}
void anticlockwise(void)
{
u = 0; w = .3; v = 1; b = 0.5; c = 1; d = 1, e = 0;
if (a == 40)
a = 40; a = a - 0.1;
if (a < -100)a += 100.0;
if (spin == 360.0)
spin = spin - 360; spin = spin + 1.0;
if (spin > 360.0)
spin = spin - 360.0; glutPostRedisplay();
}
void spinclockwise1(void)
{
u = 0; w = .4; v = 1; b = 1; c = 0.0; d = e = 1; a = a + 0.3;
if (a > 40)a -= 100.0;
spin = spin - 10.0; if (spin < 0)
spin = spin + 360.0; glutPostRedisplay();
}
void anticlockwise1(void)
{
u = 0; w = .4; v = 1; b = 1; c = 0.0; d = e = 1;
if (a == 40)
a = 40; a = a - 0.3;
if (a < -100)a += 100.0;
if (spin == 360.0)
spin = spin - 360; spin = spin + 10.0;
if (spin > 360.0)
spin = spin - 360.0; glutPostRedisplay();
}

Department of CSE, CEC 2021-2022 Page 37


Village wind mill Using OpenGL

void reshape(int w, int h)


{
glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-35.0, 35.0, -45.0, 45.0, -20.0, 20.0);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
}
void menu(int id)
{
switch (id)
{
case 1: u = v = w = b = 0.45; c = d = e = 1; glutIdleFunc(display);break;
case 2: glutIdleFunc(spinclockwise); break; case 3: glutIdleFunc(anticlockwise); break;
case 4: glutIdleFunc(spinclockwise1); break; case 5: glutIdleFunc(anticlockwise1); break;
case 6:exit(0);
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500,500);
glutInitWindowPosition(100, 100); glutCreateWindow("WIND ENERGY"); init();
glutDisplayFunc(display);
}]
}

Department of CSE, CEC 2021-2022 Page 38


Village wind mill Using OpenGL

CONCLUSION AND FUTURE SCOPE


Conclusion:
The project allows the user to rotate the wind turbines in the wind mill located at the
villages by selecting the given options in our project. Small wind mill project will enable the
wind industry, national laboratories, ana consultants to poor their knowledge and develop
cost- effective, high reliability small wind turbines in villages for domestic and international
wind energy markets. Four companies were selected through a competitive procurement to
develop advanced small wind turbines system for development in wide range of commercial
applications. At the end of this project, we will know the various rotations of the wind
turbines by selecting the option provided by the developer.

Future scope:
1. Proving rural people, a source of wind energy for the application of day-to-day life
activities
2. Electricity generated from wind power does not pollute air or water, so no smog or acid
rain.
3. It also does not emit toxic substances and contaminates that can be damaging to living
spaces and people.
4. Wind energy is critical to clean transition which promotes green environment and
ecofriendly.

Department of CSE, CEC 2021-2022 Page 39


Village wind mill Using OpenGL

REFERENCES

[1] Interactive Computer Graphics A Top-Down Approach with OpenGL - Edward Angel, 5th
[2] Edition, Addison-Wesley, 2008
[3] The Official Guide to Learning OpenGL, by Jackie Neider, Tom Davis, Mason Woo (THE
REDBOOK)
[4] 1. Jechoutek, Karl, Rural Energy and Development- An Action Plan, World Bank Renewable
Energy Roundtable, March 25, 1997.
[5] OpenGL Super Bible by Richard S. Wright, Jr. and Michael Sweet5.
http://www.cs.rutgers.edu/~decarlo/428/glman.html online man pages.
[6] OpenGL tutorials.
[7] And lastly GOOGLE.

Dept Of CSE 2021-22 Page 40

You might also like