1 package com.intel.realsense.librealsense;
3 import android.graphics.Point;
4 import android.graphics.Rect;
5 import android.opengl.GLES10;
6 import android.opengl.GLSurfaceView;
7 import android.util.Pair;
9 import java.util.ArrayList;
10 import java.util.HashMap;
11 import java.util.List;
14 import javax.microedition.khronos.egl.EGLConfig;
15 import javax.microedition.khronos.opengles.GL10;
17 public class GLRenderer implements GLSurfaceView.Renderer, AutoCloseable{
19 private final Map<Integer,GLFrame>
mFrames =
new HashMap<>();
38 return mPointcloud != null;
42 List<FilterInterface> rv =
new ArrayList<>();
51 if(mHasColorRbg8 || mHasColorYuy)
60 frameSet = frameSet.
clone();
70 mHasColorRbg8 = mHasColorizedDepth = mHasColorYuy =
false;
73 public void onFrame(
Frame f) {
83 public void onFrame(
Frame f) {
94 if(mHasColorRbg8 || mHasColorYuy)
99 mPointsTexture = mColorizer.
process(
d);
107 mHasColorRbg8 =
true;
115 mHasColorizedDepth =
true;
124 int uid = sp.getUniqueId();
125 if(!mFrames.containsKey(uid)){
147 int uid = sp.getUniqueId();
149 GLFrame curr = mFrames.get(uid);
155 ((GLPointsFrame) curr).setTextureFrame(mPointsTexture);
156 mPointsTexture.
close();
157 mPointsTexture = null;
164 for(Map.Entry<Integer,
GLFrame>
f : mFrames.entrySet())
165 f.getValue().close();
170 if(mPointsTexture != null) mPointsTexture.
close();
171 mPointsTexture = null;
176 Map<Integer, Pair<String,Rect>> rv =
new HashMap<>();
179 for (Map.Entry<Integer,
GLFrame>
entry : mFrames.entrySet()){
180 Point size = mWindowWidth > mWindowHeight ?
182 new Point(mWindowWidth, mWindowHeight / mFrames.size());
183 Point pos = mWindowWidth > mWindowHeight ?
184 new Point(i++ * size.x, 0) :
185 new Point(0, i++ * size.y);
186 rv.put(
entry.getKey(),
new Pair<>(
entry.getValue().getLabel(),
new Rect(pos.x, pos.y, pos.x + size.x, pos.y + size.y)));
198 mWindowWidth =
width;
205 GLES10.glViewport(0, 0, mWindowWidth, mWindowHeight);
206 GLES10.glClearColor(0, 0, 0, 1);
207 GLES10.glClear(GLES10.GL_COLOR_BUFFER_BIT | GLES10.GL_DEPTH_BUFFER_BIT);
209 if (mFrames.size() == 0)
214 for(Integer
uid : mFrames.keySet()){
217 Rect
r = rects.get(
uid).second;
218 if(mWindowHeight > mWindowWidth){
219 int newTop = mWindowHeight - r.height() - r.top;
220 r =
new Rect(r.left, newTop, r.right, newTop + r.height());
224 ((GLPointsFrame)fl).rotate(mDeltaX, mDeltaY);
239 default:
return false;
252 if(mPointcloud != null)
254 mPointcloud =
new HashMap<>();
259 if(mPointcloud == null)
void showPointcloud(boolean showPoints)
abstract void draw(Rect rect)
boolean isFormatSupported(StreamFormat format)
void onSurfaceChanged(GL10 gl, int width, int height)
Map< Integer, Pair< String, Rect > > calcRectangles()
Frame process(Frame original)
void choosePointsTexture(FrameSet frameSet)
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
FrameSet applyFilter(FilterInterface filter)
void onTouchEvent(float dx, float dy)
FrameSet applyFilters(FrameSet frameSet, List< FilterInterface > filters)
synchronized void setFrame(Frame frame)
final Map< Integer, GLFrame > mFrames
void foreach(FrameCallback callback)
List< FilterInterface > createProcessingPipe()
void onDrawFrame(GL10 gl)
void onSurfaceCreated(GL10 gl, EGLConfig config)
boolean mHasColorizedDepth
boolean is(Extension extension)
Map< StreamType, Pointcloud > mPointcloud
StreamProfile getProfile()
void upload(FrameSet frameSet)
Map< Integer, Pair< String, Rect > > getRectangles()
Frame first(StreamType type)
::geometry_msgs::Point_< std::allocator< void > > Point