Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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
NZ$44.99 NZ$64.99
Paperback
NZ$80.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781782169727
Vendor :
Khronos Group
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Aug 24, 2015
Length: 298 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169727
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 NZ$7 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 NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 251.97
OpenGL Data Visualization Cookbook
NZ$80.99
OpenGL 4 Shading Language Cookbook, Second Edition
NZ$89.99
OpenGL Development Cookbook
NZ$80.99
Total NZ$ 251.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.