public static String createPrefix (final Renderable renderable, final Config config) { String prefix = ""; if (Gdx.app.getType() == ApplicationType.Desktop) prefix += "#version 120\n"; else prefix += "#version 100\n"; if (config.type == ParticleType.Billboard) { prefix += "#define billboard\n"; if (config.align == AlignMode.Screen) prefix += "#define screenFacing\n"; else if (config.align == AlignMode.ViewPoint) prefix += "#define viewPointFacing\n"; // else if(config.align == AlignMode.ParticleDirection) // prefix += "#define paticleDirectionFacing\n"; } return prefix; }
public static String createPrefix (final Renderable renderable, final Config config) { String prefix = ""; if (Gdx.app.getType() == ApplicationType.Desktop) prefix += "#version 120\n"; else prefix += "#version 100\n"; if (config.type == ParticleType.Billboard) { prefix += "#define billboard\n"; if (config.align == AlignMode.Screen) prefix += "#define screenFacing\n"; else if (config.align == AlignMode.ViewPoint) prefix += "#define viewPointFacing\n"; // else if(config.align == AlignMode.ParticleDirection) // prefix += "#define paticleDirectionFacing\n"; } return prefix; }
/** 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 || Gdx.app.getType() != ApplicationType.WebGL) { this.followRedirects = followRedirects; } else { throw new IllegalArgumentException("Following redirects can't be disabled using the GWT/WebGL backend!"); } }
/** 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 || Gdx.app.getType() != ApplicationType.WebGL) { this.followRedirects = followRedirects; } else { throw new IllegalArgumentException("Following redirects can't be disabled using the GWT/WebGL backend!"); } }
/** 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); } }
/** 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); } }
private static void enablePointSprites () { Gdx.gl.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (Gdx.app.getType() == ApplicationType.Desktop) { Gdx.gl.glEnable(0x8861); // GL_POINT_OES } pointSpritesEnabled = true; }
private static void enablePointSprites () { Gdx.gl.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (Gdx.app.getType() == ApplicationType.Desktop) { Gdx.gl.glEnable(0x8861); // GL_POINT_OES } pointSpritesEnabled = true; }
public static void init () { if (initialized) return; // Need to initialize bullet before using it. if (Gdx.app.getType() == ApplicationType.Desktop && customDesktopLib != null) { System.load(customDesktopLib); } else Bullet.init(); Gdx.app.log("Bullet", "Version = " + LinearMath.btGetVersion()); initialized = true; }
@Override protected Texture createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { FloatTextureData data = new FloatTextureData( bufferBuilder.width, bufferBuilder.height, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type, attachmentSpec.isGpuOnly ); Texture result = new Texture(data); if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) result.setFilter(TextureFilter.Linear, TextureFilter.Linear); else // no filtering for float textures in OpenGL ES result.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; }
@Override public void consumeCustomData (int target) { if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS || Gdx.app.getType() == ApplicationType.WebGL) { if (!Gdx.graphics.supportsExtension("OES_texture_float")) throw new GdxRuntimeException("Extension OES_texture_float not supported!"); // 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. Gdx.gl.glTexImage2D(target, 0, GL20.GL_RGBA, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer); } else { if (!Gdx.graphics.isGL30Available()) { if (!Gdx.graphics.supportsExtension("GL_ARB_texture_float")) throw new GdxRuntimeException("Extension GL_ARB_texture_float not supported!"); } // 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, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer); } }
@Override public void consumeCustomData (int target) { if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS || Gdx.app.getType() == ApplicationType.WebGL) { if (!Gdx.graphics.supportsExtension("OES_texture_float")) throw new GdxRuntimeException("Extension OES_texture_float not supported!"); // 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. Gdx.gl.glTexImage2D(target, 0, GL20.GL_RGBA, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer); } else { if (!Gdx.graphics.isGL30Available()) { if (!Gdx.graphics.supportsExtension("GL_ARB_texture_float")) throw new GdxRuntimeException("Extension GL_ARB_texture_float not supported!"); } // 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, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer); } }
@Override protected Texture createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { FloatTextureData data = new FloatTextureData( bufferBuilder.width, bufferBuilder.height, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type, attachmentSpec.isGpuOnly ); Texture result = new Texture(data); if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) result.setFilter(TextureFilter.Linear, TextureFilter.Linear); else // no filtering for float textures in OpenGL ES result.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; }
@Override public Shader getShader (Renderable renderable) { try { return super.getShader(renderable); } catch (Throwable e) { if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop) Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(e.getMessage(), false); if (!revert()) { Gdx.app.error("ShaderCollectionTest", e.getMessage()); throw new GdxRuntimeException("Error creating shader, cannot revert to default shader", e); } error = true; Gdx.app.error("ShaderTest", "Could not create shader, reverted to default shader.", e); return super.getShader(renderable); } }
@Override protected Shader createShader (Renderable renderable) { if (config.vertexShader != null && config.fragmentShader != null && tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop) { String prefix = DefaultShader.createPrefix(renderable, config); Gdx.files.absolute(tempFolder).child(name + ".vertex.glsl").writeString(prefix + config.vertexShader, false); Gdx.files.absolute(tempFolder).child(name + ".fragment.glsl").writeString(prefix + config.fragmentShader, false); } BaseShader result = new MultiPassShader(renderable, config); if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop) Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(result.program.getLog(), false); return result; } }
private void testClasspath () throws IOException { // no classpath support on ios if (Gdx.app.getType() == ApplicationType.iOS) return; FileHandle handle = Gdx.files.classpath("com/badlogic/gdx/utils/arial-15.png"); if (!handle.exists()) fail(); if (handle.isDirectory()) fail(); try { handle.delete(); fail(); } catch (Exception expected) { } try { handle.list(); fail(); } catch (Exception expected) { } try { handle.read().close(); fail(); } catch (Exception ignored) { } FileHandle dir = Gdx.files.classpath("com/badlogic/gdx/utils"); if (dir.isDirectory()) fail(); FileHandle child = dir.child("arial-15.fnt"); if (!child.name().equals("arial-15.fnt")) fail(); if (!child.nameWithoutExtension().equals("arial-15")) fail(); if (!child.extension().equals("fnt")) fail(); handle.read().close(); if (handle.readBytes().length != handle.length()) fail(); }
@Override public void create () { super.create(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f)); environment.add(dirLight = new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f)); shaderProvider = new TestShaderProvider(); shaderBatch = new ModelBatch(shaderProvider); cam.position.set(1, 1, 1); cam.lookAt(0, 0, 0); cam.update(); showAxes = true; onModelClicked("g3d/shapes/teapot.g3dj"); shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder) : Gdx.files.internal("data/g3d/shaders"); }
ApplicationType type = Gdx.app.getType(); if (type == ApplicationType.Desktop || type == ApplicationType.Applet || type == ApplicationType.WebGL) mouseOverActor = fireEnterAndExit(mouseOverActor, mouseScreenX, mouseScreenY, -1);
ApplicationType type = Gdx.app.getType(); if (type == ApplicationType.Desktop || type == ApplicationType.Applet || type == ApplicationType.WebGL) mouseOverActor = fireEnterAndExit(mouseOverActor, mouseScreenX, mouseScreenY, -1);
glProfiler.enable(); ShaderProgram.prependVertexCode = Gdx.app.getType().equals(Application.ApplicationType.Desktop) ? "#version 140\n #extension GL_EXT_texture_array : enable\n" : "#version 300 es\n"; ShaderProgram.prependFragmentCode = Gdx.app.getType().equals(Application.ApplicationType.Desktop) ? "#version 140\n #extension GL_EXT_texture_array : enable\n" : "#version 300 es\n";