3D Maths and OpenGL -- how and where do I get started?

I’m a big fan of 3D, so it goes without saying that, being a game developer, I want to learn OpenGL. LWJGL, in fact, because I use Java. But which API I use is irrelevant in this thread because what I really want to know is – how do I get started with 3D maths?.

Yes, yes, I’ve heard of loads of books, 3D Math Primer for Graphics and Game Development being the most popular among most people. But does it cover everything I need to know about 3D maths, or are there a couple of other important (nothing is unimportant in programming anyway) topics I need to know about? I haven’t read much and all I know about 3D maths right now is how to generate a sphere, how to use matrices, how to use vectors and of course, the Cartesian coordinates system. And I know a bit about trigonometry – just the basics (I’m still 13). Despite my age, which does not limit the rate at which I learn things, I wish to learn OpenGL and 3D maths. Scratch what I said earlier about this thread not being about OpenGL – I’m still a noob when it comes to OpenGL, though I can create a rotating cube and a circle of cubes (using parametric equations). Where did all of you learn about back-face culling and well…everything? How did you guys learn OpenGL? Where did you start?

I would appreciate any sort of answer. Thanks in advance :smiley:

EDIT: I’ve been following ThinMatrix’s tutorials and he’s a great dude and he takes time to help his subscribers. Still, he skims over the maths part, especially with the terrain generation and projection matrices.

Back-face culling is just checking to see if the polygon’s surface normal faces the camera’s position.

if (normal.dot(cameraPosition) < 0) {

// This is a back face, don’t draw it

}

However, remember back face culling is done automatically by OpenGL if you enable it.

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); // GL_BACK by default
glFrontFace(GL_CCW); // or GL_CW

See this page for more details: https://www.opengl.org/wiki/Face_Culling

I never watched it till the end. But TheBennyBox (youtube) has a tutorial which is neat! (As far as I watched)

He used the LWJGL (2) and explained the math (quaternions aso).

-ClaasJG

I learned a lot from Linear Algebra class at my university. However, I needed more info related to computer graphics.
After searching around I came across this book. It’s old but very handy: Mathematics for Computer Graphics Applications (mostly useful for if you get around to working on physics)

Also the best book on OpenGL has to be: Anton’s OpenGL Tutorials

For things involving math in game dev this guys tutorials are really great: https://www.youtube.com/playlist?list=PLW3Zl3wyJwWOpdhYedlD-yCB7WQoHf-My there in no particular order, so if I’m stuck with a particular concept i see if he has a video on it, and more often than not he does. Also good on you for starting so early, the younger you start the better really :D.

When it comes to vector maths in the context of game dev, my absolute favourite is http://www.wildbunny.co.uk/blog/vector-maths-a-primer-for-games-programmers/.

Thanks guys :smiley: I’ll be sure to try your suggestions out!

Didn’t you already start a topic similar to this one?

Nope, two completely different topics. The thread you’re talking about is actually about how much 3D maths I need to know in order to make games in JME. This one is about how and where to learn 3D maths and OpenGL. OpenGL isn’t a game engine, it’s only a graphics library. And it’s low-level. JMonkeyEngine is built atop OpenGL, so you need a little more 3D Math knowledge to make games in plain OpenGL, since you’re dealing with a lot more backend stuff.

The answer is still the same, you still need around the same knowledge. For programming games with or without an engine, linear algebra and trig are pretty much essential.

It’s the same math regardless, and it never hurts to know more.

It’s the same math but I think that he’s right. There are much more things to know when you have to fill the gap between what a 3D engine based on top of OpenGL does and what OpenGL does, especially when you use modern OpenGL. You have to write your own shaders to do what the fixed pipeline does, the matrix stack, the lighting, … When you’re only a client of the higher level API, as long as it works as expected, you don’t have to rewrite the build-in shaders, you can use JMonkeyEngine 3 without knowing what Phong shading is, some engines contain some maths utilities to avoid gimbal lock… I encourage the developers to understand what they use, I agree with the last part of your sentence but I don’t deny that it’s possible to use Java3D, JMonkeyEngine or JogAmp’s Ardor3D Continuation with only a very basic understanding of geometry in 3D (translation, rotation, scale, local/world transforms) in certain limits. However, there are some prerequisites for the both (with or without an engine). Being comfortable with matrices, quaternions, trigonometry and linear geometry helps.

I’ve learnt a fair bit of OpenGL now (instanced rendering, VAOs, VBOs, etc.) and the knowledge really helps me debug applications using APIs like JavaFX, which was built atop OpenGL. If you’re trying to make a game with graphics like those in triple A games, I don’t think you’d want to try doing the entire thing in plain OpenGL :stuck_out_tongue:

OpenGL is pretty low-level, and sometimes I just give up on trying to create a 3D game in plain OpenGL. Making 2D games in OpenGL isn’t a problem though.

JavaFX uses software rendering, I’m pretty sure.

You shouldn’t be trying to make a game with triple A graphics. If you’re still learning it, steer away from 3D and stick with 2D. See what you can do with it and try to implement some common rendering practices like scenegraphs, deferred shading, and FBOs/Post Processing. You’ll learn allot more than just trying to do a 3D project straight up.

JavaFX/OpenJFX has several hardware accelerated pipeline including one based on Direct3D and another one based on OpenGL ES 2. There is a fallback based on Java2D which is the closest thing that you can consider as a code path using software rendering.

I agree with you, trying to make a AAA game alone is a very bad idea especially for a beginner and trying to learn too much things at the same time is risky too.

JavaFX/OpenJFX is internally designed with hardware acceleration in mind but it’s really obvious for those who don’t look at its source code when looking at its 3D graphics API. However, its OpenGL ES 2 pipeline isn’t bundled by default under Windows. Actually, JavaFX 1 was built on top of JOGL 1 and a contributor recently implemented an hardware accelerated pipeline for JavaFX 8 based on JOGL 2:

I think that almost nobody here really aims to make a “game with graphics like those in triple A games” and I think that we have to start by the beginning.

Vulkan is even more low-level than OpenGL. Creating a game in plain OpenGL is doable but you end up by reinventing… yet another scenegraph API or something similar :slight_smile: It’s still a nice way to learn lots of things.