OpenglES 2.0 GL_POINTS消失

时间:2012-03-01 03:20:39

标签: opengl-es-2.0

我使用gl_points作为精灵,当点到达屏幕边界时它们消失了,问题是我的点大于1个像素,所以当一半点喙通过屏幕边界时它们会消失,我假设有某种剔除打开以移除屏幕外的点,问题是如何将其关闭。

3 个答案:

答案 0 :(得分:1)

    GLES20Renderer.programLight = GLES20.glCreateProgram();
    int vertexShaderLight       = GLES20Renderer.loadShader(GLES20.GL_VERTEX_SHADER, GLES20Renderer.vertexShaderCodeLight);
    int fragmentShaderLight     = GLES20Renderer.loadShader(GLES20.GL_FRAGMENT_SHADER, GLES20Renderer.fragmentShaderCodeLight);
    GLES20.glAttachShader(GLES20Renderer.programLight, vertexShaderLight);
    GLES20.glAttachShader(GLES20Renderer.programLight, fragmentShaderLight);
    GLES20.glLinkProgram(GLES20Renderer.programLight);
    uPLocationLight             = GLES20.glGetUniformLocation(GLES20Renderer.programLight, "uP");
    uVPositionLocationLight     = GLES20.glGetUniformLocation(GLES20Renderer.programLight, "uVPosition");

    GLES20.glUseProgram(GLES20Renderer.programLight);
    GLES20.glUniform4f(uVPositionLocationLight, LightPosInEyeSpace[0], LightPosInEyeSpace[1], LightPosInEyeSpace[2], LightPosInEyeSpace[3]);
    GLES20.glUniformMatrix4fv(uPLocationLight, 1, false, ProjectionMatrix, 0);
    GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);


private static final String vertexShaderCodeLight = 
        "uniform vec4 uVPosition;                   \n"
    +   "uniform mat4 uP;                           \n"
    +   "void main(){                               \n"
    +   " gl_PointSize = 15.0;                      \n"
    +   " gl_Position = uP * uVPosition;            \n"
    +   "}                                          \n";
private static final String fragmentShaderCodeLight = 
        "#ifdef GL_FRAGMENT_PRECISION_HIGH          \n"
    +   "precision highp float;                     \n"
    +   "#else                                      \n"
    +   "precision mediump float;                   \n"
    +   "#endif                                     \n"
    +   "void main(){                               \n"
    +   " gl_FragColor = vec4(1.0,1.0,1.0,1.0);     \n"
    +   "}                                          \n";

答案 1 :(得分:0)

GL_POINTS被剪裁在中心。这只是GL_POINTS的限制。如果你不能忍受,只需使用常规四边形(假设性能可以处理它)

答案 2 :(得分:-2)

增加视口大小会有所帮助,或者您可以将其渲染为纹理和缩放:)