Java Code Examples for com.badlogic.gdx.graphics.Pixmap.Format#RGBA8888

The following examples show how to use com.badlogic.gdx.graphics.Pixmap.Format#RGBA8888 . 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: IBLBuilder.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
/**
 * Create an environment map, to be used with {@link net.mgsx.gltf.scene3d.scene.SceneSkybox}
 * @param size base size (width and height) for generated cubemap
 * @return generated cubemap, caller is responsible to dispose it when no longer used.
 */
public Cubemap buildEnvMap(int size){
	FrameBufferCubemap fbo = new FrameBufferCubemap(Format.RGBA8888, size, size, false){
		@Override
		protected void disposeColorTexture(Cubemap colorTexture) {
		}
	};
	fbo.begin();
	while(fbo.nextSide()){
		Gdx.gl.glClearColor(0, 0, 0, 0);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		CubemapSide side = fbo.getSide();
		renderGradient(side, 0);
		renderLights(side, false);
	}
	fbo.end();
	Cubemap map = fbo.getColorBufferTexture();
	fbo.dispose();
	return map;
}
 
Example 2
Source File: ShaderTest.java    From seventh with GNU General Public License v2.0 6 votes vote down vote up
/**
     * 
     */
    public ShaderTest() {        
        ShaderProgram.pedantic = false;
        
        vertBlur = loadShader("blurv.frag");
        horBlur = loadShader("blurh.frag");
        light = loadShader("light.frag");
        
        shader = loadShader("inprint.frag");
        
        this.camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        this.camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
//        camera.setToOrtho(false);
        transform = new Matrix4();
        camera.update();
        batch = new SpriteBatch();//1024, shader);
        batch.setShader(null);
        batch.setProjectionMatrix(camera.combined);
        batch.setTransformMatrix(transform);
        
        this.buffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);    
        
        this.fboPing = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
        this.fboPong = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    }
 
Example 3
Source File: LightMap.java    From box2dlights with Apache License 2.0 6 votes vote down vote up
public LightMap(RayHandler rayHandler, int fboWidth, int fboHeight) {
	this.rayHandler = rayHandler;

	if (fboWidth <= 0)
		fboWidth = 1;
	if (fboHeight <= 0)
		fboHeight = 1;
	frameBuffer = new FrameBuffer(Format.RGBA8888, fboWidth,
			fboHeight, false);
	pingPongBuffer = new FrameBuffer(Format.RGBA8888, fboWidth,
			fboHeight, false);

	lightMapMesh = createLightMapMesh();

	shadowShader = ShadowShader.createShadowShader();
	diffuseShader = DiffuseShader.createShadowShader();

	withoutShadowShader = WithoutShadowShader.createShadowShader();

	blurShader = Gaussian.createBlurShader(fboWidth, fboHeight);

}
 
Example 4
Source File: PostProcessor.java    From RuinsOfRevenge with MIT License 6 votes vote down vote up
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 5
Source File: TextureUtil.java    From seventh with GNU General Public License v2.0 6 votes vote down vote up
public static Pixmap toWhite(Pixmap img) {
    Pixmap alpha = new Pixmap(img.getWidth(), img.getHeight(), Format.RGBA8888);        
    //alpha.drawPixmap(img, 0, 0);
        
    int width = alpha.getWidth();
    int height = alpha.getHeight();
            
    //alpha.setColor(0xff00009f);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            int col = img.getPixel(x, y);
            Color color = new Color(col);
            if ( color.a > 0.2f ) {
                alpha.drawPixel(x, y, Color.WHITE.toIntBits());
            }
        }
    }
    
    img.dispose();
    
    return alpha;
}
 
Example 6
Source File: Ssao.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public Ssao (int fboWidth, int fboHeight, Quality quality) {
	Gdx.app.log("SsaoProcessor", "Quality profile = " + quality.toString());
	float oscale = quality.scale;

	// maps
	occlusionMap = new PingPongBuffer((int)((float)fboWidth * oscale), (int)((float)fboHeight * oscale), Format.RGBA8888, false);

	// shaders
	shMix = ShaderLoader.fromFile("screenspace", "ssao/mix");
	shSsao = ShaderLoader.fromFile("ssao/ssao", "ssao/ssao");

	// blur
	blur = new Blur(occlusionMap.width, occlusionMap.height);
	blur.setType(BlurType.Gaussian5x5b);
	blur.setPasses(2);

	createRandomField(16, 16, Format.RGBA8888);
	// enableDebug();
}
 
Example 7
Source File: TransitionManager.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public TransitionManager (Rectangle viewport, boolean use32Bits, boolean useAlphaChannel, boolean useDepth) {
	this.viewport.set(viewport);
	transition = null;
	paused = false;
	fbFormat = Format.RGB565;
	usedepth = useDepth;

	if (use32Bits) {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA8888;
		} else {
			fbFormat = Format.RGB888;
		}
	} else {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA4444;
		} else {
			fbFormat = Format.RGB565;
		}
	}

	fbFrom = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth);
	fbTo = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth);
}
 
Example 8
Source File: Art.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads a pixel map from the file system.
 * 
 * @param image
 * @return the Pixmap
 */
public static Pixmap loadPixmap(String image) {
    try {
        return TextureUtil.loadPixmap(image);
    } 
    catch (Exception e) {
        Cons.println("*** A problem occured loading an image: " + e);
    }
    
    return new Pixmap(10, 10, Format.RGBA8888);
}
 
Example 9
Source File: GLTFPostProcessingExample.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	sceneManager = createSceneManager();
	sceneManager.camera = camera = new PerspectiveCamera();
	camera.fieldOfView = 50;
	camera.near = 0.01f;
	camera.far = 10f;
	camera.position.set(1, 1, 1).scl(.1f);
	camera.up.set(Vector3.Y);
	camera.lookAt(Vector3.Zero);
	camera.update();
	
	// load user scene
	SceneAsset asset = new GLTFLoader().load(Gdx.files.internal("models/BoomBox/glTF/BoomBox.gltf"));
	sceneManager.addScene(new Scene(asset.scene));
	
	cameraController = new CameraInputController(camera);
	cameraController.translateUnits = .1f;
	Gdx.input.setInputProcessor(cameraController);

	viewport = new FitViewport(1000, 500, camera);
	
	// post processing
	if(postProcessingEnabled){
		fbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
		effectShader = new ShaderProgram(Gdx.files.classpath("shaders/effect.vs.glsl"), Gdx.files.classpath("shaders/effect.fs.glsl"));
		batch = new SpriteBatch();
	}
	
}
 
Example 10
Source File: FadingGame.java    From libgdx-transitions with Apache License 2.0 5 votes vote down vote up
@Override
public void resize(int width, int height) {
    if (screen != null) screen.resize(width, height);
    if (nextScreen != null) nextScreen.resize(width, height);

    this.currentScreenFBO.dispose();
    this.nextScreenFBO.dispose();

    this.currentScreenFBO = new FrameBuffer(Format.RGBA8888, width, height, false);
    this.nextScreenFBO = new FrameBuffer(Format.RGBA8888, width, height, false);

}
 
Example 11
Source File: ColorFadeTransition.java    From libgdx-transitions with Apache License 2.0 5 votes vote down vote up
/** @param color the {@link Color} to fade to
 * @param interpolation the {@link Interpolation} method */
public ColorFadeTransition (Color color, Interpolation interpolation) {
	this.color = new Color(Color.WHITE);
	this.interpolation = interpolation;

	texture = new Texture(1, 1, Format.RGBA8888);
	Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
	pixmap.setColor(color);
	pixmap.fillRectangle(0, 0, 1, 1);
	texture.draw(pixmap, 0, 0);
}
 
Example 12
Source File: Art.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public static Texture newTexture (String name, boolean mipMap) {
	Texture t = new Texture(Gdx.files.internal(name), Format.RGBA8888, mipMap);

	if (mipMap) {
		t.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
	} else {
		t.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
	}

	return t;
}
 
Example 13
Source File: DebugMeter.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public DebugMeter (int width, int height) {
	assert (width < 256 && height < 256);

	this.showLabel = true;
	this.name = "";
	this.width = width;
	this.height = height;
	this.pos = new Vector2();

	pixels = new Pixmap(this.width, this.height, Format.RGBA8888);
	texture = new Texture(width, height, Format.RGBA8888);
	texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
	region = new TextureRegion(texture, 0, 0, pixels.getWidth(), pixels.getHeight());
}
 
Example 14
Source File: GdxCanvas.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
/**
     * 
     */
    public GdxCanvas() {
        this.batch = new SpriteBatch();
        this.color = new Color();
        this.tmpColor = new Color();
        
        this.shaderStack = new Stack<>();
        this.zoomStack = new Stack<>();
        
        this.camera = new OrthographicCamera(getWidth(), getHeight());
        this.camera.setToOrtho(true, getWidth(), getHeight());
        this.camera.position.x = this.camera.viewportWidth/2;
        this.camera.position.y = this.camera.viewportHeight/2;
        this.camera.update();
        
        this.viewport = new FitViewport(getWidth(), getHeight(), camera);
        this.viewport.apply();
                
        this.generators = new HashMap<String, FreeTypeFontGenerator>();
        this.fonts = new HashMap<String, BitmapFont>();
        this.bounds = new GlyphLayout();
                
        this.transform = new Matrix4();
        //this.batch.setTransformMatrix(transform);
                
        //Matrix4 projection = new Matrix4();
        //projection.setToOrtho( 0, getWidth(), getHeight(), 0, -1, 1);
        //this.batch.setProjectionMatrix(projection);
        
//        this.wHeight = getHeight();
        this.batch.setProjectionMatrix(this.camera.combined);
        
        this.shapes = new ShapeRenderer();
        //this.shapes.setTransformMatrix(transform);    
//        this.shapes.setProjectionMatrix(projection);
        //this.shapes.setProjectionMatrix(camera.combined);
        
        this.fbo = new FrameBuffer(Format.RGBA8888, getWidth(), getHeight(), false);
    }
 
Example 15
Source File: MainMenuInterface.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private void setUpSkin() {
	Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
	pixmap.setColor(Color.LIGHT_GRAY);
	pixmap.fill();
	skin.add("grey", new Texture(pixmap));
	titleSprite.setX(TITLE_SPRITE_POS_X);
	titleSprite.setY(TITLE_SPRITE_POS_Y);

	LabelStyle labelStyle = new LabelStyle();
	skin.add("default", finePrint);
	labelStyle.font = skin.getFont("default");
	skin.add("default", labelStyle);

	CheckBoxStyle checkBoxStyle = new CheckBoxStyle();
	checkBoxStyle.checkboxOff = skin.newDrawable("grey", Color.LIGHT_GRAY);
	checkBoxStyle.checkboxOn = skin.newDrawable("grey", Color.LIGHT_GRAY);
	checkBoxStyle.font = skin.getFont("default");
	checkBoxStyle.checkboxOff = new TextureRegionDrawable(unchecked);
	checkBoxStyle.checkboxOn = new TextureRegionDrawable(checked);
	skin.add("default", checkBoxStyle);

	SliderStyle sliderStyle = new SliderStyle();
	sliderStyle.background = new TextureRegionDrawable(background);
	sliderStyle.knob = new TextureRegionDrawable(knob);
	skin.add("default-horizontal", sliderStyle);

	ButtonStyle buttonStyle = new ButtonStyle();
	skin.add("default", buttonStyle);

	TextButtonStyle textButtonStyle = new TextButtonStyle();
	textButtonStyle.font = skin.getFont("default");
	textButtonStyle.up = new NinePatchDrawable(patchBox);
	skin.add("default", textButtonStyle);
}
 
Example 16
Source File: DirectionalShadowLight.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public DirectionalShadowLight(int shadowMapWidth, int shadowMapHeight, float shadowViewportWidth,
		float shadowViewportHeight, float shadowNear, float shadowFar) {
	fbo = new FrameBuffer(Format.RGBA8888, shadowMapWidth, shadowMapHeight, true);
	cam = new OrthographicCamera(shadowViewportWidth, shadowViewportHeight);
	cam.near = shadowNear;
	cam.far = shadowFar;
	textureDesc = new TextureDescriptor();
	textureDesc.minFilter = textureDesc.magFilter = Texture.TextureFilter.Nearest;
	textureDesc.uWrap = textureDesc.vWrap = Texture.TextureWrap.ClampToEdge;
}
 
Example 17
Source File: IBLBuilder.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an radiance map, to be used with {@link net.mgsx.gltf.scene3d.attributes.PBRCubemapAttribute#SpecularEnv}
 * generated cubemap contains mipmaps in order to perform roughness in PBR shading
 * @param levels mipMapLevels how many mipmaps level, eg. 10 levels produce a 1024x1024 cubemap with mipmaps.
 * @return generated cubemap, caller is responsible to dispose it when no longer used.
 */
public Cubemap buildRadianceMap(final int mipMapLevels){
	Pixmap[] maps = new Pixmap[mipMapLevels * 6];
	int index = 0;
	for(int level=0 ; level<mipMapLevels ; level++){
		int size = 1 << (mipMapLevels - level - 1);
		FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, size, size, false);
		fbo.begin();
		for(int s=0 ; s<6 ; s++){
			Gdx.gl.glClearColor(0, 0, 0, 0);
			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
			
			CubemapSide side = CubemapSide.values()[s];
			
			float blur = (float)level / (float)mipMapLevels;
			
			renderGradient(side, blur);
			renderLights(side, false);
			
			maps[index] = ScreenUtils.getFrameBufferPixmap(0, 0, size, size);
			index++;
		}
		fbo.end();
		fbo.dispose();
	}
	FacedMultiCubemapData data = new FacedMultiCubemapData(maps, mipMapLevels);
	Cubemap map = new Cubemap(data);
	map.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
	return map;
}
 
Example 18
Source File: TextureUtil.java    From seventh with GNU General Public License v2.0 4 votes vote down vote up
public static Pixmap createPixmap(int width, int height) {
    return new Pixmap(width, height, Format.RGBA8888);
}
 
Example 19
Source File: CCScrollView.java    From cocos-ui-libgdx with Apache License 2.0 4 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
    ScrollPaneStyle style = new ScrollPaneStyle();

    if (widget.getFileData() != null) {

        style.background = editor
            .findDrawable(widget, widget.getFileData());
    }

    ScrollPane scrollPane = new ScrollPane(null, style);

    if ("Vertical_Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, true);
    } else if ("Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, false);
    } else if ("Vertical".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(false, true);
    }

    scrollPane.setClamp(widget.isClipAble());
    scrollPane.setFlickScroll(widget.isIsBounceEnabled());

    Table table = new Table();
    table.setSize(widget.getInnerNodeSize().getWidth(), widget
        .getInnerNodeSize().getHeight());

    if (widget.getComboBoxIndex() == 0) {// 无颜色

    } else if (widget.getComboBoxIndex() == 1) {// 单色

        Pixmap pixmap = new Pixmap((int) table.getWidth(),
            (int) table.getHeight(), Format.RGBA8888);
        Color color = editor.getColor(widget.getSingleColor(),
            widget.getBackColorAlpha());

        pixmap.setColor(color);

        pixmap.fill();

        Drawable drawable = new TextureRegionDrawable(new TextureRegion(
            new Texture(pixmap)));

        table.setBackground(drawable);
        pixmap.dispose();

    }
    scrollPane.setWidget(table);
    return scrollPane;
}
 
Example 20
Source File: ImageUtils.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static void createAtlas(String inDir, String outdir, String name, float scale, int maxWidth, int maxHeight,
		TextureFilter filterMin, TextureFilter filterMag, String outputFormat, boolean stripWhiteSpace)
		throws IOException {
	Settings settings = new Settings();

	settings.pot = false;
	settings.paddingX = 2;
	settings.paddingY = 2;
	settings.duplicatePadding = false;
	settings.edgePadding = true;
	settings.rotation = false;
	settings.minWidth = 16;
	settings.minWidth = 16;
	settings.stripWhitespaceX = stripWhiteSpace;
	settings.stripWhitespaceY = stripWhiteSpace;
	settings.alphaThreshold = 0;

	settings.filterMin = filterMin;
	settings.filterMag = filterMag;
	settings.wrapX = Texture.TextureWrap.ClampToEdge;
	settings.wrapY = Texture.TextureWrap.ClampToEdge;
	settings.format = Format.RGBA8888;
	settings.alias = true;
	settings.outputFormat = outputFormat;
	settings.jpegQuality = 0.9f;
	settings.ignoreBlankImages = true;
	settings.fast = false;
	settings.debug = false;

	settings.maxWidth = maxWidth;
	settings.maxHeight = maxHeight;

	EditorLogger.debug("ATLAS MAXWIDTH: " + settings.maxWidth);

	File inTmpDir = new File(inDir);

	// Resize images to create atlas for different resolutions
	if (scale != 1.0f) {
		inTmpDir = DesktopUtils.createTempDirectory();

		ImageUtils.scaleDirFiles(new File(inDir), inTmpDir, scale);
	}

	TexturePacker.process(settings, inTmpDir.getAbsolutePath(), outdir,
			name.endsWith(".atlas") ? name : name + ".atlas");

	if (scale != 1.0f) {
		DesktopUtils.removeDir(inTmpDir.getAbsolutePath());
	}
}