import jaclib.memory.heap.NativeHeapBuffer;
import jaggl.OpenGL;

public abstract class Class258 implements Interface34 {

   static int[] anIntArray3040 = new int[1];
   int anInt3041;
   static final int anInt3042 = 34962;
   int anInt3043;
   static final int anInt3044 = 34963;
   int anInt3045 = -1;
   int anInt3046;
   Class545_Sub2_Sub2 aClass545_Sub2_Sub2_3047;
   NativeHeapBuffer aNativeHeapBuffer3048;
   boolean aBool3049;


   void method4646() throws Throwable {
      this.method10();
      super.finalize();
   }

   void method4647() {
      if(this.anInt3045 < 0) {
         if(this.aClass545_Sub2_Sub2_3047.aBool10349) {
            OpenGL.glGenBuffersARB(1, anIntArray3040, 0);
            this.anInt3045 = anIntArray3040[0];
            OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
         } else {
            this.anInt3045 = 0;
         }

      }
   }

   public long method214(int var1, int var2) {
      OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
      return OpenGL.glMapBufferARB(this.anInt3043, '\u88b9') + (long)var1;
   }

   Class258(Class545_Sub2_Sub2 var1, int var2, boolean var3) {
      this.aClass545_Sub2_Sub2_3047 = var1;
      this.anInt3043 = var2;
      this.aBool3049 = var3;
   }

   void method4648() {
      if(this.aClass545_Sub2_Sub2_3047.aBool10349) {
         OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
      }

   }

   void method232(int var1) {
      if(var1 > this.anInt3041) {
         this.method4647();
         if(this.anInt3045 > 0) {
            OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
            OpenGL.glBufferDataARBub(this.anInt3043, var1, (byte[])null, 0, this.aBool3049?'\u88e0':'\u88e4');
            this.aClass545_Sub2_Sub2_3047.anInt9637 += var1 - this.anInt3041;
         } else {
            this.aNativeHeapBuffer3048 = this.aClass545_Sub2_Sub2_3047.method14989(var1, false);
         }

         this.anInt3041 = var1;
      }

      this.anInt3046 = var1;
   }

   public int method91() {
      return this.anInt3046;
   }

   public void method215() {
      OpenGL.glUnmapBufferARB(this.anInt3043);
   }

   public boolean method217(int var1, int var2, long var3) {
      this.method4647();
      if(this.anInt3045 > 0) {
         OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
         OpenGL.glBufferSubDataARBa(this.anInt3043, var1, var2, var3);
      } else {
         this.aNativeHeapBuffer3048.aNativeHeap557.copy(this.aNativeHeapBuffer3048.method75() + (long)var1, var3, var2);
      }

      return true;
   }

   void method10() {
      if(this.anInt3045 > 0) {
         this.aClass545_Sub2_Sub2_3047.method15906(this.anInt3045, this.anInt3046);
         this.anInt3045 = -1;
      }

   }

   public void finalize() throws Throwable {
      this.method10();
      super.finalize();
   }

   void method4649() throws Throwable {
      this.method10();
      super.finalize();
   }

   void method9() {
      if(this.anInt3045 > 0) {
         this.aClass545_Sub2_Sub2_3047.method15906(this.anInt3045, this.anInt3046);
         this.anInt3045 = -1;
      }

   }

   public int method83() {
      return this.anInt3046;
   }

   public void method153() {
      OpenGL.glUnmapBufferARB(this.anInt3043);
   }

   void method4650() throws Throwable {
      this.method10();
      super.finalize();
   }

   public int method34() {
      return this.anInt3046;
   }

   long method4651() {
      return this.anInt3045 == 0?this.aNativeHeapBuffer3048.method75():0L;
   }

   public int method31() {
      return this.anInt3046;
   }

   public boolean method218(int var1, int var2, long var3) {
      this.method4647();
      if(this.anInt3045 > 0) {
         OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
         OpenGL.glBufferSubDataARBa(this.anInt3043, var1, var2, var3);
      } else {
         this.aNativeHeapBuffer3048.aNativeHeap557.copy(this.aNativeHeapBuffer3048.method75() + (long)var1, var3, var2);
      }

      return true;
   }

   public boolean method216(int var1, int var2, long var3) {
      this.method4647();
      if(this.anInt3045 > 0) {
         OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
         OpenGL.glBufferSubDataARBa(this.anInt3043, var1, var2, var3);
      } else {
         this.aNativeHeapBuffer3048.aNativeHeap557.copy(this.aNativeHeapBuffer3048.method75() + (long)var1, var3, var2);
      }

      return true;
   }

   void method8() {
      if(this.anInt3045 > 0) {
         this.aClass545_Sub2_Sub2_3047.method15906(this.anInt3045, this.anInt3046);
         this.anInt3045 = -1;
      }

   }

   public int method29() {
      return this.anInt3046;
   }

   public void method147() {
      OpenGL.glUnmapBufferARB(this.anInt3043);
   }

   void method231(int var1) {
      if(var1 > this.anInt3041) {
         this.method4647();
         if(this.anInt3045 > 0) {
            OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
            OpenGL.glBufferDataARBub(this.anInt3043, var1, (byte[])null, 0, this.aBool3049?'\u88e0':'\u88e4');
            this.aClass545_Sub2_Sub2_3047.anInt9637 += var1 - this.anInt3041;
         } else {
            this.aNativeHeapBuffer3048 = this.aClass545_Sub2_Sub2_3047.method14989(var1, false);
         }

         this.anInt3041 = var1;
      }

      this.anInt3046 = var1;
   }

   public long method219(int var1, int var2) {
      OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
      return OpenGL.glMapBufferARB(this.anInt3043, '\u88b9') + (long)var1;
   }

   void method4652() {
      if(this.anInt3045 < 0) {
         if(this.aClass545_Sub2_Sub2_3047.aBool10349) {
            OpenGL.glGenBuffersARB(1, anIntArray3040, 0);
            this.anInt3045 = anIntArray3040[0];
            OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
         } else {
            this.anInt3045 = 0;
         }

      }
   }

   long method4653() {
      return this.anInt3045 == 0?this.aNativeHeapBuffer3048.method75():0L;
   }

   long method4654() {
      return this.anInt3045 == 0?this.aNativeHeapBuffer3048.method75():0L;
   }

   void method4655() {
      if(this.aClass545_Sub2_Sub2_3047.aBool10349) {
         OpenGL.glBindBufferARB(this.anInt3043, this.anInt3045);
      }

   }
}
