This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| <uses-feature android:glEsVersion="0x00020000" android:required="true" /> | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BasicGLRenderer implements GLSurfaceView.Renderer { | |
| private final GLCameraOptions mGLCameraOptions; | |
| private int mBackgroundColor; | |
| private float[] mViewMatrix = new float[16]; | |
| private float[] mMVPMatrix = new float[16]; | |
| private float[] mProjectionMatrix = new float[16]; | |
| public BasicGLRenderer(GLCameraOptions glCameraOptions) { | |
| mGLCameraOptions = glCameraOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BasicGLRenderer implements GLSurfaceView.Renderer { | |
| ... | |
| private List<Model3D> mModels = new LinkedList<>(); | |
| @Override | |
| public void onDrawFrame(GL10 gl) { | |
| ... | |
| for(Model3D model : mModels) { | |
| model.draw(mMVPMatrix); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class EasyGLView extends GLSurfaceView { | |
| public EasyGLView(Context context) { | |
| super(context); | |
| init(); | |
| } | |
| public EasyGLView(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| init(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ExampleFragment extends Fragment { | |
| private EasyGLView mEasyGLView; | |
| private BasicGLRenderer mBasicRenderer; | |
| @Nullable | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
| ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_example, container, false); | |
| mEasyGLView = (EasyGLView) viewGroup.findViewById(R.id.easygl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" android:layout_height="match_parent"> | |
| <ar.com.wolox.easygl.view.EasyGLView | |
| android:id="@+id/easygl" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" /> | |
| </FrameLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GLCameraOptions { | |
| public float eyeX; | |
| public float eyeY; | |
| public float eyeZ; | |
| public float centerX; | |
| public float centerY; | |
| public float centerZ; | |
| public float upX; | |
| public float upY; | |
| public float upZ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GLHelper { | |
| private static final String TAG = "GLHelper"; | |
| public static void checkGlError(String glOperation) { | |
| int error; | |
| while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { | |
| Log.e(TAG, glOperation + ": glError " + error); | |
| throw new RuntimeException(glOperation + ": glError " + error); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Model3D { | |
| private Integer mProgram; | |
| private int mColorHandle; | |
| private float[] mColor; | |
| private String mVertexShader; | |
| private String mFragmentShader; | |
| private void setupShaders() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Shaders { | |
| public static final String COLOR_VERTEX_SHADER = | |
| "uniform mat4 uMVPMatrix;\n" + | |
| "attribute vec4 vPosition;\n" + | |
| "void main() {\n" + | |
| " gl_Position = uMVPMatrix * vPosition;\n" + | |
| " gl_PointSize = 10.0;\n" + | |
| "}"; | |
| public static final String COLOR_FRAGMENT_SHADER = |