package com.example.opengles3;

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

import androidx.annotation.Nullable;

import com.example.rgprojekt.R;

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();

            Bitmap tekstura = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.drawable.tekstura_resource);
            mainRenderer.bitmap = tekstura;

            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 + ")");
        }
    }
}
