6. Rendering
When ARGSession.drawFrame is called, it starts to render video frames with various effects such as item, filter, and beauty. Which effects should be applied is determined by how the ARGear configuration is set.
ARGSession.drawFrame returns ARGFrame as a result, which contains texture id and configured information in ARGInferenceConfig.Feature.
From the application layer, you can draw the effects applied frames easily as the following sample code.
Java
Kotlin
1
// Sample Renderer Code in Application Layer
2
ScreenRenderer mScreenRenderer = new ScreenRenderer();
3
4
GLView.GLViewListener glViewListener = new GLView.GLViewListener() {
5
@Override
6
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
7
mScreenRenderer.create(gl, config);
8
}
9
10
@Override
11
public void onDrawFrame(GL10 gl, int width, int height) {
12
ARGFrame frame = argsession.drawFrame(gl, width, height);
13
mScreenRenderer.draw(frame, ARGFrame.Ratio.RATIO_4_3, width, height);
14
}
15
};
Copied!
1
var screenRenderer = ScreenRenderer()
2
3
private var glViewListener: GLView.GLViewListener = object : GLView.GLViewListener {
4
override fun onSurfaceCreated(
5
gl: GL10?,
6
config: EGLConfig?
7
) {
8
screenRenderer.create(gl, config)
9
}
10
11
override fun onDrawFrame(gl: GL10?, width: Int?, height: Int?) {
12
13
val localWidth = width ?: 0
14
val localHeight = height ?: 0
15
val frame = argSession.drawFrame(gl, ARGFrame.Ratio.RATIO_4_3, localWidth, localHeight)
16
frame?.let {
17
screenRenderer.draw(it, localWidth, localHeight)
18
}
19
}
20
}
Copied!
Last modified 1yr ago
Copy link