Android glDrawTexiOES图形在旋转显示时被截断

Android glDrawTexiOES图形在旋转显示时被截断,android,opengl-es,opengl-es-1.1,Android,Opengl Es,Opengl Es 1.1,我正在开发一个2D游戏,它使用本机代码绘制单个OpenGL 2D纹理。然后,纹理将在屏幕上绘制,保持不变。除非显示器旋转,否则代码工作正常。游戏继续正常运行,但纹理被截短并偏离屏幕中心。如果以任何方向开始游戏,游戏都会正常进行,但如果方向发生变化,则会出现绘制问题。我正在正确处理方向更改,以便不破坏GL上下文,并且正确计算每个方向的图形参数。我唯一能想到的是,在处理onSurfaceChanged事件时,我可能遗漏了一些步骤。以下是onSurfaceChanged调用的本机代码: if (pTe

我正在开发一个2D游戏,它使用本机代码绘制单个OpenGL 2D纹理。然后,纹理将在屏幕上绘制,保持不变。除非显示器旋转,否则代码工作正常。游戏继续正常运行,但纹理被截短并偏离屏幕中心。如果以任何方向开始游戏,游戏都会正常进行,但如果方向发生变化,则会出现绘制问题。我正在正确处理方向更改,以便不破坏GL上下文,并且正确计算每个方向的图形参数。我唯一能想到的是,在处理onSurfaceChanged事件时,我可能遗漏了一些步骤。以下是onSurfaceChanged调用的本机代码:

if (pTexture)
       free(pTexture);
pTexture = malloc(iTexturePitch * iTextureHeight);

rect[0] = 0;
rect[1] =  iHeight; // w,h fit within the texture size
rect[2] =  iWidth;
rect[3] = -iHeight;

glDeleteTextures(1, &s_texture);
while (*start)
   glDisable(*start++); // disable unused options
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &s_texture);
glBindTexture(GL_TEXTURE_2D, s_texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glShadeModel(GL_FLAT);
glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);
用于显示纹理的代码:

    glClear(GL_COLOR_BUFFER_BIT);
    glTexImage2D(GL_TEXTURE_2D,     /* target */
        0,          /* level */
        GL_RGB,         /* internal format */
        iTextureWidth,      /* width */
        iTextureHeight,     /* height */
        0,          /* border */
        GL_RGB,         /* format */
        GL_UNSIGNED_SHORT_5_6_5,/* type */
        pTexture);      /* pixels */
    // border x/y for centering; stretched x/y is the destination size on the display
    glDrawTexiOES(iBorderX, iBorderY, 0, iStretchedWidth, iStretchedHeight);