@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();
}
java类com.badlogic.gdx.Graphics的实例源码
SpacefishTests.java 文件源码
项目:spacefish
阅读 30
收藏 0
点赞 0
评论 0
DesktopLauncher.java 文件源码
项目:RageGo
阅读 26
收藏 0
点赞 0
评论 0
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);
}
}
DesktopLauncher.java 文件源码
项目:Interplanar
阅读 21
收藏 0
点赞 0
评论 0
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);
}
AndroidGraphics.java 文件源码
项目:ingress-indonesia-dev
阅读 26
收藏 0
点赞 0
评论 0
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;
}
}
DesktopLauncher.java 文件源码
项目:ggvm
阅读 29
收藏 0
点赞 0
评论 0
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!");
}
}
PCMenu.java 文件源码
项目:ggvm
阅读 32
收藏 0
点赞 0
评论 0
@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);
}
}
Stage.java 文件源码
项目:drc-sim-client
阅读 28
收藏 0
点赞 0
评论 0
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);
}
MainGameClass.java 文件源码
项目:GangsterSquirrel
阅读 37
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
FrameBufferFactory.java 文件源码
项目:gdx-gfx
阅读 20
收藏 0
点赞 0
评论 0
public FrameBufferFactory() {
super();
Graphics gfx = Gdx.graphics;
width = gfx.getWidth();
height = gfx.getHeight();
use32Bits = true;
alphaChannel = true;
depth = true;
format = null;
}
GraphicsServiceImpl.java 文件源码
项目:jrpg-engine
阅读 18
收藏 0
点赞 0
评论 0
@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);
}
Stage.java 文件源码
项目:drc-sim-client
阅读 28
收藏 0
点赞 0
评论 0
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);
}
DesktopLauncher.java 文件源码
项目:skin-composer
阅读 35
收藏 0
点赞 0
评论 0
@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);
}
DesktopLauncher.java 文件源码
项目:skin-composer
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
DesktopGraphicsUtil.java 文件源码
项目:nvlist
阅读 33
收藏 0
点赞 0
评论 0
/**
* @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());
}
ScreenUtil.java 文件源码
项目:CodeBase
阅读 39
收藏 0
点赞 0
评论 0
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);
}
}
AndroidLiveWallpaper.java 文件源码
项目:libgdxcn
阅读 35
收藏 0
点赞 0
评论 0
@Override
public Graphics getGraphics () {
return graphics;
}
FrameBufferTest.java 文件源码
项目:libgdxcn
阅读 25
收藏 0
点赞 0
评论 0
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());
}
BaseTest.java 文件源码
项目:GDX-Logic-Bricks
阅读 25
收藏 0
点赞 0
评论 0
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();
}
ShatteredPixelDungeon.java 文件源码
项目:shattered-pixel-dungeon-gdx
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
}
OisControllers.java 文件源码
项目:shadow-engine
阅读 28
收藏 0
点赞 0
评论 0
/** 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;
}
TestCombat.java 文件源码
项目:nikkylittlequest
阅读 26
收藏 0
点赞 0
评论 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 );
}
OptionsPanel.java 文件源码
项目:sft
阅读 27
收藏 0
点赞 0
评论 0
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);
}
AndroidInput.java 文件源码
项目:ingress-indonesia-dev
阅读 23
收藏 0
点赞 0
评论 0
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;
}
MyLwjglCanvas.java 文件源码
项目:featurea
阅读 41
收藏 0
点赞 0
评论 0
public Graphics getGraphics() {
return this.graphics;
}
CardBoardAndroidApplication.java 文件源码
项目:ZombieInvadersVR
阅读 25
收藏 0
点赞 0
评论 0
@Override
public Graphics getGraphics () {
return graphics;
}
GdxDemoActivity.java 文件源码
项目:thunderboard-android
阅读 21
收藏 0
点赞 0
评论 0
@Override
public Graphics getGraphics() {
return graphics;
}
MainLoader.java 文件源码
项目:beatoraja
阅读 23
收藏 0
点赞 0
评论 0
public static Graphics.DisplayMode[] getAvailableDisplayMode() {
return LwjglApplicationConfiguration.getDisplayModes();
}
MainLoader.java 文件源码
项目:beatoraja
阅读 21
收藏 0
点赞 0
评论 0
public static Graphics.DisplayMode getDesktopDisplayMode() {
return LwjglApplicationConfiguration.getDesktopDisplayMode();
}
GdxAppStub.java 文件源码
项目:nvlist
阅读 32
收藏 0
点赞 0
评论 0
@Override
public Graphics getGraphics() {
return Gdx.graphics;
}
TeaVMApplication.java 文件源码
项目:teavm-libgdx
阅读 29
收藏 0
点赞 0
评论 0
@Override
public Graphics getGraphics() {
return graphics;
}