books/resources for c++ graphics programming(and maybe math too)

Started by
4 comments, last by DejaimeNeto 10 years, 4 months ago

I was about to post this in the graphics programming forum but I feel the beginner forum is a better fit, sorry if I judged incorrectly.

I am about halfway through c++ primer and I'm starting to get an itch to work on something more interesting after all those hundreds of pages of learning stuff that I already know how to do[in other languages]. I really want to get into graphics programming with c++, I mean my end goal is always to be a great game programmer/designer/developer and I always try to work on things that will get me closer to that goal, but for some reason graphics programming never really interested me until now so it's a bit behind my other skills.

I'm already a proficient programmer but I've always used different graphics libraries or simple/restricted api's(like swing) for graphics. I do have a fuzzy and basic theoretical understanding of how accelerated graphics rendering works but I could definitely benefit from an entry level 3d/graphics programming book. I don't really have much of a preference as far as opengl/directx/whatever, I just want to get close to the metal and learn as much practical/useful stuff as I can. I am planning on being a professional game programmer at some point in the future(idk how that is going to work out with the whole not being able to afford to live, let alone go to college, thing, but I have to have some kinda productive goal to work towards in my free time so I don't go crazy) and I think graphics programming/c++ will be valuable things to learn to help get me closer to that goal. So if there is any kind of industry standard or a particular api that is most frequently used by professionals I'd prefer to learn that, but I assume that the knowledge and experience I gain will by useful regardless of the specific technology that I use. I definitely want to learn to write my own shaders as I was just checking out some tech demos people posted on youtube and it really sparked my interest.

So what resources or books do you think would be most helpful for me? What technology should I learn(I'm leaning towards openGL but not very heavily)? Oh and also I will probably need to pick up some math, my highschool didn't go past geometry(alternative school) but I have completely learned up to and including pre calc, and a good amount of regular calculus too but not enough to be comparable to taking a calc 1 class. I like math a lot and I can learn it quickly when I need to, so don't recommend things based on what I already know in math because my plan is to learn math alongside graphics as needed, if there is a book that does both that'd be optimal. I do prefer books over other resources because it helps me stay focused and learn a lot about a single topic instead of jumping around the internet doing random tutorials.

Okay finally done, thanks for reading. I'm just looking for suggestions for learning resources(preferably books) as well as any other advice you want to offer based on the information in my post

Advertisement

Start at GameInstitute.com

Well - if you want to start somewhere with learning how to program graphics opengl is a great place to start. Once you learn either opengl or directx - moving to the other is not very hard - there is really just different function calls that do that same things. I like opengl because the function calls and types and everything else don't look like such eye sores in the code - and its cross platform which is nice.

Here is a list of opengl books (that you may have already found)

http://www.opengl.org/documentation/books/

But - I know you said you didn't want online tutorials - but this tutorial is really good for learning how to use shaders for lighting/shadows/drawing starting from step one...

http://ogldev.atspace.co.uk/ - its great for learning the basics and getting some cool stuff working using opengl - it will teach you a lot

As for the math... You really only need to know a few things because there are good math libraries out there to use (such as glm).. but I'll give a quick explanation..

The tutorial I listed above goes through a lot of these things

Trigonometry - understand the basic relations of a right triangle (including the sin/cos/tan relations)

Vectors - understand that a position in 3d space can be represented by 3 values - an x y and z

a position in 2d can be represented by 2 values - an x and y - this would be a 2d vector

and in general you can have n number of values represented by an n dimensional vector

Linear Algebra - you don't really have to know how to do the math behind it if you use a math library, but you need to understand that if you have 3 vertices of a triangle, each represented in 3d space by a 3d vector (actually in general the vector is 4d - but no need to worry about the 4th value yet), you can multiply these vectors by a matrix to TRANSFORM their positions to a different coordinate system - why is this useful?

Lets pretend we have a triangle represented by 3 vectors (1 for each vertex).. how would you make something in 3 dimensions appear on a 2 dimensional screen? Well it turns out you would use something called a Projection Matrix to TRANSFORM those vectors from the 3d coordinate system to a 2d screen coordinate system.. so in pseudo-code it would be something like

screenSpaceVector = ProjectionMatrix * worldSpaceVector

In general you can use this for anything though... for example if you wanted to view the world from some other point other than the origin (usually represented by a "camera") you can just create a matrix from that point and multiply the world space vector also.. so you would have

screenSpaceVector = ProjectionMatrix * CameraMatrix * worldSpaceVector

The beauty of a matrix is that it can not only transform positions from one coordinate system to another, but also rotations and scalings... so lets say you rotate the triangle, move it somewhere else in the world, and scale it to some new size... you can represent all of that information by a single 4x4 matrix (which math libraries will generate for you if you give them the position, scaling, and rotation information).. so now, you could draw that scaled/rotated/and moved triangle from the point of view of a camera (which can also have position/rotation/scaling) on a 2 dimensional screen with the following...

screenSpaceVector = ProjectionMatrix * CameraMatrix * PositionRotationScaleMatrix * worldSpaceVector

and that is basically what you do in a "vertex shader" for every vertex you want to draw. A mesh is just a collection of triangles, which each have 3 vertices - in the shader you would transform each of these vertices by multiplying their position vectors by matrices as above.. You can provide these matrices to the shader using opengl function calls and constructs. You use an opengl draw call to provide the shader with vertices, and the "vertex shader" that is currently bound (you compile and bind shaders that you write using open gl function calls) will execute once for each vertex.

from there an optional geometry shader can be executed, then each primitive will be rasterized (primitive being a set of three vertices in the case of triangle primitives) and each pixel covering the triangle will be sent to the fragment shader...

The tutorial I linked and the books on opengl will give a much deeper explanation to each of these steps, but that basically sums up drawing things using opengl

If you're wanting to brush up on math, I would recommend giving Khan Academy a look.

It's free, online with video lectures, and it also has exercises.

Hello to all my stalkers.

I know you didn't want tutorials, but one thing that bugged me for a long time was how to use shaders in OpenGL, if you go that route. If you go to the web site: http://open.gl there is a really nice explanation how shaders work. It is really a nice tutorial that explains everything you need to start out with OpenGL 3+. (Rather than resorting to the old and (soon) deprecated NeHe-tutorial.)

If you want books still (and going for OpenGL), I would recommend:

- Open GL Programming Guide (8th ed) - The official Guide to Learning OpenGL version 4.3. (NOT the old red-book)

- Open GL 4 Shading Language Cookbook (2nd ed) (David Wolff)

Forget about OpenGL version 1 and 2, they will probably be outdated sooner than you think, and you better learn about shaders sooner than later anyways. (It is not as hard as it seems, you just need the right input.)

If you want to learn in general about different rendering techniques, I can warmly recommend the following book too:

- Realtime Rendering (3rd ed) (Thomas Akenin-Möller et al.)

It is a really thick and handy book that is not going in depth about anything, but familiarises you with a lot of different concepts that has to do with rendering in general. Even though I say that the book is not going in depth on any topic, it is by no means a shallow book. It is advanced enough that you can do most things youself, or at least point you where to get more information. (The list of sources is massive - these people have read a lot of papers and books!)

For basic trigonometry and vectors, you just need a pre-calculus book, for matrices, a book on linear algebra, for polar coordinates, (complex numbers), books on digital signal processing (phasors) can be useful (for quartenions, for instance), but I think also most calculus books also handles the matter too. This book was free in the past: http://www.dspguide.com/ Edit: Is still free. The signal processing book can also be helpful to make filters too, using FIR or IIR.

I would recommend Game Engine Architecture, Jason Gregory, and maybe Real Time Rendering, Thomas Möller.

Notice that Game Engine Architecture is on its first edition, but the second edition is almost out. So, if you plan on buying it'd be wise to wait for the 2nd ed to come out and you'll have a fresh and up-to-date book.

This topic is closed to new replies.

Advertisement