I am trying to make a 3D camera for my game. I think I might need to use the glViewport method but I am extremely new to OpenGL. Can someone please help?
This is a bit disturbing considering you just asked if people wanted to work together with you on the said game.
There are mainly three types of 3D cameras, excluding the methods they are implemented like First Person Shooter (FPS) camera, Free-Flying 6DOF (6 Directions of Freedom) camera, and Arcball Camera (I don’t know much on this one).
Writing a camera basically requires that you need to understand some Math, especially on how transformations are done, you need to program with Matrices, Vectors and Quaternions. Which type of camera are you trying to make?
Take a look at this Wikipedia article on 3d projection. (the diagram at the end helped me the most but everything is important)
Camera using shaders:
You need:
- projection matrix. Either ortho or perspective. In your case perspective.
- View matrix, camera’s rotation and negative translation.
You multiply these two by the trans matrix and vertex position in your shader.
All matrices described are mat4s there are tons of resources on how to create these projections and the math required.
Tips:
- Use quaternions for rotation. Euler angles are lame.
- Do as much math outside of shades as possible. For example proj * view = projview uniform. Instead of 2 uniforms
- Try not to branch in glsl.
Thought the exact same thing… clearly OP isn’t prepared for what he is trying to undertake. Good luck to you.