Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
OpenGL Data Visualization Cookbook
OpenGL Data Visualization Cookbook

OpenGL Data Visualization Cookbook: Over 35 hands-on recipes to create impressive, stunning visuals for a wide range of real-time, interactive applications using OpenGL

eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

OpenGL Data Visualization Cookbook

Chapter 2. OpenGL Primitives and 2D Data Visualization

In this chapter, we will cover the following topics:

  • OpenGL primitives
  • Creating a 2D plot using primitives
  • Real-time visualization of time series
  • 2D visualization of 3D/4D datasets

Introduction

In the previous chapter, we provided a sample code to render a triangle on the screen using OpenGL and the GLFW library. In this chapter, we will focus on the use of OpenGL primitives, such as points, lines, and triangles, to enable the basic 2D visualization of data, including time series such as an electrocardiogram (ECG). We will begin with an introduction to each primitive, along with sample code to allow readers to experiment with the OpenGL primitives with a minimal learning curve.

One can think of primitives as the fundamental building blocks to create graphics using OpenGL. These building blocks can be easily reused in many applications and are highly portable among different platforms. Frequently, programmers struggle with displaying their results in a visually appealing manner, and an enormous amount of time may be spent on performing simple drawing tasks on screen. In this chapter, we will introduce a rapid prototyping approach to 2D data visualization using OpenGL...

OpenGL primitives

In the simplest terms, primitives are just basic shapes that are drawn in OpenGL. In this section, we will provide a brief overview of the main geometric primitives that are supported by OpenGL and focus specifically on three commonly used primitives (which will also appear in our demo applications): points, lines, and triangles.

Drawing points

We begin with a simple, yet very useful, building block for many visualization problems: a point primitive. A point can be in the form of ordered pairs in 2D, or it can be visualized in the 3D space.

Getting ready

To simplify the workflow and improve the readability of the code, we first define a structure called Vertex, which encapsulates the fundamental elements such as the position and color of a vertex.

typedef struct
{
  GLfloat x, y, z; //position
  GLfloat r, g, b, a; //color and alpha channels
} Vertex;

Now, we can treat every object and shape in terms of a set of vertices (with a specific color) in space. In this chapter, as...

Creating a 2D plot using primitives

Creating a 2D plot is a common way of visualizing trends in datasets in many applications. With OpenGL, we can render such plots in a much more dynamic way compared to conventional approaches (such as basic MATLAB plots) as we can gain full control over the graphics shader for color manipulation and we can also provide real-time feedback to the system. These unique features allow users to create highly interactive systems, so that, for example, time series such as an electrocardiogram can be visualized with minimal effort.

Here, we first demonstrate the visualization of a simple 2D dataset, namely a sinusoidal function in discrete time.

Getting ready

This demo requires a number of functions (including the drawPoint, drawLineSegment, and drawGrid functions) implemented earlier. In addition, we will reuse the code structure introduced in the Chapter 1, Getting Started with OpenGL to execute the demo.

How to do it…

We begin by generating a simulated data...

Real-time visualization of time series

In this section, we further demonstrate the versatility of our framework to plot general time series data for biomedical applications. In particular, we will display an ECG in real time. As a brief introduction, an ECG is a very commonly used diagnostic and monitoring tool to detect abnormalities in the heart. ECG surface recording essentially probes the electrical activities of the heart. For example, the biggest spike (called a QRS complex) typically corresponds to the depolarization of the ventricles of the heart (the highly muscular chambers of the heart that pump blood). A careful analysis of the ECG can be a very powerful, noninvasive method for distinguishing many heart diseases clinically, including many forms of arrhythmia and heart attacks.

Getting ready

We begin by importing a computer-generated ECG data stream. The ECG data stream is stored in data_ecg.h (only a small portion of the data stream is provided here):

float data_ecg[]={0.396568808f...

2D visualization of 3D/4D datasets

We have now learned multiple methods to generate plots on screen using points and lines. In the last section, we will demonstrate how to visualize a million data points in a 3D dataset using OpenGL in real time. A common strategy to visualize a complex 3D dataset is to encode the third dimension (for example, the z dimension) in the form of a heat map with a desirable color scheme. As an example, we show a heat map of a 2D Gaussian function with its height z, encoded using a simple color scheme. In general, a 2-D Gaussian function, 2D visualization of 3D/4D datasets, is defined as follows:

2D visualization of 3D/4D datasets

Here, A is the amplitude (2D visualization of 3D/4D datasets) of the distribution centered at 2D visualization of 3D/4D datasets and 2D visualization of 3D/4D datasets are the standard deviations (spread) of the distribution in the x and y directions. To make this demo more interesting and more visually appealing, we vary the standard deviation or sigma term (equally in the x and y directions) over time. Indeed, we can apply the same method to visualize very complex 3D datasets.

Getting ready

By now, you...

Left arrow icon Right arrow icon

Description

OpenGL is a great multi-platform, cross-language, and hardware-accelerated graphics interface for visualizing large 2D and 3D datasets. Data visualization has become increasingly challenging using conventional approaches as datasets become larger and larger, especially with the Big Data evolution. From a mobile device to a sophisticated high-performance computing cluster, OpenGL libraries provide developers with an easy-to-use interface to create stunning visuals in 3D in real time for a wide range of interactive applications. This book provides a series of easy-to-follow, hands-on tutorials to create appealing OpenGL-based visualization tools with minimal development time. We will first illustrate how to quickly set up the development environment in Windows, Mac OS X, and Linux. Next, we will demonstrate how to visualize data for a wide range of applications using OpenGL, starting from simple 2D datasets to increasingly complex 3D datasets with more advanced techniques. Each chapter addresses different visualization problems encountered in real life and introduces the relevant OpenGL features and libraries in a modular fashion. By the end of this book, you will be equipped with the essential skills to develop a wide range of impressive OpenGL-based applications for your unique data visualization needs, on platforms ranging from conventional computers to the latest mobile/wearable devices.

Who is this book for?

This book is aimed at anyone interested in creating impressive data visualization tools using modern graphics hardware. Whether you are a developer, engineer, or scientist, if you are interested in exploring the power of OpenGL for data visualization, this book is for you. While familiarity with C/C++ is recommended, no previous experience with OpenGL is assumed.

What you will learn

  • Install, compile, and integrate the OpenGL pipeline into your own project
  • Create interactive applications using GLFW to handle user inputs and the Android Sensor framework to detect gestures and motions on mobile devices
  • Use OpenGL primitives to plot 2-D datasets such as time series dynamically
  • Render complex 3D volumetric datasets with techniques such as data slicers and multiple viewpoint projection
  • Render images, videos, and point cloud data from 3D range-sensing cameras using the OpenGL Shading Language (GLSL)
  • Develop video see-through augmented reality applications on mobile devices with OpenGL ES 3.0 and OpenCV
  • Visualize 3D models with meshes and surfaces using stereoscopic 3D technology

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 24, 2015
Length: 298 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169734
Vendor :
Khronos Group
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Aug 24, 2015
Length: 298 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169734
Vendor :
Khronos Group
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 170.97
OpenGL Data Visualization Cookbook
$54.99
OpenGL 4 Shading Language Cookbook, Second Edition
$60.99
OpenGL Development Cookbook
$54.99
Total $ 170.97 Stars icon

Table of Contents

10 Chapters
1. Getting Started with OpenGL Chevron down icon Chevron up icon
2. OpenGL Primitives and 2D Data Visualization Chevron down icon Chevron up icon
3. Interactive 3D Data Visualization Chevron down icon Chevron up icon
4. Rendering 2D Images and Videos with Texture Mapping Chevron down icon Chevron up icon
5. Rendering of Point Cloud Data for 3D Range-sensing Cameras Chevron down icon Chevron up icon
6. Rendering Stereoscopic 3D Models using OpenGL Chevron down icon Chevron up icon
7. An Introduction to Real-time Graphics Rendering on a Mobile Platform using OpenGL ES 3.0 Chevron down icon Chevron up icon
8. Interactive Real-time Data Visualization on Mobile Devices Chevron down icon Chevron up icon
9. Augmented Reality-based Visualization on Mobile or Wearable Platforms Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(5 Ratings)
5 star 80%
4 star 0%
3 star 20%
2 star 0%
1 star 0%
Elvis John Dowson Sep 10, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A very good book that covers 2D and 3D data visualization using OpenGL and other libraries, with setup instructions provided for developing applications for Windows, Linux, Mac and Android platforms.The recipes provides in the book start with the basics, with rendering a rotating triangle and progressively move on to more advanced examples, including:- a 2D electrocardiogram,- interactively visualizing complex 3D data sets,- rendering 2D images and videos with texture mapping and working with OpenCV libraries,- working with GLSL,- real-time video rendering with filters,- rendering 3D point cloud data,- rendering stereoscopic 3D models,- creating augmented reality applications.
Amazon Verified review Amazon
Kwisatz Haderach Sep 14, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is an excellent book that gets you up and running quickly on OpenGL including the fixed function pipeline (version 2), shaders (version 3) and embedded systems/Android (ES). I appreciated the coverage on various platforms (Android, Linux, Mac, Windows) as I was able to use on Ubuntu 15.04, Windows 7/10, and Yosemite.The code depends on several open source libraries that jump start the projects to quickly see the reward for the effort. More importantly, the authors clearly explain why they are taking on the dependencies (GLEW for managing OpenGL extensions, GLFW for windowing, GLM for matrix math, SOIL for handling graphics formats, and OpenCV for imaging), I think most of these have fairly permissible licenses so you should be able to re-use without much concern (but I am an engineer and not a lawyer).The content is in tutorial format so it is a good first read for someone starting with OpenGL without having to search across multiple web sites. You will want to have a good reference with you to satisfy any curiosities about API calls.I was impressed with the examples that were more interesting than the standard tea pot and simple triangle renderings. Most of the content is generated programmatically through solution of math problems. While the math can be fairly sophisticated, the problems were focused on medicine and I found them relatable despite the fact that medicine is not my principle area of study (but I have a heart beat and the authors take the time to provide background information on what a heart beat plot should look like that was quite interesting).Anyway, the recipes in the cookbook are related to computer imaging of data based on various mathematical models. You start by drawing a simple sine curve on a 2D plot and progress to 3D contour plots. Then, you will start integrating filters for image processing. There is also a recipe for working with the Microsoft Kinect 3D range sensing camera on Apple, Linux and Windows platforms. After that, there are recipes for rendering stereoscopic images but I did not have the hardware to test the images.Overall, I am extremely pleased with the book as it quickly started my development across several platforms and saved me time and effort otherwise spent reading various web pages.I struggle to find any criticism. It would be nice to have a recipe for selecting objects (perhaps polygons) with mouse clicks. You also will not find any iOS coverage (at least I did not come across any). Hope this will be in the second edition.
Amazon Verified review Amazon
Samar Nov 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
[Disclosure: I am the Technical Reviewer on this book]"OpenGL Data Visualization Cookbook" is filled with excellent real-world examples which are easy to understand and implement. Having a basic-level knowledge of C/C++ will go a long way as we traverse the examples and source code included with the book.Variety of different visualization techniques as well as examples have been provided, the reader will be able to customize a part of code, to better understand the working of individual components.My personal favorite chapter 6 introduces concepts related to stereoscopic 3D rendering techniques and its implementation in OpenGL, for beginners the concept is usually helpful if you are modelling an object lets say customizing a car, you can view and manipulate the 3D model, to have a clear direction of the end product.As mentioned in earlier reviews, most of the libraries mentioned in the book are open source and easy to obtain with instructions mentioned in the book.One of the other pains that the author has took, is providing instructions for complete setup in different operating systems available, so its windows/mac/linux, we wont have much trouble implementing the source code and solutions provided in the book.An implementation of OpenGL on mobile platforms (android) is also included which makes us understand the concept from a different angle.Overall, "OpenGL data visualization cookbook" is structured well, the contents are concise to the point, nothing extra, nothing less and I`m positive about the reader experience in finding it useful.
Amazon Verified review Amazon
Matteo Ricci Oct 29, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very interesting read. It nicely complement other OpenGL books as it focus exclusively on data visualization. Indeed this is one of the few books I am aware of dealing with this topic using OpenGL.Another good point is given by the accompanying demo source code which runs on my platform of choice (Linux), unlike many other OpenGL books leaning more towards Windows.In summary, if you are interested in data visualization and you already know enough of OpenGL, this book is worth the money.
Amazon Verified review Amazon
Tom Jul 18, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Good material however riddled with minor errors and the errata will not help you. I absolutely recommend you follow along with the book's source code, which will require you to create an account on the publisher's website.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.