BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.85k stars 605 forks source link

FillMode issue from iPhone to iPad #210

Closed doudouperrin closed 6 years ago

doudouperrin commented 6 years ago

Hello there, I am facing an issue with FillMode behavior. I use .preserveAspectRatioAndFill for my preview. Everything is OK with iPhone, but on iPad, the ratio is not respected (it fills the screen though).

After digging, I highlighted that the backingSize defined in RenderView class was wrong, compared to my real ipad screen size (on iPad, backingSize had a 1.77 ratio instead of expected 1.33) ==> WTF?

I don't know why I had this idea, in storyboard, I switched from iPhone display to iPad display...... And voilà ! the video preview is correct and the backingSize ratio is 1.33! But now it is wrong on iPhone...

Here is how backingSize is defined (Brad's code): var backingWidth:GLint = 0 var backingHeight:GLint = 0 glGetRenderbufferParameteriv(GLenum(GL_RENDERBUFFER), GLenum(GL_RENDERBUFFER_WIDTH), &backingWidth) glGetRenderbufferParameteriv(GLenum(GL_RENDERBUFFER), GLenum(GL_RENDERBUFFER_HEIGHT), &backingHeight)

backingSize = GLSize(width:backingWidth, height:backingHeight)

Why does this behavior happen? I always thank that this "switch to device" feature on storyboard was only to help interface design. I am surprised to see that it has an incidence on OpenGL display...

What can I do or check to be sure that the ratio is correct on iPhone AND iPad and fix that issue?

Thanks a lot

doudouperrin commented 6 years ago

Actually it is not a issue with GPUImage2. I fixed it by creating the renderView programmaticaly settings the frame with screen size inside my Controller.