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
R$80 R$245.99
Paperback
R$306.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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
Estimated delivery fee Deliver to Brazil

Standard delivery 10 - 13 business days

R$63.95

Premium delivery 3 - 6 business days

R$203.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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
Estimated delivery fee Deliver to Brazil

Standard delivery 10 - 13 business days

R$63.95

Premium delivery 3 - 6 business days

R$203.95
(Includes tracking information)

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
R$50 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
R$500 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 R$25 each
Feature tick icon Exclusive print discounts
R$800 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 R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 953.97
OpenGL Data Visualization Cookbook
R$306.99
OpenGL 4 Shading Language Cookbook, Second Edition
R$339.99
OpenGL Development Cookbook
R$306.99
Total R$ 953.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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela