[LibGDX] Updated LibGDX, crashes when creating SpriteBatch.

It was a while ago since I updated LibGDX. So when I did I first got some compile time errors with the stage class.

I changed the constructor from (int width, int height, boolean something) to (ScreenViewport()).
That solved those.

I tried to run my game and it crashed as I tried to initiate a sprite batch.

The code that crashed:

batch = new SpriteBatch();

The exception:

LwjglGraphics: created OpenGL 3.2+ core profile context. This is experimental!
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Error compiling shader: Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors.  No code generated

Fragment shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors.  No code generated


	at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:152)
	at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:115)
	at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:72)
	at ui.screens.Splash.show(Splash.java:41)
	at com.badlogic.gdx.Game.setScreen(Game.java:61)
	at ui.screens.ScreenManager.create(ScreenManager.java:33)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

How do I resolve this?

Shader version 110 is not compatible with GL3 as the error states.

LwjglGraphics: created OpenGL 3.2+ core profile context. This is experimental!

Hello guys, I have the same problem, how can I solve??

I tried to use config.usesgl30 = true/false, but doesn’t work :S

Edit the shader source files and add the following line in the top.


#version 330

I’m not sure whether the shader source is converted to GLSL 3.30 or not.

The class “com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader” is locked to edit.

The main error is:

		ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
		if (shader.isCompiled() == false) throw new IllegalArgumentException("Error compiling shader: " + shader.getLog());
		return shader;

I tried to force GL30 to evoid the version 110 and I get the version here:

		System.out.println (Gdx.gl.glGetString(GL30.GL_VERSION ));

And returns:

3.2.13283 Core Profile Context 14.501.1003.0

I really don’t know what to do, I think this issue started after I bought a R9 270 (GPU).

[quote]The class “com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader” is locked to edit.
[/quote]
He means in your shader files, not libGDX classes.