Java Code Examples for com.badlogic.gdx.Application.ApplicationType#WebGL

The following examples show how to use com.badlogic.gdx.Application.ApplicationType#WebGL . 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
Source File: GLTFDemo.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
private void loadModelIndex() 
{
	rootFolder = Gdx.files.internal(samplesPath);	
	
	String indexFilename = Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.Android ? "model-index-web.json" : "model-index.json";
	
	FileHandle file = rootFolder.child(indexFilename);
	
	entries = new Json().fromJson(Array.class, ModelEntry.class, file);
	
	ui.entrySelector.setItems(entries);
	
	if(AUTOLOAD_ENTRY != null && AUTOLOAD_VARIANT != null){
		for(int i=0 ; i<entries.size ; i++){
			ModelEntry entry = entries.get(i);
			if(entry.name.equals(AUTOLOAD_ENTRY)){
				ui.entrySelector.setSelected(entry);
				// will be auto select if there is only one variant.
				if(entry.variants.size != 1){
					ui.variantSelector.setSelected(AUTOLOAD_VARIANT);
				}
				break;
			}
		}
	}
}
 
Example 2
Source File: GDXDialogsSystem.java    From gdx-dialogs with Apache License 2.0 6 votes vote down vote up
private void installHTMLGDXDialogs() {
	if (Gdx.app.getType() != ApplicationType.WebGL) {
		showDebugSkipInstall(ApplicationType.WebGL.name());
		return;
	}

	try {

		final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.html.HTMLGDXDialogs");
		Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance();

		this.gdxDialogs = (GDXDialogs) dialogManager;
		showDebugInstallSuccessful(ApplicationType.WebGL.name());

	} catch (ReflectionException e) {
		showErrorInstall(ApplicationType.WebGL.name(), "html");
		e.printStackTrace();
	}

}
 
Example 3
Source File: MainMenu.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void draw (float delta) {
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	viewMatrix.setToOrtho2D(0, 0, 480, 320);
	spriteBatch.setProjectionMatrix(viewMatrix);
	spriteBatch.setTransformMatrix(transformMatrix);
	spriteBatch.begin();
	spriteBatch.disableBlending();
	spriteBatch.setColor(Color.WHITE);
	spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
	spriteBatch.enableBlending();
	spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
	spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
	glyphLayout.setText(font, "Touch screen to start!");
	font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128);
	if (Gdx.app.getType() == ApplicationType.WebGL) {
		glyphLayout.setText(font, "Press Enter for Fullscreen Mode");
		font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128 - font.getLineHeight());
	}
	spriteBatch.end();
}
 
Example 4
Source File: PixmapBinaryLoaderHack.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public static Pixmap load(byte [] encodedData, int offset, int len){
	if(Gdx.app.getType() == ApplicationType.WebGL){
		throw new GdxRuntimeException("load pixmap from bytes not supported for WebGL");
	}else{
		// call new Pixmap(encodedData, offset, len); via reflection to
		// avoid compilation error with GWT.
		try {
			return (Pixmap)ClassReflection.getConstructor(Pixmap.class, byte[].class, int.class, int.class).newInstance(encodedData, offset, len);
		} catch (ReflectionException e) {
			throw new GdxRuntimeException(e);
		}
	}
}
 
Example 5
Source File: GLTFBinaryExporter.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public static void savePNG(FileHandle file, Pixmap pixmap){
	if(Gdx.app.getType() == ApplicationType.WebGL){
		throw new GdxRuntimeException("saving pixmap not supported for WebGL");
	}else{
		// call PixmapIO.writePNG(file, pixmap); via reflection to
		// avoid compilation error with GWT.
		try {
			Class pixmapIO = ClassReflection.forName("com.badlogic.gdx.graphics.PixmapIO");
			Method pixmapIO_writePNG = ClassReflection.getMethod(pixmapIO, "writePNG", FileHandle.class, Pixmap.class);
			pixmapIO_writePNG.invoke(null, file, pixmap);
		} catch (ReflectionException e) {
			throw new GdxRuntimeException(e);
		} 
	}
}