Texture doesn't draw

后端 未结 2 1886
轻奢々
轻奢々 2021-01-26 15:00

I want to draw a image to the screen, but what I get is the black square but without the texture on it. The image path is correct and loaded, because the rect have the correct s

相关标签:
2条回答
  • 2021-01-26 15:25

    I had similar problems with my textures not being drawn (black screen) when using the same open gl commands.

    To render the texture on the screen I also added some additional open gl commands to draw the texture using a vertex shader.

    See this project for using a open gl vertex shader Simply calling the renderTexture method with the texture handle and appropriate width and height should fix your problems https://github.com/rsri/Pic2Fro/blob/b4fe69b44343dab2515c3fd6e769f3370bf31312/app/src/main/java/com/pic2fro/pic2fro/util/Util.java

    0 讨论(0)
  • 2021-01-26 15:27

    I found the problem: before the next lines were posted in the MyGLRenderer before constructing the Texture class, but now I have add them between glBindTexture() and texImage2D in Texture class:

        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    
    0 讨论(0)
提交回复
热议问题