17 package com.introlab.rtabmap;
19 import java.util.Vector;
20 import java.util.concurrent.locks.ReentrantLock;
22 import android.app.Activity;
23 import android.app.ProgressDialog;
24 import android.opengl.GLES20;
25 import android.opengl.GLSurfaceView;
26 import android.opengl.Matrix;
27 import android.util.Log;
28 import android.widget.Toast;
30 import javax.microedition.khronos.egl.EGLConfig;
31 import javax.microedition.khronos.opengles.GL10;
39 private final float[]
mtrxView =
new float[16];
59 private ReentrantLock
mTextLock =
new ReentrantLock();
63 mProgressDialog = progressDialog;
96 if(mTextManager!=null)
100 mTextChanged =
false;
101 Vector<TextObject> txtcollection =
new Vector<TextObject>();
105 if(mTexts.size() > 0)
107 txtcollection.addAll(mTexts);
117 float[] mvp =
new float[16];
118 Matrix.translateM(mvp, 0, mtrxProjectionAndView, 0, 0, mOffset, 0);
119 mTextManager.
Draw(mvp);
122 if(value != 0 && mProgressDialog != null && mProgressDialog.isShowing())
124 mActivity.runOnUiThread(
new Runnable() {
126 if(!
RTABMapActivity.
DISABLE_LOG) Log.i(
"RTABMapActivity",
"Renderer: dismiss dialog, value received=" + String.valueOf(value));
127 mProgressDialog.dismiss();
134 mActivity.runOnUiThread(
new Runnable() {
138 mToast.makeText(mActivity, String.format(
"Out of Memory!"), Toast.LENGTH_SHORT).show();
145 mActivity.runOnUiThread(
new Runnable() {
149 mToast.makeText(mActivity, String.format(
"Rendering Error!"), Toast.LENGTH_SHORT).show();
155 catch(
final Exception
e)
157 mActivity.runOnUiThread(
new Runnable() {
161 mToast.makeText(mActivity, String.format(
"Rendering error! %s", e.getMessage()), Toast.LENGTH_SHORT).show();
179 mSurfaceHeight = (float)height;
182 for(
int i=0;i<16;i++)
184 mtrxProjection[i] = 0.0f;
186 mtrxProjectionAndView[i] = 0.0f;
190 Matrix.orthoM(mtrxProjection, 0, 0
f, width, 0.0
f, height, 0, 50);
193 Matrix.setLookAtM(mtrxView, 0, 0
f, 0
f, 1
f, 0
f, 0
f, 0
f, 0
f, 1.0
f, 0.0
f);
196 Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0);
214 if(mTextManager != null && mSurfaceHeight > 0.0
f)
216 Vector<TextObject> textObjects =
new Vector<TextObject>();
220 for(
int i=0;i<texts.length; ++i)
222 if(texts[i]!=null && texts[i].
length()>0)
225 textObjects.add(txt);
233 mTexts = textObjects;
245 if(mTextManager != null)
static boolean DISABLE_LOG
static native int render(long nativeApplication)
ARCoreSharedCamera mCamera
final float[] mtrxProjection
GLM_FUNC_DECL genType e()
void setProgressDialog(ProgressDialog progressDialog)
static native void setupGraphic(long nativeApplication, int width, int height)
void onDrawFrame(GL10 useGLES20instead)
static long nativeApplication
void updateTexts(String[] texts)
void setColor(float color)
void onSurfaceChanged(GL10 useGLES20instead, int width, int height)
final float[] mtrxProjectionAndView
void setTextColor(float color)
void setCamera(ARCoreSharedCamera camera)
ProgressDialog mProgressDialog
static native void initGlContent(long nativeApplication)
static RTABMapActivity mActivity
Renderer(RTABMapActivity c)
void PrepareDraw(Vector< TextObject > txtcollection)
Vector< TextObject > mTexts
void onSurfaceCreated(GL10 useGLES20instead, EGLConfig config)
GLM_FUNC_DECL genType::value_type length(genType const &x)
void setOffset(int offset)
void run(ClassLoader *loader)
void setToast(Toast toast)