diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2016-04-25 23:13:19 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2016-04-25 23:13:19 +0200 |
commit | d687bd910f073bcae853c7f46f6cbe6b88ad66f5 (patch) | |
tree | c19d97d9558872e51f41102c5bc73cf8fb3a9ea1 | |
parent | a6d0ebd66b0ca5f4125df72fa96e3ef6bdb8d2ad (diff) | |
download | pointoverdrawbench-d687bd910f073bcae853c7f46f6cbe6b88ad66f5.tar.gz pointoverdrawbench-d687bd910f073bcae853c7f46f6cbe6b88ad66f5.tar.bz2 |
keep ratio of window filled constant regardless of aspect
-rw-r--r-- | linmath.h/linmath.h | 12 | ||||
-rw-r--r-- | main.c | 29 | ||||
-rw-r--r-- | shaderloader/shaderloader.c | 2 |
3 files changed, 37 insertions, 6 deletions
diff --git a/linmath.h/linmath.h b/linmath.h/linmath.h index d21fd7d..70b15a4 100644 --- a/linmath.h/linmath.h +++ b/linmath.h/linmath.h @@ -1,6 +1,18 @@ #ifndef LINMATH_H #define LINMATH_H +#if __STDC_VERSION__ < 199901L +# ifndef inline +# if defined(_MSC_VER) +# define inline __inline +# elif defined(__GNUC__) +# define inline __inline__ +# else +# define inline +# endif +# endif +#endif + #include <math.h> #include <string.h> @@ -163,11 +163,30 @@ void display(void) mat4x4_identity(proj); float const fov = 0.5; - mat4x4_frustum(proj, - -window.aspect*fov, - window.aspect*fov, - -fov, - fov, 1, 5); +#if 0 + if( 1. <= window.aspect ) { + mat4x4_frustum(proj, + -fov*window.aspect, + fov*window.aspect, + -fov, + fov, + 1, 5); + } else { + mat4x4_frustum(proj, + -fov, + fov, + -fov/window.aspect, + fov/window.aspect, + 1, 5); + } +#else + mat4x4_frustum(proj, + -fov, + fov, + -fov, + fov, + 1, 5); +#endif mat4x4 mv; mat4x4_identity(mv); diff --git a/shaderloader/shaderloader.c b/shaderloader/shaderloader.c index a135a98..b19fe33 100644 --- a/shaderloader/shaderloader.c +++ b/shaderloader/shaderloader.c @@ -202,7 +202,7 @@ GLuint shader_load_from_files( shader_infolog ); fprintf(stderr, "shader compilation failed; sources:\n"); for(i = 0; i < filecount; i++) { - fprintf(stderr, " %.2d: %s\n", i, filepaths[i]); + fprintf(stderr, " %.2u: %s\n", (unsigned)i, filepaths[i]); } fputs("compile log:\n", stderr); fwrite(shader_infolog, returned_length, 1, stderr); |