Is it necessary to also know OpenGL with SDL?

Is it important to know OpenGL?

I’ve been reading OpenGL tutorials for a while now, I’ve learn that the coordinate system between pure SDL and OpenGL isn’t the same.

In SDL you get to deal with the same thing as you would in canvas and all I’ve seen before getting to know the OpenGL. The origin mostly starts from the top left of the screen, but in OpenGL the coordinate system is different.

For example, if you want to setup the viewport, origin starts at bottom left of the screen.

But it you are working on textures, t = 0 is top t = 1 is bottom, and then s = 0 is left, s = 1 is right
and for vertexes, origin starts at the center of the viewport and minus to the left for X, and to the top for Y.

Why they’re different? And it it better, or faster to work with these coordinate systems instead of just with the pure SDL

Thank you very much!

OpenGL by default uses screen coordinates with the origin in the bottom left, this is mostly a carry-over from IrisGL. When you’re plotting a graph, for instance, it’s standard to have Y axis’ origin at the bottom, and that’s (basically, AFAIK) why it was like that in IrisGL. And since OpenGL was based on IrisGL…

And since screen coordinate origin is the bottom left, then for consistency so are the texture coordinates.

As to “vertex origin starts at the center of the viewport”, now you’re talking about NDC (Native Device Coordinates). This is what vertex coordinates get converted to by multiplying them against the projection and modelview matrix. If the OpenGL tutorial you’re following has you specifying vertex coordinates in NDC then it’s probably still early in the tutorial.

As for SDL, it uses the top-left-origin screen coordinates you’re used to, and you don’t need to know any OpenGL at all to use it for 2D stuff.

Fun fact: SGI IRIX, the operating system IrisGL was invented for, had the entire UI based on bottom-left screen coordinate origins. So did/does macOS.

Hi, I’ve just started learning this a couple of days ago and still working on it. The total number of lecture is 37, now I’m only on number 7. :stuck_out_tongue: This tutorial only covers 2D aspect of OpenGL. They said it would be as much as 3 times larger if it also covers the 3D part.

By the way, thanks for the info.