opengl_learn

Step-by-step introduction to OpenGL
git clone https://0xdd.org/code/opengl_learn.git
Log | Files | Refs | README | LICENSE

ogl_mat4f_translate.c (726B)


      1 /*
      2 2018 David DiPaola
      3 licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
      4 */
      5 
      6 #include "ogl.h"
      7 
      8 void
      9 ogl_mat4f_translate(
     10 	struct ogl_mat4f matrix, struct ogl_vec3f translation,
     11 	struct ogl_mat4f * out_result
     12 ) {
     13 	/* see OpenGL 2.1 glTranslate(): https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml */
     14 	/* note: glTranslate() was deprecated, then removed from later OpenGL versions. don't use it */
     15 
     16 	struct ogl_mat4f translation_matrix = { .values = {
     17 		1.0f, 0.0f, 0.0f, translation.x,
     18 		0.0f, 1.0f, 0.0f, translation.y,
     19 		0.0f, 0.0f, 1.0f, translation.z,
     20 		0.0f, 0.0f, 0.0f,          1.0f,
     21 	}};
     22 	ogl_mat4f_multiply(matrix, translation_matrix, out_result);
     23 }
     24