Pro Android with Kotlin


CHAPTER 9: User Interface


Download 5.42 Mb.
Pdf ko'rish
bet184/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   180   181   182   183   184   185   186   187   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile



225
CHAPTER 9: User Interface
var triangle:Triangle? = null
var square:Square? = null
var program:Int? = 0
val vbo = IntArray(2) // vertex buffers
val ibo = IntArray(2) // index buffers
val vMatrix:FloatArray = FloatArray(16)
val projMatrix:FloatArray = FloatArray(16)
val mvpMatrix:FloatArray = FloatArray(16)
The method onSurfaceCreated() just gets called once by the system when the OpenGL 
rendering is ready to go. We use it to set some rendering flags and to initialize the shaders.
// Called once to set up the view's
// OpenGL ES environment.
override fun onSurfaceCreated(gl: GL10?, config:
javax.microedition.khronos.egl.EGLConfig?) {
// enable face culling feature
GLES20.glEnable(GL10.GL_CULL_FACE)
// specify which faces to not draw
GLES20.glCullFace(GL10.GL_BACK)
// Set the background frame color
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f)
val vertexShader = loadShader(
GLES20.GL_VERTEX_SHADER,
vertexShaderCode)
val fragmentShader = loadShader(
GLES20.GL_FRAGMENT_SHADER,
fragmentShaderCode)
// create empty OpenGL ES Program
program = GLES20.glCreateProgram()
// add the vertex shader to program
GLES20.glAttachShader(program!!, vertexShader)
// add the fragment shader to program
GLES20.glAttachShader(program!!, fragmentShader)
// creates OpenGL ES program executables
GLES20.glLinkProgram(program!!)
GLES20.glGenBuffers(2, vbo, 0) // just buffer names
GLES20.glGenBuffers(2, ibo, 0)



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   180   181   182   183   184   185   186   187   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling