本文整理汇总了Java中com.badlogic.gdx.Application.ApplicationType.WebGL方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationType.WebGL方法的具体用法?Java ApplicationType.WebGL怎么用?Java ApplicationType.WebGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.Application.ApplicationType
的用法示例。
在下文中一共展示了ApplicationType.WebGL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
@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();
}
示例2: ShaderManager
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
public ShaderManager (String shaderDir, AssetManager am, boolean addProcessors) {
shaders = new ObjectMap<String, ShaderProgram>();
shaderPaths = new ObjectMap<String, String>();
sourcesVert = new ObjectMap<String, String>();
sourcesFrag = new ObjectMap<String, String>();
frameBuffers = new ObjectMap<String, FrameBuffer>();
openedFrameBuffers = new Array<String>(true, MAX_FRAMEBUFFERS);
screenCamera = new OrthographicCamera(Gdx.graphics.getWidth() + 2, Gdx.graphics.getHeight() + 2);
createScreenQuad();
screenCamera.translate(0, -1);
screenCamera.update();
setShaderDir(shaderDir);
setAssetManager(am);
// add("empty", "empty.vert", "empty.frag");
// add("default", "default.vert", "default.frag");
if (addProcessors && (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet
|| Gdx.app.getType() == ApplicationType.WebGL)) {
/*
* add("processor", "processor.vert", "processor.frag"); add("processor_blur", "processor.vert", "processor_blur.frag");
* add("copy", "processor.vert", "copy.frag"); add("processor_draw", "processor.vert", "processor_draw.frag");
* add("processor_fill", "processor.vert", "processor_fill.frag");
*/
}
}
示例3: tryLoadHTMLTwitterAPI
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
private void tryLoadHTMLTwitterAPI() {
if (Gdx.app.getType() != ApplicationType.WebGL) {
Gdx.app.debug(TAG, "Skip loading gdx-twitter for HTML. Not running HTML. \n");
return;
}
try {
final Class<?> twitterClazz = ClassReflection.forName("de.tomgrill.gdxtwitter.html.HTMLTwitterAPI");
Object twitter = ClassReflection.getConstructor(twitterClazz, TwitterConfig.class).newInstance(config);
twitterAPI = (TwitterAPI) twitter;
Gdx.app.debug(TAG, "gdx-twitter for HTML loaded successfully.");
} catch (ReflectionException e) {
Gdx.app.debug(TAG, "Error creating gdx-twitter for HTML (are the gdx-twitter **.jar files installed?). \n");
e.printStackTrace();
}
}
示例4: installHTMLGDXDialogs
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
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();
}
}
示例5: draw
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
@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);
String text = "Touch screen to start!";
float width = font.getBounds(text).width;
font.draw(spriteBatch, text, 240 - width / 2, 128);
if (Gdx.app.getType() == ApplicationType.WebGL) {
text = "Press Enter for Fullscreen Mode";
width = font.getBounds(text).width;
font.draw(spriteBatch, "Press Enter for Fullscreen Mode", 240 - width / 2, 128 - font.getLineHeight());
}
spriteBatch.end();
}
示例6: consumeCustomData
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
@Override
public void consumeCustomData (int target) {
if (!Gdx.graphics.supportsExtension("texture_float"))
throw new GdxRuntimeException("Extension OES_TEXTURE_FLOAT not supported!");
// this is a const from GL 3.0, used only on desktops
final int GL_RGBA32F = 34836;
// GLES and WebGL defines texture format by 3rd and 8th argument,
// so to get a float texture one needs to supply GL_RGBA and GL_FLOAT there.
if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS
|| Gdx.app.getType() == ApplicationType.WebGL) {
Gdx.gl.glTexImage2D(target, 0, GL20.GL_RGBA, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer);
} else {
// in desktop OpenGL the texture format is defined only by the third argument,
// hence we need to use GL_RGBA32F there (this constant is unavailable in GLES/WebGL)
Gdx.gl.glTexImage2D(target, 0, GL_RGBA32F, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer);
}
}
示例7: initShaderProgram
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
@Override
protected void initShaderProgram() {
// Initialise renderer
if (Gdx.app.getType() == ApplicationType.WebGL)
shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.vertex.glsl"), Gdx.files.internal("shader/point.fragment.wgl.glsl"));
else
shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.vertex.glsl"), Gdx.files.internal("shader/point.fragment.glsl"));
if (!shaderProgram.isCompiled()) {
Logger.error(this.getClass().getName(), "Pixel shader compilation failed:\n" + shaderProgram.getLog());
}
pointAlpha = new float[] { GlobalConf.scene.POINT_ALPHA_MIN, GlobalConf.scene.POINT_ALPHA_MIN + GlobalConf.scene.POINT_ALPHA_MAX };
shaderProgram.begin();
shaderProgram.setUniform2fv("u_pointAlpha", pointAlpha, 0, 2);
shaderProgram.end();
}
示例8: getPlatform
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
public static String getPlatform() {
ApplicationType type = Gdx.app.getType();
if (type == ApplicationType.Desktop)
return "desktop";
if (type == ApplicationType.Android)
return "android";
if (type == ApplicationType.iOS)
return "ios";
if (type == ApplicationType.Applet)
return "applet";
if (type == ApplicationType.WebGL)
return "web";
return "desktop";
}
示例9: platform
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
public static String platform() {
ApplicationType type = Gdx.app.getType();
if (type == ApplicationType.Desktop)
return "desktop";
if (type == ApplicationType.Android)
return "android";
if (type == ApplicationType.iOS)
return "ios";
if (type == ApplicationType.Applet)
return "applet";
if (type == ApplicationType.WebGL)
return "web";
return "desktop";
}
示例10: setFollowRedirects
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
/** Sets whether 301 and 302 redirects are followed. By default true. Can't be changed in the GWT backend because this uses
* XmlHttpRequests which always redirect.
* @param followRedirects whether to follow redirects.
* @exception IllegalArgumentException if redirection is disabled on the GWT backend. */
public void setFollowRedirects (boolean followRedirects) throws IllegalArgumentException {
if (followRedirects == true || Gdx.app.getType() != ApplicationType.WebGL) {
this.followRedirects = followRedirects;
} else {
throw new IllegalArgumentException("Following redirects can't be disabled using the GWT/WebGL backend!");
}
}
示例11: act
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
/** Calls the {@link Actor#act(float)} method on each actor in the stage. Typically called each frame. This method also fires
* enter and exit events.
* @param delta Time in seconds since the last frame. */
public void act (float delta) {
// Update over actors. Done in act() because actors may change position, which can fire enter/exit without an input event.
for (int pointer = 0, n = pointerOverActors.length; pointer < n; pointer++) {
Actor overLast = pointerOverActors[pointer];
// Check if pointer is gone.
if (!pointerTouched[pointer]) {
if (overLast != null) {
pointerOverActors[pointer] = null;
screenToStageCoordinates(tempCoords.set(pointerScreenX[pointer], pointerScreenY[pointer]));
// Exit over last.
InputEvent event = Pools.obtain(InputEvent.class);
event.setType(InputEvent.Type.exit);
event.setStage(this);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
event.setRelatedActor(overLast);
event.setPointer(pointer);
overLast.fire(event);
Pools.free(event);
}
continue;
}
// Update over actor for the pointer.
pointerOverActors[pointer] = fireEnterAndExit(overLast, pointerScreenX[pointer], pointerScreenY[pointer], pointer);
}
// Update over actor for the mouse on the desktop.
ApplicationType type = Gdx.app.getType();
if (type == ApplicationType.Desktop || type == ApplicationType.Applet || type == ApplicationType.WebGL)
mouseOverActor = fireEnterAndExit(mouseOverActor, mouseScreenX, mouseScreenY, -1);
// Run actions and determine whether to request rendering (for when setContinuousRendering is off)
root.act(delta);
}
示例12: generateMipMap
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If
* <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. */
public static void generateMipMap (int target, Pixmap pixmap, int textureWidth, int textureHeight) {
if (!useHWMipMap) {
generateMipMapCPU(target, pixmap, textureWidth, textureHeight);
return;
}
if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.WebGL
|| Gdx.app.getType() == ApplicationType.iOS) {
generateMipMapGLES20(target, pixmap);
} else {
generateMipMapDesktop(target, pixmap, textureWidth, textureHeight);
}
}
示例13: initShaderProgram
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
@Override
protected void initShaderProgram() {
// POINT (STARS) PROGRAM
if (Gdx.app.getType() == ApplicationType.WebGL)
shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.galaxy.vertex.glsl"), Gdx.files.internal("shader/point.galaxy.fragment.wgl.glsl"));
else
shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.galaxy.vertex.glsl"), Gdx.files.internal("shader/point.galaxy.fragment.glsl"));
if (!shaderProgram.isCompiled()) {
Logger.error(this.getClass().getName(), "Point shader compilation failed:\n" + shaderProgram.getLog());
}
shaderProgram.begin();
shaderProgram.setUniformf("u_pointAlphaMin", 0.1f);
shaderProgram.setUniformf("u_pointAlphaMax", 1.0f);
shaderProgram.end();
// QUAD (NEBULA) PROGRAM
quadProgram = new ShaderProgram(Gdx.files.internal("shader/nebula.vertex.glsl"), Gdx.files.internal("shader/nebula.fragment.glsl"));
if (!quadProgram.isCompiled()) {
Logger.error(this.getClass().getName(), "Nebula shader compilation failed:\n" + quadProgram.getLog());
}
nebulatextures = new Texture[4];
for (int i = 0; i < 4; i++) {
Texture tex = new Texture(Gdx.files.internal(GlobalConf.TEXTURES_FOLDER + "nebula00" + (i + 1) + ".png"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
nebulatextures[i] = tex;
}
}
示例14: UDPManager
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
/** Creates the UDP manager using the default implementation */
public UDPManager () {
if (Gdx.app.getType() == ApplicationType.WebGL) {
throw new UnsupportedOperationException("Not implemented.");
}
this.impl = new UDPSocketImpl();
}
示例15: AliasResourceManager
import com.badlogic.gdx.Application.ApplicationType; //导入方法依赖的package包/类
public AliasResourceManager() {
if (Gdx.app.getType() == ApplicationType.Desktop) {
loopLoader = new LoopLoaderDesktop();
} else if (Gdx.app.getType() == ApplicationType.WebGL) {
loopLoader = new LoopLoaderWebGL();
} else {
loopLoader = new LoopLoaderGeneral();
}
}