0% found this document useful (0 votes)
24 views

cnwtf2

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
0% found this document useful (0 votes)
24 views

cnwtf2

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/ 14

Table of Contents

Table of Contents i

1 Introduction 1

2 Display List 2
2.1 Types of Display Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Advantages of Display Lists . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Limitations of Display Lists . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Modeling 5
3.1 Types of Models: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Modeling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Applications of Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4 Challenges in Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Event Driven Input 8


4.1 Event Types in Event-Driven Input: . . . . . . . . . . . . . . . . . . . . 8
4.2 Callback Function in Event Driven Input . . . . . . . . . . . . . . . . . 9
4.3 GLUT Functions for Event Handling: . . . . . . . . . . . . . . . . . . . 9

5 Menus 10
5.1 Types of Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2 Creating a Menu in OpenGL . . . . . . . . . . . . . . . . . . . . . . . . 11

6 Conclusion 12

i
Computer Graphics(BCS515A) 2024-25

Chapter 1
Introduction

The Computer Graphics is a field of computer science focused on creating, ma-


nipulating, and visualizing images, animations, and visual representations using com-
putational techniques. It is crucial in industries such as entertainment, education,
engineering, healthcare, and design, bridging the gap between creativity and tech-
nology. By turning data and ideas into visual content, it helps in communication,
analysis, and simulation.
In computer graphics, several key techniques are used to improve efficiency and
realism. Display Lists are precompiled sequences of graphics commands, which opti-
mize rendering by reusing objects or scenes. This reduces rendering time, particularly
in complex applications where the same graphical elements are used repeatedly, such
as in simulations or video games.
Modeling involves creating mathematical representations of objects or environ-
ments in 2D or 3D space. This is essential for designing and visualizing everything
from simple shapes to complex models in applications like CAD, architectural visu-
alization, and animation. It allows designers to accurately represent and manipulate
real-world or imagined structures.
Event-Driven Input is a programming method where the program’s flow is con-
trolled by user actions, such as mouse clicks or keyboard presses. This makes graphics
applications interactive, enabling real-time user interaction, which is fundamental in
video games, virtual reality, and simulations.
Menus are graphical interface elements that help users interact with applications.
By providing easy navigation through options like pull-down menus, context menus,
or toolbars, they make complex graphics systems more intuitive and user-friendly.
Advances in hardware and software, particularly the power of graphics processing
units (GPUs), have greatly enhanced the efficiency and quality of computer graphics.
This field continues to transform industries and create immersive digital experiences,
from entertainment to scientific research.

Dept Of CSE, AIET 1


Computer Graphics(BCS515A) 2024-25

Chapter 2
Display List

In computer graphics, Display Lists are an essential technique for optimizing the
rendering process by precompiling sequences of graphics commands. They allow for
the efficient reuse of graphical objects or scenes without having to reprocess the data
multiple times. Display lists are primarily used in rendering pipelines where complex
or repetitive objects need to be rendered several times, thus saving computational
resources and improving overall performance.
Example : In OpenGL, a display list might store commands to draw a 3D cube
model that is used repeatedly in a scene.

GLuint cubeList = glGenLists(1);


glNewList(cubeList, GL_COMPILE);
glBegin(GL_QUADS);
// Front-face
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);

Figure 2.1: Display Processor Architecture

Dept Of CSE, AIET 2


Computer Graphics(BCS515A) 2024-25
2.1 Types of Display Lists
Display lists can be categorized based on how they are used in rendering:

Simple Display Lists: These are basic display lists that contain simple, static
drawing commands. For example, a basic scene with unchanging objects such as ge-
ometric shapes (e.g., a cube or sphere) can be rendered using a simple display list.

Hierarchical Display Lists: These lists involve the use of multiple display lists
that are nested or linked together. In complex scenes, you might have a main display
list that calls other display lists for individual objects or components within the scene,
creating a more efficient structure for rendering complex environments.

Dynamic Display Lists: These lists are meant for cases where objects need to
be rendered frequently but still benefit from the performance optimization of display
lists. In such cases, the display list is recreated dynamically whenever the object
changes.

2.2 Advantages of Display Lists


Using display lists offers several key benefits, particularly when dealing with static
content:

Performance Improvement: Since drawing commands are precompiled and


stored, display lists reduce the computational overhead during rendering. This speeds
up the rendering process, especially when rendering static scenes.

Reduced CPU Load: By offloading the drawing commands to the GPU and
minimizing the involvement of the CPU, display lists enable smoother and faster ren-
dering. The GPU can process the stored commands directly, reducing the time spent
on CPU-based computations.

Memory Efficiency: Display lists help save memory by reusing the precompiled
drawing commands. Once created, the display list can be invoked multiple times
without recalculating or re-executing the operations, reducing the need for repetitive
memory usage.

Dept Of CSE, AIET 3


Computer Graphics(BCS515A) 2024-25
2.3 Limitations of Display Lists
Despite their advantages, display lists come with some limitations:

Static Content: Display lists are best suited for static or rarely changing content.
If objects within the scene change dynamically, the display list must be recreated,
which can result in performance degradation.
Limited Flexibility: More advanced rendering techniques, such as shaders or
real-time effects, may not integrate seamlessly with display lists. This limits their use
in more complex graphics pipelines that require dynamic computation or real-time
adjustments.
Memory Consumption: Although display lists optimize performance by stor-
ing precompiled commands in memory, they can consume significant GPU memory,
especially in systems with limited resources. Large and complex scenes may push the
limits of available GPU memory.

2.4 Application
Display lists are particularly useful in scenarios where repeated rendering of objects
is required. They efficiently render elements that are reused multiple times within a
scene, such as trees, buildings, or vehicles, by storing precompiled drawing commands.
They are also effective for rendering static geometry, such as terrain or background
objects, that do not require dynamic updates. By minimizing command overhead,
display lists help optimize performance, especially in scenes with complex geome-
try. In hierarchical models, such as scene graphs, display lists can represent reusable
subcomponents, like a wheel in a car model, allowing for more efficient rendering. Ad-
ditionally, display lists simplify animation by storing precomputed transformations or
object states, reducing the computational burden during frame rendering.

This approach allows for better performance, particularly in static or repetitive


scenes, while maintaining flexibility and efficiency in rendering complex models.

Dept Of CSE, AIET 4


Computer Graphics(BCS515A) 2024-25

Chapter 3
Modeling

The process of defining the shape, size, and structure of objects in 2D or 3D space
is known as modeling. It involves creating representations of objects or environments
using various techniques and methods, depending on the complexity and requirements
of the scene.

3.1 Types of Models:


Polygonal Models: These models are constructed using vertices, edges, and faces to
define the shape of the object. They are commonly used for creating rigid, geometric
shapes, such as cubes, buildings, and machinery.

Spline-Based Models: These models use mathematical curves to define smooth


surfaces, making them ideal for creating organic shapes like characters, vehicles, or
any object requiring curved forms.

Procedural Models: Procedural models are generated using algorithms or rules,


often for the efficient creation of landscapes, terrains, or complex patterns, such as
forests or city layouts.

An example of a polygonal model is a simple 3D cube, whereas a spline-based


model might be a curved object like a sphere.

3.2 Modeling Techniques


Extrusion: This technique involves extending a 2D shape along a path to create a
3D object. It is commonly used to give depth to a shape and transform it into a
three-dimensional form. For example, starting with a 2D rectangle and extruding it
upward can create a 3D wall or a pipe.

Dept Of CSE, AIET 5


Computer Graphics(BCS515A) 2024-25
Subdivision: Subdivision is the process of refining an object by dividing its faces
into smaller polygons, which helps to smooth out the shape. This technique is often
used to increase the level of detail in a model. For example, applying a subdivision
modifier to a cube can create a smooth, sphere-like object by progressively refining
its geometry.

Boolean Operations: Boolean operations are used to combine, subtract, or


intersect shapes to form more complex structures. These operations allow for the
creation of intricate designs by modifying basic shapes. For instance, using a cube
and a cylinder, one could subtract the cylinder from the cube (difference) to carve a
hole or merge them together (union) into a single object.

These techniques are fundamental in 3D modeling, providing various ways to cre-


ate and modify objects efficiently.

3.3 Applications of Modeling


Modeling plays a key role in various fields and industries, and its application depends
on the complexity and type of objects to be created:

Video Games: 3D modeling is essential for creating characters, environments,


and interactive elements in video games. Game designers rely on detailed models to
bring virtual worlds to life, ensuring realistic and engaging experiences for players.

Film and Animation: In the film industry, 3D modeling is used for creating
digital effects, characters, and environments. High-quality models allow filmmakers
to craft stunning visual effects that are integral to modern blockbuster films.

Virtual Reality (VR) and Augmented Reality (AR): In VR and AR, model-
ing techniques are used to create immersive experiences by designing 3D environments
and objects that users can interact with in real-time.

Dept Of CSE, AIET 6


Computer Graphics(BCS515A) 2024-25
3.4 Challenges in Modeling
Modeling, especially in 3D, presents several challenges that can affect both the quality
and efficiency of the design process:

Complexity of Realism: Creating highly detailed and realistic models, espe-


cially organic shapes such as human faces or natural landscapes, requires a significant
amount of computational power and time.

Optimization: Efficiently modeling objects for real-time applications (e.g., games


or VR) often requires striking a balance between detail and performance. Too many
polygons can reduce the frame rate or increase load times.

Textures and Materials: Adding textures and materials to a model is a critical


step in making objects look realistic. However, finding the right textures and applying
them seamlessly can be a challenging and time-consuming process.

Dept Of CSE, AIET 7


Computer Graphics(BCS515A) 2024-25

Chapter 4
Event Driven Input

Event-Driven Input: This programming paradigm determines the flow of the pro-
gram based on user actions or external events, rather than following a pre-defined
sequence. It enables systems to be more interactive and responsive to real-time in-
puts.

4.1 Event Types in Event-Driven Input:


Mouse Events: Mouse events are triggered by user interactions with the mouse. A
click, for example, selects or activates an item, such as clicking a button. Dragging
the mouse allows the user to move an object or selection by holding and moving the
mouse across the screen.

Keyboard Events: These events detect when a key is pressed on the keyboard.
For instance, typing a letter triggers the corresponding action, while releasing a key
after pressing it can trigger a specific action as well, such as submitting a form after
pressing the ”Enter” key.

Event-driven input plays a key role in creating interactive systems, where the flow
of the program responds dynamically to the user’s actions, such as mouse clicks, key
presses, or other external events. This approach makes applications more intuitive
and responsive to user input.

Dept Of CSE, AIET 8


Computer Graphics(BCS515A) 2024-25

4.2 Callback Function in Event Driven Input


Callback Function: A callback function is a specialized function used to define how
a program responds to specific input events, such as mouse clicks, key presses, or
window resizing.

4.3 GLUT Functions for Event Handling:


glutMouseFunc(callback): This function is used to detect and handle mouse events,
such as button presses or releases, allowing the program to react to mouse interactions.

glutKeyboardFunc(callback): This function detects and handles keyboard


events, like key presses, enabling the program to respond to keyboard input.

glutMotionFunc(callback): This function captures mouse movement while a


button is pressed, allowing for interactive mouse-driven behavior.

Example:
void handleKey(unsigned char key, int x, int y) {
if (key == ’q’) exit(0);
}

glutKeyboardFunc(handleKey); In this example, the handleKey function listens for


the ’q’ key press and exits the program when pressed, demonstrating how a callback
function can define specific behavior in response to user input.
Dept Of CSE, AIET 9
Computer Graphics(BCS515A) 2024-25

Chapter 5
Menus

Menus are graphical user interface (GUI) components that allow users to interact
with and navigate a program or application by selecting options from a structured
list. They provide an organized way to access various functions or settings within a
software application, offering a more intuitive user experience. Menus can be static
or dynamic, offering a range of actions such as opening files, changing settings, or
executing specific commands.

5.1 Types of Menus


Pull-Down Menus: These menus typically appear at the top of applications, such
as ”File,” ”Edit,” and ”View.” When clicked or hovered over, they expand to reveal
additional options. Pull-down menus are commonly used to organize commands that
users might need in a structured manner, ensuring that the interface remains clean
and intuitive.
Context Menus: These menus are accessed by right-clicking on an element, such
as a file or an object in a graphical application. Context menus provide options that
are directly relevant to the selected item or action. For example, right-clicking on a file
might display options like ”Copy,” ”Paste,” or ”Rename.” This type of menu enhances
the user’s experience by offering relevant choices based on the current context.
Icon Menus: Often found in toolbars, icon menus feature buttons represented as
icons for quick access to commonly used functions. These menus are designed to be
compact and efficient, enabling users to quickly execute tasks such as ”Save,” ”Zoom,”
or ”Undo” without navigating through more complex menu structures.
GLUT (OpenGL Utility Toolkit) simplifies the creation of interactive graphical ap-
plications by providing support for both pop-up menus and hierarchical menus.
This makes it easier for developers to create menus that can be triggered by user inter-
actions like mouse clicks. Pop-up menus are often used for quick access to functions,
while hierarchical menus allow for more complex, multi-level structures.
Overall, menus enhance user interaction by associating actions with clear and
accessible menu entries. They help streamline the process of navigating software ap-
plications, making the interface more user-friendly and efficient.

Dept Of CSE, AIET 10


Computer Graphics(BCS515A) 2024-25

5.2 Creating a Menu in OpenGL


glutCreateMenu(menuCallback);
Attaching a menu in OpenGL:
glutAttachMenu(GLUT_RIGHT_BUTTON);

Example : Pop-Up Menu


glutCreateMenu(demo_menu);
glutAddMenuEntry("Quit", 1);
glutAddMenuEntry("Increase Size", 2);
glutAddMenuEntry("Decrease Size", 3);
glutAttachMenu(GLUT_RIGHT_BUTTON);

Figure 5.1: Hierarchical Menus

Dept Of CSE, AIET 11


Computer Graphics(BCS515A) 2024-25

Chapter 6
Conclusion

In conclusion, Display Lists, Modeling, Event-Driven Input, and Menus are crucial
components in the development of interactive graphical applications. Display Lists
optimize performance by allowing precompiled rendering tasks to be reused, enhanc-
ing efficiency in rendering. Modeling enables the creation of intricate objects and
environments in 3D spaces, providing a foundation for realistic visual representations.
Event-Driven Input ensures real-time responsiveness, enabling dynamic user interac-
tion with the application. Menus offer intuitive navigation, empowering users with
simple and effective control options.

When combined, these techniques form a powerful framework that drives the devel-
opment of responsive, interactive, and visually engaging user experiences. Together,
they allow developers to craft sophisticated graphical applications, enabling users to
manipulate objects, navigate environments, and perform tasks seamlessly in a dy-
namic digital world.

Dept Of CSE, AIET 12


Computer Graphics(BCS515A) 2024-25

References
1. Edward Angel: Interactive Computer Graphics A Top-Down Approach with
OpenGL, 5th Edition, Pearson Education, 2008.

2. Donald Hearn & Pauline Baker: Computer Graphics with OpenGL Version, 4th
Edition, Pearson Education, 2011.

3. John D. Foley, Andries van Dam, Steven K. Feiner, John F. Hughes, ”Computer
Graphics: Principles and Practice,” 3rd Edition, Addison-Wesley, 2013.

4. Donald Hearn, M. Pauline Baker, ”Computer Graphics with OpenGL,” 4th


Edition, Pearson, 2010.

5. James D. Foley, Andries van Dam, ”Fundamentals of Interactive Computer


Graphics,” 2nd Edition, Addison-Wesley, 1982.

6. Alan Watt, ”3D Computer Graphics,” 3rd Edition, Addison-Wesley, 2000.

Dept Of CSE, AIET 13

You might also like