Merge: gamnit: intro textures, programs, camera and the globe example
authorJean Privat <jean@pryen.org>
Fri, 11 Dec 2015 00:32:20 +0000 (19:32 -0500)
committerJean Privat <jean@pryen.org>
Fri, 11 Dec 2015 00:32:20 +0000 (19:32 -0500)
Intro 3 core modules for gamnit with a lot of features:

* textures: Provices portable services to load textures. Textures are organized as trees where only the roots have the pixels data and subtextures relay load calls to the root. This structure should remain as is but more features need to be implemented, namely automating the use of offsets in the subtexture, auto reloading textures when invalidated and services to unload the textures.

* programs: Structures to organize GL programs and shaders and to facilitate access to shader variables. The main advantages of this API are static types on shader variables and the gamnit programs that can be specialized.

  I'm not 100% satisfied with the structure of GamnitProgram and GamnitProgramFromSource, but I don't have a better idea on how to organize it. Also I will probably review the implementation of how `GamnitProgram::attributes` and `uniforms` are populated, but it shouldn't change the API much.

* cameras: Add an abstract Camera class and a simple EulerCamera based on euler angles, perfect for FPS type games or top-down strategy games. These camera main feature is to produce the MVP matrix.

  More camera should be implemented, they should also be considered objects attachable to a scene when we have scenes. The EulerCamera lacks some feature, like the usual `look_at`.

These services are independent, it's clean but maybe it's not the best idea. We can't pass a camera to a mat4 shader variable, we have to manually extract the MVP matrix from the camera and pass it to the shader. Also to assign a texture to a sampler2d shader variable, we have to load the texture, assign its GL id to a texture unit and assign the unit's index as the shader variable value. This last issue could be simplified by more code in gamnit itself, but it will add coupling, it will be for a next PR.

The globe examples should replace the triangle example as the "minimal" example for gamnit. However I plan on updating it as I integrate more code into gamnit services allowing me to remove custom calls to OpenGL ES 2.0 from the example.

Pull-Request: #1890
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge