コード例 #1
0
  public AttributeParticleDrawer(
      ShaderManager theShaderManager, String thePointSpriteAttributeShader) {
    _myShaderManager = theShaderManager;
    _myMaterial = new Material();

    _myPointSpriteShader = _myShaderManager.createShaderProgram();
    _myShaderManager.attachVertexShader(
        _myPointSpriteShader, Resource.getStream(thePointSpriteAttributeShader));
  }
コード例 #2
0
  private void display(GL gl, GLU glu, final JoglFrameBufferObject theFBO) {
    final int w = theFBO.getPixelWidth();
    final int h = theFBO.getPixelHeight();

    /* bind position data */
    gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myVBO);
    gl.glVertexPointer(4, GL.GL_FLOAT, 0, 0);

    /* bind point size data */
    _myShaderManager.enable(_myPointSpriteShader);
    final int myPointSizeAttrib =
        gl.glGetAttribLocation(_myPointSpriteShader.getOpenGLID(), "vertexAttribute");
    gl.glEnableVertexAttribArray(myPointSizeAttrib);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myIBO);
    gl.glVertexAttribPointer(myPointSizeAttrib, 3, GL.GL_FLOAT, false, 0, 0);
    gl.glEnable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB);

    /* --- */
    final JoglFrameBufferObject READ_FBO = _myFBO;
    _myShaderManager.setUniform(
        _myPointSpriteShader,
        "textureVelocity",
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit() - GL.GL_TEXTURE0);
    _myShaderManager.setUniform(_myPointSpriteShader, "velocityThreshold", velocity_threshold);
    _myShaderManager.setUniform(_myPointSpriteShader, "sizeThreshold", size_threshold);
    _myShaderManager.setUniform(_myPointSpriteShader, "pointSize", point_size);
    _myShaderManager.setUniform(_myPointSpriteShader, "flowdirection", flow_direction);
    _myShaderManager.setUniform(_myPointSpriteShader, "collisionratio", collision_ratio);

    gl.glActiveTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit());
    gl.glBindTexture(
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(),
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureID());

    JoglUtil.printGLError(gl, glu, "binding texture", true);

    gl.glDrawArrays(GL.GL_POINTS, 0, w * h);

    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
    gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
    gl.glDisableVertexAttribArray(myPointSizeAttrib);
    _myShaderManager.disable();
    gl.glDisable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
    gl.glBindTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(), 0);

    JoglUtil.printGLError(gl, glu, "display()", true);
  }