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];
58 private ReentrantLock
mTextLock =
new ReentrantLock();
62 mProgressDialog = progressDialog;
82 if(mTextManager!=null)
87 Vector<TextObject> txtcollection =
new Vector<TextObject>();
93 txtcollection.addAll(mTexts);
103 float[] mvp =
new float[16];
104 Matrix.translateM(mvp, 0, mtrxProjectionAndView, 0, 0, mOffset, 0);
105 mTextManager.
Draw(mvp);
108 if(value != 0 && mProgressDialog != null && mProgressDialog.isShowing())
110 mActivity.runOnUiThread(
new Runnable() {
112 if(!
RTABMapActivity.
DISABLE_LOG) Log.i(
"RTABMapActivity",
"Renderer: dismiss dialog, value received=" + String.valueOf(value));
113 mProgressDialog.dismiss();
120 mActivity.runOnUiThread(
new Runnable() {
124 mToast.makeText(mActivity, String.format(
"Out of Memory!"), Toast.LENGTH_SHORT).show();
131 mActivity.runOnUiThread(
new Runnable() {
135 mToast.makeText(mActivity, String.format(
"Rendering Error!"), Toast.LENGTH_SHORT).show();
141 catch(
final Exception
e)
143 mActivity.runOnUiThread(
new Runnable() {
147 mToast.makeText(mActivity, String.format(
"Rendering error! %s", e.getMessage()), Toast.LENGTH_SHORT).show();
160 mSurfaceHeight = (float)height;
163 for(
int i=0;i<16;i++)
165 mtrxProjection[i] = 0.0f;
167 mtrxProjectionAndView[i] = 0.0f;
171 Matrix.orthoM(mtrxProjection, 0, 0
f, width, 0.0
f, height, 0, 50);
174 Matrix.setLookAtM(mtrxView, 0, 0
f, 0
f, 1
f, 0
f, 0
f, 0
f, 0
f, 1.0
f, 0.0
f);
177 Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0);
192 if(mTextManager != null && mSurfaceHeight > 0.0
f)
194 Vector<TextObject> textObjects =
new Vector<TextObject>();
198 for(
int i=0;i<texts.length; ++i)
200 if(texts[i]!=null && texts[i].
length()>0)
203 textObjects.add(txt);
211 mTexts = textObjects;
223 if(mTextManager != null)
static native void setupGraphic(int width, int height)
static boolean DISABLE_LOG
final float[] mtrxProjection
GLM_FUNC_DECL genType e()
void setProgressDialog(ProgressDialog progressDialog)
void onDrawFrame(GL10 useGLES20instead)
void updateTexts(String[] texts)
void setColor(float color)
void onSurfaceChanged(GL10 useGLES20instead, int width, int height)
final float[] mtrxProjectionAndView
void setTextColor(float color)
ProgressDialog mProgressDialog
static RTABMapActivity mActivity
Renderer(RTABMapActivity c)
void PrepareDraw(Vector< TextObject > txtcollection)
Vector< TextObject > mTexts
void onSurfaceCreated(GL10 useGLES20instead, EGLConfig config)
static native int render()
GLM_FUNC_DECL genType::value_type length(genType const &x)
void setOffset(int offset)
void run(ClassLoader *loader)
void setToast(Toast toast)
static native void initGlContent()