예제 #1
0
  public Skybox(String texture) {
    vertexBuffer = BufferUtils.newFloatBuffer(72);
    vertexBuffer.put(
        new float[] {
          -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
          -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
          0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f,
          0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f,
          0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f,
          -0.5f, 0.5f, -0.5f, 0.5f
        });
    vertexBuffer.rewind();

    texCoordBuffer = BufferUtils.newFloatBuffer(48);
    texCoordBuffer.put(
        new float[] {
          0.5f, 0.75f, 0.5f, 1.0f, 0.25f, 0.75f, 0.25f, 1.0f, // bottom
          0.25f, 0.75f, 0f, 0.75f, 0.25f, 0.5f, 0f, 0.5f, // left
          0.25f, 0.5f, 0.25f, 0.25f, 0.5f, 0.5f, 0.5f, 0.25f, // top
          0.5f, 0.5f, 0.75f, 0.5f, 0.5f, 0.75f, 0.75f, 0.75f, // right
          0.75f, 0.75f, 0.75f, 0.5f, 1f, 0.75f, 1.0f, 0.5f, // right right
          0.5f, 0.75f, 0.5f, 0.5f, 0.25f, 0.75f, 0.25f, 0.5f, // center
        });
    texCoordBuffer.rewind();

    tex = new Texture(Gdx.files.internal(texture));
    useTexture = true;
  }
예제 #2
0
  /**
   * Constructs a new interleaved VertexBufferObject.
   *
   * @param isStatic whether the vertex data is static.
   * @param numVertices the maximum number of vertices
   * @param attributes the {@link VertexAttributes}.
   */
  public VertexArrayEmulator(boolean isStatic, int numVertices, VertexAttributes attributes) {
    this.isStatic = isStatic;
    this.attributes = attributes;

    buffer = BufferUtils.newFloatBuffer(this.attributes.vertexSize / 4 * numVertices);
    buffer.flip();
    bufferHandle = Gdx.gl20.glGenBuffer();
    usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
  }
예제 #3
0
  public static void create(int vertexPointer) {

    CannonGraphic.vertexPointer = vertexPointer;

    // VERTEX ARRAY IS FILLED HERE
    float[] array = {-20f, 60f, -20f, -60f, 20f, -60f, 20f, 60f};

    vertexBuffer = BufferUtils.newFloatBuffer(8);
    vertexBuffer.put(array);
    vertexBuffer.rewind();
  }
예제 #4
0
  public void CreateWall() {
    vertexBuffer = BufferUtils.newFloatBuffer(72);

    vertexBuffer.put(
        new float[] {
          -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
          -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
          0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f,
          0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f,
          0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f,
          -0.5f, 0.5f, -0.5f, 0.5f
        });
    vertexBuffer.rewind();

    texCoordBuffer = BufferUtils.newFloatBuffer(8);
    texCoordBuffer.put(new float[] {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f});
    texCoordBuffer.rewind();

    // tex = new Texture(Gdx.files.internal("textures/block.jpg"));
  }
 public BufferObject(final int pCapacity, final int pDrawType) {
   this.mDrawType = pDrawType;
   this.mBufferData = new float[pCapacity];
   this.mFloatBuffer = BufferUtils.newFloatBuffer(pCapacity);
 }