com.badlogic.gdx.graphics.GL30 Java Examples

The following examples show how to use com.badlogic.gdx.graphics.GL30. 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: BasePicker.java    From Mundus with Apache License 2.0 6 votes vote down vote up
public Pixmap getFrameBufferPixmap(Viewport viewport) {
    int w = viewport.getScreenWidth();
    int h = viewport.getScreenHeight();
    int x = viewport.getScreenX();
    int y = viewport.getScreenY();
    final ByteBuffer pixelBuffer = BufferUtils.newByteBuffer(w * h * 4);

    Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, fbo.getFramebufferHandle());
    Gdx.gl.glReadPixels(x, y, w, h, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE, pixelBuffer);
    Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, 0);

    final int numBytes = w * h * 4;
    byte[] imgLines = new byte[numBytes];
    final int numBytesPerLine = w * 4;
    for (int i = 0; i < h; i++) {
        pixelBuffer.position((h - i - 1) * numBytesPerLine);
        pixelBuffer.get(imgLines, i * numBytesPerLine, numBytesPerLine);
    }

    Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
    BufferUtils.copy(imgLines, 0, pixmap.getPixels(), imgLines.length);

    return pixmap;
}
 
Example #2
Source File: Main.java    From graphicsfuzz with Apache License 2.0 5 votes vote down vote up
private String glErrorToString(int error) {
  switch (error) {
    case GL30.GL_INVALID_ENUM: return "GL_INVALID_ENUM";
    case GL30.GL_INVALID_VALUE: return "GL_INVALID_VALUE";
    case GL30.GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
    case GL30.GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
    case GL30.GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
    default: return "GL_UNKNOWN_ERROR";
  }
}
 
Example #3
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 #4
Source File: SceneList.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private TextureRegion createBgIcon(String atlas, String region) {
	TextureAtlas a = new TextureAtlas(
			Gdx.files.absolute(Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/1/" + atlas + ".atlas"));
	AtlasRegion r = a.findRegion(region);

	if (r == null) {
		a.dispose();
		return null;
	}

	GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(200,
			(int) (r.getRegionHeight() * 200f / r.getRegionWidth()));

	frameBufferBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE);
	FrameBuffer fbo = frameBufferBuilder.build();

	SpriteBatch fboBatch = new SpriteBatch();
	fboBatch.setColor(Color.WHITE);
	OrthographicCamera camera = new OrthographicCamera();
	camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
	fboBatch.setProjectionMatrix(camera.combined);

	Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
	fbo.begin();
	fboBatch.begin();
	fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
	fboBatch.end();

	TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
	// tex.flip(false, true);

	fbo.end();
	Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

	fbo.dispose();
	a.dispose();
	fboBatch.dispose();

	return tex;
}
 
Example #5
Source File: IOSMini2DxGraphics.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public void setGL30 (GL30 gl30) {
	this.gl30 = gl30;
	if (gl30 != null) {
		this.gl20 = gl30;

		Gdx.gl = gl20;
		Gdx.gl20 = gl20;
		Gdx.gl30 = gl30;
	}
}
 
Example #6
Source File: DesktopLauncher.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
private static void start(
		String server,
		ImageJob standaloneRenderJob,
		String output,
		boolean shortBackoff) {
	Main main = new Main();
	if(standaloneRenderJob != null) {
		main.standaloneRenderJob = standaloneRenderJob;
		main.standaloneOutputFilename = output;
	}
	if(shortBackoff){
		main.setBackoffLimit(2);
	}

	main.setUrl(server);
   main.watchdog = new DesktopWatchdog();
   main.setOverrideLogger(new BothLogger());
   main.persistentData = new PersistentData();
	main.programBinaryGetter = new DesktopProgramBinaryGetter();
	main.computeJobManager = new DesktopComputeJobManager();

	try {
     Class<?> cl = DesktopLauncher.class.getClassLoader().loadClass("com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL30");
     Constructor<?> co = cl.getDeclaredConstructor();
     co.setAccessible(true);
     GL30 gl30 = (GL30) co.newInstance();
     main.gl30 = gl30;
   }
   catch (InvocationTargetException |NoSuchMethodException|ClassNotFoundException|IllegalAccessException|InstantiationException e) {
     throw new RuntimeException(e);
   }

	Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
	config.disableAudio(true);

	//config.forceExit = false;
	config.useOpenGL3(false, 3, 2);
	config.setHdpiMode(HdpiMode.Pixels);
	config.setTitle("GLES worker");
	config.setResizable(false);
	//config.foregroundFPS = 10;
	//config.backgroundFPS = 10;
	new Lwjgl3Application(main, config);
}
 
Example #7
Source File: GLTextureUtils.java    From libgdx-snippets with MIT License 4 votes vote down vote up
public static boolean isInternalFormatSupported(int target, int format) {
	tmp.clear();
	glGetInternalFormativ(target, format, GL_INTERNALFORMAT_SUPPORTED, tmp);
	return tmp.get(0) == GL30.GL_TRUE;
}
 
Example #8
Source File: Sprite3DRenderer.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void retrieveAssets() {
	// create STATIC BATCHS if not created yet
	if (modelBatch == null)
		createBatchs();

	createEnvirontment();

	for (String key : sourceCache.keySet()) {
		if (sourceCache.get(key).refCounter > 0)
			retrieveSource(key);
	}

	if (currentAnimation != null) { // RESTORE FA
		ModelCacheEntry entry = (ModelCacheEntry) sourceCache.get(currentAnimation.source);
		currentSource = entry;

		float speed = currentAnimation.duration;

		if (currentAnimationType == Tween.Type.REVERSE || currentAnimationType == Tween.Type.REVERSE_REPEAT)
			speed *= -1;

		((ModelCacheEntry) currentSource).controller.setAnimation(currentAnimation.id, currentCount, speed,
				animationListener);

		update(lastAnimationTime);

	} else if (initAnimation != null) {
		startAnimation(initAnimation, Tween.Type.SPRITE_DEFINED, 1, null);

		if (currentAnimation != null)
			lookat(modelRotation);
	}

	if (currentSource != null && renderShadow)
		genShadowMap();

	if (USE_FBO) {
		GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(width, height);

		frameBufferBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE);
		fb = frameBufferBuilder.build();

		tex = new TextureRegion(fb.getColorBufferTexture());
		tex.flip(false, true);

		renderTex();
	}

	computeBbox();
}
 
Example #9
Source File: IOSMini2DxGraphics.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public GL30 getGL30 () {
	return gl30;
}
 
Example #10
Source File: Lwjgl3Mini2DxGraphics.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public GL30 getGL30() {
	return gl30;
}
 
Example #11
Source File: Lwjgl3Mini2DxGraphics.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public void setGL30 (GL30 gl30) {
	this.gl30 = gl30;
}