Java Code Examples for org.lwjgl.opengl.GL11#GL_LINEAR

The following examples show how to use org.lwjgl.opengl.GL11#GL_LINEAR . 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: Graphics.java    From AnyaBasic with MIT License 6 votes vote down vote up
public Graphics( int screenWidth, int screenHeight, int vsynch )
{

    super( screenWidth, screenHeight );

    if( vsynch !=  0)
    {
        Display.setVSyncEnabled( true );
    }

    spriteFont = new SpriteFont( new ImageAtlas(
                                 new ImageTextureDataFont(),
                                 32, 32, GL11.GL_NEAREST ));

    glowImages = new ImageAtlas( new ImageTextureDataGlowSprites(), GL11.GL_LINEAR, 0 );

}
 
Example 2
Source File: GeneratorHalos.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
public final Texture[] generate() {
	Channel channel_shadow = new Ring(size, size, shadow_parms, Ring.SMOOTH).toChannel();
	Channel channel_ring = new Ring(size, size, ring_parms, Ring.LINEAR).toChannel();
	Channel channel_black = new Channel(size, size).fill(0f);
	Channel channel_white = new Channel(size, size).fill(1f);
	Layer layers[] = new Layer[2];
	layers[SHADOWED] = new Layer(channel_black, channel_black, channel_black, channel_shadow);
	layers[SELECTED] = new Layer(channel_white.copy(), channel_white.copy(), channel_white.copy(), channel_ring);
	layers[SELECTED] = layers[SHADOWED].copy().layerBlend(layers[SELECTED]);
	Texture[] textures = new Texture[layers.length];
	for (int i = 0; i < layers.length; i++) {
		if (Landscape.DEBUG) new GLIntImage(layers[i]).saveAsPNG("generator_halos_" + i);
		textures[i] = new Texture(new GLImage[]{new GLIntImage(layers[i])}, GL11.GL_RGBA, GL11.GL_LINEAR, GL11.GL_LINEAR, GL11.GL_CLAMP, GL11.GL_CLAMP);
	}
	return textures;
}
 
Example 3
Source File: TextureAttachment.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
private void setTextureParams(){
	int filterType = nearestFiltering ? GL11.GL_NEAREST : GL11.GL_LINEAR;
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filterType);
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filterType);
	int wrapType = clampEdges ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT;
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapType);
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapType);
}
 
Example 4
Source File: Graphics.java    From AnyaBasic with MIT License 5 votes vote down vote up
public int loadImage( String filename )
{
    //System.out.println(filename);
    ImageTextureData texture = new ImageTextureDataDefault();
    texture.setFileName( filename );
    ImageAtlas atlas = new ImageAtlas( texture, GL11.GL_LINEAR );
    sprites.add( atlas.getSprite( 0 ) );
    return (sprites.size()-1);   // return last index index
}
 
Example 5
Source File: IslandGenerator.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final Texture createDetail(GLImage detail_image, int base_level) {
	GLImage[] detail_mipmaps = detail_image.buildMipMaps();
	GLImage.updateMipMapsArea(detail_mipmaps, base_level, Globals.LANDSCAPE_DETAIL_FADEOUT_FACTOR,
							  0, 0, detail_mipmaps[0].getWidth(), detail_mipmaps[0].getHeight(), false);
	return new Texture(detail_mipmaps, Globals.COMPRESSED_RGBA_FORMAT, GL11.GL_LINEAR_MIPMAP_LINEAR,
							  GL11.GL_LINEAR, GL11.GL_REPEAT, GL11.GL_REPEAT);
}
 
Example 6
Source File: GeneratorRing.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final Texture[] generate() {
	Channel channel_ring = new Ring(size, size, ring_parms, Ring.LINEAR).toChannel();
	Channel channel_white = new Channel(size, size).fill(1f);
	Layer layer = new Layer(channel_white.copy(), channel_white.copy(), channel_white.copy(), channel_ring);
	Texture[] textures = new Texture[1];
	textures[0] = new Texture(new GLImage[]{new GLIntImage(layer)}, GL11.GL_RGBA, GL11.GL_LINEAR, GL11.GL_LINEAR, GL11.GL_CLAMP, GL11.GL_CLAMP);
	return textures;
}
 
Example 7
Source File: BuildingSiteRenderer.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public BuildingSiteRenderer() {
	GLIntImage img = new GLIntImage(16, 16, GL11.GL_RGBA);
	for (int y = 1; y < img.getHeight() - 1; y++)
		for (int x = 1; x < img.getWidth() - 1; x++)
			img.putPixel(x, y, 0xffffffff);
	green = new Texture(new GLIntImage[]{img}, GL11.GL_RGBA, GL11.GL_LINEAR, GL11.GL_LINEAR, GL11.GL_CLAMP, GL11.GL_CLAMP);
}
 
Example 8
Source File: Font.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public Font(FontInfo font_info) {
	this.key_array = font_info.getKeyMap();
	TextureFile file = new TextureFile(font_info.getTextureName(),
									   GL11.GL_RGBA,
									   GL11.GL_LINEAR,
									   GL11.GL_LINEAR,
									   GL11.GL_REPEAT,
									   GL11.GL_REPEAT);
	this.texture = (Texture)Resources.findResource(file);
	this.x_border = font_info.getBorderX();
	this.y_border = font_info.getBorderY();
	this.height = font_info.getHeight();
}
 
Example 9
Source File: Skin.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static Texture loadTexture(String tex_file) {
	TextureFile file = new TextureFile(tex_file,
									   GL11.GL_RGBA,
									   GL11.GL_LINEAR,
									   GL11.GL_LINEAR,
									   GL11.GL_CLAMP,
									   GL11.GL_CLAMP);
	return (Texture)Resources.findResource(file);
}
 
Example 10
Source File: Icons.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static Texture loadTexture(String tex_file) {
	TextureFile file = new TextureFile(tex_file,
									   GL11.GL_RGBA,
									   GL11.GL_LINEAR,
									   GL11.GL_LINEAR,
									   GL11.GL_CLAMP,
									   GL11.GL_CLAMP);
	return (Texture)Resources.findResource(file);
}
 
Example 11
Source File: MapTexture.java    From mapwriter with MIT License 5 votes vote down vote up
public MapTexture(int textureSize, boolean linearScaling) {
	super(textureSize, textureSize, 0x00000000, GL11.GL_LINEAR, GL11.GL_LINEAR, GL11.GL_REPEAT);
	
	this.setLinearScaling(linearScaling);
	
	this.textureRegions = textureSize >> Region.SHIFT;
	this.textureSize = textureSize;
	this.regionArray = new Region[this.textureRegions * this.textureRegions];
}
 
Example 12
Source File: TextureFile.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public TextureFile(String location, int internal_format) {
	this(location, internal_format, GL11.GL_LINEAR_MIPMAP_NEAREST, GL11.GL_LINEAR, GL11.GL_REPEAT, GL11.GL_REPEAT);
}
 
Example 13
Source File: BlendInfo.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
private final Texture createAlphaMap(GLByteImage alpha_image, int format) {
	return new Texture(new GLByteImage[]{alpha_image}, format, GL11.GL_LINEAR,
									  GL11.GL_LINEAR, GL11.GL_REPEAT, GL11.GL_REPEAT);
}
 
Example 14
Source File: StructureBlend.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
private final Texture createStructureMap(GLIntImage structure_image) {
	return new Texture(new GLIntImage[]{structure_image}, GL11.GL_RGB, GL11.GL_LINEAR, GL11.GL_LINEAR, GL11.GL_REPEAT, GL11.GL_REPEAT);
}
 
Example 15
Source File: IslandGenerator.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
private final static Texture[][] blendTextures(OffscreenRendererFactory factory, int chunks_per_colormap, BlendInfo[] blend_infos, int alpha_size, int structure_size, int scale) {
		boolean use_pbuffer = Settings.getSettings().usePbuffer();
		boolean use_fbo = Settings.getSettings().useFBO();
		OffscreenRenderer offscreen = factory.createRenderer(TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, new PixelFormat(Globals.VIEW_BIT_DEPTH, 0, 0, 0, 0), Settings.getSettings().use_copyteximage, use_pbuffer, use_fbo);
		GL11.glColor4f(1f, 1f, 1f, 1f);
		GL11.glDisable(GL11.GL_DEPTH_TEST);
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();
		GL11.glOrtho(0f, TEXELS_PER_CHUNK, 0, TEXELS_PER_CHUNK, -1f, 1f);

		GL11.glMatrixMode(GL11.GL_TEXTURE);
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
		GL11.glLoadIdentity();
		GLState.activeTexture(GL13.GL_TEXTURE0);
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
		GL11.glLoadIdentity();
		GL11.glMatrixMode(GL11.GL_MODELVIEW);

		float alpha_texel_size = 1f/(alpha_size*scale);
		float structure_texel_size = 1f/structure_size;
		float structure_texels_per_chunk_border = Globals.TEXELS_PER_CHUNK_BORDER*structure_texel_size;
		float structure_offset = TEXELS_PER_CHUNK*structure_texel_size - 2*structure_texels_per_chunk_border;
		float structure_length = structure_offset + 2*structure_texels_per_chunk_border;

		float alpha_texels_per_chunk_border = Globals.TEXELS_PER_CHUNK_BORDER*alpha_texel_size;
		float alpha_offset = TEXELS_PER_CHUNK*alpha_texel_size;
		float alpha_length = alpha_offset + 2*alpha_texels_per_chunk_border;

		Texture[][] chunk_maps = new Texture[chunks_per_colormap][chunks_per_colormap];
		FloatBuffer coordinates = BufferUtils.createFloatBuffer(4*3);
		coordinates.put(new float[]{0f, 0f, 0f,
									TEXELS_PER_CHUNK, 0f, 0f,
									TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, 0f,
									0f, TEXELS_PER_CHUNK, 0f});
		coordinates.rewind();
		FloatBuffer structure_tex_coords = BufferUtils.createFloatBuffer(4*2);
		FloatBuffer alpha_tex_coords = BufferUtils.createFloatBuffer(4*2);
		GLStateStack.switchState(GLState.VERTEX_ARRAY | GLState.TEXCOORD0_ARRAY | GLState.TEXCOORD1_ARRAY);
		GL11.glVertexPointer(3, 0, coordinates);
		GL11.glTexCoordPointer(2, 0, structure_tex_coords);
		GLState.clientActiveTexture(GL13.GL_TEXTURE1);
		GL11.glTexCoordPointer(2, 0, alpha_tex_coords);
		GLState.clientActiveTexture(GL13.GL_TEXTURE0);
		for (int y = 0; y < chunk_maps.length; y++) {
			for (int x = 0; x < chunk_maps[y].length; x++) {
				chunk_maps[y][x] = new Texture(TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, GL11.GL_LINEAR_MIPMAP_NEAREST, GL11.GL_LINEAR, GL12.GL_CLAMP_TO_EDGE, GL12.GL_CLAMP_TO_EDGE, Globals.NO_MIPMAP_CUTOFF);
				int mip_scale = 1;
				int mip_level = 0;
				int mip_size = TEXELS_PER_CHUNK;
				while (mip_size >= 1) {
					GL11.glLoadIdentity();
					GL11.glScalef(1f/mip_scale, 1f/mip_scale, 1f);
					GL11.glEnable(GL11.GL_BLEND);

					for (int i = 0; i < blend_infos.length; i++) {
						blend_infos[i].setup();
						float structure_offset_u = x*structure_offset - structure_texels_per_chunk_border;
						float structure_offset_v = y*structure_offset - structure_texels_per_chunk_border;
						float alpha_offset_u = x*alpha_offset - alpha_texels_per_chunk_border;
						float alpha_offset_v = y*alpha_offset - alpha_texels_per_chunk_border;
						structure_tex_coords.put(0, structure_offset_u).put(1, structure_offset_v);
						structure_tex_coords.put(2, structure_offset_u + structure_length).put(3, structure_offset_v);
						structure_tex_coords.put(4, structure_offset_u + structure_length).put(5, structure_offset_v + structure_length);
						structure_tex_coords.put(6, structure_offset_u).put(7, structure_offset_v + structure_length);
						alpha_tex_coords.put(0, alpha_offset_u).put(1, alpha_offset_v);
						alpha_tex_coords.put(2, alpha_offset_u + alpha_length).put(3, alpha_offset_v);
						alpha_tex_coords.put(4, alpha_offset_u + alpha_length).put(5, alpha_offset_v + alpha_length);
						alpha_tex_coords.put(6, alpha_offset_u).put(7, alpha_offset_v + alpha_length);
						GL11.glDrawArrays(GL11.GL_QUADS, 0, 4);
						blend_infos[i].reset();
					}
/*if (mip_level == 0)
offscreen.dumpToFile("colormap-" + x + "-" + y);*/
					offscreen.copyToTexture(chunk_maps[y][x], mip_level, Globals.COMPRESSED_RGB_FORMAT, 0, 0, mip_size, mip_size);
					mip_scale <<= 1;
					mip_level++;
					mip_size >>= 1;
				}
			}
		}
		boolean succeeded = offscreen.destroy();
		if (!succeeded) {
/*			for (int y = 0; y < chunk_maps.length; y++)
				for (int x = 0; x < chunk_maps[y].length; x++)
					chunk_maps[y][x].delete();*/
			return null;
		} else
			return chunk_maps;
	}
 
Example 16
Source File: Texture.java    From mapwriter with MIT License 4 votes vote down vote up
public Texture(int w, int h, int fillColour) {
	this(w, h, fillColour, GL11.GL_LINEAR, GL11.GL_NEAREST, GL12.GL_CLAMP_TO_EDGE);
}