package com.example.opengles3;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.Nullable;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        boolean supportsES3 = (info.reqGlEsVersion >= 0x30000);
        if(supportsES3){
            MainRenderer mainRenderer = new MainRenderer();
            MainSurfaceView mainSurfaceView = new MainSurfaceView(this);
            mainSurfaceView.setEGLContextClientVersion(3);
            mainSurfaceView.setRenderer(mainRenderer);
            this.setContentView(mainSurfaceView);
        }
        else{
            Log.e("OpenGLES 3", "Your device doesn't support ES3. (" + info.reqGlEsVersion + ")");
        }
    }
}
