com.badlogic.gdx.graphics.Texture.TextureWrap Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.Texture.TextureWrap.
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: PostProcessor.java From RuinsOfRevenge with MIT License | 6 votes |
public PostProcessor( int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits, TextureWrap u, TextureWrap v ) { if( use32Bits ) { if( useAlphaChannel ) { fbFormat = Format.RGBA8888; } else { fbFormat = Format.RGB888; } } else { if( useAlphaChannel ) { fbFormat = Format.RGBA4444; } else { fbFormat = Format.RGB565; } } composite = newPingPongBuffer( fboWidth, fboHeight, fbFormat, useDepth ); setBufferTextureWrap( u, v ); pipelineState = new PipelineState(); capturing = false; hasCaptured = false; enabled = true; this.useDepth = useDepth; }
Example #2
Source File: Art.java From uracer-kotd with Apache License 2.0 | 6 votes |
private static void loadMeshesGraphics (boolean mipmap) { meshTrackWall = newTexture("data/track/wall_4.png", mipmap); meshTrackWall.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); meshMissing = newTexture("data/3d/textures/missing-mesh.png", mipmap); // car textures meshCar = new ObjectMap<String, Texture>(); meshCar.put("car", newTexture("data/3d/textures/car.png", mipmap)); meshCar.put("car_yellow", newTexture("data/3d/textures/car_yellow.png", mipmap)); // meshCar.get("car").setFilter(TextureFilter.Linear, TextureFilter.Linear); // meshCar.get("car_yellow").setFilter(TextureFilter.Linear, TextureFilter.Linear); // trees meshTreeTrunk = newTexture("data/3d/textures/trunk_6_col.png", mipmap); meshTreeLeavesSpring = new Texture[7]; for (int i = 0; i < 7; i++) { meshTreeLeavesSpring[i] = newTexture("data/3d/textures/leaves_" + (i + 1) + "_spring_1.png", mipmap); } }
Example #3
Source File: Ssao.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** Computes random field for the ssao shader */ private void createRandomField (int width, int height, Format format) { randomField = new Texture(width, height, format); randomField.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); randomField.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); Pixmap pixels = new Pixmap(width, height, format); ByteBuffer bytes = pixels.getPixels(); int wrote = 0; while (wrote < width * height * 4) { float x = (MathUtils.random() - 0.5f) * 2.0f; float y = (MathUtils.random() - 0.5f) * 2.0f; float z = (MathUtils.random() - 0.5f) * 2.0f; float l = (float)Math.sqrt(x * x + y * y + z * z); if (l <= 1.0f && l > 0.1f) { x = (x + 1.0f) * 0.5f; y = (y + 1.0f) * 0.5f; z = (z + 1.0f) * 0.5f; bytes.put((byte)(x * 255f)); bytes.put((byte)(y * 255f)); bytes.put((byte)(z * 255f)); bytes.put((byte)255); wrote += 4; } } bytes.flip(); randomField.draw(pixels, 0, 0); pixels.dispose(); }
Example #4
Source File: PostProcessor.java From RuinsOfRevenge with MIT License | 5 votes |
public void setBufferTextureWrap( TextureWrap u, TextureWrap v ) { compositeWrapU = u; compositeWrapV = v; composite.texture1.setWrap( compositeWrapU, compositeWrapV ); composite.texture2.setWrap( compositeWrapU, compositeWrapV ); }
Example #5
Source File: PickerCommons.java From vis-ui with Apache License 2.0 | 5 votes |
private void createPixmap () { Pixmap whitePixmap = new Pixmap(2, 2, Format.RGB888); whitePixmap.setColor(Color.WHITE); whitePixmap.drawRectangle(0, 0, 2, 2); whiteTexture = new Texture(whitePixmap); whiteTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); whitePixmap.dispose(); }
Example #6
Source File: Art.java From uracer-kotd with Apache License 2.0 | 5 votes |
private static void loadPostProcessorMaps () { postXpro = newTexture("data/base/xpro-lut.png", false); postXpro.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); postLensFlare = newTexture("data/base/lenscolor.png", false); postLensFlare.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); // depthMapGen = ShaderLoader.fromFile( "depth", "depth" ); // depthMapGenTransparent = ShaderLoader.fromFile( "depth-transparent", // "depth-transparent" ); }
Example #7
Source File: GLTFTypes.java From gdx-gltf with Apache License 2.0 | 5 votes |
private static TextureWrap mapTextureWrap(Integer wrap) { if(wrap == null) return TextureWrap.Repeat; switch(wrap){ case 33071: return TextureWrap.ClampToEdge; case 33648: return TextureWrap.MirroredRepeat; case 10497: return TextureWrap.Repeat; } throw new GdxRuntimeException("unexpected texture wrap " + wrap); }
Example #8
Source File: PostProcessing.java From uracer-kotd with Apache License 2.0 | 5 votes |
public PostProcessing (GameWorld gameWorld) { if (UserPreferences.bool(Preference.PostProcessing)) { postProcessor = new PostProcessor(ScaleUtils.PlayViewport, true /* depth */, true /* alpha */, URacer.Game.isDesktop() /* supports32Bpp */); PostProcessor.EnableQueryStates = false; postProcessor.setClearBits(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); postProcessor.setClearColor(0, 0, 0, 1); postProcessor.setClearDepth(1); postProcessor.setEnabled(true); postProcessor.setBufferTextureWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); hasPostProcessor = true; createEffects(gameWorld); setAnimator(new DefaultAnimator(this, gameWorld)); } }
Example #9
Source File: PostProcessor.java From uracer-kotd with Apache License 2.0 | 5 votes |
public void setBufferTextureWrap (TextureWrap u, TextureWrap v) { compositeWrapU = u; compositeWrapV = v; composite.texture1.setWrap(compositeWrapU, compositeWrapV); composite.texture2.setWrap(compositeWrapU, compositeWrapV); }
Example #10
Source File: PostProcessor.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** Construct a new PostProcessor with the given parameters and the specified texture wrap mode */ public PostProcessor (int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits, TextureWrap u, TextureWrap v) { if (use32Bits) { if (useAlphaChannel) { fbFormat = Format.RGBA8888; } else { fbFormat = Format.RGB888; } } else { if (useAlphaChannel) { fbFormat = Format.RGBA4444; } else { fbFormat = Format.RGB565; } } composite = newPingPongBuffer(fboWidth, fboHeight, fbFormat, useDepth); setBufferTextureWrap(u, v); pipelineState = new PipelineState(); capturing = false; hasCaptured = false; enabled = true; this.useDepth = useDepth; if (useDepth) { clearBits |= GL20.GL_DEPTH_BUFFER_BIT; } setViewport(null); }
Example #11
Source File: GLTFMaterialExporter.java From gdx-gltf with Apache License 2.0 | 5 votes |
private Integer map(TextureWrap wrap) { switch (wrap) { case ClampToEdge: return 33071; case MirroredRepeat:return 33648; default: case Repeat:return null; } }
Example #12
Source File: TextureResolver.java From gdx-gltf with Apache License 2.0 | 5 votes |
public TextureDescriptor<Texture> getTexture(GLTFTextureInfo glMap) { GLTFTexture glTexture = glTextures.get(glMap.index); TextureDescriptor<Texture> textureDescriptor = new TextureDescriptor<Texture>(); boolean useMipMaps; if(glTexture.sampler != null){ GLTFSampler glSampler = glSamplers.get(glTexture.sampler); GLTFTypes.mapTextureSampler(textureDescriptor, glSampler); useMipMaps = GLTFTypes.isMipMapFilter(glSampler); }else{ // default sampler options. // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#texture textureDescriptor.minFilter = TextureFilter.Linear; textureDescriptor.magFilter = TextureFilter.Linear; textureDescriptor.uWrap = TextureWrap.Repeat; textureDescriptor.vWrap = TextureWrap.Repeat; useMipMaps = false; } ObjectMap<Integer, Texture> textureMap = useMipMaps ? texturesMipmap : texturesSimple; Texture texture = textureMap.get(glTexture.source); if(texture == null){ throw new GdxRuntimeException("texture not loaded"); } textureDescriptor.texture = texture; return textureDescriptor; }
Example #13
Source File: GameWorld.java From uracer-kotd with Apache License 2.0 | 4 votes |
private List<OrthographicAlignedStillModel> createWalls () { List<OrthographicAlignedStillModel> models = null; if (mapUtils.hasObjectGroup(ObjectGroup.Walls)) { Vector2 fromMt = new Vector2(); Vector2 toMt = new Vector2(); Vector2 offsetMt = new Vector2(); // create material TextureAttribute ta = new TextureAttribute(Art.meshTrackWall, 0, "u_texture"); ta.uWrap = TextureWrap.Repeat.getGLEnum(); ta.vWrap = TextureWrap.Repeat.getGLEnum(); Material mat = new Material("trackWall", ta); MapLayer group = mapUtils.getObjectGroup(ObjectGroup.Walls); if (group.getObjects().getCount() > 0) { models = new ArrayList<OrthographicAlignedStillModel>(group.getObjects().getCount()); for (int i = 0; i < group.getObjects().getCount(); i++) { PolylineMapObject o = (PolylineMapObject)group.getObjects().get(i); //@off List<Vector2> points = MapUtils.extractPolyData( o.getPolyline().getVertices()); //@on if (points.size() >= 2) { float wallTicknessMt = 0.75f; float[] mags = new float[points.size() - 1]; offsetMt.set(o.getPolyline().getX(), o.getPolyline().getY()); offsetMt.set(Convert.px2mt(offsetMt)); fromMt.set(Convert.px2mt(points.get(0))).add(offsetMt); fromMt.y = worldSizeMt.y - fromMt.y; for (int j = 1; j <= points.size() - 1; j++) { toMt.set(Convert.px2mt(points.get(j))).add(offsetMt); toMt.y = worldSizeMt.y - toMt.y; // create box2d wall Box2DFactory.createWall(box2dWorld, fromMt, toMt, wallTicknessMt, 0f); // compute magnitude mags[j - 1] = (float)Math.sqrt((toMt.x - fromMt.x) * (toMt.x - fromMt.x) + (toMt.y - fromMt.y) * (toMt.y - fromMt.y)); fromMt.set(toMt); } Mesh mesh = buildWallMesh(points, mags); StillSubMesh[] subMeshes = new StillSubMesh[1]; subMeshes[0] = new StillSubMesh("wall", mesh, GL20.GL_TRIANGLES); OrthographicAlignedStillModel model = new OrthographicAlignedStillModel(new StillModel(subMeshes), mat); model.setPosition(o.getPolyline().getX(), worldSizePx.y - o.getPolyline().getY()); model.setScale(1); models.add(model); } } } } return models; }
Example #14
Source File: PostProcessor.java From uracer-kotd with Apache License 2.0 | 4 votes |
/** Construct a new PostProcessor with the given parameters, viewport and the specified texture wrap mode */ public PostProcessor (Rectangle viewport, boolean useDepth, boolean useAlphaChannel, boolean use32Bits, TextureWrap u, TextureWrap v) { this((int)viewport.width, (int)viewport.height, useDepth, useAlphaChannel, use32Bits, u, v); setViewport(viewport); }
Example #15
Source File: PostProcessor.java From uracer-kotd with Apache License 2.0 | 4 votes |
/** Construct a new PostProcessor with the given parameters and viewport, defaulting to <em>TextureWrap.ClampToEdge</em> as * texture wrap mode */ public PostProcessor (Rectangle viewport, boolean useDepth, boolean useAlphaChannel, boolean use32Bits) { this((int)viewport.width, (int)viewport.height, useDepth, useAlphaChannel, use32Bits, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); setViewport(viewport); }
Example #16
Source File: TextureAttribute.java From uracer-kotd with Apache License 2.0 | 4 votes |
public TextureAttribute (Texture texture, int unit, String name, TextureFilter minFilter, TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) { this(texture, unit, name, minFilter.getGLEnum(), magFilter.getGLEnum(), uWrap.getGLEnum(), vWrap.getGLEnum()); }
Example #17
Source File: TexturePacker.java From gdx-texture-packer-gui with Apache License 2.0 | 4 votes |
private String getRepeatValue () { if (settings.wrapX == TextureWrap.Repeat && settings.wrapY == TextureWrap.Repeat) return "xy"; if (settings.wrapX == TextureWrap.Repeat && settings.wrapY == TextureWrap.ClampToEdge) return "x"; if (settings.wrapX == TextureWrap.ClampToEdge && settings.wrapY == TextureWrap.Repeat) return "y"; return "none"; }
Example #18
Source File: ServerConnectGUI.java From Radix with MIT License | 4 votes |
@Override public void init() { stage = new Stage(); // TODO memory manage background = new Texture(Gdx.files.internal("textures/block/obsidian.png")); background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); errorLabel = new Label(null, new LabelStyle(new BitmapFont(), Color.RED)); TextFieldStyle fieldStyle = new TextFieldStyle(); fieldStyle.font = new BitmapFont(); fieldStyle.fontColor = Color.WHITE; TextField ipField = new TextField("IP:Port", fieldStyle); ImageTextButtonStyle btnStyle = RadixClient.getInstance().getSceneTheme().getButtonStyle(); TextButton connectButton = new TextButton("Connect", btnStyle); connectButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { String[] ipPort = ipField.getText().split(":"); if(ipPort.length != 2) { invalidIpSyntax(); return; } try { RadixClient.getInstance().enterRemoteWorld(ipPort[0], Short.parseShort(ipPort[1])); } catch (NumberFormatException ex) { invalidPort(); } } }); Table table = new Table(); table.setFillParent(true); table.add(ipField); table.row(); table.add(errorLabel); table.row(); table.add(connectButton); stage.addActor(table); }
Example #19
Source File: PostProcessor.java From uracer-kotd with Apache License 2.0 | 4 votes |
/** Construct a new PostProcessor with the given parameters, defaulting to <em>TextureWrap.ClampToEdge</em> as texture wrap mode */ public PostProcessor (int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits) { this(fboWidth, fboHeight, useDepth, useAlphaChannel, use32Bits, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); }
Example #20
Source File: TiledMapLoader.java From seventh with GNU General Public License v2.0 | 4 votes |
private TilesetAtlas parseTilesets(LeoArray tilesets, boolean loadImages) throws Exception { if(tilesets.isEmpty()) { throw new IllegalArgumentException("There must be at least 1 tileset"); } TilesetAtlas atlas = new TilesetAtlas(); for(LeoObject t : tilesets) { LeoMap tileset = t.as(); // skip the sourced tilesets if(t.hasObject("source")) { // HACK: Updated version of Tiled which no longer supports inlining // shared tilests (lame) String source = tileset.getString("source"); if(source.endsWith("collidables.tsx")) { tileset.putByString("image", LeoString.valueOf("./assets/gfx/tiles/collision_tileset.png")); tileset.putByString("name", LeoString.valueOf("collidables")); } else if(source.endsWith("city.tsx")) { tileset.putByString("image", LeoString.valueOf("./assets/gfx/tiles/cs2dnorm.png")); tileset.putByString("name", LeoString.valueOf("city")); } else if(source.endsWith("surface_types.tsx")) { tileset.putByString("image", LeoString.valueOf("./assets/gfx/tiles/surface_types.png")); tileset.putByString("name", LeoString.valueOf("surfaces")); } tileset.putByString("tilewidth", LeoObject.valueOf(32)); tileset.putByString("tileheight", LeoObject.valueOf(32)); } int firstgid = tileset.getInt("firstgid"); int margin = tileset.getInt("margin"); int spacing = tileset.getInt("spacing"); int tilewidth = tileset.getInt("tilewidth"); int tileheight = tileset.getInt("tileheight"); LeoMap tilesetprops = null; LeoObject props = tileset.getByString("tileproperties"); if(LeoObject.isTrue(props) && props.isMap()) { tilesetprops = props.as(); } TextureRegion image = null; TextureRegion[] images = null; if(loadImages) { String imagePath = tileset.getString("image"); // override to local assets tile directory if(!new File(imagePath).exists()) { imagePath = "./assets/gfx/tiles" + imagePath.substring(imagePath.lastIndexOf("/"), imagePath.length()); } image = TextureUtil.loadImage(imagePath); image.flip(false, true); image.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); image.getTexture().setWrap(TextureWrap.MirroredRepeat, TextureWrap.MirroredRepeat); images = TextureUtil.toTileSet(image, tilewidth, tileheight, margin, spacing); } atlas.addTileset(new Tileset(firstgid, images, tilesetprops)); } return atlas; }
Example #21
Source File: PostProcessor.java From RuinsOfRevenge with MIT License | 4 votes |
/** Construct a new PostProcessor with the given parameters. */ public PostProcessor( int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits ) { this( fboWidth, fboHeight, useDepth, useAlphaChannel, use32Bits, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge ); }