Book Image

OpenGL Data Visualization Cookbook

Book Image

OpenGL Data Visualization Cookbook

Overview of this book

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.
Table of Contents (16 chapters)
OpenGL Data Visualization Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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.

  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.

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.

  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.

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.