1> glSurface view 설정 한다.
setZorderOnTop, setEGLConfigChooser, getHolder().setFormat 을 설정한다.
val binding by lazy { ActivityShapeBinding.inflate(layoutInflater) }
with (binding) {
glSurfaceView.setEGLContextClientVersion(2)
glSurfaceView.setZOrderOnTop(true);
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0)
glSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888)
glSurfaceView.setRenderer(this@ShapeActivity)
glSurfaceView.renderMode = GLSurfaceView.RENDERMODE_CONTINUOUSLY
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_shape"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".ShapeActivity">
.....
<android.opengl.GLSurfaceView
android:id="@+id/glSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_marginTop="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
2> glClear할때 마지막 알파값을 0으로 해준다.
override fun onSurfaceCreated(p0: GL10?, p1: EGLConfig?) {
GLES31.glClearColor(0f, 0f, 0f, 0f)
...
}
override fun onDrawFrame(p0: GL10?) {
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT)
....
}
3>frag shader에서 alpha 값을 설정한다.
void main(void) {
....
FragColor = vec4(col, 0.);
}
'Andorid Kotlin' 카테고리의 다른 글
리사이클 레코드 보여주기 (0) | 2024.10.02 |
---|---|
액티비티간 데이터 주고 받기 (0) | 2024.10.02 |
common 위젯 사용 (seekBar, toggle, progress bar, spiner (0) | 2024.10.02 |
체크박스 리스너 등록 (1) | 2024.10.02 |
layout에 생성한 오브젝트 접근 방법 (0) | 2024.10.01 |