Java Code Examples for android.opengl.GLES20#GL_FLOAT

The following examples show how to use android.opengl.GLES20#GL_FLOAT . 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: VertexBufferObjectAttributesBuilder.java    From tilt-game-android with MIT License 6 votes vote down vote up
public VertexBufferObjectAttributesBuilder add(final int pLocation, final String pName, final int pSize, final int pType, final boolean pNormalized) {
	if (VertexBufferObjectAttributesBuilder.WORAROUND_GLES2_GLVERTEXATTRIBPOINTER_MISSING) {
		this.mVertexBufferObjectAttributes[this.mIndex] = new VertexBufferObjectAttributeFix(pLocation, pName, pSize, pType, pNormalized, this.mOffset);
	} else {
		this.mVertexBufferObjectAttributes[this.mIndex] = new VertexBufferObjectAttribute(pLocation, pName, pSize, pType, pNormalized, this.mOffset);
	}

	switch (pType) {
		case GLES20.GL_FLOAT:
			this.mOffset += pSize * DataConstants.BYTES_PER_FLOAT;
			break;
		case GLES20.GL_UNSIGNED_BYTE:
			this.mOffset += pSize * DataConstants.BYTES_PER_BYTE;
			break;
		default:
			throw new IllegalArgumentException("Unexpected pType: '" + pType + "'.");
	}

	this.mIndex++;

	return this;
}
 
Example 2
Source File: VertexBufferObjectAttributesBuilder.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
public VertexBufferObjectAttributesBuilder add(final int pLocation, final String pName, final int pSize, final int pType, final boolean pNormalized) {
	if(VertexBufferObjectAttributesBuilder.WORAROUND_GLES2_GLVERTEXATTRIBPOINTER_MISSING) {
		this.mVertexBufferObjectAttributes[this.mIndex] = new VertexBufferObjectAttributeFix(pLocation, pName, pSize, pType, pNormalized, this.mOffset);
	} else {
		this.mVertexBufferObjectAttributes[this.mIndex] = new VertexBufferObjectAttribute(pLocation, pName, pSize, pType, pNormalized, this.mOffset);
	}

	switch(pType) {
		case GLES20.GL_FLOAT:
			this.mOffset += pSize * DataConstants.BYTES_PER_FLOAT;
			break;
		case GLES20.GL_UNSIGNED_BYTE:
			this.mOffset += pSize * DataConstants.BYTES_PER_BYTE;
			break;
		default:
			throw new IllegalArgumentException("Unexpected pType: '" + pType + "'.");
	}

	this.mIndex++;

	return this;
}
 
Example 3
Source File: Texture2D.java    From Spectaculum with Apache License 2.0 5 votes vote down vote up
public static Texture2D generateFloatTexture(int width, int height) {
    if(GLUtils.HAS_GLES30 && GLUtils.HAS_GL_OES_texture_half_float && GLUtils.HAS_FLOAT_FRAMEBUFFER_SUPPORT) {
        return new Texture2D(GLES30.GL_RGBA16F, GLES20.GL_RGBA, width, height, GLES20.GL_FLOAT, null);
    } else {
        Log.i(TAG, "Texture fallback mode to GLES20 8 bit");
        return new Texture2D(GLES20.GL_RGBA, GLES20.GL_RGBA, width, height, GLES20.GL_UNSIGNED_BYTE, null);
    }
}
 
Example 4
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private int convertFormat(Format format) {
        switch (format) {
            case Byte:
                return GLES20.GL_BYTE;
            case UnsignedByte:
                return GLES20.GL_UNSIGNED_BYTE;
            case Short:
                return GLES20.GL_SHORT;
            case UnsignedShort:
                return GLES20.GL_UNSIGNED_SHORT;
            case Int:
                return GLES20.GL_INT;
            case UnsignedInt:
                return GLES20.GL_UNSIGNED_INT;
            /*
            case Half:
            return NVHalfFloat.GL_HALF_FLOAT_NV;
            //                return ARBHalfFloatVertex.GL_HALF_FLOAT;
             */
            case Float:
                return GLES20.GL_FLOAT;
//            case Double:
//                return GLES20.GL_DOUBLE;
            default:
                throw new RuntimeException("Unknown buffer format.");

        }
    }