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! 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
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$14.99 NZ$64.99
Paperback
NZ$80.99
Subscription
Free Trial

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
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

OpenGL Data Visualization Cookbook

Chapter 1. Getting Started with OpenGL

In this chapter, we will cover the following topics:

  • Setting up a Windows-based development platform
  • Setting up a Mac-based development platform
  • Setting up a Linux-based development platform
  • Installing the GLFW library in Windows
  • Installing the GLFW library in Mac OS X and Linux
  • Creating your first OpenGL application with GLFW
  • Compiling and running your first OpenGL application in Windows
  • Compiling and running your first OpenGL application in Mac OS X or Linux

Introduction

OpenGL is an ideal multiplatform, cross-language, and hardware-accelerated graphics rendering interface that is well suited to visualize large 2D and 3D datasets in many fields. In fact, OpenGL has become the industry standard to create stunning graphics, most notably in gaming applications and numerous professional tools for 3D modeling. As we collect more and more data in fields ranging from biomedical imaging to wearable computing (especially with the evolution of Big Data), a high-performance platform for data visualization is becoming an essential component of many future applications. Indeed, the visualization of massive datasets is becoming an increasingly challenging problem for developers, scientists, and engineers in many fields. Therefore, OpenGL can provide a unified solution for the creation of impressive, stunning visuals in many real-time applications.

The APIs of OpenGL encapsulate the complexity of hardware interactions while allowing users to have low-level control over the process. From a sophisticated multiserver setup to a mobile device, OpenGL libraries provide developers with an easy-to-use interface for high-performance graphics rendering. The increasing availability and capability of graphics hardware and mass storage devices, coupled with their decreasing cost, further motivate the development of interactive OpenGL-based data visualization tools.

Modern computers come with dedicated Graphics Processing Units (GPUs), highly customized pieces of hardware designed to accelerate graphics rendering. GPUs can also be used to accelerate general-purpose, highly parallelizable computational tasks. By leveraging hardware and OpenGL, we can produce highly interactive and aesthetically pleasing results.

This chapter introduces the essential tools to develop OpenGL-based data visualization applications and provides a step-by-step tutorial on how to set up the environment for our first demo application. In addition, this chapter outlines the steps to set up a popular tool called CMake, which is a cross-platform software that automates the process of generating standard build files (for example, makefiles in Linux that define the compilation parameters and commands) with simple configuration files. The CMake tool will be used to compile additional libraries in the future, including the GLFW (OpenGL FrameWork) library introduced later in this chapter. Briefly, the GLFW library is an open source, multiplatform library that allows users to create and manage windows with OpenGL contexts as well as handle inputs from peripheral devices such as the mouse and keyboard. By default, OpenGL itself does not support other peripherals; thus, the GLFW library is used to fill in the gap. We hope that this detailed tutorial will be especially useful for beginners who are interested in exploring OpenGL for data visualization but have little or no prior experience. However, we will assume that you are familiar with the C/C++ programming language.

Setting up a Windows-based development platform

There are various development tools available to create applications in the Windows environment. In this book, we will focus on creating OpenGL applications using Visual C++ from Microsoft Visual Studio 2013, given its extensive documentation and support.

Installing Visual Studio 2013

In this section, we outline the steps to install Visual Studio 2013.

Getting ready

We assume that you have already installed Windows 7.0 or higher. For optimal performance, we recommend that you get a dedicated graphics card, such as NVIDIA GeForce graphics cards, and have at least 10 GB of free disk space as well as 4 GB of RAM on your computer. Download and install the latest driver for your graphics card.

How to do it...

To install Microsoft Visual Studio 2013 for free, download the Express 2013 version for Windows Desktop from Microsoft's official website (refer to https://www.visualstudio.com/en-us/downloads/). Once you have downloaded the installer executable, we can start the process. By default, we will assume that programs are installed in the following path:

How to do it...

To verify the installation, click on the Launch button at the end of the installation, and it will execute the VS Express 2013 for Desktop application for the first time.

Installing CMake in Windows

In this section, we outline the steps to install CMake, which is a popular tool that automates the process of creating standard build files for Visual Studio (among other tools).

Getting ready

To obtain the CMake tool (CMake 3.2.1), you can download the executable (cmake-3.2.1-win32-x86.exe) from http://www.cmake.org/download/.

How to do it…

The installation wizard will guide you through the process (select Add CMake to the system PATH for all users when prompted for installation options). To verify the installation, run CMake(cmake-gui).

How to do it…

At this point, you should have both Visual Studio 2013 and CMake successfully installed on your machine and be ready to compile/install the GLFW library to create your first OpenGL application.

Setting up a Mac-based development platform

One important advantage of using OpenGL is the possibility of cross-compiling the same source code on different platforms. If you are planning to develop your application on a Mac platform, you can easily set up your machine for development using the upcoming steps. We assume that you have either Mac OS X 10.9 or higher installed. OpenGL updates are integrated into the system updates for Mac OS X through the graphics driver.

Installing Xcode and command-line tools

The Xcode development software from Apple provides developers with a comprehensive set of tools, which include an IDE, OpenGL headers, compilers, and debugging tools, to create native Mac applications. To simplify the process, we will compile our code using the command-line interface that shares most of the common features in Linux.

Getting ready

If you are using Mac OS X 10.9 or higher, you can download Xcode through the App Store shipped with Mac OS. Full installation support and instructions are available on the Apple Developer website (https://developer.apple.com/xcode/).

How to do it...

We can install the command-line tools in Xcode through the following steps:

  1. Search for the keyword Terminal in Spotlight and run Terminal.
    How to do it...
  2. Execute the following command in the terminal:
     xcode-select --install
    

    Note that if you have previously installed the command-line tools, an error stating "command-line are already installed" will appear. In this case, simply skip to step 4 to verify the installation.

  3. Click on the Install button to directly install the command-line tools. This will install basic compiling tools such as gcc and make for application development purposes (note that CMake needs to be installed separately).
  4. Finally, enter gcc --version to verify the installation.
    How to do it...

See also

If you encounter the command not found error or other similar issues, make sure that the command-line tools are installed successfully. Apple provides an extensive set of documentation, and more information on installing Xcode can be found at https://developer.apple.com/xcode.

Installing MacPorts and CMake

In this section, we outline the steps to install MacPorts, which greatly simplifies the subsequent setup steps, and CMake for Mac.

Getting ready

Similar to the Windows installation, you can download the binary distribution of CMake from http://www.cmake.org/cmake/resources/software.html and manually configure the command-line options. However, to simplify the installation and automate the configuration process, we highly recommend that you use MacPorts.

How to do it...

To install MacPorts, follow these steps:

  1. Download the MacPorts package installer for the corresponding version of Mac OS X (https://guide.macports.org/#installing.macports):
  2. Double-click on the package installer and follow the onscreen instructions.
    How to do it...
  3. Verify the installation in the terminal by typing in port version, which returns the version of MacPorts currently installed (Version: 2.3.3 in the preceding package).

To install CMake on Mac, follow these steps:

  1. Open the Terminal application.
  2. Execute the following command:
    sudo port install cmake +gui
    

To verify the installation, enter cmake –version to show the current version installed and enter cmake-gui to explore the GUI.

How to do it...

At this point, your Mac is configured for OpenGL development and is ready to compile your first OpenGL application. For those who have been more accustomed to GUIs, using the command-line interface in Mac can initially be an overwhelming experience. However, in the long run, it is a rewarding learning experience due to its overall simplicity. Command-line tools and interfaces are often more time-invariant compared to constantly evolving GUIs. At the end of the day, you can just copy and paste the same command lines, thereby saving precious time needed to consult new documentation every time a GUI changes.

Setting up a Linux-based development platform

To prepare your development environment on the Linux platform, we can utilize the powerful Debian Package Management system. The apt-get or aptitude program automatically retrieves the precompiled packages from the server and also resolves and installs all dependent packages that are required. If you are using non-Debian based platform, such as Fedora, you can find the equivalents by searching for the keywords of each packages listed in this recipe.

Getting ready

We assume that you have successfully installed all updates and latest graphics drivers associated with your graphics hardware. Ubuntu 12.04 or higher has support for third-party proprietary NVIDIA and AMD graphics drivers, and more information can be found at https://help.ubuntu.com/community/BinaryDriverHowto.

How to do it…

Use the following steps to install all development tools and the associated dependencies:

  1. Open a terminal.
  2. Enter the update command:
    sudo apt-get update
    
  3. Enter the install command and enter y for all prompts:
    sudo apt-get install build-essential cmake-gui xorg-dev libglu1-mesa-dev mesa-utils
    
  4. Verify the results:
    gcc --version
    

    If successful, this command should return the current version of gcc installed.

How it works…

In summary, the apt-get update command automatically updates the local database in the Debian Package Management system. This ensures that the latest packages are retrieved and installed in the process. The apt-get system also provides other package management features, such as package removal (uninstall), dependency retrieval, as well as package upgrades. These advanced functions are outside the scope of this book, but more information can be found at https://wiki.debian.org/apt-get.

The preceding commands install a number of packages to your machine. Here, we will briefly explain the purpose of each package.

The build-essential package, as the name itself suggests, encapsulates the essential packages, namely gcc and g++, that are required to compile C and C++ source code in Linux. Additionally, it will download header files and resolve all dependencies in the process.

The cmake-gui package is the CMake program described earlier in the chapter. Instead of downloading CMake directly from the website and compiling from the source, it retrieves the latest supported version that had been compiled, tested, and released by the Ubuntu community. One advantage of using the Debian Package Management system is the stability and ease of updating in the future. However, for users who are looking for the cutting-edge version, apt-get based systems would be a few versions behind.

The xorg-dev and libglu1-mesa-dev packages are the development files required to compile the GLFW library. These packages include header files and libraries required by other programs. If you choose to use the precompiled binary version of GLFW, you may be able to skip some of the packages. However, we highly recommend that you follow the steps for the purpose of this tutorial.

See also

For more information, most of the steps described are documented and explained in depth in this online documentation: https://help.ubuntu.com/community/UsingTheTerminal.

Installing the GLFW library in Windows

There are two ways to install the GLFW library in Windows, both of which will be discussed in this section. The first approach involves compiling the GLFW source code directly with CMake for full control. However, to simplify the process, we suggest that you download the precompiled binary distribution.

Getting ready

We assume that you have successfully installed both Visual Studio 2013 and CMake, as described in the earlier section. For completeness, we will demonstrate how to install GLFW using CMake.

How to do it...

To use the precompiled binary package for GLFW, follow these steps:

  1. Create the C:/Program Files (x86)/glfw-3.0.4 directory. Grant the necessary permissions when prompted.
  2. Download the glfw-3.0.4.bin.WIN32.zip package from http://sourceforge.net/projects/glfw/files/glfw/3.0.4/glfw-3.0.4.bin.WIN32.zip and unzip the package.
  3. Copy all the extracted content inside the glfw-3.0.4.bin.WIN32 folder (for example, include lib-msvc2012) into the C:/Program Files (x86)/glfw-3.0.4 directory. Grant permissions when prompted.
  4. Rename the lib-msvc2012 folder to lib inside the C:/Program Files (x86)/glfw-3.0.4 directory. Grant permissions when prompted.

Alternatively, to compile the source files directly, follow these procedures:

  1. Download the source package from http://sourceforge.net/projects/glfw/files/glfw/3.0.4/glfw-3.0.4.zip and unzip the package on the desktop. Create a new folder called build inside the extracted glfw-3.0.4 folder to store the binaries.and open cmake-gui.
  2. Select glfw-3.0.4 (from the desktop) as the source directory and glfw-3.0.4/build as the build directory. The screenshot is shown as follows:
    How to do it...
  3. Click on Generate and select Visual Studio 12 2013 in the prompt.
    How to do it...
  4. Click on Generate again.
    How to do it...
  5. Open the build directory and double-click on GLFW.sln to open Visual Studio.
  6. In Visual Studio, click Build Solution (press F7).
  7. Copy build/src/Debug/glfw3.lib to C:/Program Files (x86)/glfw-3.0.4/lib.
  8. Copy the include directory (inside glfw-3.0.4/include) to C:/Program Files (x86)/glfw-3.0.4/.

After this step, we should have the include (glfw3.h) and library (glfw3.lib) files inside the C:/Program Files (x86)/glfw-3.0.4 directory, as shown in the setup procedure using precompiled binaries.

Installing the GLFW library in Mac OS X and Linux

The installation procedures for Mac and Linux are essentially identical using the command-line interface. To simplify the process, we recommend that you use MacPorts for Mac users.

Getting ready

We assume that you have successfully installed the basic development tools, including CMake, as described in the earlier section. For maximum flexibility, we can compile the library directly from the source code (refer to http://www.glfw.org/docs/latest/compile.html and http://www.glfw.org/download.html).

How to do it...

For Mac users, enter the following command in a terminal to install GLFW using MacPorts:

sudo port install glfw

For Linux users (or Mac users who would like to practice using the command-line tools), here are the steps to compile and install the GLFW source package directly with the command-line interface:

  1. Create a new folder called opengl_dev and change the current directory to the new path:
    mkdir ~/opengl_dev
    cd ~/opengl_dev
    
  2. Obtain a copy of the GLFW source package (glfw-3.0.4) from the official repository: http://sourceforge.net/projects/glfw/files/glfw/3.0.4/glfw-3.0.4.tar.gz.
  3. Extract the package.
    tar xzvf glfw-3.0.4.tar.gz
    
  4. Perform the compilation and installation:
    cd glfw-3.0.4
    mkdir build
    cd build
    cmake ../
    make && sudo make install
    

How it works...

The first set of commands create a new working directory to store the new files retrieved using the wget command, which downloads a copy of the GLFW library to the current directory. The tar xzvf command extracts the compressed packages and creates a new folder with all the contents.

Then, the cmake command automatically generates the necessary build files that are needed for the compilation process to the current build directory. This process also checks for missing dependencies and verifies the versioning of the applications.

The make command then takes all instructions from the Makefile script that is generated automatically and compiles the source code into libraries.

The sudo make install command installs the library header files as well as the static or shared libraries onto your machine. As this command requires writing to the root directory, the sudo command is needed to grant such permissions. By default, the files will be copied to the /usr/local directory. In the rest of the book, we will assume that the installations follow these default paths.

For advanced users, we can optimize the compilation by configuring the packages with the CMake GUI (cmake-gui).

How it works...

For example, you can enable the BUILD_SHARED_LIBS option if you are planning to compile the GLFW library as a shared library. In this book, we will not explore the full functionality of the GLFW library, but these options can be useful to developers who are looking for further customizations. Additionally, you can customize the installation prefix (CMAKE_INSTALL_PREFIX) if you would like to install the library files at a separate location.

Creating your first OpenGL application with GLFW

Now that you have successfully configured your development platform and installed the GLFW library, we will provide a tutorial on how to create your first OpenGL-based application.

Getting ready

At this point, you should already have all the pre requisite tools ready regardless of which operating system you may have, so we will immediately jump into building your first OpenGL application using these tools.

How to do it...

The following code outlines the basic steps to create a simple OpenGL program that utilizes the GLFW library and draws a rotating triangle:

  1. Create an empty file, and then include the header file for the GLFW library and standard C++ libraries:
    #include <GLFW/glfw3.h>
    #include <stdlib.h>
    #include <stdio.h>
  2. Initialize GLFW and create a GLFW window object (640 x 480):
    int main(void)
    {
      GLFWwindow* window;
      if (!glfwInit())
        exit(EXIT_FAILURE);
      window = glfwCreateWindow(640, 480, "Chapter 1: Simple GLFW Example", NULL, NULL);
      if (!window)
      {
        glfwTerminate();
        exit(EXIT_FAILURE);
      }
      glfwMakeContextCurrent(window);
  3. Define a loop that terminates when the window is closed:
      while (!glfwWindowShouldClose(window))
      {
  4. Set up the viewport (using the width and height of the window) and clear the screen color buffer:
        float ratio;
        int width, height;
    
        glfwGetFramebufferSize(window, &width, &height);
        ratio = (float) width / (float) height;
    
        glViewport(0, 0, width, height);
        glClear(GL_COLOR_BUFFER_BIT);
  5. Set up the camera matrix. Note that further details on the camera model will be discussed in Chapter 3, Interactive 3D Data Visualization:
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
  6. Draw a rotating triangle and set a different color (red, green, and blue channels) for each vertex (x, y, and z) of the triangle. The first line rotates the triangle over time:
        glRotatef((float)glfwGetTime() * 50.f, 0.f, 0.f, 1.f);
        glBegin(GL_TRIANGLES);
        glColor3f(1.f, 0.f, 0.f);
        glVertex3f(-0.6f, -0.4f, 0.f);
        glColor3f(0.f, 1.f, 0.f);
        glVertex3f(0.6f, -0.4f, 0.f);
        glColor3f(0.f, 0.f, 1.f);
        glVertex3f(0.f, 0.6f, 0.f);
        glEnd();
  7. Swap the front and back buffers (GLFW uses double buffering) to update the screen and process all pending events:
        glfwSwapBuffers(window);
        glfwPollEvents();
      }
  8. Release the memory and terminate the GLFW library. Then, exit the application:
      glfwDestroyWindow(window);
      glfwTerminate();
      exit(EXIT_SUCCESS);
    }
  9. Save the file as main.cpp using the text editor of your choice.

How it works...

By including the GLFW library header, glfw3.h, we automatically import all necessary files from the OpenGL library. Most importantly, GLFW automatically determines the platform and thus allows you to write portable source code seamlessly.

In the main function, we must first initialize the GLFW library with the glfwInit function in the main thread. This is required before any GLFW functions can be used. Before a program exits, GLFW should be terminated to release any allocated resources.

Then, the glfwCreateWindow function creates a window and its associated context, and it also returns a pointer to the GLFWwindow object. Here, we can define the width, height, title, and other properties for the window. After the window is created, we then call the glfwMakeContextCurrent function to switch the context and make sure that the context of the specified window is current on the calling thread.

At this point, we are ready to render our graphics element on the window. The while loop provides a mechanism to redraw our graphics as long as the window remains open. OpenGL requires an explicit setup on the camera parameters; further details will be discussed in the upcoming chapters. In the future, we can provide different parameters to simulate perspective and also handle more complicated issues (such as anti-aliasing). For now, we have set up a simple scene to render a basic primitive shape (namely a triangle) and fixed the color for the vertices. Users can modify the parameters in the glColor3f and glVertex3f functions to change the color as well as the position of the vertices.

This example demonstrates the basics required to create graphics using OpenGL. Despite the simplicity of the sample code, it provides a nice introductory framework on how you can create high-performance graphics rendering applications with graphics hardware using OpenGL and GLFW.

Compiling and running your first OpenGL application in Windows

There are several ways to set up an OpenGL project. Here, we create a sample project using Visual Studio 2013 or higher and provide a complete walkthrough for the first-time configuration of the OpenGL and GLFW libraries. These same steps can be incorporated into your own projects in the future.

Getting ready

Assuming that you have both Visual Studio 2013 and GLFW (version 3.0.4) installed successfully on your environment, we will start our project from scratch.

How to do it...

In Visual Studio 2013, use the following steps to create a new project and compile the source code:

  1. Open Visual Studio 2013 (VS Express 2013 for desktop).
  2. Create a new Win32 Console Application and name it as Tutorial1.
    How to do it...
  3. Check the Empty project option, and click on Finish.
    How to do it...
  4. Right-click on Source Files, and add a new C++ source file (Add | New Item) called main.cpp.
    How to do it...
  5. Copy and paste the source code from the previous section into the main.cpp and save it.
  6. Open Project Properties (Alt + F7).
  7. Add the include path of the GLFW library, C:\Program Files (x86)\glfw-3.0.4\include, by navigating to Configuration Properties | C/C++ | General | Additional Include Directories.
    How to do it...

    Tip

    Downloading the example code

    You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

  8. Add the GLFW library path, C:\Program Files (x86)\glfw-3.0.4\lib, by navigating to Configuration Properties | Linker | General | Additional Library Directories.
    How to do it...
  9. Add the GLFW and OpenGL libraries (glu32.lib, glfw3.lib and opengl32.lib) by navigating to Configuration Properties | Linker | Input | Additional Dependencies.
    How to do it...
  10. Build Solution (press F7).
  11. Run the program (press F5).

Here is your first OpenGL application showing a rotating triangle that is running natively on your graphics hardware. Although we have only defined the color of the vertices to be red, green, and blue, the graphics engine interpolates the intermediate results and all calculations are performed using the graphics hardware. The screenshot is shown as follows:

How to do it...

Compiling and running your first OpenGL application in Mac OS X or Linux

Setting up a Linux or Mac machine is made much simpler with the command-line interface. We assume that you have all the components that were discussed earlier ready, and all default paths are used as recommended.

Getting ready

We will start by compiling the sample code described previously. You can download the complete code package from the official website of Packt Publishing https://www.packtpub.com. We assume that all files are saved to a top-level directory called code and the main.cpp file is saved inside the /code/Tutorial1 subdirectory.

How to do it...

  1. Open a terminal or an equivalent command-line interface.
  2. Change the current directory to the working directory:
    cd ~/code
    
  3. Enter the following command to compile the program:
    gcc -Wall `pkg-config --cflags glfw3` -o main Tutorial1/main.cpp `pkg-config --static --libs glfw3`
    
  4. Run the program:
    ./main
    

Here is your first OpenGL application that runs natively on your graphics hardware and displays a rotating triangle. Although we have defined the color of only three vertices to be red, green, and blue, the graphics engine interpolates the intermediate results and all calculations are performed using the graphics hardware.

How to do it...

To further simplify the process, we have provided a compile script in the sample code. You can execute the script by simply typing the following commands in a terminal:

chmod  +x compile.sh
./compile.sh

You may notice that the OpenGL code is platform-independent. One of the most powerful features of the GLFW library is that it handles the windows management and other platform-dependent functions behind the scene. Therefore, the same source code (main.cpp) can be shared and compiled on multiple platforms without the need for any changes.

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 New Zealand

Standard delivery 10 - 13 business days

NZ$20.95

Premium delivery 5 - 8 business days

NZ$74.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
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to New Zealand

Standard delivery 10 - 13 business days

NZ$20.95

Premium delivery 5 - 8 business days

NZ$74.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
$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
Banner background image

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