KEMBAR78
Interactive Graphics Programming with OpenGL.pptx
Interactive Graphics
Programming with OpenGL
-By Rahul Naveen
What is Interactive Programs?
● An interactive program is a computer software program that
requires user interaction to operate.
● This interaction could include inputting information, modifying
information, managing information or otherwise manipulating data.
● Most software programs are interactive & one of those software to
create interactive program is OpenGL
OpenGL Overview and History
● OpenGL (Open Graphics Library) is a cross-language, cross-platform application
programming interface (API) for rendering 2D and 3D vector graphics.
● The API is typically used to interact with a graphics processing unit (GPU), to
achieve hardware-accelerated rendering. - (Source: Wikipedia)
● OpenGL was first released on June 30, 1992 by Mark Segal and Kurt Akeley.
Example of OpenGl
Example of OpenGL Applications
OpenGL enables creation of:
● Real-time 3D graphics (games, simulations)
● Interactive visualizations (data analysis, scientific modeling)
● Animated user interfaces (modern GUI applications)
● Virtual reality applications (immersive environments)
Common examples include video games, CAD software, medical imaging applications,
and scientific simulations
glutIdleFunc(idle)
● Consider a 2D point p(x,y) such that x = cos , y= sin . This point would lie on a unit
circle regardless of the value of . Thus, if we connect the above given four points
we get a square which has its center as the origin.
glutIdleFunc(idle)
● Suppose that we change the value of as the program is running, the square
appears to rotating about its origin.
● If the value of is to be changed by a fixed amount whenever nothing else is
happening then an idle callback function must be designed.
glutMouseFunc(mouse);
● Suppose that we want to turn off and turn on the rotation feature then we can write
a mouse callback function as shown below:
● The above mouse callback function must be registered in the main
function as follow:
glutMouseFunc(mouse);
DOUBLE
BUFFERING
What is Buffer?
Buffer Objects are OpenGL Objects
that store an array of unformatted
memory allocated by the OpenGL
● Double buffering provides two complete color buffers for use in
drawing.
● One buffer is displayed while the other buffer is being drawn into.
● When the drawing is complete, the two buffers are swapped so
that the one that was being viewed is now used for drawing.
It can be Initialized as:
glutInitDisplayMode(GLUT_RGB| GLUT_DOUBLE);
USING
TIMER
What is Timer?
glutTimerFunc registers the timer
callback func to be triggered in at least
msecs milliseconds. The value
parameter to the timer callback will be
the value of the value parameter to
glutTimerFunc. Multiple timer
callbacks at same or differing times
may be registered simultaneously.
● To understand the usage of timer, consider cube rotation
program and its execution is done by using fast GPU
(modern GPUs can render tens of millions of primitives per
second) then cube will be rendered thousands of time per
second and we will see the blur on the display.
● Therefore, GLUT provides the following timer function:
glutTimerFunc(int delay, void(*timer_func (int), int value)
● Execution of this function starts timer in the event loop that
delays for delay milliseconds
.
● When timer has counted down, timer_func is executed
the value parameter allow user to pass variable into the timer call
back.
Thank You

Interactive Graphics Programming with OpenGL.pptx

  • 1.
  • 2.
    What is InteractivePrograms? ● An interactive program is a computer software program that requires user interaction to operate. ● This interaction could include inputting information, modifying information, managing information or otherwise manipulating data. ● Most software programs are interactive & one of those software to create interactive program is OpenGL
  • 3.
    OpenGL Overview andHistory ● OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. ● The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering. - (Source: Wikipedia) ● OpenGL was first released on June 30, 1992 by Mark Segal and Kurt Akeley.
  • 4.
  • 5.
    Example of OpenGLApplications OpenGL enables creation of: ● Real-time 3D graphics (games, simulations) ● Interactive visualizations (data analysis, scientific modeling) ● Animated user interfaces (modern GUI applications) ● Virtual reality applications (immersive environments) Common examples include video games, CAD software, medical imaging applications, and scientific simulations
  • 6.
    glutIdleFunc(idle) ● Consider a2D point p(x,y) such that x = cos , y= sin . This point would lie on a unit circle regardless of the value of . Thus, if we connect the above given four points we get a square which has its center as the origin.
  • 7.
    glutIdleFunc(idle) ● Suppose thatwe change the value of as the program is running, the square appears to rotating about its origin. ● If the value of is to be changed by a fixed amount whenever nothing else is happening then an idle callback function must be designed.
  • 8.
    glutMouseFunc(mouse); ● Suppose thatwe want to turn off and turn on the rotation feature then we can write a mouse callback function as shown below: ● The above mouse callback function must be registered in the main function as follow: glutMouseFunc(mouse);
  • 9.
    DOUBLE BUFFERING What is Buffer? BufferObjects are OpenGL Objects that store an array of unformatted memory allocated by the OpenGL ● Double buffering provides two complete color buffers for use in drawing. ● One buffer is displayed while the other buffer is being drawn into. ● When the drawing is complete, the two buffers are swapped so that the one that was being viewed is now used for drawing. It can be Initialized as: glutInitDisplayMode(GLUT_RGB| GLUT_DOUBLE);
  • 10.
    USING TIMER What is Timer? glutTimerFuncregisters the timer callback func to be triggered in at least msecs milliseconds. The value parameter to the timer callback will be the value of the value parameter to glutTimerFunc. Multiple timer callbacks at same or differing times may be registered simultaneously. ● To understand the usage of timer, consider cube rotation program and its execution is done by using fast GPU (modern GPUs can render tens of millions of primitives per second) then cube will be rendered thousands of time per second and we will see the blur on the display. ● Therefore, GLUT provides the following timer function: glutTimerFunc(int delay, void(*timer_func (int), int value) ● Execution of this function starts timer in the event loop that delays for delay milliseconds . ● When timer has counted down, timer_func is executed the value parameter allow user to pass variable into the timer call back.
  • 11.