Android OpenGL ES,使用2D纹理的奇怪质量

时间:2012-12-20 12:27:41

标签: android opengl-es textures

经过长时间的搜索,我没有找到解决问题的方法,所以这里是:

我有以下精灵:

http://i46.tinypic.com/rmji2d.png"“>

但在我使用OpenGLSurface的游戏中,使用2d纹理看起来像这样:

http://i47.tinypic.com/2wqb9qs.png"“>

我在纹理中使用的选项是:

public void onSurfaceCreated(GL10 gl, EGLConfig confid) {
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glClearColor(255,255, 255,0);
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_BLEND);
gl.glDisable(GL10.GL_DEPTH_TEST);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

}

 public void loadTextures(GL10 gl, Context context) {
 gl.glGenTextures(textureCount, textures, 0);
    for (int loop = 0; loop < textureCount; loop++) {
        gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[loop]);
        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
                GL10.GL_LINEAR);
        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
                GL10.GL_LINEAR);
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, // OpenGL docs.
                GL10.GL_NICEST);
        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap[loop], 0);
        bitmap[loop].recycle();
    }
}

只是这种奇怪,因为我正在缩放图像,使它更短吗? 有什么我可以做的更好的图形?

添加了抽奖:

public void draw(GL10 gl) {
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
    for (int loop = 0; loop < sprites.size(); loop++) {
        gl.glPushMatrix();
        try {
            DevQuestSprite sprite = sprites.get(loop);
            sprite.update(screenHeight); // update enemy
            gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[sprite.curSprite]);
            float transx = (wRatio * sprite.x);
            float transy = (screenHeight * wRatio) - (wRatio * sprite.y)
                    - 1 / hRatio;
            gl.glTranslatef(transx, transy, 0.0f);

            sprite.draw(gl);
        } catch (NullPointerException e) {
        }
        gl.glPopMatrix();
    }
}

0 个答案:

没有答案