GlViewport different result in Android and iOS

I just got started with a renderer for my cross platform platform (iOS and Android) using opengl es. When I got to the viewport stuff (which is required for splitscreen files) and noticed there is a difference between iOS and Android. Here are two images.

Android There is actually another glitch. It seems to be wrapped up.

Android quarter sized viewport

IOS

iOS quarter size viewport

My question. Which of the two is correct? I have no transforms, but one to bring back a little back quad. glTranslatef (0.0f, 0.0f, -5.f);

Initialization code:

glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);            //Enable Smooth Shading
glClearColor(0.f, 0.f, 0.f, 1.0f);  //Black Background
glClearDepthf(1.0f);                    //Depth Buffer Setup
glEnable(GL_DEPTH_TEST);            //Enables Depth Testing
glDepthFunc(GL_LEQUAL);             //The Type Of Depth Testing To Do

//Really Nice Perspective Calculations
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

      

Viewport and project code

glViewport(viewportX, viewportY, viewportW, viewportH);.

glEnable(GL_SCISSOR_TEST);
glScissor(viewportX, viewportY, viewportW, viewportH);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

      

... Finally, frustrum is evaluated and glFrustrum is set. I also used this code:

float widthH = width * .1f;
float heightH = height * .1f;
glOrthof(-widthH, widthH, -heightH, heightH, .1f, 100.f);
glScalef(widthH, heightH, 1.f);

      

Perhaps Android or iOS has something by default? I dont know.

+3


source to share


2 answers


Answering my question for anyone with the same problem.



I am using GLKView, which apparently calls glViewport for every render call, resetting what I just did in the previous frame. So if you are using GLKView, be sure to call glViewport on every frame! ... or roll your own EAGLView to have some kind of real control, which I think I'm going to.

+6


source


It looks like you are not factoring in the scale factor of the iOS device. Keep in mind that most recent iOS devices have extremely high ppi mesh displays. You can see this artifact in the lower left corner of the iOS snapshot. It only displays the bottom 25% of your texture because the entire view has a scale factor of 2.



In short, make sure you scaleFactor

factor in on iOS and use this factor in your call glScalef

.

0


source







All Articles