Example usage for org.lwjgl.opengl GL11 GL_POINTS

List of usage examples for org.lwjgl.opengl GL11 GL_POINTS

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 GL_POINTS.

Prototype

int GL_POINTS

To view the source code for org.lwjgl.opengl GL11 GL_POINTS.

Click Source Link

Document

BeginMode

Usage

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

private int getGLIndexMode(final IndexMode indexMode) {
    int glMode = GL11.GL_TRIANGLES;
    switch (indexMode) {
    case Triangles:
        glMode = GL11.GL_TRIANGLES;//ww w .ja v a2s .c o  m
        break;
    case TriangleStrip:
        glMode = GL11.GL_TRIANGLE_STRIP;
        break;
    case TriangleFan:
        glMode = GL11.GL_TRIANGLE_FAN;
        break;
    case Quads:
        glMode = GL11.GL_QUADS;
        break;
    case QuadStrip:
        glMode = GL11.GL_QUAD_STRIP;
        break;
    case Lines:
        glMode = GL11.GL_LINES;
        break;
    case LineStrip:
        glMode = GL11.GL_LINE_STRIP;
        break;
    case LineLoop:
        glMode = GL11.GL_LINE_LOOP;
        break;
    case Points:
        glMode = GL11.GL_POINTS;
        break;
    }
    return glMode;
}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void draw(VertexCache verts, PrimitiveType type, RenderStates states) {

    if (verts == null) {
        return;/*from w  ww  .j  av a 2  s .  com*/
    }

    if (verts.getSize() <= 0) {
        return;
    }

    FloatBuffer v, c, t;
    v = verts.getVertexBuffer();
    c = verts.getColorBuffer();
    t = verts.getTexcoordsBuffer();

    if (v == null || c == null || t == null) {
        return;
    }

    //if(true) {return;}

    if (!activate(true)) {
        return;
    }

    if (!mCache.glStatesSet) {
        resetGLStates();
    }

    View oldView = null;

    if (states.gui) {

        oldView = mView;

        setView(new View(0.f, 0.f, mView.mSizeX, mView.mSizeY));

    }

    applyTransform(states.transform);

    if (mCache.viewChanged) {
        applyCurrentView();
    }

    if (mCache.lastBlendMode != states.blendMode) {
        applyBlendMode(states.blendMode);
    }

    int textureId = (states.texture != null ? states.texture.getTextureID() : 0);
    if (textureId != mCache.lastTextureId) {
        applyTexture(states.texture);
    }

    //        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    //        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);                
    //        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);                

    // Give the buffers to OpenGL
    GL11.glVertexPointer(2, 0, v);
    GL11.glColorPointer(4, 0, c);
    GL11.glTexCoordPointer(2, 0, t);

    int mode = -1;

    switch (type) {
    case Points:
        mode = GL11.GL_POINTS;
        break;
    case Lines:
        mode = GL11.GL_LINES;
        break;
    case LinesStrip:
        mode = GL11.GL_LINE_STRIP;
        break;
    case Triangles:
        mode = GL11.GL_TRIANGLES;
        break;
    case TrianglesStrip:
        mode = GL11.GL_TRIANGLE_STRIP;
        break;
    case TrianglesFan:
        mode = GL11.GL_TRIANGLE_FAN;
        break;
    case Quads:
        mode = GL11.GL_QUADS;
        break;
    }

    if (mode == -1) {
        return;
    }

    // Draw the verticies
    GL11.glDrawArrays(mode, 0, verts.getSize());

    if (oldView != null) {
        setView(oldView);
    }

}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void draw(Vertex[] verts, PrimitiveType type, RenderStates states) {

    if (verts == null) {
        return;/*from w ww . java  2 s  . c om*/
    }

    if (verts.length == 0) {
        return;
    }

    if (activate(true)) {

        if (!mCache.glStatesSet) {
            resetGLStates();
        }

        boolean useVertexCache = (verts.length <= StatusCache.VertexCacheSize);
        if (useVertexCache) {

            for (int i = 0; i < verts.length; i++) {

                Vertex v = mCache.vertexCache[i];

                Vector2f p = Transform.multiply(states.transform, new Vector2f(verts[i].x, verts[i].y));

                v.x = p.x;
                v.y = p.y;

                v.color = verts[i].color;
                v.tx = verts[i].tx;
                v.ty = verts[i].ty;

            }

            if (!mCache.useVertexCache) {
                applyTransform(Transform.Identity);
            }

        } else {
            applyTransform(states.transform);
        }

        if (mCache.viewChanged) {
            applyCurrentView();
        }

        if (!mCache.lastBlendMode.equals(states.blendMode)) {
            applyBlendMode(states.blendMode);
        }

        int textureId = (states.texture != null ? states.texture.getTextureID() : 0);
        if (textureId != mCache.lastTextureId) {
            applyTexture(states.texture);
        }

        if (useVertexCache) {
            if (!mCache.useVertexCache) {
                verts = new Vertex[mCache.vertexCache.length];
                for (int i = 0; i < mCache.vertexCache.length; i++) {
                    verts[i] = new Vertex(mCache.vertexCache[i]);
                }
            } else {
                //verts = null;
                return;
            }
        }

        if (verts != null) {

            // Create some buffers to store vertex and color data
            FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(verts.length * 2);
            FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(verts.length * 4);
            FloatBuffer tcBuffer = BufferUtils.createFloatBuffer(verts.length * 2);

            // Copy the vertex and color data to the buffers
            for (Vertex vert : verts) {

                // Write vertex coordinate (XY)
                vertexBuffer.put(vert.x);
                vertexBuffer.put(vert.y);

                tcBuffer.put(vert.tx);
                tcBuffer.put(vert.ty);

                // Write Color (RGBA)
                GLColor c = vert.color.toGLColor();
                colorBuffer.put(c.getRed());
                colorBuffer.put(c.getGreen());
                colorBuffer.put(c.getBlue());
                colorBuffer.put(c.getAlpha());

            }

            // Flip the buffer so it can be used
            vertexBuffer.flip();
            colorBuffer.flip();
            tcBuffer.flip();

            GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
            GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
            GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

            // Give the buffers to OpenGL
            GL11.glVertexPointer(2, 0, vertexBuffer);
            GL11.glColorPointer(4, 0, colorBuffer);
            GL11.glTexCoordPointer(2, 0, tcBuffer);

        }

        int mode = -1;

        switch (type) {
        case Points:
            mode = GL11.GL_POINTS;
            break;
        case Lines:
            mode = GL11.GL_LINES;
            break;
        case LinesStrip:
            mode = GL11.GL_LINE_STRIP;
            break;
        case Triangles:
            mode = GL11.GL_TRIANGLES;
            break;
        case TrianglesStrip:
            mode = GL11.GL_TRIANGLE_STRIP;
            break;
        case TrianglesFan:
            mode = GL11.GL_TRIANGLE_FAN;
            break;
        case Quads:
            mode = GL11.GL_QUADS;
            break;
        }

        if (mode == -1) {
            return;
        }

        if (verts != null) {
            GL11.glDrawArrays(mode, 0, verts.length);
        }

        mCache.useVertexCache = useVertexCache;

    }

}

From source file:com.google.gapid.glviewer.Geometry.java

License:Apache License

public Renderable asRenderable(DisplayMode displayMode) {
    if (model == null) {
        return Renderable.NOOP;
    }/*  w w w  . j  a  va2s  .  co  m*/

    final int polygonMode = displayMode.glPolygonMode;
    final int modelPrimitive = translatePrimitive(model.getPrimitive());
    final float[] positions = model.getPositions();
    final float[] normals = model.getNormals();
    final int[] indices = isNonPolygonPoints(displayMode) ? null : model.getIndices();

    return new Renderable() {
        private VertexBuffer positionBuffer;
        private VertexBuffer normalBuffer;
        private IndexBuffer indexBuffer;

        @Override
        public void init(Renderer renderer) {
            positionBuffer = renderer.newVertexBuffer(positions, 3);
            if (normals != null) {
                normalBuffer = renderer.newVertexBuffer(normals, 3);
            }
            if (indices != null) {
                indexBuffer = renderer.newIndexBuffer(indices);
            }
        }

        @Override
        public void render(Renderer renderer, State state) {
            state.transform.push(modelMatrix);
            state.transform.apply(state.shader);

            GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode);

            state.shader.setAttribute(Constants.POSITION_ATTRIBUTE, positionBuffer);
            if (normalBuffer != null) {
                state.shader.setAttribute(Constants.NORMAL_ATTRIBUTE, normalBuffer);
            } else {
                state.shader.setAttribute(Constants.NORMAL_ATTRIBUTE, 1, 0, 0);
            }
            if (indexBuffer != null) {
                Renderer.draw(state.shader, modelPrimitive, indexBuffer);
            } else {
                Renderer.draw(state.shader, GL11.GL_POINTS, positions.length / 3);
            }
            GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);

            state.transform.pop();
        }

        @Override
        public void dispose(Renderer renderer) {
            if (positionBuffer != null) {
                positionBuffer.delete();
                positionBuffer = null;
            }
            if (normalBuffer != null) {
                normalBuffer.delete();
                normalBuffer = null;
            }
            if (indexBuffer != null) {
                indexBuffer.delete();
                indexBuffer = null;
            }
        }
    };
}

From source file:com.google.gapid.glviewer.Geometry.java

License:Apache License

private static int translatePrimitive(API.DrawPrimitive primitive) {
    switch (primitive) {
    case Points://from  w w w . ja  v a2s  .c  om
        return GL11.GL_POINTS;
    case Lines:
        return GL11.GL_LINES;
    case LineStrip:
        return GL11.GL_LINE_STRIP;
    case LineLoop:
        return GL11.GL_LINE_LOOP;
    case Triangles:
        return GL11.GL_TRIANGLES;
    case TriangleStrip:
        return GL11.GL_TRIANGLE_STRIP;
    case TriangleFan:
        return GL11.GL_TRIANGLE_FAN;
    default:
        throw new AssertionError();
    }
}

From source file:com.grillecube.client.renderer.gui.GuiRenderer.java

public void renderTexturedQuad(GLTexture glTexture, float ux, float uy, float vx, float vy, float transparency,
        Matrix4f transformMatrix) {// w  w w .  ja v  a 2s.com
    this.programTexturedQuad.useStart();
    this.programTexturedQuad.loadQuadTextured(glTexture, ux, uy, vx, vy, transparency, transformMatrix);
    GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1);
}

From source file:com.grillecube.client.renderer.gui.GuiRenderer.java

public void renderColoredQuad(float r, float g, float b, float a, float transparency,
        Matrix4f transformMatrix) {/*from   w  w w . j  a v  a 2s  .c  o m*/
    this.programColoredQuad.useStart();
    this.programColoredQuad.loadQuadColored(r, g, b, a * transparency, transformMatrix);
    GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1);
}

From source file:com.grillecube.client.renderer.particles.ParticleRenderer.java

/**
 * render every given billoaded particles with the given camera (billboarded
 * = textured quad facing the camera)//  w w  w. j a v  a2s.c  om
 */
public final void renderBillboardedParticles(CameraProjective camera,
        ArrayList<ParticleBillboarded> particles) {
    if (particles.size() == 0) {
        return;
    }
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); // Texture unit 0

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    this.programBillboardedParticles.useStart();
    this.getMainRenderer().getDefaultVAO().bind();

    this.programBillboardedParticles.loadGlobalUniforms(camera);

    HashMap<ParticleBillboarded, Double> distances = new HashMap<ParticleBillboarded, Double>(
            particles.size() * 4);
    for (ParticleBillboarded particle : particles) {
        distances.put(particle, Vector3f.distanceSquare(particle.getPosition(), camera.getPosition()));
    }
    particles.sort(new Comparator<ParticleBillboarded>() {
        @Override
        public int compare(ParticleBillboarded a, ParticleBillboarded b) {
            double da = distances.get(a);
            double db = distances.get(b);
            if (da < db) {
                return (1);
            } else if (da > db) {
                return (-1);
            }
            return (0);
        }
    });

    int i = 0;
    while (i < particles.size()) {
        ParticleBillboarded particle = particles.get(i);
        float radius = Maths.max(Maths.max(particle.getSizeX(), particle.getSizeY()), particle.getSizeZ());
        if (particle != null && distances.get(particle) < camera.getSquaredRenderDistance()
                && camera.isSphereInFrustum(particle.getPosition(), radius)) {
            this.programBillboardedParticles.loadInstanceUniforms(particle);
            this.getMainRenderer().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1);
        }
        ++i;
    }
}

From source file:com.grillecube.client.renderer.world.WorldRenderer.java

private void renderPostProcessingEffects() {

    if (this.postProcessingProgram != null) {
        // bind the fbo texture to texture attachment 0
        this.getFBOTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D);

        this.postProcessingProgram.useStart();
        this.postProcessingProgram.loadUniforms((float) super.getTimer().getTime());
        this.getMainRenderer().getDefaultVAO().bind();
        GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1);
        this.postProcessingProgram.useStop();
    }/*from  ww w  .  j a  v  a  2 s  . c  o m*/
}

From source file:com.grillecube.engine.renderer.MainRenderer.java

private void renderFinalImage() {

    // bind the fbo texture to texture attachment 0
    this.getFBOTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D);

    this._final_process_program.useStart();
    this._final_process_program.loadUniforms(this);
    this._default_vao.bind();
    GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1);
    this._final_process_program.useStop();
}