Book Image

OpenGL ES 3.0 Cookbook

By : Parminder Singh
Book Image

OpenGL ES 3.0 Cookbook

By: Parminder Singh

Overview of this book

<p>"Write once, use anywhere" is truly the power behind OpenGL ES and has made it an embedded industry standard. The library provides cutting-edge, easy-to-use features to build a wide range of applications in the gaming, simulation, augmented-reality, image-processing, and geospatial domains.</p> <p>The book starts by providing you with all the necessary OpenGL ES 3.0 setup guidelines on iOS and Android platforms. You'll go on to master the fundamentals of modern 3D graphics, such as drawing APIs, transformations, buffer objects, the model-view-project analogy, and much more. The book goes on to deal with advanced topics and offers a wide range of recipes on the light shading, real-time rendering techniques with static and procedure textures to create stunning visualizations and runtime effects.</p>
Table of Contents (21 chapters)
OpenGL ES 3.0 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Navigating the scene with a camera system


In 3D graphics, a camera allows you to navigate through the 3D space; it can be used to perform the rotation and displacement on any arbitrary axis. In OpenGL ES, there is nothing such as a camera. This has to be implemented programmatically. Implementing a camera is extremely simple. In fact, we do not require any specific OpenGL ES APIs for this and it's all about manipulating matrices. In this recipe, we will simulate a first person camera.

How to do it...

Reuse the last implement recipe and perform the following steps to implement the camera system:

  1. Create a Camera.h/.cpp file and define a Camera class derived from Object. This class contains three unit vectors: Left, Up, and Forward, which store directional unit vectors in the 3D space along the x, y, and z axis respectively. The Position specifies the location of the camera and Target specifies the location of the camera view:

       struct ViewPort{ int x, y, width, height; };
       struct CameraViewParams...