Beispiel #1
0
 public Tessellator(int p_i52_1_) {
   renderingChunk = false;
   defaultTexture = true;
   autoGrow = true;
   subTessellators = new Tessellator[0];
   subTextures = new int[0];
   terrainTexture = 0;
   textureUpdateTime = 0L;
   field_1505_h = 0;
   field_1501_l = false;
   field_1500_m = false;
   field_35838_p = false;
   field_1499_n = false;
   field_1498_o = 0;
   field_1497_p = 0;
   field_1495_q = false;
   field_1488_w = false;
   field_1487_x = false;
   field_1485_z = 0;
   field_1496_A = 10;
   field_1494_B = p_i52_1_;
   field_1509_d = GLAllocation.func_1127_b(p_i52_1_ * 4);
   field_1508_e = field_1509_d.asIntBuffer();
   field_1507_f = field_1509_d.asFloatBuffer();
   field_35836_g = field_1509_d.asShortBuffer();
   field_1506_g = new int[p_i52_1_];
   field_1487_x = field_1510_c && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
   if (field_1487_x) {
     field_1486_y = GLAllocation.func_1125_c(field_1496_A);
     ARBVertexBufferObject.glGenBuffersARB(field_1486_y);
   }
 }
  Tessellator(int par1) {
    vertexCount = 0;
    hasColor = false;
    hasTexture = false;
    hasBrightness = false;
    hasNormals = false;
    rawBufferIndex = 0;
    addedVertices = 0;
    isColorDisabled = false;
    isDrawing = false;
    useVBO = false;
    vboIndex = 0;
    vboCount = 10;
    bufferSize = par1;
    byteBuffer = GLAllocation.createDirectByteBuffer(par1 * 4);
    intBuffer = byteBuffer.asIntBuffer();
    floatBuffer = byteBuffer.asFloatBuffer();
    shortBuffer = byteBuffer.asShortBuffer();
    rawBuffer = new int[par1];
    useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;

    if (useVBO) {
      vertexBuffers = GLAllocation.createDirectIntBuffer(vboCount);
      ARBVertexBufferObject.glGenBuffersARB(vertexBuffers);
    }
  }
 private void attachIndexBuffer(int id, IntBuffer buf) {
   buf.rewind();
   ARBVertexBufferObject.glBufferDataARB(
       ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
       buf,
       ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
 }
 private Tessellator(int par1) {
   this.bufferSize = par1;
   this.byteBuffer = GLAllocation.createDirectByteBuffer(par1 * 4);
   this.intBuffer = this.byteBuffer.asIntBuffer();
   this.floatBuffer = this.byteBuffer.asFloatBuffer();
   this.shortBuffer = this.byteBuffer.asShortBuffer();
   this.rawBuffer = new int[par1];
   this.useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
   if (this.useVBO) {
     this.vertexBuffers = GLAllocation.createDirectIntBuffer(this.vboCount);
     ARBVertexBufferObject.glGenBuffersARB(this.vertexBuffers);
   }
 }
Beispiel #5
0
  public int func_982_a() {
    if (!field_1488_w) {
      throw new IllegalStateException("Not tesselating!");
    }
    if (renderingChunk && subTessellators.length > 0) {
      boolean flag = false;
      for (int j = 0; j < subTessellators.length; j++) {
        int k = subTextures[j];
        if (k <= 0) {
          break;
        }
        Tessellator tessellator = subTessellators[j];
        if (tessellator.field_1488_w) {
          GL11.glBindTexture(3553, k);
          tessellator.func_982_a();
          flag = true;
        }
      }

      if (flag) {
        GL11.glBindTexture(3553, getTerrainTexture());
      }
    }
    field_1488_w = false;
    if (field_1505_h > 0) {
      field_1508_e.clear();
      field_1508_e.put(field_1506_g, 0, field_1498_o);
      field_1509_d.position(0);
      field_1509_d.limit(field_1498_o * 4);
      if (field_1487_x) {
        field_1485_z = (field_1485_z + 1) % field_1496_A;
        ARBVertexBufferObject.glBindBufferARB(34962, field_1486_y.get(field_1485_z));
        ARBVertexBufferObject.glBufferDataARB(34962, field_1509_d, 35040);
      }
      if (field_1500_m) {
        if (field_1487_x) {
          GL11.glTexCoordPointer(2, 5126, 32, 12L);
        } else {
          field_1507_f.position(3);
          GL11.glTexCoordPointer(2, 32, field_1507_f);
        }
        GL11.glEnableClientState(32888);
      }
      if (field_35838_p) {
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40455_b);
        if (field_1487_x) {
          GL11.glTexCoordPointer(2, 5122, 32, 28L);
        } else {
          field_35836_g.position(14);
          GL11.glTexCoordPointer(2, 32, field_35836_g);
        }
        GL11.glEnableClientState(32888);
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40457_a);
      }
      if (field_1501_l) {
        if (field_1487_x) {
          GL11.glColorPointer(4, 5121, 32, 20L);
        } else {
          field_1509_d.position(20);
          GL11.glColorPointer(4, true, 32, field_1509_d);
        }
        GL11.glEnableClientState(32886);
      }
      if (field_1499_n) {
        if (field_1487_x) {
          GL11.glNormalPointer(5121, 32, 24L);
        } else {
          field_1509_d.position(24);
          GL11.glNormalPointer(32, field_1509_d);
        }
        GL11.glEnableClientState(32885);
      }
      if (field_1487_x) {
        GL11.glVertexPointer(3, 5126, 32, 0L);
      } else {
        field_1507_f.position(0);
        GL11.glVertexPointer(3, 32, field_1507_f);
      }
      GL11.glEnableClientState(32884);
      if (field_1493_r == 7 && field_1511_b) {
        GL11.glDrawArrays(4, 0, field_1505_h);
      } else {
        GL11.glDrawArrays(field_1493_r, 0, field_1505_h);
      }
      GL11.glDisableClientState(32884);
      if (field_1500_m) {
        GL11.glDisableClientState(32888);
      }
      if (field_35838_p) {
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40455_b);
        GL11.glDisableClientState(32888);
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40457_a);
      }
      if (field_1501_l) {
        GL11.glDisableClientState(32886);
      }
      if (field_1499_n) {
        GL11.glDisableClientState(32885);
      }
    }
    int i = field_1498_o * 4;
    func_985_d();
    return i;
  }
  /** Draws the data set up in this tessellator and resets the state to prepare for new drawing. */
  public int draw() {
    if (!isDrawing) {
      throw new IllegalStateException("Not tesselating!");
    }

    isDrawing = false;

    if (vertexCount > 0) {
      intBuffer.clear();
      intBuffer.put(rawBuffer, 0, rawBufferIndex);
      byteBuffer.position(0);
      byteBuffer.limit(rawBufferIndex * 4);

      if (useVBO) {
        vboIndex = (vboIndex + 1) % vboCount;
        ARBVertexBufferObject.glBindBufferARB(
            ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, vertexBuffers.get(vboIndex));
        ARBVertexBufferObject.glBufferDataARB(
            ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
            byteBuffer,
            ARBVertexBufferObject.GL_STREAM_DRAW_ARB);
      }

      if (hasTexture) {
        if (useVBO) {
          GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 32, 12L);
        } else {
          floatBuffer.position(3);
          GL11.glTexCoordPointer(2, 32, floatBuffer);
        }

        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      }

      if (hasBrightness) {
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);

        if (useVBO) {
          GL11.glTexCoordPointer(2, GL11.GL_SHORT, 32, 28L);
        } else {
          shortBuffer.position(14);
          GL11.glTexCoordPointer(2, 32, shortBuffer);
        }

        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
      }

      if (hasColor) {
        if (useVBO) {
          GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 32, 20L);
        } else {
          byteBuffer.position(20);
          GL11.glColorPointer(4, true, 32, byteBuffer);
        }

        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
      }

      if (hasNormals) {
        if (useVBO) {
          GL11.glNormalPointer(GL11.GL_UNSIGNED_BYTE, 32, 24L);
        } else {
          byteBuffer.position(24);
          GL11.glNormalPointer(32, byteBuffer);
        }

        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
      }

      if (useVBO) {
        GL11.glVertexPointer(3, GL11.GL_FLOAT, 32, 0L);
      } else {
        floatBuffer.position(0);
        GL11.glVertexPointer(3, 32, floatBuffer);
      }

      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);

      if (drawMode == 7 && convertQuadsToTriangles) {
        GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount);
      } else {
        GL11.glDrawArrays(drawMode, 0, vertexCount);
      }

      GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

      if (hasTexture) {
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      }

      if (hasBrightness) {
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
      }

      if (hasColor) {
        GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
      }

      if (hasNormals) {
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
      }
    }

    int i = rawBufferIndex * 4;
    reset();
    return i;
  }
 public void bind(int id, int target) {
   ARBVertexBufferObject.glBindBufferARB(target, id);
 }
 private void attachDrawBuffer(int id, FloatBuffer buf) {
   buf.rewind();
   ARBVertexBufferObject.glBufferDataARB(
       ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buf, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
 }
 private int createID() {
   IntBuffer id = BufferUtils.createIntBuffer(1);
   ARBVertexBufferObject.glGenBuffersARB(id);
   return id.get(0);
 }
Beispiel #10
0
  public int draw() {
    if (!this.isDrawing) {
      throw new IllegalStateException("Not tesselating!");
    } else {
      this.isDrawing = false;
      if (this.vertexCount > 0) {
        this.intBuffer.clear();
        this.intBuffer.put(this.rawBuffer, 0, this.rawBufferIndex);
        this.byteBuffer.position(0);
        this.byteBuffer.limit(this.rawBufferIndex * 4);
        if (this.useVBO) {
          this.vboIndex = (this.vboIndex + 1) % this.vboCount;
          ARBVertexBufferObject.glBindBufferARB(
              ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.vertexBuffers.get(this.vboIndex));
          ARBVertexBufferObject.glBufferDataARB(
              ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
              this.byteBuffer,
              ARBVertexBufferObject.GL_STREAM_DRAW_ARB);
        }

        if (this.hasTexture) {
          if (this.useVBO) {
            GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 32, 12L);
          } else {
            this.floatBuffer.position(3);
            GL11.glTexCoordPointer(2, 32, this.floatBuffer);
          }

          GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

          // Spout Start
          if (textureOverride > 0) GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureOverride);
          // Spout End
        }

        if (this.hasBrightness) {
          OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapEnabled);
          if (this.useVBO) {
            GL11.glTexCoordPointer(2, GL11.GL_SHORT, 32, 28L);
          } else {
            this.shortBuffer.position(14);
            GL11.glTexCoordPointer(2, 32, this.shortBuffer);
          }

          GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
          OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapDisabled);
        }

        if (this.hasColor) {
          if (this.useVBO) {
            GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 32, 20L);
          } else {
            this.byteBuffer.position(20);
            GL11.glColorPointer(4, true, 32, this.byteBuffer);
          }

          GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        }

        if (this.hasNormals) {
          if (this.useVBO) {
            GL11.glNormalPointer(GL11.GL_UNSIGNED_BYTE, 32, 24L);
          } else {
            this.byteBuffer.position(24);
            GL11.glNormalPointer(32, this.byteBuffer);
          }

          GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        }

        if (this.useVBO) {
          GL11.glVertexPointer(3, GL11.GL_FLOAT, 32, 0L);
        } else {
          this.floatBuffer.position(0);
          GL11.glVertexPointer(3, 32, this.floatBuffer);
        }

        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        if (this.drawMode == 7 && convertQuadsToTriangles) {
          GL11.glDrawArrays(4, 0, this.vertexCount);
        } else {
          GL11.glDrawArrays(this.drawMode, 0, this.vertexCount);
        }

        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        if (this.hasTexture) {
          GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        }

        if (this.hasBrightness) {
          OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapEnabled);
          GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
          OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapDisabled);
        }

        if (this.hasColor) {
          GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
        }

        if (this.hasNormals) {
          GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
        }
      }

      int var1 = this.rawBufferIndex * 4;
      this.reset();
      return var1;
    }
  }
 @Override
 public void bufferData(int target, int usage) {
   ARBVertexBufferObject.glBufferDataARB(target, doubleBuffer, usage);
 }