@Before public void setUp() { final BitmapFont bitmapFont = mock(BitmapFont.class); // setup Mock for Game resources when(mResources.getBackgroundMusic()).thenReturn(mock(Music.class)); when(mResources.getGameOver()).thenReturn(mock(Sound.class)); when(mResources.getFont()).thenReturn(bitmapFont); when(bitmapFont.getBounds(anyString())).thenReturn(new BitmapFont.TextBounds()); // Mock Gdx lib Gdx.graphics = mock(Graphics.class); Gdx.app = mock(Application.class); mGame.create(); }
public static void main (String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); if(IS_PRODUCTION) { config.resizable = false; config.fullscreen = true; config.vSyncEnabled = true; } else { config.fullscreen = false; config.height = 600; config.width = 1000; config.resizable = true; } config.title = "RageGo"; new LwjglApplication(RageGoGame.getInstance(), config); if(IS_PRODUCTION) { for (Graphics.DisplayMode displayMode : Gdx.graphics.getDisplayModes()) { System.out.println(displayMode); } Gdx.graphics.setDisplayMode(Gdx.graphics.getDesktopDisplayMode().width, Gdx.graphics.getDesktopDisplayMode().height, true); } }
public static void main(String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.resizable = false; Graphics.DisplayMode currentDisplayMode = LwjglApplicationConfiguration.getDesktopDisplayMode(); if (currentDisplayMode.width > LARGE_BREAKPOINT_WIDTH && currentDisplayMode.height > LARGE_BREAKPOINT_HEIGHT) { config.width = LARGE_WIDTH; config.height = LARGE_HEIGHT; } else if (currentDisplayMode.width > SMALL_BREAKPOINT_WIDTH && currentDisplayMode.height > SMALL_BREAKPOINT_HEIGHT) { config.width = SMALL_WIDTH; config.height = SMALL_HEIGHT; } else { // Everything smaller than the small breakpoint will be fullscreen by default config.width = currentDisplayMode.width; config.height = currentDisplayMode.height; config.fullscreen = true; } new LwjglApplication(new Interplanar(new KeyboardInputProcessor()), config); }
private void logConfig(EGLConfig paramEGLConfig) { EGL10 localEGL10 = (EGL10)EGLContext.getEGL(); EGLDisplay localEGLDisplay = localEGL10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int i = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12324, 0); int j = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12323, 0); int k = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12322, 0); int m = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12321, 0); int n = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12325, 0); int i1 = getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12326, 0); int i2 = Math.max(getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12337, 0), getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12513, 0)); if (getAttrib(localEGL10, localEGLDisplay, paramEGLConfig, 12513, 0) != 0); for (boolean bool = true; ; bool = false) { Gdx.app.log("AndroidGraphics", "framebuffer: (" + i + ", " + j + ", " + k + ", " + m + ")"); Gdx.app.log("AndroidGraphics", "depthbuffer: (" + n + ")"); Gdx.app.log("AndroidGraphics", "stencilbuffer: (" + i1 + ")"); Gdx.app.log("AndroidGraphics", "samples: (" + i2 + ")"); Gdx.app.log("AndroidGraphics", "coverage sampling: (" + bool + ")"); this.bufferFormat = new Graphics.BufferFormat(i, j, k, m, n, i1, i2, bool); return; } }
public static void main (String[] arg) { //Initialize log file try { File file = new File("log.txt"); if (file.exists()) { file.delete(); } PrintStream printStream = new PrintStream(file); System.setOut(printStream); System.setErr(printStream); } catch (FileNotFoundException fileNotFoundException) { System.out.println("Could not create log file."); } //Initialize application Graphics.DisplayMode selectedDisplayMode = LwjglApplicationConfiguration.getDesktopDisplayMode(); if (selectedDisplayMode != null) { GameModule gameModule = GameModuleProvider.provideGameModule(); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.setFromDisplayMode(selectedDisplayMode); config.vSyncEnabled = true; if (gameModule.provideIconFileName() != null) { config.addIcon(gameModule.provideIconFileName(), Files.FileType.Internal); } new LwjglApplication(new GGVmApplication(gameModule, PCMenu.class, KeyboardInputProcessor.class), config); } else { System.out.println("Sorry, this game requires a graphics card that can display 32 bpp!"); } }
@Override public void action() { boolean fullScreen = Gdx.graphics.isFullscreen(); Graphics.DisplayMode currentMode = Gdx.graphics.getDisplayMode(); if (fullScreen == true) { currentMenuOption.text = "TO FULLSCREEN"; Gdx.graphics.setWindowedMode(512, 480); } else { currentMenuOption.text = "TO WINDOWED"; Gdx.graphics.setFullscreenMode(currentMode); } }
private void toggleFullscreen() { if (Gdx.graphics.isFullscreen()) { Gdx.graphics.setWindowedMode(1280, 720); return; } Graphics.DisplayMode largest = null; for (Graphics.DisplayMode displayMode : Gdx.graphics.getDisplayModes()) { if (largest == null) largest = displayMode; if (displayMode.width > largest.width || displayMode.height > largest.height) largest = displayMode; } Gdx.graphics.setFullscreenMode(largest); }
/** * Changes the window size of the game and switches between fullscreen and windowed mode depending on the settings */ public void changeGameResolution() { Settings settings = new Settings(); Graphics.DisplayMode mode = Gdx.graphics.getDisplayMode(); if (settings.getFullscreen()) { Gdx.graphics.setWindowedMode(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setFullscreenMode(mode); } else if (!settings.getFullscreen()) { Gdx.graphics.setWindowedMode(settings.getGameWidth(), settings.getGameHeight()); } }
public FrameBufferFactory() { super(); Graphics gfx = Gdx.graphics; width = gfx.getWidth(); height = gfx.getHeight(); use32Bits = true; alphaChannel = true; depth = true; format = null; }
@Override public void init() { viewport = new FitViewport(resolutionWidth, resolutionHeight, camera); camera.update(); spriteBatch = spriteBatchFactory.createSpriteBatch(); Graphics.Monitor monitor = Gdx.graphics.getMonitor(); Graphics.DisplayMode displayMode = Gdx.graphics.getDisplayMode(monitor); Gdx.graphics.setFullscreenMode(displayMode); }
@Override public void centerWindow(Graphics graphics) { Lwjgl3Graphics g = (Lwjgl3Graphics) graphics; Graphics.DisplayMode mode = g.getDisplayMode(); Lwjgl3Window window = g.getWindow(); window.setPosition(mode.width / 2 - g.getWidth() / 2, mode.height / 2 - g.getHeight() / 2); }
@Override public void sizeWindowToFit(int maxWidth, int maxHeight, int displayBorder, Graphics graphics) { Graphics.DisplayMode mode = graphics.getDisplayMode(); int width = Math.min(mode.width - displayBorder * 2, maxWidth); int height = Math.min(mode.height - displayBorder * 2, maxHeight); graphics.setWindowedMode(width, height); centerWindow(graphics); }
/** * @return The new windowed size for the application after applying the safe window size limits. */ public static Dim limitInitialWindowSize(Graphics graphics) { if (graphics.isFullscreen()) { // If fullscreen, we fill the entire screen already so nothing needs to be done } else { // Width/height of the window in physical pixels int w = graphics.getBackBufferWidth(); int h = graphics.getBackBufferHeight(); // Limit window size so it fits inside the current monitor (with a margin for OS bars/decorations) DisplayMode displayMode = graphics.getDisplayMode(); int maxW = displayMode.width - 100; int maxH = displayMode.height - 150; int dw = Math.min(0, maxW - w); int dh = Math.min(0, maxH - h); graphics.setWindowedMode(w + dw, h + dh); // Also change the window's position so it's centered on its previous location Lwjgl3Window window = getCurrentWindow(); window.setPosition(window.getPositionX() - dw / 2, window.getPositionY() - dh / 2); } return Dim.of(graphics.getBackBufferWidth(), graphics.getBackBufferHeight()); }
public static void toggleFullscreen() { if (Gdx.graphics.isFullscreen()) { Gdx.graphics.setDisplayMode(lastWidth, lastHeight, false); } else { lastWidth = Gdx.graphics.getWidth(); lastHeight = Gdx.graphics.getHeight(); Graphics.DisplayMode mode = Gdx.graphics.getDesktopDisplayMode(); Gdx.graphics.setDisplayMode(mode.width, mode.height, true); } }
@Override public Graphics getGraphics () { return graphics; }
private void createShader (Graphics graphics) { String vertexShader = "attribute vec4 a_Position; \n" + "attribute vec4 a_Color;\n" + "attribute vec2 a_texCoords;\n" + "varying vec4 v_Color;" + "varying vec2 v_texCoords; \n" + "void main() \n" + "{ \n" + " v_Color = a_Color;" + " v_texCoords = a_texCoords;\n" + " gl_Position = a_Position; \n" + "} \n"; String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "varying vec4 v_Color;\n" + "varying vec2 v_texCoords; \n" + "uniform sampler2D u_texture;\n" + "void main() \n" + "{ \n" + " gl_FragColor = v_Color * texture2D(u_texture, v_texCoords);\n" + "}"; meshShader = new ShaderProgram(vertexShader, fragmentShader); if (meshShader.isCompiled() == false) throw new IllegalStateException(meshShader.getLog()); }
public BaseTest() { GdxNativesLoader.load(); SpriteBatch batch = Mockito.mock(SpriteBatch.class); when(batch.getColor()).thenReturn(new Color()); Gdx.input = Mockito.mock(Input.class); Gdx.app = Mockito.mock(Application.class); Gdx.graphics = Mockito.mock(Graphics.class); when(Gdx.graphics.getWidth()).thenReturn((int) Settings.WIDTH); when(Gdx.graphics.getHeight()).thenReturn((int) Settings.HEIGHT); Settings.DEBUG_LEVEL = Logger.DEBUG; Settings.TESTING = true; Settings.MAX_STEPS = 60; GameContext context = new ContextTest(); context.load(); this.game = context.get(Game.class); engine = context.get(LogicBricksEngine.class); builders = context.get(LBBuilders.class); entityBuilder = builders.getEntityBuilder(); bodyBuilder = builders.getBodyBuilder(); }
@Override public void resize(int width, int height) { super.resize(width, height); Graphics.DisplayMode mode = Gdx.graphics.getDisplayMode(); boolean maximized = width >= mode.width || height >= mode.height; if (!maximized && !fullscreen()) { final Preferences prefs = Preferences.INSTANCE; prefs.put(Preferences.KEY_WINDOW_WIDTH, width); prefs.put(Preferences.KEY_WINDOW_HEIGHT, height); } }
/** Returns the window handle from LWJGL needed by OIS. */ static public long getWindowHandle () { // don't need a window handle for Mac OS X if (System.getProperty("os.name").toLowerCase().contains("mac")) { return 0; } try { if (Gdx.graphics.getType() == Graphics.GraphicsType.JGLFW) return (Long)Gdx.graphics.getClass().getDeclaredMethod("getWindow").invoke(Gdx.graphics); if (Gdx.graphics.getType() == Graphics.GraphicsType.LWJGL) { if (Gdx.app.getClass().getName().equals("com.badlogic.gdx.backends.lwjgl.LwjglCanvas")) { Class canvasClass = Class.forName("com.badlogic.gdx.backends.lwjgl.LwjglCanvas"); Object canvas = canvasClass.getDeclaredMethod("getCanvas").invoke(Gdx.app); return (Long)invokeMethod(invokeMethod(SwingUtilities.windowForComponent((Component) canvas), "getPeer"), "getHWnd"); } Class displayClass = Class.forName("org.lwjgl.opengl.Display"); Method getImplementation = displayClass.getDeclaredMethod("getImplementation", new Class[0]); getImplementation.setAccessible(true); Object display = getImplementation.invoke(null, (Object[])null); String fieldName = System.getProperty("os.name").toLowerCase().contains("windows") ? "hwnd" : "parent_window"; Field field = display.getClass().getDeclaredField(fieldName); field.setAccessible(true); return (Long)field.get(display); } } catch (Exception ex) { throw new RuntimeException("Unable to get window handle.", ex); } return 0; }
@Before public void setUp() throws Exception { Gdx.graphics = mock(Graphics.class); nikki = new NikkiActor(10); Batch dummyBatch =mock(Batch.class); stage = new CombatStage(nikki, dummyBatch ); }
private static ISelectable makeDisplaySlider() { final IAction1<MDisplayMode.DisplayType> setDisplay = new IAction1<MDisplayMode.DisplayType>() { @Override public void eval(MDisplayMode.DisplayType arg1) { final int width; final int height; if (arg1 == MDisplayMode.DisplayType.FullScreen || arg1 == MDisplayMode.DisplayType.WindowedFullScreen) { final Graphics.DisplayMode desktopMode = Gdx.graphics.getDesktopDisplayMode(); width = desktopMode.width; height = desktopMode.height; } else { width = Game.WindowWidth; height = Game.WindowHeight; } Game.settings.setDisplayMode(new MDisplayMode(width, height, arg1)); } }; final IFunction2<MDisplayMode.DisplayType, String> getDisplayString = new IFunction2<MDisplayMode.DisplayType, String>() { @Override public String apply(MDisplayMode.DisplayType input) { return input.toString(); } }; final List<MDisplayMode.DisplayType> displayTypes = Slider.getVideoOptions(); final int initialDisplay = Slider.getIndex(displayTypes, Game.settings.getDisplayMode().type, 0); return new Slider<MDisplayMode.DisplayType>(sliderX, sliderY + ySpace*2, "Display Mode:", displayTypes, setDisplay, getDisplayString, initialDisplay, true, 130); }
public AndroidInput(AndroidApplication paramAndroidApplication, View paramView, AndroidApplicationConfiguration paramAndroidApplicationConfiguration) { paramView.setOnKeyListener(this); paramView.setOnTouchListener(this); paramView.setFocusable(true); paramView.setFocusableInTouchMode(true); paramView.requestFocus(); paramView.requestFocusFromTouch(); this.config = paramAndroidApplicationConfiguration; this.onscreenKeyboard = new AndroidOnscreenKeyboard(paramAndroidApplication, new Handler(), this); while (i < this.realId.length) { this.realId[i] = -1; i++; } this.handle = new Handler(); this.app = paramAndroidApplication; this.sleepTime = paramAndroidApplicationConfiguration.touchSleepTime; if (Integer.parseInt(Build.VERSION.SDK) >= 5); for (this.touchHandler = new AndroidMultiTouchHandler(); ; this.touchHandler = new AndroidSingleTouchHandler()) { this.hasMultitouch = this.touchHandler.supportsMultitouch(this.app); this.vibrator = ((Vibrator)paramAndroidApplication.getSystemService("vibrator")); int j = getRotation(); Graphics.DisplayMode localDisplayMode = this.app.graphics.getDesktopDisplayMode(); if (((j == 0) || (j == 180)) && ((localDisplayMode.width < localDisplayMode.height) && (((j != 90) && (j != 270)) || (localDisplayMode.width > localDisplayMode.height)))) break; this.nativeOrientation = Input.Orientation.Landscape; return; } this.nativeOrientation = Input.Orientation.Portrait; }
public Graphics getGraphics() { return this.graphics; }
@Override public Graphics getGraphics() { return graphics; }
public static Graphics.DisplayMode[] getAvailableDisplayMode() { return LwjglApplicationConfiguration.getDisplayModes(); }
public static Graphics.DisplayMode getDesktopDisplayMode() { return LwjglApplicationConfiguration.getDesktopDisplayMode(); }
@Override public Graphics getGraphics() { return Gdx.graphics; }