use of com.badlogic.gdx.tests.utils.GdxTest in project libgdx by libgdx.
the class LwjglDebugStarter method main.
public static void main(String[] argv) {
// this is only here for me to debug native code faster
// new SharedLibraryLoader("../../extensions/gdx-audio/libs/gdx-audio-natives.jar").load("gdx-audio");
// new SharedLibraryLoader("../../extensions/gdx-image/libs/gdx-image-natives.jar").load("gdx-image");
// new SharedLibraryLoader("../../extensions/gdx-freetype/libs/gdx-freetype-natives.jar").load("gdx-freetype");
// new SharedLibraryLoader("../../extensions/gdx-controllers/gdx-controllers-desktop/libs/gdx-controllers-desktop-natives.jar").load("gdx-controllers-desktop");
// new SharedLibraryLoader("../../gdx/libs/gdx-natives.jar").load("gdx");
GdxTest test = new GroupTest();
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.r = config.g = config.b = config.a = 8;
// config.width = 320;
// config.height = 241;
config.width = 960;
config.height = 600;
// config.setFromDisplayMode(LwjglApplicationConfiguration.getDesktopDisplayMode());
new LwjglApplication(test, config);
}
use of com.badlogic.gdx.tests.utils.GdxTest in project libgdx by libgdx.
the class JglfwTestStarter method runTest.
/** Runs the {@link GdxTest} with the given name.
* @param testName the name of a test class
* @return {@code true} if the test was found and run, {@code false} otherwise */
public static JglfwApplication runTest(String testName) {
final GdxTest test = GdxTests.newTest(testName);
if (test == null)
throw new GdxRuntimeException("Test not found: " + testName);
final JglfwApplicationConfiguration config = new JglfwApplicationConfiguration();
config.width = 640;
config.height = 480;
config.title = testName;
config.forceExit = false;
return new JglfwApplication(test, config);
}
use of com.badlogic.gdx.tests.utils.GdxTest in project libgdx by libgdx.
the class LwjglTestStarter method runTest.
/**
* Runs the {@link GdxTest} with the given name.
*
* @param testName the name of a test class
* @return {@code true} if the test was found and run, {@code false} otherwise
*/
public static boolean runTest(String testName) {
boolean useGL30 = false;
GdxTest test = GdxTests.newTest(testName);
if (test == null) {
return false;
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 640;
config.height = 480;
config.title = testName;
config.forceExit = false;
if (useGL30) {
config.useGL30 = true;
ShaderProgram.prependVertexCode = "#version 140\n#define varying out\n#define attribute in\n";
ShaderProgram.prependFragmentCode = "#version 140\n#define varying in\n#define texture2D texture\n#define gl_FragColor fragColor\nout vec4 fragColor;\n";
} else {
config.useGL30 = false;
ShaderProgram.prependVertexCode = "";
ShaderProgram.prependFragmentCode = "";
}
new LwjglApplication(test, config);
return true;
}
use of com.badlogic.gdx.tests.utils.GdxTest in project libgdx by libgdx.
the class Lwjgl3DebugStarter method main.
public static void main(String[] argv) throws NoSuchFieldException, SecurityException, ClassNotFoundException {
GdxTest test = new GdxTest() {
float r = 0;
SpriteBatch batch;
BitmapFont font;
FPSLogger fps = new FPSLogger();
Texture texture;
@Override
public void create() {
BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
texture = new Texture("data/badlogic.jpg");
batch = new SpriteBatch();
font = new BitmapFont();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
System.out.println("Key down: " + Keys.toString(keycode));
return false;
}
@Override
public boolean keyUp(int keycode) {
System.out.println("Key up: " + Keys.toString(keycode));
return false;
}
@Override
public boolean keyTyped(char character) {
System.out.println("Key typed: '" + character + "', " + (int) character);
if (character == 'f') {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
// DisplayMode[] modes = Gdx.graphics.getDisplayModes();
// for(DisplayMode mode: modes) {
// if(mode.width == 1920 && mode.height == 1080) {
// Gdx.graphics.setFullscreenMode(mode);
// break;
// }
// }
}
if (character == 'w') {
Gdx.graphics.setWindowedMode(MathUtils.random(400, 800), MathUtils.random(400, 800));
}
if (character == 'e') {
throw new GdxRuntimeException("derp");
}
if (character == 'c') {
Gdx.input.setCursorCatched(!Gdx.input.isCursorCatched());
}
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
if (character == 'v') {
window.setVisible(false);
}
if (character == 's') {
window.setVisible(true);
}
if (character == 'q') {
window.closeWindow();
}
if (character == 'i') {
window.iconifyWindow();
}
if (character == 'm') {
window.maximizeWindow();
}
if (character == 'r') {
window.restoreWindow();
}
if (character == 'u') {
Gdx.net.openURI("https://google.com");
}
return false;
}
});
}
long start = System.nanoTime();
@Override
public void render() {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.begin();
font.draw(batch, Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() + ", " + Gdx.graphics.getBackBufferWidth() + "x" + Gdx.graphics.getBackBufferHeight() + ", " + Gdx.input.getX() + ", " + Gdx.input.getY() + ", " + Gdx.input.getDeltaX() + ", " + Gdx.input.getDeltaY(), 0, 20);
batch.draw(texture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY());
batch.end();
fps.log();
}
@Override
public void resize(int width, int height) {
Gdx.app.log("Test", "Resized " + width + "x" + height);
}
@Override
public void resume() {
Gdx.app.log("Test", "resuming");
}
@Override
public void pause() {
Gdx.app.log("Test", "pausing");
}
@Override
public void dispose() {
Gdx.app.log("Test", "disposing");
}
};
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setWindowedMode(640, 480);
config.setWindowListener(new Lwjgl3WindowListener() {
@Override
public void iconified(boolean isIconified) {
Gdx.app.log("Window", "iconified: " + (isIconified ? "true" : "false"));
}
@Override
public void maximized(boolean isMaximized) {
Gdx.app.log("Window", "maximized: " + (isMaximized ? "true" : "false"));
}
@Override
public void focusLost() {
Gdx.app.log("Window", "focus lost");
}
@Override
public void focusGained() {
Gdx.app.log("Window", "focus gained");
}
@Override
public boolean closeRequested() {
Gdx.app.log("Window", "closing");
return false;
}
@Override
public void filesDropped(String[] files) {
for (String file : files) {
Gdx.app.log("Window", "File dropped: " + file);
}
}
@Override
public void refreshRequested() {
Gdx.app.log("Window", "refreshRequested");
}
});
for (DisplayMode mode : Lwjgl3ApplicationConfiguration.getDisplayModes()) {
System.out.println(mode.width + "x" + mode.height);
}
System.setProperty("java.awt.headless", "true");
new Lwjgl3Application(test, config);
}
use of com.badlogic.gdx.tests.utils.GdxTest in project libgdx by libgdx.
the class GdxTestActivity method onCreate.
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
// obtain the test info
Bundle extras = getIntent().getExtras();
String testName = (String) extras.get("test");
GdxTest test = GdxTests.newTest(testName);
// and run the application...
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useImmersiveMode = true;
initialize(test, config);
}
Aggregations