title: Couldn't initialise audio and illegal state exception
body: <p>I keep getting an error when I run this code.</p>
  
  <pre><code>WARNING: An illegal reflective access operation has occurred
  WARNING: Illegal reflective access by org.lwjgl.LWJGLUtil$3 (file:/C:/Users/david/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl/2.9.3/3df168ac74e4a8c96562cdff24ad352e255bf89c/lwjgl-2.9.3.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
  WARNING: Please consider reporting this to the maintainers of org.lwjgl.LWJGLUtil$3
  WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
  WARNING: All illegal access operations will be denied in a future release
  [LwjglApplication] Couldn't initialize audio, disabling audio
  java.lang.IllegalStateException: Only one OpenAL context may be instantiated at any one time.
      at org.lwjgl.openal.AL.create(AL.java:113)
      at org.lwjgl.openal.AL.create(AL.java:102)
      at org.lwjgl.openal.AL.create(AL.java:206)
      at com.badlogic.gdx.backends.lwjgl.audio.OpenALAudio.&lt;init&gt;(OpenALAudio.java:72)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.&lt;init&gt;(LwjglApplication.java:90)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.&lt;init&gt;(LwjglApplication.java:71)
      at com.bludbourne.game.desktop.DesktopLauncher.main(DesktopLauncher.java:20)
  Exception in thread "LWJGL Application" java.lang.IllegalStateException: From thread Thread[LWJGL Application,5,main]: Thread[LWJGL Application,5,main] already has the context current
      at org.lwjgl.opengl.ContextGL.checkAccess(ContextGL.java:184)
      at org.lwjgl.opengl.ContextGL.forceDestroy(ContextGL.java:241)
      at org.lwjgl.opengl.DrawableGL.destroy(DrawableGL.java:130)
      at org.lwjgl.opengl.Display$5.destroy(Display.java:834)
      at org.lwjgl.opengl.Display.destroy(Display.java:1095)
      at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.createDisplayPixelFormat(LwjglGraphics.java:325)
      at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:250)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:146)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:128)
  [MainGameScreen] WorldRenderer: virtual: (10.0,10.0)
  [MainGameScreen] WorldRenderer: viewport: (10.0,10.0)
  [MainGameScreen] WorldRenderer: physical: (480.0,480.0)
  [Utility] Map loaded!: maps/town.tmx
  [MapManager] Player Start: (208.0,32.0)
  [MainGameScreen] UnitScale value is: 0.0625
  </code></pre>
  
  <p>I don't know what is causing this error or how I can go about solving it. I don't think I have a NullPointerException, however, I don't know. I am not worried about the warnings as they show up on other LibGDX applications that work, so the warnings are not a problem. I am not using any audio files at the moment so I don't know why the error is referring to audio. I don't know what to do so help is much appreciated.</p>
  
  <p>/</p>
  
  <pre><code>package com.bludbourne.game.desktop;
  
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.Application;
  import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
  import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
  import com.bludbourne.game.BludBourne;
  
  public class DesktopLauncher {
      public static void main (String[] arg) {
          LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
          new LwjglApplication(new BludBourne(), config);
  
  
          config.title="BludBourne";
          config.useGL30=false;
          config.width =480;
          config.height=480;
  
          Application app = new LwjglApplication(new BludBourne(),config);
  
          Gdx.app=app;
          Gdx.app.setLogLevel(Application.LOG_DEBUG);
  
  
      }
  }
  </code></pre>
  
  <p>/</p>
  
  <pre><code>package com.bludbourne.game.screens;
  
  import com.badlogic.gdx.Screen;
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.GL20;
  import com.badlogic.gdx.graphics.OrthographicCamera;
  import com.badlogic.gdx.graphics.g2d.Sprite;
  import com.badlogic.gdx.graphics.g2d.TextureRegion;
  import com.badlogic.gdx.maps.MapLayer;
  import com.badlogic.gdx.maps.MapObject;
  import com.badlogic.gdx.maps.objects.RectangleMapObject;
  import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
  import com.badlogic.gdx.math.Rectangle;
  import com.bludbourne.game.*;
  
  
  
  
  public class MainGameScreen implements Screen
  {
  
      private static final String TAG=MainGameScreen.class.getSimpleName();
  
      private static class VIEWPORT{
  
          static float viewportWidth;
          static float viewportHeight;
          static float virtualWidth;
          static float virtualHeight;
          static float physicalWidth;
          static float physicalHeight;
          static float aspectRatio;
      }
  
      private PlayerController _controller;
      private TextureRegion _currentPlayerFrame;
      private Sprite _currentPlayerSprite;
  
      private OrthogonalTiledMapRenderer _mapRenderer=null;
      private OrthographicCamera _camera =null;
      private static MapManager _mapMgr;
  
      public MainGameScreen() {
  
          _mapMgr = new MapManager();
      }
  
  
      private static Entity _player;
  
      @Override
      public void render(float delta) {
  
          Gdx.gl.glClearColor(0, 0, 0, 1);
          Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
  
          _camera.position.set(_currentPlayerSprite.getX(),_currentPlayerSprite.getY(),0f);
          _camera.update();
  
          _player.update(delta);
          _currentPlayerFrame = _player.getFrame();
          updatePortalLayerActivation(_player.boundingBox);
  
          if(!isCollisionWithMapLayer(_player.boundingBox)) {
  
              _player.setNextPositionToCurrent();
  
          }
  
          _controller.update(delta);
  
          _mapRenderer.setView(_camera);
          _mapRenderer.render();
  
          _mapRenderer.getBatch().begin();
          _mapRenderer.getBatch().draw(_currentPlayerFrame, _currentPlayerSprite.getX(), _currentPlayerSprite.getY(), 1, 1);
          _mapRenderer.getBatch().end();
  
      }
  
      private boolean isCollisionWithMapLayer(Rectangle boundingBox) {
  
          MapLayer mapCollisionLayer = _mapMgr.getCollisionLayer();
  
          if (mapCollisionLayer==null) {
  
  
              return false;
  
          }
  
          Rectangle rectangle =null;
  
          for(MapObject object: mapCollisionLayer.getObjects()) {
  
              if(object instanceof RectangleMapObject) {
  
                  rectangle = ((RectangleMapObject)object).getRectangle();
  
                  if (boundingBox.overlaps(rectangle)) {
                      return true;
                  }
              }
  
  
  
  
          }
  
          return false;
      }
  
  
      private boolean updatePortalLayerActivation(Rectangle boundingBox) {
  
          MapLayer mapPortalLayer = _mapMgr.getPortalLayer();
  
          if(mapPortalLayer==null) {
  
              return false;
          }
  
          Rectangle rectangle=null;
  
          for(MapObject object:mapPortalLayer.getObjects()) {
  
              if (object instanceof RectangleMapObject) {
  
                  rectangle =((RectangleMapObject)object).getRectangle();
                  if(boundingBox.overlaps(rectangle)) {
  
                      String mapName=object.getName();
  
                      if(mapName==null) {
                          return false;
                      }
  
                      _mapMgr.setClosestStartPositionFromScaledUnits(_player.getCurrentPosition());
                      _mapMgr.loadMap(mapName);
                      _player.init(_mapMgr.getPlayerStartUnitScaled().x,_mapMgr.getPlayerStartUnitScaled().y);
                      _mapRenderer.setMap(_mapMgr.getCurrentMap());
                      Gdx.app.debug(TAG, "Portal Activated");
                      return true;
                  }
              }
  
  
  
          }
  
  
          return false;
  
      }
  
  
  
      @Override
      public void show()
      {
          setupViewport(10,10);
          _camera = new OrthographicCamera();
          _camera.setToOrtho(false,VIEWPORT.viewportWidth,VIEWPORT.viewportHeight);
  
          _mapRenderer = new OrthogonalTiledMapRenderer(_mapMgr.getCurrentMap(),MapManager.UNIT_SCALE);
          _mapRenderer.setView(_camera);
  
  
          Gdx.app.debug(TAG, "UnitScale value is: "+_mapRenderer.getUnitScale());
  
          _player = new Entity();
          _player.init(_mapMgr.getPlayerStartUnitScaled().x,_mapMgr.getPlayerStartUnitScaled().y);
  
          _currentPlayerSprite = _player.getFrameSprite();
  
          _controller = new PlayerController(_player);
          Gdx.input.setInputProcessor(_controller);
      }
  
  
      @Override
      public void hide()
      {
          // TODO Auto-generated method stub
  
      }
  
  
      @Override
      public  void resize(int width,int height) {
  
      }
  
  
      @Override
      public void pause() {
  
      }
  
      @Override
      public void dispose() {
  
          _player.dispose();
          _controller.dispose();
          Gdx.input.setInputProcessor(null);
          _mapRenderer.dispose();
  
  
      }
  
      private void setupViewport(int width,int height) {
  
          VIEWPORT.virtualWidth=width;
          VIEWPORT.virtualHeight=height;
  
          VIEWPORT.viewportWidth=VIEWPORT.virtualWidth;
          VIEWPORT.viewportHeight=VIEWPORT.virtualHeight;
  
          VIEWPORT.physicalWidth=Gdx.graphics.getWidth();
          VIEWPORT.physicalHeight=Gdx.graphics.getHeight();
  
          VIEWPORT.aspectRatio=(VIEWPORT.virtualWidth/VIEWPORT.virtualHeight);
  
          if(VIEWPORT.physicalWidth/VIEWPORT.physicalHeight&gt;=VIEWPORT.aspectRatio) {
  
              VIEWPORT.viewportWidth=VIEWPORT.viewportHeight*(VIEWPORT.physicalWidth/VIEWPORT.physicalHeight);
              VIEWPORT.viewportHeight=VIEWPORT.virtualHeight;
  
  
          }
  
          else {
  
              VIEWPORT.viewportWidth=VIEWPORT.virtualWidth;
              VIEWPORT.viewportHeight=VIEWPORT.viewportHeight*(VIEWPORT.physicalHeight/VIEWPORT.physicalWidth);
  
          }
  
          Gdx.app.debug(TAG,"WorldRenderer: virtual: ("+VIEWPORT.virtualWidth+","+VIEWPORT.virtualHeight+")");
          Gdx.app.debug(TAG, "WorldRenderer: viewport: (" +VIEWPORT.viewportWidth+","+VIEWPORT.viewportHeight+")");
          Gdx.app.debug(TAG,"WorldRenderer: physical: ("+VIEWPORT.physicalWidth+","+VIEWPORT.physicalHeight+")");
  
  
  
      }
  
      @Override
      public void resume()
      {
          // TODO Auto-generated method stub
  
      }
  
  
  
  }
  </code></pre>
  
  <p>/</p>
  
  <pre><code>package com.bludbourne.game;
  
  import com.badlogic.gdx.ApplicationAdapter;
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.GL20;
  import com.badlogic.gdx.graphics.Texture;
  import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  
  
  import com.bludbourne.game.screens.MainGameScreen;
  import com.badlogic.gdx.Game;
  
  public class BludBourne extends Game {
  
      public static final MainGameScreen _mainGameScreen = new MainGameScreen();
  
  
      @Override
      public void create () {
          setScreen(_mainGameScreen);
      }
  
      @Override
      public void render () {
  
      }
  
      @Override
      public void dispose () {
          _mainGameScreen.dispose();
      }
  }
  </code></pre>
  
  <p>/</p>
  
  <pre><code>package com.bludbourne.game;
  
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.Texture;
  import com.badlogic.gdx.assets.loaders.TextureLoader;
  import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
  import com.badlogic.gdx.maps.tiled.TiledMap;
  import com.badlogic.gdx.maps.tiled.TmxMapLoader;
  import com.badlogic.gdx.assets.AssetManager;
  
  public final class Utility
  {
  
      public static final AssetManager            _assetManager       = new AssetManager();
  
      private static final String                 TAG                 = Utility.class.getSimpleName();
  
      private static InternalFileHandleResolver   _filePathResolver   = new InternalFileHandleResolver();
  
      public static void unloadAsset(String assetFilenamePath)
      {
  
          if (_assetManager.isLoaded(assetFilenamePath))
          {
  
              _assetManager.unload(assetFilenamePath);
  
          }
          else
          {
  
              Gdx.app.debug(TAG, "Asset is not loaded; Nothing to unload: " + assetFilenamePath);
  
          }
  
      }
  
      public static float loadCompleted()
      {
  
          return _assetManager.getProgress();
  
      }
  
      public static int numberAssetsQueued()
      {
  
          return _assetManager.getQueuedAssets();
  
      }
  
      public static boolean updateAssetLoading()
      {
  
          return _assetManager.update();
  
      }
  
      public static boolean isAssetLoaded(String fileName)
      {
  
          return _assetManager.isLoaded(fileName);
  
      }
  
      public static void loadMapAsset(String mapFilenamePath)
      {
  
          if (mapFilenamePath == null || mapFilenamePath.isEmpty())
          {
  
              return;
          }
  
          if (_filePathResolver.resolve(mapFilenamePath).exists())
          {
  
              _assetManager.setLoader(TiledMap.class, new TmxMapLoader(_filePathResolver));
              _assetManager.load(mapFilenamePath, TiledMap.class);
              _assetManager.finishLoadingAsset(mapFilenamePath);
              Gdx.app.debug(TAG, "Map loaded!: " + mapFilenamePath);
  
          }
  
          else
          {
  
              Gdx.app.debug(TAG, "Map doesn't exist!: " + mapFilenamePath);
  
          }
  
      }
  
      public static TiledMap getMapAsset(String mapFilenamePath)
      {
  
          TiledMap map = null;
  
          if (_assetManager.isLoaded(mapFilenamePath))
          {
  
              map = _assetManager.get(mapFilenamePath, TiledMap.class);
  
          }
  
          else
          {
  
              Gdx.app.debug(TAG, "Map is not loaded: " + mapFilenamePath);
  
          }
  
          return map;
      }
  
      public static void loadTextureAsset(String textureFilenamePath) {
  
          if (textureFilenamePath == null||textureFilenamePath.isEmpty()) {
  
              return;
          }
          if (_filePathResolver.resolve(textureFilenamePath).exists()) {
  
              _assetManager.setLoader(Texture.class, new TextureLoader(_filePathResolver));
  
              _assetManager.load(textureFilenamePath,Texture.class);
  
              _assetManager.finishLoadingAsset(textureFilenamePath);
          }
  
          else {
  
              Gdx.app.debug(TAG, "Texture doesn't exist!: "+textureFilenamePath);
  
          }
  
      }
  
  
      public static Texture getTextureAsset(String textureFilenamePath) {
  
          Texture texture =null;
  
          if(_assetManager.isLoaded(textureFilenamePath)) {
  
              texture = _assetManager.get(textureFilenamePath,Texture.class);
  
          }
  
          else {
  
              Gdx.app.debug(TAG,"Texture is not loaded: "+textureFilenamePath);
  
  
          }
  
  
  
          return texture;
  
      }
  
  
  }
  </code></pre>
  
  <p>I've included a link to my github so you can see the project structure as well. I think I have structured the project correctly, however, I don't know.</p>
  
  <p>I have included </p>
  
  <p>Assets/sprites/characters/Warrior.png </p>
  
  <p>Assets/maps/castle_of_doom.tmx</p>
  
  <p>Assets/maps/town.tmx</p>
  
  <p>Assets/maps/topworld.tmx</p>
  
  <p>src/com/bludbourne/game/MapManager.java</p>
  
  <p>src/com/bludbourne/game/PlayerController.java</p>
  
  <p>src/com/bludbourne/game/Utility.java</p>
  
  <p>due to the 30k character limit.</p>
  
  <p>Here is a link to my github <a href="https://github.com/davey67/bludbourne" rel="nofollow noreferrer">https://github.com/davey67/bludbourne</a></p>