opengl_learn

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

ogl_GLfloat_print.c (376B)


      1 /*
      2 2018 David DiPaola
      3 licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
      4 */
      5 
      6 #include <GL/glew.h>
      7 
      8 #include <stdio.h>
      9 
     10 #include <math.h>
     11 
     12 #include "ogl.h"
     13 
     14 void
     15 ogl_GLfloat_print(
     16 	GLfloat f
     17 ) {
     18 	printf("%g", f);
     19 
     20 	long int rounded = lroundf(f);
     21 	if (ogl_GLfloat_isapproxequal((float)rounded, f)) {
     22 		printf(".0");
     23 	}
     24 
     25 	printf("f");
     26 }
     27