SHARE
TWEET

Untitled

a guest Nov 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyRenderer: GLSurfaceView.Renderer {
  2.     private var kat = 0f
  3.     override fun onDrawFrame(gl: GL10?) {
  4.         var points = mutableListOf<Float>()
  5.         var x = 0.0f
  6.  
  7.         for(i in 1..255)
  8.         {
  9.             var k = i.toFloat()
  10.  
  11.             points.add(sin(x) * 0.1f)
  12.             points.add(cos(x) * 0.1f)
  13.             points.add(-1.0f)
  14.  
  15.             x = ((k / 255) * PI.toFloat() * 2)
  16.         }
  17.  
  18.         val bufor = ByteBuffer.allocateDirect(256 * 3 * 4)
  19.         bufor.order(ByteOrder.nativeOrder())
  20.  
  21.         val bufor_wierzcholkow = bufor.asFloatBuffer()
  22.         bufor_wierzcholkow.put(points.toFloatArray())
  23.         bufor_wierzcholkow.position(0)
  24.  
  25.         gl?.glClear(GL10.GL_COLOR_BUFFER_BIT or GL10.GL_DEPTH_BUFFER_BIT)
  26.         gl?.glColor4f(0.0f, 0.0f, 1.0f, 1.0f)
  27.         gl?.glLoadIdentity()
  28.         gl?.glEnableClientState(GL10.GL_VERTEX_ARRAY)
  29.         gl?.glVertexPointer(3, GL10.GL_FLOAT, 0, bufor_wierzcholkow)
  30.         gl?.glDrawArrays(GL10.GL_TRIANGLES, 0, 256)
  31.         gl?.glDisableClientState(GL10.GL_VERTEX_ARRAY)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top