summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 929ac83)
raw | patch | inline | side by side (parent: 929ac83)
author | Eric Wertz <ericdwertz@gmail.com> | |
Thu, 1 Dec 2016 18:52:57 +0000 (13:52 -0500) | ||
committer | Eric Wertz <ericdwertz@gmail.com> | |
Thu, 1 Dec 2016 18:52:57 +0000 (13:52 -0500) |
main.c | patch | blob | history |
index 109cc635d08f64b19a6a2f6b79b8d7ea9a03f4f0..ea7afc21c66e7823199912e16daf87d51f6cf001 100644 (file)
--- a/main.c
+++ b/main.c
tx2 = tx1; ty2 = ty1; tw2 = tw1; th2 = th1; //Copy old values
float aspect = (float)screen_width/(float)screen_height;
float sw, sh;
- if( (float)width / aspect >= (float)screen_height )
+ float targetheight = (float)width / aspect;
+ float targetwidth = (float)height * aspect;
+ if( targetwidth >= screen_width )
{
//Scale width, crop height
tx1 = 0.0f;
tx1 = (1.0f - tw1) / 2.0f;
}
+ printf( "target width: %f, target height: %f\n", targetwidth, targetheight );
printf( "tx: %f, ty: %f, tw: %f, th: %f\n", tx1, ty1, tw1, th1 );
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,pixels);