Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.GL20


  @Override
  public void dispose () {
    tmpHandle.clear();
    tmpHandle.put(bufferHandle);
    tmpHandle.flip();
    GL20 gl = Gdx.gl20;
    gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
    gl.glDeleteBuffers(1, tmpHandle);
    bufferHandle = 0;
    BufferUtils.disposeUnsafeByteBuffer(byteBuffer);
  }
View Full Code Here


  public void end () {
    if (!drawing) throw new IllegalStateException("begin must be called before end.");
    drawing = false;

    shader.end();
    GL20 gl = Gdx.gl20;
    gl.glDepthMask(true);
    if (customShader != null)
      mesh.unbind(customShader);
    else
      mesh.unbind(shader);
  }
View Full Code Here

    isCompiled = true;
  }

  private int loadShader (int type, String source) {
    GL20 gl = Gdx.graphics.getGL20();
    IntBuffer intbuf = BufferUtils.newIntBuffer(1);

    int shader = gl.glCreateShader(type);
    if (shader == 0) return -1;

    gl.glShaderSource(shader, source);
    gl.glCompileShader(shader);
    gl.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, intbuf);

    int compiled = intbuf.get(0);
    if (compiled == 0) {
//      gl.glGetShaderiv(shader, GL20.GL_INFO_LOG_LENGTH, intbuf);
//      int infoLogLength = intbuf.get(0);
//      if (infoLogLength > 1) {
        String infoLog = gl.glGetShaderInfoLog(shader);
        log += infoLog;
//      }
      return -1;
    }
View Full Code Here

    return shader;
  }

  private int linkProgram () {
    GL20 gl = Gdx.graphics.getGL20();
    int program = gl.glCreateProgram();
    if (program == 0) return -1;

    gl.glAttachShader(program, vertexShaderHandle);
    gl.glAttachShader(program, fragmentShaderHandle);
    gl.glLinkProgram(program);

    ByteBuffer tmp = ByteBuffer.allocateDirect(4);
    tmp.order(ByteOrder.nativeOrder());
    IntBuffer intbuf = tmp.asIntBuffer();

    gl.glGetProgramiv(program, GL20.GL_LINK_STATUS, intbuf);
    int linked = intbuf.get(0);
    if (linked == 0) {
//      Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf);
//      int infoLogLength = intbuf.get(0);
//      if (infoLogLength > 1) {
View Full Code Here

  public boolean isCompiled () {
    return isCompiled;
  }

  private int fetchAttributeLocation (String name) {
    GL20 gl = Gdx.graphics.getGL20();
    int location;
    if ((location = attributes.get(name, -1)) == -1) {
      location = gl.glGetAttribLocation(program, name);
      if (location != -1) attributes.put(name, location);
    }
    return location;
  }
View Full Code Here

    }
    return location;
  }

  private int fetchUniformLocation (String name) {
    GL20 gl = Gdx.graphics.getGL20();
    int location;
    if ((location = uniforms.get(name, -1)) == -1) {
      location = gl.glGetUniformLocation(program, name);
      if (location == -1 && pedantic) throw new IllegalArgumentException("no uniform with name '" + name + "' in shader");
      uniforms.put(name, location);
    }
    return location;
  }
View Full Code Here

   * {@link #begin()}/{@link #end()} block.
   *
   * @param name the name of the uniform
   * @param value the value */
  public void setUniformi (String name, int value) {
    GL20 gl = Gdx.graphics.getGL20();
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform1i(location, value);
  }
View Full Code Here

   *
   * @param name the name of the uniform
   * @param value1 the first value
   * @param value2 the second value */
  public void setUniformi (String name, int value1, int value2) {
    GL20 gl = Gdx.graphics.getGL20();
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform2i(location, value1, value2);
  }
View Full Code Here

   * @param name the name of the uniform
   * @param value1 the first value
   * @param value2 the second value
   * @param value3 the third value */
  public void setUniformi (String name, int value1, int value2, int value3) {
    GL20 gl = Gdx.graphics.getGL20();
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform3i(location, value1, value2, value3);
  }
View Full Code Here

   * @param value1 the first value
   * @param value2 the second value
   * @param value3 the third value
   * @param value4 the fourth value */
  public void setUniformi (String name, int value1, int value2, int value3, int value4) {
    GL20 gl = Gdx.graphics.getGL20();
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform4i(location, value1, value2, value3, value4);
  }
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.