Skip to main content
Engineering LibreTexts


  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    This textbook represents my attempt to develop a modern, one-semester first course in computer graphics, which would typically be taken by a computer science student in the third or fourth year of college. (Whether it will continue to be appropriate is an open question, given the always-rapid changes in the field of computer graphics.)

    A reader of this book should have substantial experience with at least one programming language, including some knowledge of object-oriented programming and data structures. Everyone taking my own computer graphics course has had at least two semesters of programming, and most will have additional experience beyond that. My students have studied the Java programming language, but the book should also be accessible to people with background in other languages. Examples in the book use Java, C, and JavaScript. The essential features of those languages are covered in an appendix. (If you need to learn programming from the beginning, try my free introductory Java textbook, which is available at

    I used Version 1.0 of this book for a course in Fall 2015. Version 1.1 corrected some errors and typos and added some material. It was used in the Fall 2017 version of my course. The current version of the book, Version 1.2, makes more corrections, but the major change is that the chapter on three.js has been updated to use Release 89 of three.js.

    The home web site for this book is The page at that address contains links for downloading a copy of the web site and for downloading PDF versions.

    This is a free textbook. You are welcome to redistribute it, as long as you do not charge for it. You can make and distribute modified versions (including translations), as long as your version makes the original source clear and is distributed free of charge. (Officially, the book is licensed under a “Creative Commons Non-Commercial Attribution Share-Alike License.”)

    Many of the sample programs for this book are actually Web pages meant to be viewed in a Web browser. The Web version of this book includes interactive demo programs that are integrated into the Web pages that make up the book.

    The sample programs and demos use HTML canvas graphics (in Chapter 2) or WebGL (in later chapters). Canvas graphics should work well in almost any modern browser. WebGL is a newer technology and is more problematic. It is implemented in all modern desktop browsers. It also runs in many browsers on newer mobile devices. However, each of those browsers have had some problems with some of my programs on some machines. Firefox and Chrome seem to work most consistently. I wish I could be more definite than that, but the reality of WebGL at this point is that you might have to look for a combination of computer and browser that will work for you.

    The sample programs and demos can all be found in the download of the web site version of this book, which is available from its main page at Look for them in the folders named source and demo. Note that some Web browsers won’t use images from the local file system in canvas and WebGL graphics. Those browsers will have errors when they try to run some of the samples locally instead of over the Web. For me, Firefox can run such examples. This issue affects only some of the examples.

    I have taught computer graphics every couple of years or so for almost 30 years. As the field developed, I had to make major changes almost every time I taught the course, but for much of that time, I was able to structure the course primarily around OpenGL 1.1, a graphics API that was in common use for an extended period. OpenGL 1.1 supported fundamental graphics concepts in a way that was fairly easy to use. OpenGL is still widely supported, but, for various reasons, the parts of it that were easy to use have been officially dropped from the latest versions (although they are in practice supported on most desktop computers). The result is a much more powerful API but one that is much harder to learn. In particular, modern OpenGL in its pure form does not make for a good introduction to graphics programming.

    My approach in this book is to use a subset of OpenGL 1.1 to introduce the fundamental concepts of three-dimensional graphics. I then go on to cover WebGL—a version of OpenGL that runs in a web browser—as an example of the more modern approach to computer graphics. While OpenGL makes up the major foundation for the course, the real emphasis is on fundamental concepts such as geometric modeling and transformations; hierarchical modeling and scene graphs; color, lighting, and textures; and animation.

    Chapter 1 is a short overview of computer graphics. It introduces many concepts that will be covered in much more detail in the rest of the book.

    Chapter 2 covers two-dimensional graphics in Java, JavaScript, and SVG, with an emphasis on ideas such as transformations and scene graphs that carry over to three dimensions.

    Chapter 3 and Chapter 4 cover OpengGL 1.1. While OpenGL 1.1 is fairly primitive by today’s standard, it includes many basic features that are still fundamental to three-dimensional computer graphics, in a form that is an easier starting point for people new to 3D graphics. Only part of the API is covered.

    Chapter 5 covers three.js, a higher-level 3D graphics API for Web graphics using JavaScript. This chapter shows how fundamental concepts can be used in a higher-level interface.

    Chapter 6 and Chapter 7 cover WebGL, a modern version of OpenGL for graphics on the Web. WebGL is very low-level, and it requires the programmer to write “shader programs” to implement many features that are built into OpenGL 1.1. Looking at the implementation is an opportunity to understand more deeply how computers actually make 3D images.

    And Chapter 8 looks briefly at some advanced techniques that are not possible in OpenGL.

    Appendix A contains brief introductions to three programming languages that are used in the book: Java, C, and JavaScript. Appendix B is meant to get readers started with the most basic uses of Blender, a sophisticated 3D modeling program. I have found that introducing students to Blender is a good way to help them develop their three-dimensional intuition. Appendix C contains even briefer introductions to two 2D graphics programs, Gimp and Inkscape.

    • Was this article helpful?