当前位置: 首页>>代码示例>>Java>>正文


Java TextureData类代码示例

本文整理汇总了Java中com.jogamp.opengl.util.texture.TextureData的典型用法代码示例。如果您正苦于以下问题:Java TextureData类的具体用法?Java TextureData怎么用?Java TextureData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextureData类属于com.jogamp.opengl.util.texture包,在下文中一共展示了TextureData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private boolean loadTexture(TextureTile tile, java.net.URL textureURL)
{
    TextureData textureData;

    synchronized (this.fileLock)
    {
        textureData = readTexture(textureURL);
    }

    if (textureData == null)
        return false;

    tile.setTextureData(textureData);
    this.addTileToCache(tile);

    return true;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:18,代码来源:AbstractTrackTiler.java

示例2: bindTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
/**
 * Binds a texture if it isn't already bound and destroys the old, exisiting
 * one.
 * 
 * @param gl
 *            The OpenGL context.
 */
public void bindTexture(GL2 gl) {
	// Only called if a new texture has to be bound and the weather resource
	// exists.
	if (toBeBound && currentRes != null) {
		// First destroy old existing texture.
		if (currentTex != null) {
			currentTex.destroy(gl);
		}

		// Now create new texture.
		TextureData texData = currentRes.getTexture();
		if (texData != null) {
			if(currentTex != null) {
				currentTex.destroy(gl);
			}
			
			currentTex = TextureIO.newTexture(currentRes.getTexture());				
			texData.destroy();
		}
	}
}
 
开发者ID:johb,项目名称:GAIA,代码行数:29,代码来源:WeatherAdapter.java

示例3: initBGTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private void initBGTexture(final DrawContext dc) {
	try {
		InputStream iconStream = this.getClass().getResourceAsStream("/" + iconFilePath_bg);
		if (iconStream == null) {
			final File iconFile = new File(iconFilePath_bg);
			if (iconFile.exists()) {
				iconStream = new FileInputStream(iconFile);
			}
		}

		final TextureData textureData = OGLUtil.newTextureData(dc.getGL().getGLProfile(), iconStream, false);
		iconTexture = TextureIO.newTexture(textureData);
		iconTexture.bind(dc.getGL());
		this.bgWidth = iconTexture.getWidth();
		this.bgHeight = iconTexture.getHeight();
	} catch (final IOException e) {
		final String msg = Logging.getMessage("layers.IOExceptionDuringInitialization");
		Logging.logger().severe(msg);
		throw new WWRuntimeException(msg, e);
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:22,代码来源:StatusLayer.java

示例4: loadTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private boolean loadTexture( MercatorTextureTile tile, java.net.URL textureURL ) {
    TextureData textureData;

    synchronized (this.fileLock) {
        textureData = readTexture(textureURL, this.isUseMipMaps());
    }

    if (textureData == null)
        return false;

    tile.setTextureData(textureData);
    if (tile.getLevelNumber() != 0 || !this.isRetainLevelZeroTiles())
        this.addTileToCache(tile);

    return true;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:BasicMercatorTiledImageLayer.java

示例5: readTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private static TextureData readTexture(URL url)
{
    try
    {
    	 return OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, (Boolean) null);
        //return TextureIO.newTextureData(url, false, null);
    }
    catch (Exception e)
    {
        Logging.logger().log(
            java.util.logging.Level.SEVERE, "layers.TextureLayer.ExceptionAttemptingToReadTextureFile", e);
        return null;
    }
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:15,代码来源:AbstractTrackTiler.java

示例6: initTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private void initTexture(GL4 gl) {

        try {
            URL texture = getClass().getClassLoader().getResource("images/globe.png");

            TextureData textureData = TextureIO.newTextureData(gl.getGLProfile(), texture, false, TextureIO.PNG);

            gl.glCreateTextures(GL_TEXTURE_2D, 1, textureName);

            gl.glTextureParameteri(textureName.get(0), GL_TEXTURE_BASE_LEVEL, 0);
            gl.glTextureParameteri(textureName.get(0), GL_TEXTURE_MAX_LEVEL, 0);

            gl.glTextureStorage2D(textureName.get(0),
                    1, // level
                    textureData.getInternalFormat(),
                    textureData.getWidth(), textureData.getHeight());

            gl.glTextureSubImage2D(textureName.get(0),
                    0, // level
                    0, 0, // offset
                    textureData.getWidth(), textureData.getHeight(),
                    textureData.getPixelFormat(), textureData.getPixelType(),
                    textureData.getBuffer());

        } catch (IOException ex) {
            Logger.getLogger(HelloGlobe.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
开发者ID:java-opengl-labs,项目名称:hello-triangle,代码行数:29,代码来源:HelloGlobe.java

示例7: initTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private void initTexture(GL3 gl) {

        try {
            URL texture = getClass().getClassLoader().getResource("images/door.png");

            /* Texture data is an object containing all the relevant information about texture.    */
            TextureData data = TextureIO.newTextureData(gl.getGLProfile(), texture, false, TextureIO.PNG);

            int level = 0;

            gl.glGenTextures(1, textureName);

            gl.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
            {
                gl.glTexImage2D(GL_TEXTURE_2D,
                        level,
                        data.getInternalFormat(),
                        data.getWidth(), data.getHeight(),
                        data.getBorder(),
                        data.getPixelFormat(), data.getPixelType(),
                        data.getBuffer());

                gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
                gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);

                IntBuffer swizzle = GLBuffers.newDirectIntBuffer(new int[]{GL_RED, GL_GREEN, GL_BLUE, GL_ONE});
                gl.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);

                destroyBuffer(swizzle);
            }
            gl.glBindTexture(GL_TEXTURE_2D, 0);

        } catch (IOException ex) {
            Logger.getLogger(HelloTextureK.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
开发者ID:java-opengl-labs,项目名称:hello-triangle,代码行数:37,代码来源:HelloTexture.java

示例8: importTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
@Deprecated
	static Texture importTexture(GL gl, String string) throws IOException {
		final FileInputStream f = new FileInputStream("test.png");
		final TextureData tx_dat = TextureIO.newTextureData(gl.getGLProfile(), f, false, TextureIO.PNG);
		final Texture tex = new Texture(gl, tx_dat);
		tex.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
		tex.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
//		tex.setTexParameteri(gl, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
//		tex.setTexParameteri(gl, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
		return tex;
	}
 
开发者ID:XDrake99,项目名称:WarpPI,代码行数:12,代码来源:GPURenderer.java

示例9: get

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
@Override
public TileResource get(String key) {
	// Check if the requested tile is in cache:
	TileResource result = super.get(key);
	
	if(result != null && result instanceof CachedTile) {
		CachedTile entry = (CachedTile) result;
		// Create the new tile-resource:
		IntegerVector3D coords = entry.getCoord();
		TileResource tile = new TileResource(coords.getX(), coords.getY(), coords.getZ());
		
		// The created tiles timestamp equals the results one:
		tile.setTimestamp(entry.getTimestamp());
		
		Style style = entry.getStyle();
		tile.setStyle(style); // Apply the style
		
		// Set the tiles image-data:
		String suffix = style.getImageSuffix();
		TextureData texData;
		try {
			texData = TextureIO.newTextureData(profile, entry.getFile(), false, suffix);
			
		} catch (IOException e) {
			return null;
		}
		tile.setTextureData(texData);
		
		// The resource is now valid:
		tile.setDummy(false);
		
		return tile;
		
	} else {
		return null;
	}
}
 
开发者ID:johb,项目名称:GAIA,代码行数:38,代码来源:TileCache.java

示例10: getTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
/**
 * Create a drawable "image" of this <code>WeatherResource</code> object.
 * This "image" contains all information needed and available, such as
 * temperature, weather-icon and the name of the location.
 * 
 * @see <code>TextureData</code>
 * @return A <code>TextureData</code> object which can be bound and drawn
 *         immediately by OpenGL.
 */
public TextureData getTexture() {

	// Check if there already exists a TextureData instance.
	if (textureData == null && !this.isDummy()) {
		// Create texture
		/* TODO */
	}

	// Return the TextureData or null, if this WeatherResource is a dummy
	// yet.
	return textureData;
}
 
开发者ID:johb,项目名称:GAIA,代码行数:22,代码来源:WeatherResource.java

示例11: onUpdate

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
@Override
public void onUpdate(Collection<TileResource> resources) {
	if(resources != null) {
		// Call the method of TextureAdapter as required:
		super.onUpdate(resources);
		
		Collection<GLResource> drawableResources = new LinkedList<>();
		
		GLState glState = (GLState) StateManager.getInstance().getState(StateType.GLState);
		FloatBoundingBox glBBox = glState.getBoundingBox();
		glBBox.getLowerLeft();
		
		for(TileResource tile : resources) {
			if(!tile.isDummy()) {
				String key = tile.getKey();
				FloatBoundingBox bbox = getTileBoundingBox(tile);
				TextureData texData = tile.getTextureData();
				
				scheduleTextureCreation(key, texData);
				
				GLResource glResource = new GLResource(key, bbox);
				
				drawableResources.add(glResource);
			}
		}
		
		setGLResources(drawableResources);
	}
}
 
开发者ID:johb,项目名称:GAIA,代码行数:30,代码来源:TileAdapter.java

示例12: loadTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
private TextureData loadTexture(GL2 gl, GLProfile profile, final String filename) {
  try (InputStream stream = ScatterPlot.class.getResourceAsStream(filename)) {
    return TextureIO.newTextureData(profile, stream, false, "png");
  }
  catch(IOException exc) {
    throw new RuntimeException("Could not load texture: " + filename, exc);
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:9,代码来源:ScatterPlotOpenGL4.java

示例13: newTextureData

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
/**
 * Method newTextureData()
 * 
 * @see com.jogamp.opengl.util.texture.spi.TextureProvider#newTextureData(com.jogamp.opengl.GLProfile, java.io.File,
 *      int, int, boolean, java.lang.String)
 */
@Override
public TextureData newTextureData(final GLProfile glp, final File file, final int internalFormat,
		final int pixelFormat, final boolean mipmap, final String fileSuffix) throws IOException {
	final IScope scope = GAMA.getRuntimeScope();
	final GamaImageFile f = new GamaImageFile(scope, file.getAbsolutePath());
	if (f.getExtension(scope).equals("pgm")) {
		final BufferedImage image = f.getImage(scope, true);
		return AWTTextureIO.newTextureData(glp, image, internalFormat, pixelFormat, mipmap);
	} else {
		return null;
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:19,代码来源:PGMTextureProvider.java

示例14: buildTexture

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
public static Texture buildTexture(final GL gl, final BufferedImage image) {
	try {
		final TextureData data = AWTTextureIO.newTextureData(gl.getGLProfile(),
				correctImage(image, !Abstract3DRenderer.isNonPowerOf2TexturesAvailable), false);
		final Texture texture = new Texture(gl, data);
		data.flush();
		return texture;
	} catch (final GLException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:13,代码来源:OpenGL.java

示例15: update

import com.jogamp.opengl.util.texture.TextureData; //导入依赖的package包/类
public void update(GL2GL3 g) {
    if (textureId == -1) {
        g.glEnable(GL2GL3.GL_TEXTURE_2D_ARRAY);
        IntBuffer singleTexBuffer = GLBuffers.newDirectIntBuffer(1);

        g.glGenTextures(1, singleTexBuffer);
        textureId = singleTexBuffer.get();
        g.glBindTexture(GL2GL3.GL_TEXTURE_2D_ARRAY, textureId);
        g.glTexStorage3D(GL2GL3.GL_TEXTURE_2D_ARRAY, 255, GL2GL3.GL_RGBA8, width, height, depth);
    }
    
    if (lastUpdate == subtexturesCount) {
        return;
    }
    
    g.glBindTexture(GL2GL3.GL_TEXTURE_2D_ARRAY, textureId);
    
    for (int i = lastUpdate; i < subtexturesCount; i++) {
        try {
            String texturePath = subtexturesLocations.get(i);
            TextureData data = TextureIO.newTextureData(GLProfile.getDefault(), new File(texturePath), true, FilenameUtils.getExtension(texturePath));
            
            if (data.getWidth() != width || data.getHeight() != height) {
                throw new IllegalArgumentException("Textures width/height does not match.");
            }
            
            g.glTexSubImage3D(GL2GL3.GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, subtexturesCount, GL2GL3.GL_RGBA, GL2GL3.GL_UNSIGNED_BYTE, data.getBuffer());
            g.glGenerateMipmap(GL2GL3.GL_TEXTURE_2D_ARRAY);
            
            if (g.glGetError() != GL2GL3.GL_NO_ERROR) {
                throw new GLException("Failed subtexture loading");
            }
        } catch (IOException ex) {
            Log.err(ex);
        }
    }
    
    lastUpdate = subtexturesCount;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:40,代码来源:ArrayTex.java


注:本文中的com.jogamp.opengl.util.texture.TextureData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。