Java Code Examples for com.badlogic.gdx.Gdx#graphics()

The following examples show how to use com.badlogic.gdx.Gdx#graphics() . These examples are extracted from open source projects. 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
protected void onResume() {
    Gdx.app = this;
    Gdx.input = this.getInput();
    Gdx.audio = this.getAudio();
    Gdx.files = this.getFiles();
    Gdx.graphics = this.getGraphics();
    Gdx.net = this.getNet();
    this.input.onResume();
    if (this.graphics != null) {
        this.graphics.onResumeGLSurfaceView();
    }

    if (!this.firstResume) {
        this.graphics.resume();
    } else {
        this.firstResume = false;
    }

    this.isWaitingForAudio = true;
    if (this.wasFocusChanged == 1 || this.wasFocusChanged == -1) {
        this.audio.resume();
        this.isWaitingForAudio = false;
    }

    super.onResume();
}
 
Example 2
Source Project: Cubes   File: Graphics.java    License: MIT License 6 votes vote down vote up
public static void init() {
  if (init) return;
  init = true;

  modelBatch = new CubesModelBatch();

  for (Block block : IDManager.getBlocks()) {
    block.loadGraphics();
  }
  for (ItemBlock itemBlock : IDManager.getItemBlocks()) {
    itemBlock.loadGraphics();
  }
  for (Item item : IDManager.getItems()) {
    item.loadGraphics();
  }
  WorldGraphicsPools.init();
  BlockIcons.renderIcons();

  glProfiler = new GLProfiler(Gdx.graphics);
}
 
Example 3
Source Project: seventh   File: ClientMain.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void logVideoSpecs(Logger console) {
    try {
        if(Gdx.graphics != null) {                
            console.println("GL30: " + Gdx.graphics.isGL30Available());
            console.println("OpenGL Version: " + Gdx.gl.glGetString(GL20.GL_VERSION));
            console.println("OpenGL Vendor: " + Gdx.gl.glGetString(GL20.GL_VENDOR));
            console.println("Renderer: " + Gdx.gl.glGetString(GL20.GL_RENDERER));
            console.println("Gdx Version: " + Gdx.app.getVersion());
            console.println("Is Fullscreen: " + Gdx.graphics.isFullscreen());
        }
        else {
            console.println("OpenGL Version: " + Gdx.gl.glGetString(GL20.GL_VERSION));
            console.println("OpenGL Vendor: " + Gdx.gl.glGetString(GL20.GL_VENDOR));
            console.println("Renderer: " + Gdx.gl.glGetString(GL20.GL_RENDERER));                
        }
    }
    catch(Throwable t) {
        console.println("Error retrieving video specifications: " + t);
    }
}
 
Example 4
Source Project: gdx-vfx   File: GwtVfxGlExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int getBoundFboHandle() {
    GwtGraphics graphics = (GwtGraphics) Gdx.graphics;
    GwtGL20 gwtGl = (GwtGL20) graphics.getGL20();
    WebGLRenderingContext glContext = graphics.getContext();
    WebGLFramebuffer frameBuffer = glContext.getParametero(WebGLRenderingContext.FRAMEBUFFER_BINDING);

    if (frameBuffer == null) {
        return 0;
    } else {
        return getFrameBufferId(gwtGl, frameBuffer);
    }
}
 
Example 5
Source Project: xibalba   File: PlayScreen.java    License: MIT License 5 votes vote down vote up
/**
 * Play Screen.
 *
 * @param main Instance of Main class
 */
public PlayScreen(Main main) {
  glProfiler = new GLProfiler(Gdx.graphics);

  autoTimer = 0;
  keyHoldTimerDelay = 0;
  keyHoldTimer = 0;
  batch = new SpriteBatch();

  // Setup camera;
  OrthographicCamera worldCamera = new OrthographicCamera();

  // Setup renderers
  worldRenderer = new WorldRenderer(worldCamera, batch);
  hudRenderer = new HudRenderer(main, batch);

  // Debug console
  console = new GUIConsole(Main.skin, false);
  console.setCommandExecutor(new ConsoleCommandExecutor());
  console.setSizePercent(100, 50);

  // Setup input
  multiplexer = new InputMultiplexer();
  playerInput = new PlayerInput(worldCamera);
  multiplexer.addProcessor(hudRenderer.stage);
  multiplexer.addProcessor(playerInput);

  // Player attributes & their god
  playerAttributes = ComponentMappers.attributes.get(WorldManager.player);
  god = ComponentMappers.god.get(WorldManager.god);

  // Generate all dijkstra maps
  WorldManager.world.getCurrentMap().dijkstra.updateAll();

  // Change state to playing
  WorldManager.state = WorldManager.State.PLAYING;
}
 
Example 6
Source Project: gdx-gltf   File: GLTFDemo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	GLProfiler profiler = new GLProfiler(Gdx.graphics);
	profiler.setListener(new GLErrorListener() {
		@Override
		public void onError(int error) {
			Gdx.app.error("OpenGL", String.valueOf(error));
		}
	});
	profiler.enable();
	
	assetManager = new AssetManager();
	Texture.setAssetManager(assetManager);
	
	assetManager.setLoader(SceneAsset.class, ".gltf", new GLTFAssetLoader());
	assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
	
	shapeRenderer = new ShapeRenderer();
	
	spriteBatch = new SpriteBatch();
	
	createSceneManager();
	
	createUI();
	
	loadModelIndex();
}
 
Example 7
Source Project: mini2Dx   File: LibgdxGraphicsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	mockery = new Mockery();
	mockery.setImposteriser(ClassImposteriser.INSTANCE);
	fonts = mockery.mock(Fonts.class);
	gameFont = mockery.mock(GameFont.class);
	gameWrapper = mockery.mock(GameWrapper.class);
	spriteBatch = mockery.mock(LibgdxSpriteBatchWrapper.class);
	polygonSpriteBatch = mockery.mock(PolygonSpriteBatch.class);
	shapeRenderer = mockery.mock(ShapeRenderer.class);
	gdxGraphics = mockery.mock(com.badlogic.gdx.Graphics.class);

	Mdx.fonts = fonts;
	Gdx.graphics = gdxGraphics;
	
	mockery.checking(new Expectations() {
		{
			one(shapeRenderer).setAutoShapeType(true);
			one(fonts).defaultFont();
			will(returnValue(gameFont));
			one(gdxGraphics).getWidth();
			will(returnValue(800));
			one(gdxGraphics).getHeight();
			will(returnValue(600));
			one(spriteBatch).getColor();
			will(returnValue(new Color()));
		}
	});
	
	graphics = new LibgdxGraphics(gameWrapper, spriteBatch, polygonSpriteBatch, shapeRenderer);
}
 
Example 8
Source Project: mini2Dx   File: DeferredRunnableTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    Mdx.platform = Platform.WINDOWS;

    mockery.setImposteriser(ClassImposteriser.INSTANCE);

    assetManager = mockery.mock(AssetManager.class);
    graphics = mockery.mock(Graphics.class);
    uiContainer = mockery.mock(UiContainer.class);
    Gdx.graphics = graphics;
}
 
Example 9
Source Project: mini2Dx   File: Lwjgl3Mini2DxWindow.java    License: Apache License 2.0 5 votes vote down vote up
void makeCurrent() {
	Gdx.graphics = graphics;
	Gdx.gl30 = graphics.getGL30();
	Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
	Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
	Gdx.input = input;

	GLFW.glfwMakeContextCurrent(windowHandle);
}
 
Example 10
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) {
    if (this.getVersion() < 8) {
        throw new GdxRuntimeException("LibGDX requires Android API Level 8 or later.");
    } else {
        this.setApplicationLogger(new AndroidApplicationLogger());
        this.graphics = new AndroidGraphics(this, config, (ResolutionStrategy) (config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy));
        this.input = AndroidInputFactory.newAndroidInput(this, this, this.graphics.view, config);
        this.audio = new AndroidAudio(this, config);
        this.getFilesDir();
        this.files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());
        this.net = new AndroidNet(this);
        this.listener = listener;
        this.handler = new Handler();
        this.useImmersiveMode = config.useImmersiveMode;
        this.hideStatusBar = config.hideStatusBar;
        this.clipboard = new AndroidClipboard(this);
        this.addLifecycleListener(new LifecycleListener() {
            public void resume() {
            }

            public void pause() {
                audio.pause();
            }

            public void dispose() {
                audio.dispose();
            }
        });
        Gdx.app = this;
        Gdx.input = this.getInput();
        Gdx.audio = this.getAudio();
        Gdx.files = this.getFiles();
        Gdx.graphics = this.getGraphics();
        Gdx.net = this.getNet();
        if (!isForView) {
            try {
                this.requestWindowFeature(1);
            } catch (Exception var8) {
                this.log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", var8);
            }

            this.getWindow().setFlags(1024, 1024);
            this.getWindow().clearFlags(2048);
            this.setContentView(this.graphics.getView(), this.createLayoutParams());
        }

        this.createWakeLock(config.useWakelock);
        this.hideStatusBar(this.hideStatusBar);
        this.useImmersiveMode(this.useImmersiveMode);
        if (this.useImmersiveMode && this.getVersion() >= 19) {
            try {
                Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener");
                Object o = vlistener.newInstance();
                Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class);
                method.invoke(o, this);
            } catch (Exception var7) {
                this.log("AndroidApplication", "Failed to create AndroidVisibilityListener", var7);
            }
        }

    }
}