Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.GL20


   *
   * @param name the name of the uniform
   * @param matrix the matrix
   * @param transpose whether the matrix should be transposed */
  public void setUniformMatrix (String name, Matrix4 matrix, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchUniformLocation(name);
    this.matrix.clear();
    BufferUtils.copy(matrix.val, this.matrix, matrix.val.length, 0);
    gl.glUniformMatrix4fv(location, 1, transpose, this.matrix);
  }
View Full Code Here


  public void setUniformMatrix (int location, Matrix4 matrix) {
    setUniformMatrix(location, matrix, false);
  }

  public void setUniformMatrix (int location, Matrix4 matrix, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    this.matrix.clear();
    BufferUtils.copy(matrix.val, this.matrix, matrix.val.length, 0);
    gl.glUniformMatrix4fv(location, 1, transpose, this.matrix);
  }
View Full Code Here

    if (!drawing) throw new IllegalStateException("SpriteBatch.begin must be called before end.");
    if (idx > 0) flush();
    lastTexture = null;
    drawing = false;

    GL20 gl = Gdx.gl;
    gl.glDepthMask(true);
    if (isBlendingEnabled()) gl.glDisable(GL20.GL_BLEND);

    if (customShader != null)
      customShader.end();
    else
      shader.end();
View Full Code Here

   *
   * @param name the name of the uniform
   * @param matrix the matrix
   * @param transpose whether the uniform matrix should be transposed */
  public void setUniformMatrix (String name, Matrix3 matrix, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchUniformLocation(name);
    float[] vals = matrix.getValues();
    this.matrix.clear();
    BufferUtils.copy(vals, this.matrix, vals.length, 0);
    gl.glUniformMatrix3fv(location, 1, transpose, this.matrix);
  }
View Full Code Here

  public void setUniformMatrix (int location, Matrix3 matrix) {
    setUniformMatrix(location, matrix, false);
  }

  public void setUniformMatrix (int location, Matrix3 matrix, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    float[] vals = matrix.getValues();
    this.matrix.clear();
    BufferUtils.copy(vals, this.matrix, vals.length, 0);
    gl.glUniformMatrix3fv(location, 1, transpose, this.matrix);
  }
View Full Code Here

   *
   * @param name the name of the uniform
   * @param buffer buffer containing the matrix data
   * @param transpose whether the uniform matrix should be transposed */
  public void setUniformMatrix3fv (String name, FloatBuffer buffer, int count, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    buffer.position(0);
    int location = fetchUniformLocation(name);
    gl.glUniformMatrix3fv(location, count, transpose, buffer);
  }
View Full Code Here

   *
   * @param name the name of the uniform
   * @param buffer buffer containing the matrix data
   * @param transpose whether the uniform matrix should be transposed */
  public void setUniformMatrix4fv (String name, FloatBuffer buffer, int count, boolean transpose) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    buffer.position(0);
    int location = fetchUniformLocation(name);
    gl.glUniformMatrix4fv(location, count, transpose, buffer);
  }
View Full Code Here

    colorTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    colorTexture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
  }

  private void build () {
    GL20 gl = Gdx.gl20;

    // iOS uses a different framebuffer handle! (not necessarily 0)
    if (!defaultFramebufferHandleInitialized) {
      defaultFramebufferHandleInitialized = true;
      if (Gdx.app.getType() == ApplicationType.iOS) {
        IntBuffer intbuf = ByteBuffer.allocateDirect(16 * Integer.SIZE / 8).order(ByteOrder.nativeOrder()).asIntBuffer();
        gl.glGetIntegerv(GL20.GL_FRAMEBUFFER_BINDING, intbuf);
        defaultFramebufferHandle = intbuf.get(0);
      } else {
        defaultFramebufferHandle = 0;
      }
    }

    setupTexture();

    IntBuffer handle = BufferUtils.newIntBuffer(1);
    gl.glGenFramebuffers(1, handle);
    framebufferHandle = handle.get(0);

    if (hasDepth) {
      handle.clear();
      gl.glGenRenderbuffers(1, handle);
      depthbufferHandle = handle.get(0);
    }

    gl.glBindTexture(GL20.GL_TEXTURE_2D, colorTexture.getTextureObjectHandle());

    if (hasDepth) {
      gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, depthbufferHandle);
      gl.glRenderbufferStorage(GL20.GL_RENDERBUFFER, GL20.GL_DEPTH_COMPONENT16, colorTexture.getWidth(),
        colorTexture.getHeight());
    }

    gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, framebufferHandle);
    gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, GL20.GL_TEXTURE_2D,
      colorTexture.getTextureObjectHandle(), 0);
    if (hasDepth) {
      gl.glFramebufferRenderbuffer(GL20.GL_FRAMEBUFFER, GL20.GL_DEPTH_ATTACHMENT, GL20.GL_RENDERBUFFER, depthbufferHandle);
    }
    int result = gl.glCheckFramebufferStatus(GL20.GL_FRAMEBUFFER);

    gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, 0);
    gl.glBindTexture(GL20.GL_TEXTURE_2D, 0);
    gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, defaultFramebufferHandle);

    if (result != GL20.GL_FRAMEBUFFER_COMPLETE) {
      colorTexture.dispose();
      if (hasDepth) {
        handle.clear();
        handle.put(depthbufferHandle);
        handle.flip();
        gl.glDeleteRenderbuffers(1, handle);
      }

      handle.clear();
      handle.put(framebufferHandle);
      handle.flip();
      gl.glDeleteFramebuffers(1, handle);

      if (result == GL20.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)
        throw new IllegalStateException("frame buffer couldn't be constructed: incomplete attachment");
      if (result == GL20.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS)
        throw new IllegalStateException("frame buffer couldn't be constructed: incomplete dimensions");
View Full Code Here

    }
  }

  /** Releases all resources associated with the FrameBuffer. */
  public void dispose () {
    GL20 gl = Gdx.gl20;

    IntBuffer handle = BufferUtils.newIntBuffer(1);

    colorTexture.dispose();
    if (hasDepth) {
      handle.put(depthbufferHandle);
      handle.flip();
      gl.glDeleteRenderbuffers(1, handle);
    }

    handle.clear();
    handle.put(framebufferHandle);
    handle.flip();
    gl.glDeleteFramebuffers(1, handle);

    if (buffers.get(Gdx.app) != null) buffers.get(Gdx.app).removeValue(this, true);
  }
View Full Code Here

    bind(shader, null);
  }

  @Override
  public void bind (final ShaderProgram shader, final int[] locations) {
    final GL20 gl = Gdx.gl20;

    gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle);
    if (isDirty) {
      byteBuffer.limit(buffer.limit() * 4);
      gl.glBufferData(GL20.GL_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage);
      isDirty = false;
    }

    final int numAttributes = attributes.size();
    if (locations == null) {
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.GL20

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.