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

You're reading from   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

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher Packt
ISBN-13 9781782169727
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (11) Chapters Close

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

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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime