Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.opengl.GLES20;

public class Main {
    public static int createProgram(int vsh, int fsh, String... attributes) {
        int[] status = new int[1];
        int ph = GLES20.glCreateProgram();
        if (ph <= 0) {
            throw new RuntimeException("Could not create program");
        }
        GLES20.glAttachShader(ph, vsh);
        GLES20.glAttachShader(ph, fsh);
        for (int i = 0; i < attributes.length; ++i) {
            GLES20.glBindAttribLocation(ph, i, attributes[i]);
        }
        GLES20.glLinkProgram(ph);
        GLES20.glGetProgramiv(ph, GLES20.GL_LINK_STATUS, status, 0);
        if (status[0] == 0) {
            GLES20.glDeleteProgram(ph);
            throw new RuntimeException("Could not link program");
        }

        return ph;
    }
}