Java Code Examples for com.badlogic.gdx.graphics.GL20#GL_LINES

The following examples show how to use com.badlogic.gdx.graphics.GL20#GL_LINES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MG3dModelLoader.java    From Mundus with Apache License 2.0 6 votes vote down vote up
private int parseType(String type) {
    if (type.equals("TRIANGLES")) {
        return GL20.GL_TRIANGLES;
    } else if (type.equals("LINES")) {
        return GL20.GL_LINES;
    } else if (type.equals("POINTS")) {
        return GL20.GL_POINTS;
    } else if (type.equals("TRIANGLE_STRIP")) {
        return GL20.GL_TRIANGLE_STRIP;
    } else if (type.equals("LINE_STRIP")) {
        return GL20.GL_LINE_STRIP;
    } else {
        throw new GdxRuntimeException("Unknown primitive type '" + type
                + "', should be one of triangle, trianglestrip, line, linestrip, lineloop or point");
    }
}
 
Example 2
Source File: HeadlessG3dModelLoader.java    From gdx-proto with Apache License 2.0 6 votes vote down vote up
private int parseType (String type) {
	if (type.equals("TRIANGLES")) {
		return GL20.GL_TRIANGLES;
	} else if (type.equals("LINES")) {
		return GL20.GL_LINES;
	} else if (type.equals("POINTS")) {
		return GL20.GL_POINTS;
	} else if (type.equals("TRIANGLE_STRIP")) {
		return GL20.GL_TRIANGLE_STRIP;
	} else if (type.equals("LINE_STRIP")) {
		return GL20.GL_LINE_STRIP;
	} else {
		throw new GdxRuntimeException("Unknown primitive type '" + type
				+ "', should be one of triangle, trianglestrip, line, linestrip, lineloop or point");
	}
}
 
Example 3
Source File: GdxRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/*********************************************************************\
 |* Render Calls                                                      *|
 \*********************************************************************/
public int convertElementMode(Mode mode) {
    switch (mode) {
        case Points:
            return GL20.GL_POINTS;
        case Lines:
            return GL20.GL_LINES;
        case LineLoop:
            return GL20.GL_LINE_LOOP;
        case LineStrip:
            return GL20.GL_LINE_STRIP;
        case Triangles:
            return GL20.GL_TRIANGLES;
        case TriangleFan:
            return GL20.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GL20.GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 4
Source File: GLTFTypes.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
/** https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#primitivemode */
public static int mapPrimitiveMode(Integer glMode){
	if(glMode == null) return GL20.GL_TRIANGLES; // TODO not sure
	switch (glMode) {
	case 0: return GL20.GL_POINTS;
	case 1: return GL20.GL_LINES;
	case 2: return GL20.GL_LINE_LOOP;
	case 3: return GL20.GL_LINE_STRIP;
	case 4: return GL20.GL_TRIANGLES;
	case 5: return GL20.GL_TRIANGLE_STRIP;
	case 6: return GL20.GL_TRIANGLE_FAN;
	}
	throw new GdxRuntimeException("unsupported mode " + glMode);
}
 
Example 5
Source File: GLTFMeshExporter.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public static Integer mapPrimitiveMode(int type){
	switch(type){
	case GL20.GL_POINTS: return 0;
	case GL20.GL_LINES: return 1;
	case GL20.GL_LINE_LOOP: return 2;
	case GL20.GL_LINE_STRIP: return 3;
	case GL20.GL_TRIANGLES: return null; // default not need to be set
	case GL20.GL_TRIANGLE_STRIP: return 5;
	case GL20.GL_TRIANGLE_FAN: return 6;
	}
	throw new GdxRuntimeException("unsupported primitive type " + type);
}
 
Example 6
Source File: Chunk.java    From Radix with MIT License 4 votes vote down vote up
private void updateModelInstances() {
    if(opaqueFaces != null) {
        if(opaqueModel != null)
            opaqueModel.dispose();

        Mesh opaqueMesh = mesher.meshFaces(opaqueFaces, meshBuilder);
        modelBuilder.begin();
        modelBuilder.part(String.format("c-%d,%d", startPosition.x, startPosition.z), opaqueMesh, GL20.GL_TRIANGLES,
                new Material(TextureAttribute.createDiffuse(NormalBlockRenderer.getBlockMap())));
        opaqueModel = modelBuilder.end();

        opaqueModelInstance = new ModelInstance(opaqueModel) {
            @Override
            public Renderable getRenderable(final Renderable out, final Node node,
                                            final NodePart nodePart) {
                super.getRenderable(out, node, nodePart);
                if(RadixClient.getInstance().isWireframe()) {
                    out.primitiveType = GL20.GL_LINES;
                } else {
                    out.primitiveType = GL20.GL_TRIANGLES;
                }
                return out;
            }
        };

        opaqueFaces = null;
    }

    if(translucentFaces != null) {
        if(translucentModel != null)
            translucentModel.dispose();

        Mesh translucentMesh = mesher.meshFaces(translucentFaces, meshBuilder);
        modelBuilder.begin();
        modelBuilder.part(String.format("c-%d,%d-t", startPosition.x, startPosition.z), translucentMesh, GL20.GL_TRIANGLES,
                new Material(TextureAttribute.createDiffuse(NormalBlockRenderer.getBlockMap()),
                        new BlendingAttribute(),
                        FloatAttribute.createAlphaTest(0.25f)));
        translucentModel = modelBuilder.end();

        translucentModelInstance = new ModelInstance(translucentModel) {
            @Override
            public Renderable getRenderable(final Renderable out, final Node node,
                                            final NodePart nodePart) {
                super.getRenderable(out, node, nodePart);
                if(RadixClient.getInstance().isWireframe()) {
                    out.primitiveType = GL20.GL_LINES;
                } else {
                    out.primitiveType = GL20.GL_TRIANGLES;
                }
                return out;
            }
        };

        translucentFaces = null;
    }
}