Home | History | Annotate | Download | only in glutils
      1 /*******************************************************************************
      2  * Copyright 2011 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *   http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.graphics.glutils;
     18 
     19 import com.badlogic.gdx.Application.ApplicationType;
     20 import com.badlogic.gdx.Gdx;
     21 import com.badlogic.gdx.graphics.Texture;
     22 import com.badlogic.gdx.graphics.Texture.TextureFilter;
     23 import com.badlogic.gdx.graphics.Texture.TextureWrap;
     24 import com.badlogic.gdx.utils.GdxRuntimeException;
     25 
     26 /** This is a {@link FrameBuffer} variant backed by a float texture. */
     27 public class FloatFrameBuffer extends FrameBuffer {
     28 
     29 	/** Creates a new FrameBuffer with a float backing texture, having the given dimensions and potentially a depth buffer attached.
     30 	 *
     31 	 * @param width the width of the framebuffer in pixels
     32 	 * @param height the height of the framebuffer in pixels
     33 	 * @param hasDepth whether to attach a depth buffer
     34 	 * @throws GdxRuntimeException in case the FrameBuffer could not be created */
     35 	public FloatFrameBuffer (int width, int height, boolean hasDepth) {
     36 		super(null, width, height, hasDepth);
     37 	}
     38 
     39 	@Override
     40 	protected Texture createColorTexture () {
     41 		FloatTextureData data = new FloatTextureData(width, height);
     42 		Texture result = new Texture(data);
     43 		if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet)
     44 			result.setFilter(TextureFilter.Linear, TextureFilter.Linear);
     45 		else
     46 			// no filtering for float textures in OpenGL ES
     47 			result.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
     48 		result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
     49 		return result;
     50 	}
     51 
     52 	@Override
     53 	protected void disposeColorTexture (Texture colorTexture) {
     54 		colorTexture.dispose();
     55 	}
     56 }
     57