List of usage examples for org.lwjgl.opengl GL11 glTexParameterf
public static void glTexParameterf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param)
From source file:net.lyonlancer5.mcmp.karasu.client.renderer.tileentity.TileEntityBeaconRenderer.java
License:Apache License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) { TileEntityBeacon beacon = (TileEntityBeacon) tile; float f1 = beacon.func_146002_i(); //OpenGLHelper.alphaFunc(GL11.GL_GREATER, 0.1F); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); if (f1 > 0.0F) { Tessellator tessellator = Tessellator.instance; List<BeamSegment> list = beacon.getSegments(); int j = 0; for (int i = 0; i < list.size(); i++) { BeamSegment beamsegment = list.get(i); int l = j + beamsegment.getCurrentSegment(); bindTexture(BEAM_TEXTURE);/*w w w. ja v a 2s .co m*/ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); //OpenGLHelper.disableLighting(); GL11.glDisable(GL11.GL_LIGHTING); //OpenGLHelper.disableCull(); GL11.glDisable(GL11.GL_CULL_FACE); //OpenGLHelper.disableBlend(); GL11.glDisable(GL11.GL_BLEND); //OpenGLHelper.depthMask(true); GL11.glDepthMask(true); OpenGlHelper.glBlendFunc(770, 1, 1, 0); float f2 = tile.getWorldObj().getTotalWorldTime() + partialTickTime; float f3 = -f2 * 0.2F - MathHelper.floor_float(-f2 * 0.1F); double d3 = f2 * 0.025D * -1.5D; tessellator.startDrawingQuads(); double d4 = 0.2D; double d5 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d4; double d6 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d4; double d7 = 0.5D + Math.cos(d3 + Math.PI / 4D) * d4; double d8 = 0.5D + Math.sin(d3 + Math.PI / 4D) * d4; double d9 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d4; double d10 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d4; double d11 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d4; double d12 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d4; double d13 = 0.0D; double d14 = 1.0D; double d15 = -1.0F + f3; double d16 = beamsegment.getCurrentSegment() * f1 * (0.5D / d4) + d15; tessellator.setColorRGBA_F(beamsegment.getSegmentColors()[0], beamsegment.getSegmentColors()[1], beamsegment.getSegmentColors()[2], 0.125F); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d14, d16); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d14, d15); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d13, d15); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d13, d16); tessellator.addVertexWithUV(x + d11, y + l, z + d12, d14, d16); tessellator.addVertexWithUV(x + d11, y + j, z + d12, d14, d15); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d13, d15); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d13, d16); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d14, d16); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d14, d15); tessellator.addVertexWithUV(x + d11, y + j, z + d12, d13, d15); tessellator.addVertexWithUV(x + d11, y + l, z + d12, d13, d16); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d14, d16); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d14, d15); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d13, d15); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d13, d16); tessellator.draw(); //OpenGLHelper.enableBlend(); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); //OpenGLHelper.depthMask(false); GL11.glDepthMask(false); tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(beamsegment.getSegmentColors()[0], beamsegment.getSegmentColors()[1], beamsegment.getSegmentColors()[2], 0.125F); d3 = 0.2D; d4 = 0.2D; d5 = 0.8D; d6 = 0.2D; d7 = 0.2D; d8 = 0.8D; d9 = 0.8D; d10 = 0.8D; d11 = 0.0D; d12 = 1.0D; d13 = -1.0F + f3; d14 = beamsegment.getCurrentSegment() * f1 + d13; tessellator.addVertexWithUV(x + d3, y + l, z + d4, d12, d14); tessellator.addVertexWithUV(x + d3, y + j, z + d4, d12, d13); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d11, d13); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d11, d14); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d12, d14); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d12, d13); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d11, d13); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d11, d14); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d12, d14); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d12, d13); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d11, d13); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d11, d14); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d12, d14); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d12, d13); tessellator.addVertexWithUV(x + d3, y + j, z + d4, d11, d13); tessellator.addVertexWithUV(x + d3, y + l, z + d4, d11, d14); tessellator.draw(); //OpenGLHelper.enableLighting(); GL11.glEnable(GL11.GL_LIGHTING); //OpenGLHelper.enableTexture2D(); GL11.glEnable(GL11.GL_TEXTURE_2D); //OpenGLHelper.depthMask(true); j = l; } } }
From source file:net.neilcsmith.praxis.video.opengl.internal.Texture.java
License:Apache License
/** Sets the {@link TextureWrap} for this texture on the u and v axis. This will bind this texture! * // w w w.ja v a2 s . c o m * @param u the u wrap * @param v the v wrap */ public void setWrap(TextureWrap u, TextureWrap v) { this.uWrap = u; this.vWrap = v; bind(); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, u.getGLEnum()); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, v.getGLEnum()); }
From source file:net.neilcsmith.praxis.video.opengl.internal.Texture.java
License:Apache License
public void setFilter(TextureFilter minFilter, TextureFilter magFilter) { this.minFilter = minFilter; this.magFilter = magFilter; bind();/*from w w w .ja va 2 s . c o m*/ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, minFilter.getGLEnum()); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, magFilter.getGLEnum()); }
From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java
License:Apache License
public void setLodBias(float lodBias) { GL11.glTexParameterf(textureTarget, GL14.GL_TEXTURE_LOD_BIAS, lodBias); }
From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java
License:Apache License
public void setMaxLod(float maxLod) { GL11.glTexParameterf(textureTarget, GL12.GL_TEXTURE_MAX_LOD, maxLod); }
From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java
License:Apache License
public void setMinLod(float minLod) { GL11.glTexParameterf(textureTarget, GL12.GL_TEXTURE_MIN_LOD, minLod); }
From source file:org.free.jake2.render.lwjgl.Draw.java
License:Open Source License
protected void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { int i, j, trows; int sourceIndex; int frac, fracstep; float hscale; int row;//from ww w . j a va 2s . c o m float t; GL_Bind(0); if (rows <= 256) { hscale = 1; trows = rows; } else { hscale = rows / 256.0f; trows = 256; } t = rows * hscale / 256; if (!qglColorTableEXT) { //int[] image32 = new int[256*256]; image32.clear(); int destIndex = 0; for (i = 0; i < trows; i++) { row = (int) (i * hscale); if (row > rows) { break; } sourceIndex = cols * row; destIndex = i * 256; fracstep = cols * 0x10000 / 256; frac = fracstep >> 1; for (j = 0; j < 256; j++) { image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac >> 16)] & 0xff]); frac += fracstep; } } GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image32); } else { //byte[] image8 = new byte[256*256]; image8.clear(); int destIndex = 0; for (i = 0; i < trows; i++) { row = (int) (i * hscale); if (row > rows) { break; } sourceIndex = cols * row; destIndex = i * 256; fracstep = cols * 0x10000 / 256; frac = fracstep >> 1; for (j = 0; j < 256; j++) { image8.put(destIndex + j, data[sourceIndex + (frac >> 16)]); frac += fracstep; } } GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, image8); } GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) { GL11.glDisable(GL11.GL_ALPHA_TEST); } GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(x + w, y); GL11.glTexCoord2f(1, t); GL11.glVertex2f(x + w, y + h); GL11.glTexCoord2f(0, t); GL11.glVertex2f(x, y + h); GL11.glEnd(); if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) { GL11.glEnable(GL11.GL_ALPHA_TEST); } }
From source file:org.free.jake2.render.lwjgl.Image.java
License:Open Source License
boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) { int samples;//w w w . j ava2 s.c o m int scaled_width, scaled_height; int i, c; int comp; Arrays.fill(scaled, 0); // Arrays.fill(paletted_texture, (byte)0); paletted_texture.clear(); for (int j = 0; j < 256 * 256; j++) { paletted_texture.put(j, (byte) 0); } uploaded_paletted = false; for (scaled_width = 1; scaled_width < width; scaled_width <<= 1) ; if (gl_round_down.value > 0.0f && scaled_width > width && mipmap) { scaled_width >>= 1; } for (scaled_height = 1; scaled_height < height; scaled_height <<= 1) ; if (gl_round_down.value > 0.0f && scaled_height > height && mipmap) { scaled_height >>= 1; } // let people sample down the world textures for speed if (mipmap) { scaled_width >>= (int) gl_picmip.value; scaled_height >>= (int) gl_picmip.value; } // don't ever bother with >256 textures if (scaled_width > 256) { scaled_width = 256; } if (scaled_height > 256) { scaled_height = 256; } if (scaled_width < 1) { scaled_width = 1; } if (scaled_height < 1) { scaled_height = 1; } upload_width = scaled_width; upload_height = scaled_height; if (scaled_width * scaled_height > 256 * 256) { Com.Error(Defines.ERR_DROP, "GL_Upload32: too big"); } // scan the texture for any non-255 alpha c = width * height; samples = gl_solid_format; for (i = 0; i < c; i++) { if ((data[i] & 0xff000000) != 0xff000000) { samples = gl_alpha_format; break; } } if (samples == gl_solid_format) { comp = gl_tex_solid_format; } else if (samples == gl_alpha_format) { comp = gl_tex_alpha_format; } else { VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); comp = samples; } // simulates a goto try { if (scaled_width == width && scaled_height == height) { if (!mipmap) { if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { uploaded_paletted = true; GL_BuildPalettedTexture(paletted_texture, data, scaled_width, scaled_height); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, paletted_texture); } else { tex.rewind(); tex.put(data); tex.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, tex); } //goto done; throw gotoDone; } //memcpy (scaled, data, width*height*4); were bytes System.arraycopy(data, 0, scaled, 0, width * height); } else { GL_ResampleTexture(data, width, height, scaled, scaled_width, scaled_height); } GL_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap); if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && (samples == gl_solid_format)) { uploaded_paletted = true; GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, paletted_texture); } else { tex.rewind(); tex.put(scaled); tex.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, tex); } if (mipmap) { int miplevel; miplevel = 0; while (scaled_width > 1 || scaled_height > 1) { GL_MipMap(scaled, scaled_width, scaled_height); scaled_width >>= 1; scaled_height >>= 1; if (scaled_width < 1) { scaled_width = 1; } if (scaled_height < 1) { scaled_height = 1; } miplevel++; if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { uploaded_paletted = true; GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, miplevel, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, paletted_texture); } else { tex.rewind(); tex.put(scaled); tex.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, miplevel, comp, scaled_width, scaled_height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, tex); } } } // label done: } catch (Throwable e) { // replaces label done } if (mipmap) { GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); } else { GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); } return (samples == gl_alpha_format); }
From source file:org.free.jake2.render.lwjgl.Image.java
License:Open Source License
boolean GL_Upload8(byte[] data, int width, int height, boolean mipmap, boolean is_sky) { Arrays.fill(trans, 0);//from w w w.ja va 2 s.c om int s = width * height; if (s > trans.length) { Com.Error(Defines.ERR_DROP, "GL_Upload8: too large"); } if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, ByteBuffer.wrap(data)); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); // TODO check this return false; } else { int p; int rgb; for (int i = 0; i < s; i++) { p = data[i] & 0xff; trans[i] = d_8to24table[p]; if (p == 255) { // transparent, so scan around for another color // to avoid alpha fringes // FIXME: do a full flood fill so mips work... if (i > width && (data[i - width] & 0xff) != 255) { p = data[i - width] & 0xff; } else if (i < s - width && (data[i + width] & 0xff) != 255) { p = data[i + width] & 0xff; } else if (i > 0 && (data[i - 1] & 0xff) != 255) { p = data[i - 1] & 0xff; } else if (i < s - 1 && (data[i + 1] & 0xff) != 255) { p = data[i + 1] & 0xff; } else { p = 0; } // copy rgb components // ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0]; // ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1]; // ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2]; trans[i] = d_8to24table[p] & 0x00FFFFFF; // only rgb } } return GL_Upload32(trans, width, height, mipmap); } }
From source file:org.free.jake2.render.lwjgl.Misc.java
License:Open Source License
void GL_SetDefaultState() { GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2 //GL11.glClearColor(0, 0, 0, 0); // replaced with black GL11.glCullFace(GL11.GL_FRONT);/*from w w w .j a v a 2s .c o m*/ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glShadeModel(GL11.GL_FLAT); GL_TextureMode(gl_texturemode.string); GL_TextureAlphaMode(gl_texturealphamode.string); GL_TextureSolidMode(gl_texturesolidmode.string); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL_TexEnv(GL11.GL_REPLACE); if (qglPointParameterfEXT) { // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4); att_buffer.put(0, gl_particle_att_a.value); att_buffer.put(1, gl_particle_att_b.value); att_buffer.put(2, gl_particle_att_c.value); GL11.glEnable(GL11.GL_POINT_SMOOTH); GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value); GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value); GL14.glPointParameter(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer); } if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) { GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT); GL_SetTexturePalette(d_8to24table); } GL_UpdateSwapInterval(); /* * vertex array extension */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL13.glClientActiveTexture(GL_TEXTURE0); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }