Example usage for org.lwjgl.opengl GL32 GL_PROGRAM_POINT_SIZE

List of usage examples for org.lwjgl.opengl GL32 GL_PROGRAM_POINT_SIZE

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL32 GL_PROGRAM_POINT_SIZE.

Prototype

int GL_PROGRAM_POINT_SIZE

To view the source code for org.lwjgl.opengl GL32 GL_PROGRAM_POINT_SIZE.

Click Source Link

Document

Accepted by the cap parameter of Enable, Disable, and IsEnabled, and by the pname parameter of GetIntegerv, GetFloatv, GetDoublev, and GetBooleanv.

Usage

From source file:com.xrbpowered.gl.examples.GLPoints.java

License:Open Source License

@Override
protected void setupResources() {
    super.setupResources();

    FeedbackVertexInfo tInfo = (FeedbackVertexInfo) new FeedbackVertexInfo()
            .setFeedbackNames(new String[] { "out_Position", "out_Size" }).addAttrib("in_Position", 3)
            .addAttrib("in_Size", 1);
    VertexInfo rInfo = new VertexInfo().addAttrib("in_Position", 4).addAttrib("in_Size", 1);
    VertexInfo simpleInfo = new VertexInfo().addAttrib("in_Position", 3).addAttrib("in_Size", 1);

    pointData = new float[NUM_POINTS * 4];
    indexData = new Integer[NUM_POINTS];
    Random random = new Random();
    int offs = 0;
    for (int i = 0; i < NUM_POINTS; i++) {
        pointData[offs++] = random.nextFloat() * 2f * POINTS_RANGE - POINTS_RANGE;
        pointData[offs++] = random.nextFloat() * 2f * POINTS_RANGE - POINTS_RANGE;
        pointData[offs++] = random.nextFloat() * 2f * POINTS_RANGE - POINTS_RANGE;
        pointData[offs++] = 0.1f;/*from  ww w  .  j  ava 2s  . c  o m*/
    }
    // points = new StaticMesh(info, pointData, GL11.GL_POINTS, NUM_POINTS, true);

    pointsTShader = new Shader(tInfo, "points_tv.glsl", null) {
        private int projectionMatrixLocation;
        private int viewMatrixLocation;
        private int screenHeightLocation;

        @Override
        protected void storeUniformLocations() {
            projectionMatrixLocation = GL20.glGetUniformLocation(pId, "projectionMatrix");
            viewMatrixLocation = GL20.glGetUniformLocation(pId, "viewMatrix");
            screenHeightLocation = GL20.glGetUniformLocation(pId, "screenHeight");
        }

        @Override
        public void updateUniforms() {
            uniform(projectionMatrixLocation, scene.activeCamera.getProjection());
            uniform(viewMatrixLocation, scene.activeCamera.getView());
            GL20.glUniform1f(screenHeightLocation, getTargetHeight());
        }
    };
    pointsRShader = new Shader(rInfo, "points_pv.glsl", "points_f.glsl") {
        @Override
        protected void storeUniformLocations() {
        }

        @Override
        public void updateUniforms() {
            GL11.glEnable(GL32.GL_PROGRAM_POINT_SIZE);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        }

        @Override
        public void unuse() {
            GL11.glDisable(GL11.GL_BLEND);
            super.unuse();
        }
    };

    points = new FeedbackVertices(pointsTShader, pointsRShader, NUM_POINTS, true);
    points.updateVertexData(pointData);

    simplePointsShader = new Shader(simpleInfo, "points_v.glsl", "points_f.glsl") {
        private int projectionMatrixLocation;
        private int viewMatrixLocation;
        private int screenHeightLocation;

        @Override
        protected void storeUniformLocations() {
            projectionMatrixLocation = GL20.glGetUniformLocation(pId, "projectionMatrix");
            viewMatrixLocation = GL20.glGetUniformLocation(pId, "viewMatrix");
            screenHeightLocation = GL20.glGetUniformLocation(pId, "screenHeight");
        }

        @Override
        public void updateUniforms() {
            GL11.glEnable(GL32.GL_PROGRAM_POINT_SIZE);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            uniform(projectionMatrixLocation, scene.activeCamera.getProjection());
            uniform(viewMatrixLocation, scene.activeCamera.getView());
            GL20.glUniform1f(screenHeightLocation, getTargetHeight());
        }

        @Override
        public void unuse() {
            GL11.glDisable(GL11.GL_BLEND);
            super.unuse();
        }
    };
    simplePoints = new StaticMesh(simpleInfo, pointData, 1, NUM_POINTS, false);

    Client.checkError();
    updateInfo();
}