0% found this document useful (0 votes)
22 views32 pages

1.1 Computer Graphics Computer Graphics Deals With Generating Images and Art With The Aid of Computers

Computer graphics report

Uploaded by

manjunathnlm13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views32 pages

1.1 Computer Graphics Computer Graphics Deals With Generating Images and Art With The Aid of Computers

Computer graphics report

Uploaded by

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

Virtual Art Gallery

Chapter 1

INTRODUCTION
1.1 Computer Graphics

Computer graphics deals with generating images and art with the aid of computers.
Computer graphics is a core technology in digital photography, film, video games, digital art,
cell phone and computer displays, and many specialized applications. A great deal of specialized
hardware and software has been developed, with the displays of most devices being driven
by computer graphics hardware. It is a vast and recently developed area of computer science.
The phrase was coined in 1960 by computer graphics researchers Verne Hudson and William
Fetter of Boeing. It is often abbreviated as CG, or typically in the context of film as computer
generated imagery (CGI). The non-artistic aspects of computer graphics are the subject
of computer science research
Some topics in computer graphics include user interface design, sprite
graphics, rendering, ray tracing, geometry processing, computer animation, vector graphics, 3D
modeling, shaders, GPU design, implicit surfaces, visualization, scientific computing, image
processing, computational photography, scientific visualization, computational
geometry and computer vision, among others. The overall methodology depends heavily on the
underlying sciences of geometry, optics, physics, and perception.

Computer graphics is responsible for displaying art and image data effectively and
meaningfully to the consumer. It is also used for processing image data received from the
physical world, such as photo and video content

Computer animation is the art of creating moving images via the use of computers. It is a
subfield of computer graphics and animation. Increasingly it is created by means of 3D
computer graphics, though 2D computer graphics are still widely used for stylistic, low
bandwidth, and faster real-time rendering needs. Sometimes the target of the animation is the
computer itself, but sometimes the target is another medium, such as film. It is also referred to
as CGI (Computer-generated imagery or computer-generated imaging), especially when used in
films.

Dept of CSE , K K GEC K R Pet. Page 1


Virtual Art Gallery

Virtual entities may contain and be controlled by assorted attributes, such as transform
values (location, orientation, and scale) stored in an object's transformation matrix. Animation is
the change of an attribute over time. Multiple methods of achieving animation exist; the
rudimentary form is based on the creation and editing of keyframes, each storing a value at a
given time, per attribute to be animated.

The 2D/3D graphics software will change with each keyframe, creating an editable curve of a
value mapped over time, in which results in animation. Other methods of animation
include procedural and expression-based techniques: the former consolidates related elements of
animated entities into sets of attributes, useful for creating particle effects and crowd
simulations; the latter allows an evaluated result returned from a user-defined logical expression,
coupled with mathematics, to automate animation in a predictable way (convenient for
controlling bone behavior beyond what a hierarchy offers in skeletal system set up).

1.2 OpenGL

Most of our application will be designed to access OpenGL directly through functions in
three libraries. Functions in the main GL (or OpenGL in windows) library have names that
begin with the letters gl and are stored in a library usually referred to as GL (or OpenGL in
windows).
The second is the OpenGL Utility Library (GLU). This library uses only GL functions
but contains code for creating common objects and simplifying viewing. All functions in GLU
can be created from the core GL library but application programmers prefer not to write the
code repeatedly. The GLU library is available in all OpenGL implementations; functions in the
GLU library begin with letters glu.
To interface with the window system and to get input from external devices into our
programs, we need at least one more system-specific library that provides the “glue” between
the window system and OpenGL. For the X window system, this library is functionality that
should be expected in any modern windowing system. Fig 1. 2. shows the organization of the
libraries for an X Window System environment. For this window system, GLUT will use GLX
and the X libraries. The application program, however, can use only GLUT functions and thus
can be recompiled with the GLUT library for other window systems.

Dept of CSE , K K GEC K R Pet. Page 2


Virtual Art Gallery

GLU

GL Frame
OpenGL Buffer
application Xlib, Xtk
Program
GLUT

GLX

Fig 1.2 Library organization

1.3 Problem Statement

The goal of this project is to design and implement an interactive virtual art gallery using
OpenGL and C++. The virtual gallery should provide a realistic 3D environment where users can
navigate through different rooms and view digital representations of artworks. This project aims
to enhance the accessibility and visibility of artworks by creating an immersive and interactive
digital platform, allowing users to explore and appreciate art from anywhere at any time. Key
challenges include creating a realistic gallery layout, implementing smooth user navigation,
applying effective lighting techniques, and enabling interactive elements for detailed artwork
information

1.4Objective

Dept of CSE , K K GEC K R Pet. Page 3


Virtual Art Gallery

The objectives of this project are to create a realistic 3D virtual art gallery using OpenGL
and C++, where users can navigate through different rooms and view digital artworks. This
involves designing a visually appealing gallery layout, implementing smooth user navigation
with keyboard and mouse controls, and enhancing visual realism through effective lighting
techniques. The project aims to provide interactive elements, such as information panels, to
display detailed information about the artworks. Additionally, it focuses on optimizing
performance for a smooth user experience and developing a user-friendly interface to make
the virtual gallery accessible to a wide audience.

Dept of CSE , K K GEC K R Pet. Page 4


Virtual Art Gallery

Chapter 2
LITERATURE SURVEY
The origins of computer graphics can be traced back to the 1960s, with the development
of early computer systems capable of displaying simple images and shapes. The field gained
significant momentum in the 1970s and 1980s with the advent of raster graphics and the
development of graphical user interfaces (GUIs). The introduction of affordable and powerful
graphics hardware in the 1990s revolutionized the industry, enabling the creation of realistic 3D
graphics and paving the way for advancements in gaming, film, and virtual reality.

OpenGL, the industry-standard API for rendering 2D and 3D graphics, is crucial for the
development of interactive virtual environments. "OpenGL Programming Guide" by Dave
Shreiner et al., known as the "Red Book," serves as an indispensable resource for learning
OpenGL. It offers detailed explanations of OpenGL functions, techniques, and practical
examples, making it essential for developers aiming to create immersive virtual galleries.
Complementing this, the "OpenGL Superbible" by Graham Sellers et al. provides an extensive
introduction to OpenGL, covering both fundamental and advanced techniques for rendering and
shading, which are vital for optimizing performance in a virtual art gallery setting.

Creating an immersive virtual art gallery requires an understanding of virtual reality (VR)
and 3D user interfaces. "Virtual Reality Technology" by Grigore C. Burdea and Philippe Coiffet
discusses the hardware, software, and applications of VR, offering insights into the creation of
immersive virtual environments. This knowledge is critical for designing a virtual gallery that
provides a realistic and engaging user experience. Additionally, "3D User Interfaces: Theory and
Practice" by Doug A. Bowman et al. focuses on the design and implementation of 3D user
interfaces, covering interaction techniques and user experience considerations that are essential
for creating an intuitive navigation system within the virtual gallery.

Practical insights can be gleaned from case studies and specific implementations of
virtual environments. "Design and Implementation of a Virtual Museum" by T. Anja et al.
presents a case study on creating a virtual museum using OpenGL. It discusses design decisions,
technical challenges, and solutions, providing valuable lessons for similar projects like a virtual
art gallery. Similarly, "A Web-based Virtual Art Gallery" by D. P. Mendes et al. explores the
Dept of CSE , K K GEC K R Pet. Page 5
Virtual Art Gallery

development of a virtual art gallery accessible via the web, discussing user interface design,
artwork digitization, and user interaction, which are crucial considerations for the successful
implementation of a virtual gallery.

The concept of virtual art galleries has evolved significantly with advancements in
computer graphics and virtual reality technologies. Early implementations were basic and often
limited to simple 2D displays within 3D environments. However, with the advent of high-
performance graphics hardware and sophisticated software, modern virtual galleries offer highly
realistic and interactive experiences. These advancements include detailed 3D modeling of
gallery spaces, realistic lighting and shading techniques, and the integration of interactive
elements that enhance user engagement

Dept of CSE , K K GEC K R Pet. Page 6


Virtual Art Gallery

Chapter 3
SYSTEM REQUIRMENTS FOR ART GALLERY

When developing an art gallery system using OpenGL with C++, it is crucial to understand
the system requirements to ensure optimal performance and a seamless user experience. The
system requirements encompass both hardware and software components that collectively
support the complex computations and rendering tasks associated with graphical applications.

3.1Hardware Requirements

3.1.1 Processor (CPU):

a. Recommended: Quad-core processor or higher (e.g., Intel Core i5/i7 or


equivalent).

3.1.2 Memory (RAM):

b. Recommended: 8 GB or higher.

3.1.3 Graphics Card (GPU):

c. Recommended: Dedicated graphics card (e.g., NVIDIA GeForce GTX 1050 or


AMD Radeon RX 560) with support for OpenGL 4.5 or higher.

3.1.4 Storage:

d. Recommended: Solid State Drive (SSD) with at least 1 GB of available space for
faster load times and better performance.

3.1.5 Display:

e. Minimum: 1280x720 resolution.


f. Recommended: 1920x1080 resolution or higher for a better viewing experience.

Dept of CSE , K K GEC K R Pet. Page 7


Virtual Art Gallery

3.1.6 Input Devices:

g. Keyboard and mouse for navigation and interaction.


h. Optional: Game controller or VR headset for enhanced navigation and immersive
experience.

3.2 Software Requirements

3.2.1 Operating System:

a. Recommended: Windows 10.

3.2.2 Development Environment:

b. Compiler: GCC.
c. IDE: Codeblocks

3.2.3 Libraries and Tools:

d. OpenGL: Ensure OpenGL 3.3 or higher is supported. Use GLEW or GLAD for
managing OpenGL extensions.
e. Window Management: GLFW or GLUT for creating windows and handling
input.
f. Image Loading: SOIL, stb_image, or similar libraries for loading textures.
g. Math Library: GLM for mathematics operations related to graphics.
h. Shader Language: GLSL for writing vertex and fragment shaders.

3.3 Functional Requirements

3.3.1 3D Environment Creation:

a. Requirement: The system must render a 3D gallery environment with multiple


rooms and display areas.
b. Description: The gallery should have walls, floors, ceilings, and display stands
for artworks.

Dept of CSE , K K GEC K R Pet. Page 8


Virtual Art Gallery

3.3.2 Artwork Display:

c. Requirement: The system must load and display digital images of artworks
within the 3D gallery.
d. Description: Artworks should be mapped onto 3D frames or panels and placed at
various locations in the gallery.

3.3.3 User Navigation:

e. Requirement: The system must allow users to navigate through the gallery using
keyboard and mouse controls.
f. Description: Users should be able to move forward, backward, and rotate the
view to explore the gallery.

3.3.4 Lighting and Shading:

g. Requirement: The system must implement lighting and shading to enhance


visual realism.
h. Description: Apply techniques such as ambient, diffuse, and specular lighting to
create realistic effects.

3.3.5 User Interaction:

i. Requirement: The system must provide interactive elements to display detailed


information about each artwork.
j. Description: When a user approaches or selects an artwork, information panels or
tooltips should appear with details about the piece.

3.3.6 Optimized Rendering:

k. Requirement: The system must optimize rendering performance to handle a large


number of artworks.
l. Description: Use techniques such as level of detail (LOD), frustum culling, and
efficient texture management.

Dept of CSE , K K GEC K R Pet. Page 9


Virtual Art Gallery

3.4 Non-Functional Requirements

3.4.1 Performance:

a. Requirement: The system should provide smooth and responsive user controls
with minimal latency.
b. Description: Ensure frame rates of at least 30 FPS on the recommended hardware
configuration.

3.4.2 Scalability:

c. Requirement: The system should be scalable to accommodate additional


artworks and gallery rooms without significant performance degradation.
d. Description: Design the architecture to support future expansions and
optimizations.

3.4.3 Usability:

e. Requirement: The system should offer an intuitive and user-friendly interface.


f. Description: Provide clear navigation controls, easy-to-understand interaction
mechanisms, and helpful guidance for first-time users.

3.4.4 Portability:

g. Requirement: The system should be portable across different operating systems.


h. Description: Ensure compatibility with Windows, macOS, and Linux by using
cross-platform libraries and tools.

3.4.5 Maintainability:

i. Requirement: The system should be maintainable and extensible.


j. Description: Use modular code design, comprehensive documentation, and
version control to facilitate maintenance and future development.

Dept of CSE , K K GEC K R Pet. Page 10


Virtual Art Gallery

3.4.6 Security:

k. Requirement: The system should be secure against potential threats.


l. Description: Implement security measures to protect digital artwork files and user
data, especially if the gallery has an online component.

3.4.7 Accessibility:

m. Requirement: The system should be accessible to users with disabilities.


n. Description: Incorporate features such as adjustable font sizes, color contrast
options, and keyboard-only navigation support.

3.4.8 Compatibility:

o. Requirement: The system should be compatible with various display resolutions


and aspect ratios.
p. Description: Ensure the virtual gallery renders correctly on different screen sizes,
from standard monitors to high-resolution displays.

Dept of CSE , K K GEC K R Pet. Page 11


Virtual Art Gallery

Chapter 4

DESIGN OF ART GALLERY

Designing an art gallery using OpenGL and C++ involves setting up an OpenGL
environment with necessary libraries like GLUT or GLFW and configuring the viewport and
perspective. The gallery structure, including walls, floor, and ceiling, is created using quads with
appropriate textures to simulate materials such as wood or marble. Artwork is added by creating
frames and applying textures that represent paintings or photographs, which are then positioned
on the walls. Lighting and depth testing are set up to enhance the 3D effect, and camera controls
are implemented to allow navigation through the gallery using keyboard and mouse inputs.
Interaction features, such as displaying information about the artwork, can be added for a more
immersive experience.

4.1 System Design

4.1.1. Overall Architecture

a. User Interface: Develop a user-friendly interface for navigation and interaction, including
controls for movement and viewing angles.
b. Rendering Engine: Implement OpenGL for rendering 3D graphics, including loading textures,
applying lighting models, and displaying objects.
c. Artwork Management: Load digital artwork textures and associate them with 3D models or
frames within the gallery environment.
d. User Interaction: Enable user interaction with artworks to display details such as artist
information, title, and description.

4.1.2. Scene Setup

a. Gallery Layout: Design a 3D model of the gallery layout, including walls, floors, and rooms
using modeling software like Blender or Maya.
b. Object Placement: Position 3D models or frames within the gallery to represent artworks. Each
artwork should have a designated display area.

Dept of CSE , K K GEC K R Pet. Page 12


Virtual Art Gallery

c. Lighting Setup: Implement lighting techniques (ambient, diffuse, specular) to illuminate the
gallery and artworks realistically.

4.1.3. Rendering Pipeline

a. Vertex and Fragment Shaders: Write GLSL shaders for handling vertex transformations and
fragment coloring, supporting realistic lighting and shading effects.
b. Texture Mapping: Apply textures to 3D models representing artwork frames, ensuring high-
quality rendering of digital images.
c. Depth Testing and Culling: Use OpenGL functionalities to manage depth testing and face
culling for efficient rendering.

4.1.4. User Interaction

a. Camera Control: Enable camera movement (pan, tilt, zoom) to navigate through the gallery
environment, providing a first-person or third-person perspective.
b. Artwork Interaction: Implement mechanisms for users to interact with artworks, such as
hovering over or clicking on frames to display detailed information.

4.1.5. Performance Optimization

a. Level of Detail (LOD): Implement LOD techniques to adjust the detail level of artworks based
on their proximity to the camera, optimizing rendering performance.
b. Texture Management: Efficiently load and manage artwork textures to minimize memory usage
and loading times.
c. Batch Rendering: Utilize batch rendering techniques to reduce draw calls and improve overall
rendering efficiency.

4.1.6. Additional Features

a. Audio Integration: Optionally integrate background music or ambient sounds to enhance the
immersive experience.
b. Virtual Reality (VR) Support: Extend the gallery to support VR headsets for an immersive VR
experience, leveraging libraries like OpenVR or Oculus SDK.
c. Web Integration: Develop a web-based version of the gallery using WebGL for cross-platform
accessibility.

Dept of CSE , K K GEC K R Pet. Page 13


Virtual Art Gallery

4.2 Algorithm for Design a virtual art gallery

Creating a virtual art gallery involves several key steps, including initializing the
environment, loading assets, setting up the scene, rendering the scene, and handling user
interactions. Here’s a detailed algorithm:

4.2.1. Initialize the Environment

 Initialize OpenGL Context:


a. Use a library like GLFW to set up the OpenGL context.
b. Create a window with an appropriate title and size for rendering the gallery.
 Load OpenGL Extensions:
a. Use a library like GLEW or GLAD to load the necessary OpenGL extensions.
 Set Up the Viewport:
a. Define the viewport dimensions to match the window size.
b. Set up the projection matrix (e.g., perspective projection) to render the 3D scene
correctly.

4.2.2. Load Assets

 Load 3D Models:
a. Import 3D models of the gallery structure, including walls, floors, and display
stands.
b. Use a 3D modeling tool (e.g., Blender) to create and export these models.
 Load Textures:
a. Load digital images of artworks and other textures (e.g., wall textures).
b. Use an image loading library to handle various image formats.
 Load Shaders:
a. Load and compile vertex and fragment shaders for handling lighting, shading, and
texture mapping.

Dept of CSE , K K GEC K R Pet. Page 14


Virtual Art Gallery

4.2.3. Set Up the Scene

 Create Gallery Layout:


a. Position the 3D models of the gallery structure in the scene.
b. Arrange display stands and frames for artworks at appropriate locations.
 Apply Textures:
a. Map artwork textures onto 3D frames or panels.
b. Ensure that textures are correctly aligned and scaled.
 Set Up Lighting:
a. Define light sources (e.g., ambient light, directional lights, spotlights) to
illuminate the gallery.
b. Adjust light properties such as intensity, color, and position.

4.2.4. Rendering Loop

 Clear Buffers:
a. At the beginning of each frame, clear the color and depth buffers to prepare for
rendering.
 Render Gallery Structure:
a. Draw the 3D models of the gallery structure with appropriate textures and lighting
effects.
 Render Artworks:
a. Draw the textured 3D frames or panels representing the artworks.
b. Apply shading and lighting to enhance visual realism.
 Update Camera:
a. Update the camera position and orientation based on user input to navigate
through the gallery.
 Swap Buffers:
a. Swap the front and back buffers to display the rendered frame on the screen.

Dept of CSE , K K GEC K R Pet. Page 15


Virtual Art Gallery

4.2.5. User Interaction

 Handle Input:
a. Capture user input from the keyboard and mouse (e.g., movement, looking
around).
b. Update the camera position and orientation based on input to allow navigation.
 Interact with Artworks:
a. Implement functionality to detect when the user interacts with an artwork (e.g.,
clicking or approaching).
b. Display additional information about the artwork (e.g., title, artist, description)
when interacted with.

4.2.6. Performance Optimization

 Optimize Rendering:
a. Implement techniques like frustum culling and level of detail (LOD) to optimize
rendering performance.
b. Reduce the number of draw calls by batching similar objects together.
 Efficient Texture Management:
a. Use texture atlases or other techniques to minimize texture binding operations.
b. Implement mipmapping to improve texture rendering quality and performance.

4.2.7. Testing and Debugging

 Visual Inspection:
a. Inspect the rendered gallery for visual correctness (e.g., texture alignment,
lighting effects).
 Performance Testing:
a. Monitor frame rates and identify performance bottlenecks.
b. Optimize code and assets to ensure smooth performance.

Dept of CSE , K K GEC K R Pet. Page 16


Virtual Art Gallery

Chapter 5

IMPLEMETATION OF ART GALLERY

Implementing a virtual art gallery using OpenGL and C++ involves a series of steps,
including setting up the development environment, initializing OpenGL, loading and rendering
3D models and textures, handling user input for navigation, and optimizing performance. Here is
a detailed guide to implementing the project:

5.1. Set Up the Development Environment

5.1.1 Install Necessary Tools:

a. Compiler: Ensure you have a C++ compiler (e.g., GCC, Clang, or MSVC).
b. IDE: Use an integrated development environment (IDE) such as Visual Studio,
CLion, or Eclipse.
c. Libraries: Install GLFW for window creation and input handling, and GLAD for
loading OpenGL extensions.

5.1.2 Create a New Project:

d. Set up a new C++ project in your IDE.


e. Configure the project to include the GLFW and GLAD libraries.

5.2. Initialize OpenGL

5.2.1 Initialize GLFW:.

a. Set up GLFW to create a window and handle input events.

5.2.2 Load OpenGL Extensions:

b. Use GLAD to load OpenGL function pointers.

Dept of CSE , K K GEC K R Pet. Page 17


Virtual Art Gallery

5.2.3 Create a Window:


a. Create an OpenGL context and a window using GLFW.
5.2.4 Set Up the Viewport:

a. Define the viewport dimensions and set up the projection matrix for rendering
the 3D scene.

5.3. Load and Render 3D Models and Textures

5.3.1 Load Shaders:

a. Write vertex and fragment shaders to handle vertex transformations and fragment
coloring.
b. Compile and link shaders into a shader program.

5.3.2 Load 3D Models:

c. Import 3D models of the gallery structure (walls, floors, display stands) and
artwork frames.
d. Create and bind vertex buffer objects (VBOs), vertex array objects (VAOs), and
element buffer objects (EBOs) for the models.

5.3.3 Load Textures:

e. Load digital images of artworks and other textures using an image loading library.
f. Generate and bind textures in OpenGL, and map them onto the 3D models.

5.4. Set Up the Scene

5.4.1 Create Gallery Layout:

a. Position the 3D models of the gallery structure in the scene.


b. Arrange display stands and frames for artworks at appropriate locations within the
gallery.

Dept of CSE , K K GEC K R Pet. Page 18


Virtual Art Gallery

5.4.2 Apply Textures:

c. Map artwork textures onto 3D frames or panels, ensuring correct alignment and
scaling.

5.4.3 Set Up Lighting:

d. Define and position light sources to illuminate the gallery realistically.


e. Adjust light properties such as intensity, color, and position for desired lighting
effects.

5..5. Implement the Rendering Loop

5.5.1 Clear Buffers:

a. Clear the color and depth buffers at the beginning of each frame to prepare for
rendering.

5.5.2 Render Gallery Structure:

b. Draw the 3D models of the gallery structure with appropriate textures and lighting
effects.

5.5.3 Render Artworks:

c. Draw the textured 3D frames or panels representing the artworks.


d. Apply shading and lighting to enhance visual realism.

5.5.4 Update Camera:

e. Update the camera position and orientation based on user input to allow
navigation through the gallery.

5.5.5 Swap Buffers:

f. Swap the front and back buffers to display the rendered frame on the screen

Dept of CSE , K K GEC K R Pet. Page 19


Virtual Art Gallery

5.6. Handle User Interaction

5.6.1 Handle Input:

a. Capture user input from the keyboard and mouse for movement and interaction.
b. Update the camera position and orientation based on input to navigate the gallery.

5.6.2 Interact with Artworks:

c. Implement functionality to detect when the user interacts with an artwork (e.g.,
clicking or approaching).
d. Display additional information about the artwork (e.g., title, artist, description)
when interacted with.

5.7. Optimize Performance

5.7.1 Optimize Rendering:

a. Implement techniques such as frustum culling and level of detail (LOD) to


optimize rendering performance.
b. Reduce the number of draw calls by batching similar objects together.

5.7.2 Efficient Texture Management:

c. Use texture atlases or other techniques to minimize texture binding operations.


d. Implement mipmapping to improve texture rendering quality and performance.

5.8. Test and Debug

5.8.1 Visual Inspection:

a. Inspect the rendered gallery for visual correctness, including texture alignment
and lighting effects.

Dept of CSE , K K GEC K R Pet. Page 20


Virtual Art Gallery

5.8.2 Performance Testing:

b. Monitor frame rates and identify performance bottlenecks.


c. Optimize code and assets to ensure smooth performance.

5.8.3 User Testing:

d. Conduct usability testing to ensure that navigation and interactions are intuitive
and responsive.

5.9 Source Code


#include <iostream>

#include <stdlib.h>

#include <string>

#include <sstream>

#include <ctime>

#include <vector>

#include <cmath>

#include <gl/glut.h> //include glut library (automatically includes gl and glu libraries)

#include <windows.h>

#define MY_PI 3.14159265359f //declare PI value

#define DEG2RAD(a) (MY_PI/180*(a)) //convert degrees into radians

5.9.1 Defined Variables

//RGB values for color struct

struct Color

Dept of CSE , K K GEC K R Pet. Page 21


Virtual Art Gallery

double r, g, b;

5.9.3 Functions

//reset pressed keys

void resetKeys(bool fb, bool lr, bool ud, bool p, bool y, bool r); //reset pressed
keys

void displayText(float posX, float posY, std::string text, Color color); //function for drawing
text

unsigned char* LoadBMPFile(char *filename, int id); //function for loading bmp files for
textures

void resetCamera(); //reset camera


to initial state

void setupTexture(char * filename, int id); //load texture

void setupLights(); //setup lights

void myTimer(int v); //timer function

void myIdleFunc(); //idle function


- calculates fps

5.9.3 Key Functions

//called when ASCII key pressed

void myKeypress(unsigned char key, int x, int y)

switch (key)

//if ESC pressed, quit program

case 27: exit(1); //quit

break;

//show/hide user menu

case 'H':

Dept of CSE , K K GEC K R Pet. Page 22


Virtual Art Gallery

case 'h': if (displayMenu) { displayMenu = false; }

else { drawMenu(); displayMenu = true; }

break;

case 'a':

case 'A': gCameraYaw -= gRotationSensitivity; //increment camera yaw

resetKeys(false, false, false, false, true, false);

break;

else if (whiteBgBlackWire)

whiteBgBlackWire = false;

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //fill mode

if (nightMode)

glClearColor(0.0, 0.0, 0.0, 1.0); //clears background colour to


black

else

glClearColor(colorArray[10].r, colorArray[10].g,
colorArray[10].b, 1.0); //clears background colour to blue

break;

case '3': glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //yellow wireframe


mode

if (!blueBgYellowWire)

blueBgYellowWire = true;

Dept of CSE , K K GEC K R Pet. Page 23


Virtual Art Gallery

whiteBgBlackWire = false;

blackBgWhiteWire = false;

glClearColor(0.0, 0.0, 1.0, 1.0); //clears background colour to blue

else if (blueBgYellowWire)

blueBgYellowWire = false

5.9.4 Main

int main(int argc, char* argv[])

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);


//requests properties for the window (sets up the rendering context)

glutInitWindowSize(windowWidth, windowHeight);
//set window size in pixels

glutInitWindowPosition(50, 100);
//set window position from top-left corner of display

glutCreateWindow("Assignment 4 - Art Gallery"); //set


window title

init();
//call function to setup states

glutReshapeFunc(resizeWindow); //register reshape callback function

glutDisplayFunc(drawScene); //register display callback function

glutKeyboardFunc(myKeypress); //register keyboard callback function

Dept of CSE , K K GEC K R Pet. Page 24


Virtual Art Gallery

glutSpecialFunc(mySpecialKeys); //register non-ASCII keypress


callback function

glutTimerFunc(100, myTimer, 0); //timer function

glutIdleFunc(myIdleFunc); //idle function

glutMainLoop(); //enter event loop

delete textures;

Dept of CSE , K K GEC K R Pet. Page 25


Virtual Art Gallery

Chapter 7

TESTING

Testing a virtual art gallery involves various steps to ensure that the application
functions correctly, performs well, and provides a good user experience. Here’s a detailed guide
to testing the project.

7.1. Navigation and Controls:

 Test the usability of the navigation controls (keyboard and mouse) to ensure they are
intuitive and responsive.
 Verify that users can easily navigate through the gallery and interact with artworks.

7.2 User Interface:

 Check that the user interface elements (e.g., information panels, tooltips) are displayed
correctly and are easy to read.
 Ensure that the interface provides helpful feedback and guidance for users.

Keys Output Completed

+ Day mode Yes

- Night mode Yes

1 White frame with black background Yes

2 Black frame with white background Yes

Dept of CSE , K K GEC K R Pet. Page 26


Virtual Art Gallery

Yellow frame with blue Yes


3
background
Yes
L Togling light blink on / off

Dept of CSE , K K GEC K R Pet. Page 27


Virtual Art Gallery

Chapter 7

SNAPSHOTS

Fig 7.1 Default mode

Fig 7.2 Light mode

Dept of CSE , K K GEC K R Pet. Page 28


Virtual Art Gallery

Fig 7.3 Black background

Fig 74 White wireframe with Black background

Dept of CSE , K K GEC K R Pet. Page 29


Virtual Art Gallery

Fig 7.5 Yellow frame with Blue background

Fig 7.6 Inside the gallery

Dept of CSE , K K GEC K R Pet. Page 30


Virtual Art Gallery

Chapter 8

CONCLUSION

The development of a virtual art gallery using OpenGL and C++ has demonstrated the
remarkable potential of computer graphics to create an immersive and interactive art viewing
experience. By leveraging 3D modeling, textures, and efficient rendering techniques, the project
successfully replicates the ambiance of a physical gallery, allowing users to navigate the space
and interact with digital artworks seamlessly. Despite the inherent challenges of managing 3D
graphics and ensuring performance optimization, the use of advanced libraries and careful design
resulted in a visually appealing, high-performance application compatible across multiple
platforms. This virtual gallery not only enhances accessibility to art but also opens new avenues
for digital exhibitions, providing a rich and engaging experience for users.

Dept of CSE , K K GEC K R Pet. Page 31


Virtual Art Gallery

REFERENCES
[1]. Shreiner, D., Sellers, G., Kessenich, J., & Licea-Kane, B. (2013). OpenGL Programming
Guide: The Official Guide to Learning OpenGL, Version 4.3. Addison-Wesley Professional.

[2].Angel, E., & Shreiner, D. (2014). Interactive Computer Graphics: A Top-Down Approach
with WebGL. Pearson.

[3].GLFW. (n.d.). An Open Source, Multi-Platform Library for OpenGL, OpenGL ES and
Vulkan Development. Retrieved from https://www.glfw.org/

[4].GLAD. (n.d.). Multi-Language GL/GLES/EGL/GLX/WGL Loader-Generator Based on the


Official Khronos-Registry. Retrieved from https://glad.dav1d.de/

Dept of CSE , K K GEC K R Pet. Page 32

You might also like