My study notes

I hope you will find my notes useful in case you intend to study more about engine and graphics programming.

C++

C++ Super-FAQ

Questions in round brackets are the ones I find more important or difficult to grasp at first. The numbers are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.

  • Classes and Inheritance: Classes and Objects

    • 7.7 - Can a method directly access the non-public members of another instance of its class?

  • General Topics: References

    • 8.3 - What happens if you return a reference?

    • 8.4 - What does object.method1().method2() mean?

    • 8.6 - When should I use references, and when should I use pointers?

  • Beyond Classes: Inline functions

    • 9.1 - What’s the deal with inline functions?

    • 9.5 - Why should I use inline functions instead of plain old #define macros?

    • 9.6 - How do you tell the compiler to make a non-member function inline?

    • 9.7 - How do you tell the compiler to make a member function inline?

    • 9.8 - Is there another way to tell the compiler to make a member function inline?

    • 9.9 - With inline member functions that are defined outside the class, is it best to put the inline keyword next to the declaration within the class body, next to the definition outside the class body, or both?

  • Classes and Inheritance: Constructors

    • 10.3 - Can one constructor of a class call another constructor of the same class to initialize the this object?

    • 10.4 - Is the default constructor for Fred always Fred::Fred()?

    • (10.5) - Which constructor gets called when I create an array of Fred objects?

    • 10.6 - Should my constructors use "initialization lists" or "assignment"?

    • 10.8 - What is the "Named Constructor Idiom"?

    • (10.9) - Does return-by-value mean extra copies and extra overhead?

    • 10.10 - What about returning a local variable by value? Does the local exist as a separate object, or does it get optimized away?

    • (10.14) - What’s the "static initialization order 'fiasco' (problem)"?

    • 10.20 - What is the "Named Parameter Idiom"?

    • (10.22) - What is the purpose of the explicit keyword?

  • Classes and Inheritance: Destructors

    • 11.7 - Okay, okay, already; I won’t explicitly call the destructor of a local; but how do I handle the situation from the previous FAQ?

    • 11.10 - What is "placement new" and why would I use it?

    • 11.14 - Is there a way to force new to allocate memory from a specific memory area?

  • Classes and Inheritance: Assignment Operators

    • 12.3 - Okay, okay, already; I’ll handle self-assignment. How do I do it?

    • 12.4 - I’m creating a derived class; should my assignment operator call my base class’s assignment operator?

  • Classes and Inheritance: Operator Overloading

    • 13.9 - What are some guidelines / "rules of thumb" for overloading operators?

    • 13.10 - How do I create a subscript operator for a Matrix class?

    • 13.14 - How can I overload the prefix and postfix forms of operators ++ and --?

    • 13.15 - Which is more efficient: i++ or ++i?

  • Classes and Inheritance: Friends

    • 14.3 - What are some advantages/disadvantages of using friend functions?

    • 14.5 - Should my class declare a member function or a friend function?

  • General Topics: Memory Management

    • 16.4 - Why should I use new instead of trustworthy old malloc()?

    • 16.8 - Do I need to check for null before delete p?

    • 16.10 - In p = new Fred(), does the Fred memory "leak" if the Fred constructor throws an exception?

    • 16.21 - How can I force objects of my class to always be created via new rather than as local, namespace-scope, global, or static?

  • Beyond Classes: Exceptions and Error Handling

    • 17.2 - I’m still not convinced: a 4-line code snippet shows that return-codes aren’t any worse than exceptions; why should I therefore use exceptions on an application that is orders of magnitude larger?

    • 17.3 - How do exceptions simplify my function return type and parameter types?

    • 17.4 - What does it mean that exceptions separate the "good path" (or "happy path") from the "bad path"?

    • 17.8 - How can I handle a constructor that fails?

    • 17.9 - How can I handle a destructor that fails?

    • 17.10 - How should I handle resources if my constructors may throw exceptions?

  • General Topics: Const Correctness

    • 18.5 - What’s the difference between “const X* p”, “X* const p” and “const X* const p”?

    • 18.7 - Does “C& const x” make any sense?

    • 18.10 - What is a "const member function"?

    • 18.12 - What’s the deal with "const-overloading"?

    • (18.13) - What do I do if I want a const member function to make an "invisible" change to a data member?

    • 18.15 - Why does the compiler allow me to change an int after I’ve pointed at it with a const int*?

  • Classes and Inheritance: Inheritance — virtual functions

    • 20.3 - What’s the difference between how virtual and non-virtual member functions are called?

    • 20.4 - What happens in the hardware when I call a virtual function? How many layers of indirection are there? How much overhead is there?

    • 20.5 - How can a member function in my derived class call the same function from its base class?

    • 20.6 - I have a heterogeneous list of objects, and my code needs to do class-specific things to the objects. Seems like this ought to use dynamic binding but can’t figure it out. What should I do?

    • (20.7) - When should my destructor be virtual?

    • 20.8 - What is a "virtual constructor"?

  • Classes and Inheritance: Inheritance — Proper Inheritance and Substitutability

    • (21.4) - Is an array of Derived a kind-of array of Base?

    • 21.6 - Is a Circle a kind-of an Ellipse?

    • 21.8 - But I have a Ph.D. in Mathematics, and I’m sure a Circle is a kind of an Ellipse! Does this mean Marshall Cline is stupid? Or that C++ is stupid? Or that OO is stupid?

    • 21.12 - If SortedList has exactly the same public interface as List, is SortedList a kind-of List?

  • Section 22: Inheritance — Abstract Base Classes (ABCs)

    • 22.4 - What is a "pure virtual" member function?

    • 22.5 - How do you define a copy constructor or assignment operator for a class that contains a pointer to a (abstract) base class?

  • Classes and Inheritance: Inheritance — what your mother never told you

    • 23.1 - Is it okay for a non-virtual function of the base class to call a virtual function?

    • 23.3 - Should I use protected virtuals instead of public virtuals?

    • 23.4 - When should someone use private virtuals?

    • 23.5 - When my base class’s constructor calls a virtual function on its this object, why doesn’t my derived class’s override of that virtual function get invoked?

    • (23.9) - What’s the meaning of, Warning: Derived::f(char) hides Base::f(double)?

  • Classes and Inheritance: Inheritance — private and protected inheritance

    • 24.2 - How are "private inheritance" and "composition" similar?

    • 24.3 - Which should I prefer: composition or private inheritance?

    • 24.5 - How is protected inheritance related to private inheritance?

    • 24.6 - What are the access rules with private and protected inheritance?

  • Classes and Inheritance: Inheritance — Multiple and Virtual Inheritance

    • 25.4 - What are some disciplines for using multiple inheritance?

    • 25.5 - Can you provide an example that demonstrates the above guidelines?

    • (25.9) - Where in a hierarchy should I use virtual inheritance?

    • 25.10 - What does it mean to "delegate to a sister class" via virtual inheritance?

  • General Topics: Built-in / Intrinsic / Primitive Data Types

    • 26.12 - How can I tell if an integer is a power of two without looping?

    • 26.13 - What should be returned from a function?

  • Overview Topics: Coding Standards

    • 27.10 - Are there any lint-like guidelines for C++?

  • Overview Topics: Newbie Questions & Answers

    • 29.5 - What are the criteria for choosing between short / int / long data types?

    • 29.7 - Why would I use a const variable / const identifier as opposed to #define?

    • 29.17 - Why doesn’t my floating-point comparison work?

    • 29.18 - Why is cos(x) != cos(y) even though x == y? (Or sine or tangent or log or just about any other floating point computation)

    • (29.19) - What is the type of an enumeration such as enum Color? Is it of type int?

    • 29.20 - If an enumeration type is distinct from any other type, what good is it? What can you do with it?

  • Beyond Classes: Templates

    • 35.2 - What’s the syntax / semantics for a "class template"?

    • 35.3 - What’s the syntax / semantics for a "function template"?

    • 35.4 - How do I explicitly select which version of a function template should get called?

    • (35.7) - My template function does something special when the template type T is int or std::string; how do I write my template so it uses the special code when T is one of those specific types?

    • 35.9 - But most of the code in my template function is the same; is there some way to get the benefits of template specialization without duplicating all that source code?

    • 35.11 - So templates are overloading, right?

    • 35.16 - Why do I get linker errors when I use template friends?

    • 35.18 - Why am I getting errors when my template-derived-class uses a nested type it inherits from its template-base-class?

    • 35.19 - Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?

    • 35.22 - Follow-up to previous: can I pass in the underlying structure and the element-type separately?

Topics

A list of concepts, ideas, idioms, patterns and keywords to understand and remember. The numbers in round brackets are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.

More topics

A second list of concepts to keep in mind, only a bit harder this time. As before, the numbers in round brackets are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.

For optimizations have also a look at Optimizing software in C++ and at the other free optimization books by Agner Fog. Another free C++ book is The C++ Annotations.

C++11

The book "Effective Modern C++" by Scott Meyers is a must-have. Chapters and items are references to this book.

Math and geometry

Books

Read about the same math concepts on more than one book. Some books are targeted to game developers, like:

  • "Essential Mathematics for Games and Interactive Applications" by James M. Van Verth and Lars M. Bishop

  • "3D Math Primer for Graphics and Game Development" by Fletcher Dunn and Ian Parberry

  • "Mathematics for 3D Game Programming and Computer Graphics" by Eric Lengyel and John Flynt

Algorithms and more

CPU

Important links from Wikipedia about the architecture of a CPU. One of the book you could read to learn more on the subject is "Computer Architecture: A Quantitative Approach" by David A. Patterson.

Multi-threading

One of the book on the topic is "The Art of Multiprocessor Programming" by Maurice Herlihy and Nir Shavit

Graphics

Mobile GPUs architecture

The book "OpenGL ES 3.0 Programming Guide" by Dan Ginsburg and Budirijanto Purnomo is a must-have.

Graphics techniques

Older resources

More topics

Data Oriented Design