Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/src/main/java/com/googlecreativelab/drawar/DrawAR.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ public void onWindowFocusChanged(boolean hasFocus) {
*/
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
if (mSession == null) return;

GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);

// Create the texture and pass it to ARCore session to be filled during update().
Expand Down Expand Up @@ -527,7 +529,7 @@ public void onDrawFrame(GL10 gl) {
mBackgroundRenderer.draw(mFrame);

// Draw Lines
if (mFrame.getCamera().getTrackingState() == TrackingState.TRACKING) {
if (mFrame != null && mFrame.getCamera().getTrackingState() == TrackingState.TRACKING) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will prove to be helpful because if in case mFrame is null, the condition will still go false without notifying the developer about it.

mLineShaderRenderer.draw(viewmtx, projmtx, mScreenWidth, mScreenHeight, AppSettings.getNearClip(), AppSettings.getFarClip());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public void createOnGlThread(Context context) {
* @param frame The last {@code Frame} returned by {@link Session#update()}.
*/
public void draw(Frame frame) {
if (frame == null) return;

// If display rotation changed (also includes view size change), we need to re-query the uv
// coordinates for the screen rect, as they may have changed as well.
if (frame.hasDisplayGeometryChanged()) {
Expand Down