Java Code Examples for org.lwjgl.opengl.GL11#GL_LINEAR_MIPMAP_NEAREST
The following examples show how to use
org.lwjgl.opengl.GL11#GL_LINEAR_MIPMAP_NEAREST .
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: Texture.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public Texture(TextureFile texture_file) { this.texture_handle = initTexture(texture_file.getMinFilter(), texture_file.getMagFilter(), texture_file.getWrapS(), texture_file.getWrapT(), texture_file.getMaxMipmapLevel()); if (texture_file.isDXTImage()) { DXTImage dxt_image = texture_file.getDXTImage(); this.width = dxt_image.getWidth(); this.height = dxt_image.getHeight(); uploadDXTTexture(dxt_image, texture_file); return; } else { GLImage img = texture_file.getImage(); this.width = img.getWidth(); this.height = img.getHeight(); GLImage[] mipmaps; if (texture_file.getMinFilter() == GL11.GL_LINEAR_MIPMAP_NEAREST || texture_file.getMinFilter() == GL11.GL_LINEAR_MIPMAP_LINEAR) { mipmaps = img.buildMipMaps(); GLImage.updateMipMapsArea(mipmaps, texture_file.getBaseFadeoutLevel(), texture_file.getFadeoutFactor(), 0, 0, width, height, texture_file.hasMaxAlpha()); } else mipmaps = new GLImage[]{img}; uploadTexture(mipmaps, texture_file.getInternalFormat(), texture_file.getMaxMipmapLevel()); } }
Example 2
Source File: TextureFile.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
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 3
Source File: IslandGenerator.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
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; }