O'Reilly logo

Learning Virtual Reality by Tony Parisi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required


Virtual reality has captured the world’s imagination. Over the last few years, developers and enthusiasts in the thousands have devoted countless hours to coding, designing, and speculating about the possibilities of this exciting new medium. Affordable hardware systems like the Oculus Rift, Samsung Gear VR, and Google Cardboard VR allow consumers to experience virtual reality firsthand in the comfort of their homes, in a cafe, or on the train to work. Press coverage has reached beyond the trade press and blogosphere to mainstream publications extolling the virtues of VR, and the possibilities seem endless: from gaming and cinema to architecture, education, training, and medicine. Even though it has a long way to go, virtual reality appears poised to become the next major entertainment medium, and perhaps even the computing platform of the future.

I first tried an Oculus Rift in the summer of 2013. I was, to put it bluntly, underwhelmed. The graphics of the original development kit (the so-called “DK1”) were low-res by today’s standards, and I lasted about 10 minutes before the nausea kicked in—which, according to my friend Dave, was an impressive display of endurance. I put the device aside, grumbled “not ready,” staggered back to work, and didn’t give the matter much thought again until nine months later, when the tech industry was set on its ear by the announcement that social media giant Facebook had acquired Oculus VR, the makers of the Rift. Like many of my peers, I was stunned. Also, like many of my peers, I decided to jump right in and start developing something in VR.

Since the watershed Oculus acquisition, the industry has invested millions in developing applications, content, tools, display hardware, video capture systems, and peripherals. Big tech players are already staking out their turf, making bets on what the future will look like with respect to distribution channels, “killer apps,” and such, and creating platforms and ecosystems to align with their visions. Developers of all shapes and sizes are flocking to VR, some out of genuine excitement for a new medium with great potential, and others preparing to take advantage of what could be the next tech boom after mobile. However it all ultimately shakes out, being a VR developer promises to be an exciting ride.

Every journey begins with a first step, and this book is here to set you on your path. It’s not deep; the goal is to familiarize you with core programming concepts, and the innovations in hardware and software that have made VR possible. It is broad: we cover three of the major platforms, using three different development environments and as many programming languages. By the end, you should come away with the feeling that you understand the basics, and a desire to learn more.


This book was written for programmers and designers looking for an introduction to virtual reality development. It assumes at least entry-level programming experience, but you don’t have to be a professional developer to read it. Creative coders, producers with a programming background, and technically savvy artists should also be able to follow along. I want anyone who likes to make things on a computer to be able to walk away having learned something from this book.

Readers should know the basics of JavaScript, Java, C#, or another C-family programming language. Experience with 3D graphics is also helpful. If you don’t have 3D experience, Chapter 3 contains a primer that you may find useful.

If you are a professional developer, a lot of this material will seem basic to you. But go through it carefully: interleaved with the how-tos and 101s are essential nuggets of technical information for putting together desktop, mobile, and web VR apps. It represents many hours of carefully working through the details of various tools, SDKs, APIs, and operating systems, including suffering through a few major upgrades that were sprung on me halfway through writing the manuscript. Maybe my effort will help save you from hitting those same land mines along the way.

If you are a native developer of mobile and desktop apps, and know Unity3D or another game engine, then this book should help you extend your skills into VR. If you are comfortable developing for WebGL, then you should have an easy time creating VR for the Web with the introduction of just a few new concepts. If you are a newbie at both, no worries; I like to think I wrote the book in a way that will get you going, no matter your starting point.

How This Book Is Organized

This book is divided into seven chapters, as follows:

  • Chapters 1 and 2 provide an introduction to virtual reality concepts and survey the new hardware systems coming to market.
  • Chapters 3 through 6 cover virtual reality development in detail. This is the heart of the book, in which we look at developing for three of the major virtual reality hardware systems: the Oculus Rift, Gear VR, and Cardboard VR. These chapters explore different tools for creating VR applications, including Unity3D and Android Studio, as well as several programming languages. There is also a chapter about creating web-based VR applications using WebVR, a new JavaScript API supported in development versions of popular browsers like Firefox and Chrome.
  • Chapter 7 brings the concepts introduced in Chapters 3 through 6 together in a simple working application: a 360-degree panoramic VR photo viewer for Google Cardboard, built in Unity3D.

Conventions Used in This Book

The following typographical conventions are used in this book:


Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, objects, parameters, and values.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.


This element signifies a general note.

Using Code Examples

Supplemental material for this book is available for download at https://github.com/tparisi/LearningVirtualReality and https://github.com/tparisi/WebVR.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning Virtual Reality by Tony Parisi (O’Reilly). Copyright 2016 Tony Parisi, 978-1-4919-2283-5.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

About Third-Party Copyrighted Material

Note that some of the content assets used in this book are subject to copyright. Their creators have kindly granted me permission to redistribute them for use with the book for the sole purpose of supporting the programming examples included. For any other purpose, including and especially use in your applications, you must obtain your own copies of those assets, which may include purchasing a license.

Safari® Books Online

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.

Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/learning-virtual-reality.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia


It takes a village to make a good VR book, and I was able to lean on some great developers to get my job done. “That VR Guy” Dave Arendash and Alex Sink of RIVER Studios provided much-needed expert information on using Unity3D. Patrick Chen and Andrew Dickerson from Samsung lent early moral support (and a Gear VR) to get me going with mobile development. The WebVR brain trust, including Josh Carpenter, Vlad Vukićević, Diego Marcos, and Brandon Jones, have been stalwart, always ready with advice and answers to questions, and always willing to consider an API design change.

I am grateful for the excellent technical reviews done for the book, especially the review by my friend and startup collaborator Jason Marsh. Jason worked through the code examples in painstaking detail, and identified several critical issues. Jason also contributed the beautiful panoramic photos featured in the example in Chapter 7.

I would like to thank the team at O’Reilly, especially my editor, Meg Foley. Meg was exceedingly patient with my halting progress due to conflicting startup commitments. She also gave me much-needed encouragement when I hit a snag and had to rewrite several chapters due to massive changes in the Oculus SDK software. That’s life on the bleeding edge, I guess, but nevertheless, Meg has been a champ.

Finally, thanks to my family. Marina and Lucian are used to my book-writing antics by now, but each one is a new exercise in forbearance. Guys, you’re the best.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required