I'm just wondering how anyone can make 2D games in OpenGL. I have sprites, but when I load them in game, they're all big and stuff, not pixel for pixel how I'd like them. How can I do this?
OpenGL expects the vertex positions you give to be in "clip space"... which is the same as "NDC space" before the perspective division.
In 2D, you won't have perspective division, so you can think of clip space and NDC space as the same thing.
X=-1 is the left edge of the screen
X=+1 is the right edge
Y=-1 is the bottom
Y=+1 is the top
These are the cords OpenGL expects to get regardless of your window size. So if you are outputting positions that have X=10 because you want your object to be 10 pixels wide... that is wrong because X=10 is waaaaaaay offscreen.
You need to transform/scale your output positions to conform to NDC space. This is usually done by multiplying the positions by some kind of projection matrix. In modern OpenGL this would be done by your vertex shader.
This might help http://www.arcsynthesis.org/gltut/Positioning/Tut04%20Perspective%20Projection.html it is from the tutorials Disch suggested. I would highly suggest going through them since they seem to be very informative (Also wanted to say thanks for introducing me to that tutorial Disch).
No you need to scale your positions so that the final coords you give OpenGL fall between -1 and +1. Anything outside that range is "offscreen" and won't be displayed.
For example... if you want your coords to be pixels... and you have a 800x600 screen...
If you want to draw an object at pixel coord 20,80 (20 pixels from the left, 80 pixels from the bottom), you'd have to scale it like so:
Though I really recommend you read that arcsynthesis tutorial I linked. I can give you the magical math you need to make this work, but reading that tutorial will explain how it all works and you'll be able to come up with this on your own.
If you want to make it easier on yourself, you can use the openGL math library (glm) to make vector and matrix math easier. It's also a header only lib, so you don't have to worry about linking.
It's good to learn how it all works beforehand, so that you understand what you're doing though.
1 2 3 4 5
glm::mat4 scale_mat = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
//this gets you a transformation matrix which will scale a 3d vector by .5
glm::mat4 scale_mat = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f, .1f, .3f));
//this gets matrix for scaling by .5 in x dim, .1 in y dim, and .3 in z dim
glm also has the functionality to make perspective matrices, view matrices, rotation matrices, translation matrices, and so forth. What's nice about it is that the operators such as +, -, *, and /, are overloaded to do the appropriate math when multiplying vectors/matrices/scalars.