Java Code Examples for com.badlogic.gdx.graphics.GL20#GL_NO_ERROR

The following examples show how to use com.badlogic.gdx.graphics.GL20#GL_NO_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java    From graphicsfuzz with Apache License 2.0 6 votes vote down vote up
private boolean isProgramValid() {
  Gdx.gl.glValidateProgram(program.getProgramHandle());
  int glErr = Gdx.gl.glGetError();
  if (glErr != GL20.GL_NO_ERROR) {
    Gdx.app.log("Main", "glValidateProgram RAISED ERROR");
  }
  ByteBuffer bb = ByteBuffer.allocateDirect(16);
  bb.order(ByteOrder.nativeOrder());
  IntBuffer res = bb.asIntBuffer();
  res.position(0);
  res.put(0);
  Gdx.gl.glGetProgramiv(program.getProgramHandle(), GL20.GL_VALIDATE_STATUS, res);
  glErr = Gdx.gl.glGetError();
  if (glErr != GL20.GL_NO_ERROR) {
    Gdx.app.log("Main", "glGetProgramiv RAISED ERROR");
  }
  res.position(0);
  int validInt = res.get();
  return (validInt == GL20.GL_TRUE);
}
 
Example 2
Source File: PlatformInfoUtil.java    From graphicsfuzz with Apache License 2.0 5 votes vote down vote up
public static void getGlVersionInfo(JsonObject platformInfoJson, GL30 gl30) {

    BufferUtils.newIntBuffer(16);

    platformInfoJson.addProperty("GL_VERSION", Gdx.gl.glGetString(GL20.GL_VERSION));
    platformInfoJson.addProperty("GL_SHADING_LANGUAGE_VERSION", Gdx.gl.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION));
    platformInfoJson.addProperty("GL_VENDOR", Gdx.gl.glGetString(GL20.GL_VENDOR));
    platformInfoJson.addProperty("GL_RENDERER", Gdx.gl.glGetString(GL20.GL_RENDERER));

    IntBuffer buff = BufferUtils.newIntBuffer(16);

    buff.clear();
    Gdx.gl.glGetIntegerv(GL30.GL_MAJOR_VERSION, buff);
    platformInfoJson.addProperty("GL_MAJOR_VERSION", buff.get(0));

    buff.clear();
    Gdx.gl.glGetIntegerv(GL30.GL_MINOR_VERSION, buff);
    platformInfoJson.addProperty("GL_MINOR_VERSION", buff.get(0));

    JsonArray array = new JsonArray();
    try {
      final int GL_NUM_SHADING_LANGUAGE_VERSIONS = 0x82E9;
      buff.clear();
      Gdx.gl.glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, buff);
      if(Gdx.gl.glGetError() == GL20.GL_NO_ERROR && gl30 != null) {
        int size = buff.get(0);
        for(int i=0; i < size; ++i) {
          array.add(gl30.glGetStringi(GL20.GL_SHADING_LANGUAGE_VERSION, i));
        }
      }
    }
    catch (IllegalStateException e) {
      // The above may not work depending what OpenGL version is supported.
    }
    platformInfoJson.add("Supported_GLSL_versions", array);

  }
 
Example 3
Source File: GdxRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void checkGLError2() {
    int error;
    while ((error = Gdx.gl20.glGetError()) != GL20.GL_NO_ERROR) {
        logger.log(Level.WARNING, "glError {0}", error);
        //	throw new RuntimeException("glError " + error);
    }
}
 
Example 4
Source File: Main.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
public static void checkForGlError() throws com.graphicsfuzz.glesworker.GlErrorException {
  int error = Gdx.gl.glGetError();
  if(error != GL20.GL_NO_ERROR) {
    throw new com.graphicsfuzz.glesworker.GlErrorException(error);
  }
}
 
Example 5
Source File: Main.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
private void prepareProgram(String vertexSource, String fragmentSource, String uniformsInfo,
    boolean getProgramBinary) throws PrepareShaderException {

  try {
    watchdog.start(watchdogMutex,"CompileWatchdog", COMPILE_SHADER_WATCHDOG_TIME_SECONDS, persistentData);

    clearProgram();

    Gdx.app.log("Main","Compiling shader.");

    long compilation_start = System.nanoTime();

    program = new MyShaderProgram(vertexSource, fragmentSource);

    long compilation_time_microsec = (System.nanoTime() - compilation_start) / 1000;
    timingInfo.setCompilationTime(new Long(compilation_time_microsec).intValue());
    persistentData.setInt(Constants.PERSISTENT_KEY_TIME_COMPILE, timingInfo.getCompilationTime());
    Gdx.app.log("Main","Compilation Time, in microsec: "  + timingInfo.getCompilationTime());

    if(program.fragmentOrVertexFailedToCompile()) {
      throw new PrepareShaderException(
          ResultConstant.COMPILE_ERROR,
          program.getLog());
    }

    if(program.failedToLink()) {
      throw new PrepareShaderException(
          ResultConstant.LINK_ERROR,
          program.getLog());
    }

    if(!program.isCompiled()) {
      throw new PrepareShaderException(
          ResultConstant.UNEXPECTED_ERROR,
          "Did not expect to get here! Shader failed to compile?");
    }

    uniformDict = UniformSetter.getUniformDict(uniformsInfo);

    programBinaryWritten = false;

    if (programBinaryGetter != null) {
      if (getProgramBinary) {
        int[] bytesWritten = new int[1];
        int[] binaryFormatWritten = new int[1];

        if (programBinaryBytes == null) {
          programBinaryBytes = ByteBuffer.allocateDirect(INITIAL_BYTES_FOR_PROGRAM_BINARY);
        }

        programBinaryBytes.position(0);
        programBinaryBytes.limit(programBinaryBytes.capacity());

        try {
          programBinaryGetter.glGetProgramBinary(
              program.getProgramHandle(),
              bytesWritten,
              binaryFormatWritten,
              programBinaryBytes);

          if (Gdx.gl.glGetError() == GL20.GL_NO_ERROR) {
            programBinaryBytes.position(0);
            // Set the limit (size) to the number of bytes written:
            programBinaryBytes.limit(bytesWritten[0]);
            programBinaryWritten = true;

            Gdx.app.log("Main", "Successfully read program binary.");

          } else {
            // There was an error getting the binary: ignore it.
            // TODO: The binary might be too big for our buffer; if so, retry.

            Gdx.app.log("Main", "GL error getting program binary.");
          }
        } catch (Exception ex) {
          Gdx.app.log("Main", "Exception getting program binary.", ex);
        }
      }
      else {
        Gdx.app.log("Main", "Skipped getting program binary.");
      }
    } else {
      Gdx.app.log("Main", "Getting program binary is not supported by app version.");
    }
  }
  finally {
    watchdog.stop();
  }
}