List of usage examples for org.lwjgl.opengl GL11 glGetFloat
@NativeType("void") public static float glGetFloat(@NativeType("GLenum") int pname)
From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}// w w w.j a v a 2s . c o m */ @Override public RenderCapabilities glCapabilities() { //! //! Retrieves the capabilities from the context. //! final GLCapabilities capabilities = GL.getCapabilities(); final RenderCapabilities.LanguageVersion version; if (capabilities.OpenGL33) { version = RenderCapabilities.LanguageVersion.GL33; } else if (capabilities.OpenGL32) { version = RenderCapabilities.LanguageVersion.GL32; } else if (capabilities.OpenGL31) { version = RenderCapabilities.LanguageVersion.GL31; } else if (capabilities.OpenGL30) { version = RenderCapabilities.LanguageVersion.GL30; } else if (capabilities.OpenGL21) { version = RenderCapabilities.LanguageVersion.GL21; } else { throw new RuntimeException("Cannot find a suitable context, OpenGL 2.1 is at-least required."); } //! //! Retrieves the limitation from the context. //! final Map<RenderCapabilities.Limit, Float> limit = new HashMap<>(); limit.put(RenderCapabilities.Limit.FRAME_ATTACHMENT, GL11.glGetFloat(GL30.GL_MAX_COLOR_ATTACHMENTS)); limit.put(RenderCapabilities.Limit.FRAME_MULTIPLE_RENDER_ATTACHMENT, GL11.glGetFloat(ARBDrawBuffers.GL_MAX_DRAW_BUFFERS_ARB)); limit.put(RenderCapabilities.Limit.FRAME_SAMPLE, GL11.glGetFloat(GL30.GL_MAX_SAMPLES)); limit.put(RenderCapabilities.Limit.TEXTURE_ANISOTROPIC, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); limit.put(RenderCapabilities.Limit.TEXTURE_SIZE, GL11.glGetFloat(GL11.GL_MAX_TEXTURE_SIZE)); limit.put(RenderCapabilities.Limit.TEXTURE_STAGE, GL11.glGetFloat(GL20.GL_MAX_TEXTURE_IMAGE_UNITS)); limit.put(RenderCapabilities.Limit.GLSL_MAX_VERTEX_ATTRIBUTES, GL11.glGetFloat(GL20.GL_MAX_VERTEX_ATTRIBS)); //! //! Retrieves the extension from the context. //! final Map<RenderCapabilities.Extension, Boolean> extension = new HashMap<>(); extension.put(RenderCapabilities.Extension.FRAME_BUFFER, capabilities.GL_ARB_framebuffer_object); extension.put(RenderCapabilities.Extension.FRAME_BUFFER_MULTIPLE_RENDER_TARGET, capabilities.GL_ARB_draw_buffers); extension.put(RenderCapabilities.Extension.FRAME_BUFFER_MULTIPLE_SAMPLE, capabilities.GL_ARB_multisample); extension.put(RenderCapabilities.Extension.VERTEX_ARRAY_OBJECT, capabilities.GL_ARB_vertex_array_object); extension.put(RenderCapabilities.Extension.TEXTURE_3D, true); extension.put(RenderCapabilities.Extension.TEXTURE_COMPRESSION_S3TC, capabilities.GL_EXT_texture_compression_s3tc); extension.put(RenderCapabilities.Extension.TEXTURE_FILTER_ANISOTROPIC, capabilities.GL_EXT_texture_filter_anisotropic); extension.put(RenderCapabilities.Extension.GLSL_PRECISION, capabilities.GL_ARB_shader_precision); extension.put(RenderCapabilities.Extension.GLSL_EXPLICIT_ATTRIBUTE, capabilities.GL_ARB_explicit_attrib_location); extension.put(RenderCapabilities.Extension.GLSL_EXPLICIT_UNIFORM, capabilities.GL_ARB_explicit_uniform_location); extension.put(RenderCapabilities.Extension.GLSL_GEOMETRY, capabilities.GL_ARB_geometry_shader4); return new RenderCapabilities(version, extension, limit); }
From source file:blusunrize.immersiveengineering.client.ClientEventHandler.java
@SubscribeEvent public void onRenderWorldLastEvent(RenderWorldLastEvent event) { //Overlay renderer for the sample drill boolean chunkBorders = false; if (sampleDrill.isEmpty()) sampleDrill = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.SAMPLE_DRILL.getMeta()); for (EnumHand hand : EnumHand.values()) if (OreDictionary.itemMatches(sampleDrill, ClientUtils.mc().player.getHeldItem(hand), true)) { chunkBorders = true;/* w w w.java2 s . com*/ break; } if (!chunkBorders && ClientUtils.mc().objectMouseOver != null && ClientUtils.mc().objectMouseOver.typeOfHit == Type.BLOCK && ClientUtils.mc().world.getTileEntity( ClientUtils.mc().objectMouseOver.getBlockPos()) instanceof TileEntitySampleDrill) chunkBorders = true; float partial = event.getPartialTicks(); if (!ParticleFractal.PARTICLE_FRACTAL_DEQUE.isEmpty()) { double px = TileEntityRendererDispatcher.staticPlayerX; double py = TileEntityRendererDispatcher.staticPlayerY; double pz = TileEntityRendererDispatcher.staticPlayerZ; Tessellator tessellator = Tessellator.getInstance(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableCull(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); tessellator.getBuffer().setTranslation(-px, -py, -pz); ParticleFractal part; while ((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst()) != null) part.render(tessellator, tessellator.getBuffer(), partial); tessellator.getBuffer().setTranslation(0, 0, 0); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } if (chunkBorders) { EntityPlayer player = ClientUtils.mc().player; double px = TileEntityRendererDispatcher.staticPlayerX; double py = TileEntityRendererDispatcher.staticPlayerY; double pz = TileEntityRendererDispatcher.staticPlayerZ; int chunkX = (int) player.posX >> 4 << 4; int chunkZ = (int) player.posZ >> 4 << 4; int y = Math.min((int) player.posY - 2, player.getEntityWorld().getChunk(new BlockPos(player.posX, 0, player.posZ)).getLowestHeight()); float h = (float) Math.max(32, player.posY - y + 4); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableCull(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); float r = Lib.COLOUR_F_ImmersiveOrange[0]; float g = Lib.COLOUR_F_ImmersiveOrange[1]; float b = Lib.COLOUR_F_ImmersiveOrange[2]; BufferBuilder.setTranslation(chunkX - px, y + 2 - py, chunkZ - pz); GlStateManager.glLineWidth(5f); BufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); BufferBuilder.pos(0, 0, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, h, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 0, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, h, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 0, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, h, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 0, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, h, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 16).color(r, g, b, .375f).endVertex(); tessellator.draw(); BufferBuilder.setTranslation(0, 0, 0); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } if (!FAILED_CONNECTIONS.isEmpty()) { Entity viewer = ClientUtils.mc().getRenderViewEntity(); if (viewer == null) viewer = ClientUtils.mc().player; double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial; double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial; double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial; Tessellator tes = Tessellator.getInstance(); BufferBuilder bb = tes.getBuffer(); float oldLineWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH); GlStateManager.glLineWidth(5); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); for (Entry<Connection, Pair<BlockPos, AtomicInteger>> entry : FAILED_CONNECTIONS.entrySet()) { Connection conn = entry.getKey(); bb.setTranslation(conn.start.getX() - dx, conn.start.getY() - dy, conn.start.getZ() - dz); Vec3d[] points = conn.getSubVertices(ClientUtils.mc().world); int time = entry.getValue().getValue().get(); float alpha = (float) Math.min((2 + Math.sin(time * Math.PI / 40)) / 3, time / 20F); for (int i = 0; i < points.length - 1; i++) { bb.pos(points[i].x, points[i].y, points[i].z).color(1, 0, 0, alpha).endVertex(); alpha = (float) Math.min((2 + Math.sin((time + (i + 1) * 8) * Math.PI / 40)) / 3, time / 20F); bb.pos(points[i + 1].x, points[i + 1].y, points[i + 1].z).color(1, 0, 0, alpha).endVertex(); } } bb.setTranslation(0, 0, 0); tes.draw(); GlStateManager.glLineWidth(oldLineWidth); GlStateManager.enableBlend(); GlStateManager.color(1, 0, 0, .5F); renderObstructingBlocks(bb, tes, dx, dy, dz); //Code to render the obstructing block through other blocks //GlStateManager.color(1, 0, 0, .25F); //GlStateManager.depthFunc(GL11.GL_GREATER); //renderObstructingBlocks(bb, tes, dx, dy, dz); //GlStateManager.depthFunc(GL11.GL_LEQUAL); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } }
From source file:blusunrize.immersiveengineering.client.render.TileRenderTeslaCoil.java
@Override public void render(TileEntityTeslaCoil tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (tile.isDummy() || !tile.getWorld().isBlockLoaded(tile.getPos(), false)) return;// www. j a va 2 s. c o m Iterator<LightningAnimation> animationIt = TileEntityTeslaCoil.effectMap.get(tile.getPos()).iterator(); setLightmapDisabled(true); boolean wasLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING); GlStateManager.disableLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); while (animationIt.hasNext()) { LightningAnimation animation = animationIt.next(); if (animation.shoudlRecalculateLightning()) animation.createLightning(Utils.RAND); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); double tx = tile.getPos().getX(); double ty = tile.getPos().getY(); double tz = tile.getPos().getZ(); float curWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH); drawAnimation(animation, tx, ty, tz, new float[] { 77 / 255f, 74 / 255f, 152 / 255f, .75f }, 4f); drawAnimation(animation, tx, ty, tz, new float[] { 1, 1, 1, 1 }, 1f); GL11.glLineWidth(curWidth); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } if (wasLightingEnabled) GlStateManager.enableLighting(); else GlStateManager.disableLighting(); setLightmapDisabled(false); }
From source file:com.xrbpowered.gl.examples.GLBasicTerrain.java
License:Open Source License
@Override protected void setupResources() { super.setupResources(); specular = new Texture("ice2a.jpg"); diffuse = new Texture("ice1a2.jpg"); float anis = GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); System.out.printf("Max anisotropy: %.1f\n", anis); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, anis); normal = new Texture("ice_n.jpg"); createTerrain();//from w w w .ja v a2s .c om water = FastMeshBuilder.plane(64f, 4, 32, StandardShader.standardVertexInfo, null); for (int x = 0; x < 3; x++) for (int y = 0; y < 3; y++) { waterActor[x][y] = StaticMeshActor.make(scene, water, StandardShader.getInstance(), BufferTexture.createPlainColor(4, 4, new Color(0.4f, 0.5f, 0.65f)), plainSpecularTexture, plainNormalTexture); waterActor[x][y].position.set((x - 1) * CHUNK_SIZE, 0f, (y - 1) * CHUNK_SIZE); waterActor[x][y].updateTransform(); } // pickObjects = new StaticMesh[] {null, terrain}; CLEAR_COLOR = new Color(0.7f, 0.75f, 0.82f); StandardShader.environment.setFog(0f, 50f, new Vector4f(0.7f, 0.75f, 0.82f, 1f)); StandardShader.environment.ambientColor.set(0.05f, 0.1f, 0.2f); StandardShader.environment.lightColor.set(0.9f, 0.85f, 0.8f); lightActor.rotation.x = (float) Math.PI / 6f; lightActor.updateTransform(); }
From source file:dataAccess.lwjgl.VAO_Loader.java
public static int loadTexture(File file) { int textureID; if (textureMap.containsKey(file.getAbsolutePath())) { textureID = textureMap.get(file.getAbsolutePath()); } else {//from w w w .ja va2 s. c o m Texture texture = null; try { texture = TextureLoader.getTexture("PNG", new FileInputStream(file)); } catch (IOException ex) { Logger.getLogger(VAO_Loader.class.getName()).log(Level.SEVERE, null, ex); } textureID = texture.getTextureID(); textureMap.put(file.getAbsolutePath(), textureID); } GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0f); if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { if (Settings.ANISOTROPIC_FILTERING) { float amount = Math.min(4f, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount); } } else { System.out.println("no anisotropic filtering possible!"); } return textureID; }
From source file:de.ellpeck.actuallyadditions.mod.util.AssetUtil.java
@SideOnly(Side.CLIENT) public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double rotationTime, float alpha, double beamWidth, float[] color) { Tessellator tessy = Tessellator.getInstance(); VertexBuffer render = tessy.getBuffer(); World world = Minecraft.getMinecraft().world; float r = color[0]; float g = color[1]; float b = color[2]; Vec3d vec1 = new Vec3d(firstX, firstY, firstZ); Vec3d vec2 = new Vec3d(secondX, secondY, secondZ); Vec3d combinedVec = vec2.subtract(vec1); double rot = rotationTime > 0 ? (360D * ((world.getTotalWorldTime() % rotationTime) / rotationTime)) : 0; double pitch = Math.atan2(combinedVec.yCoord, Math.sqrt(combinedVec.xCoord * combinedVec.xCoord + combinedVec.zCoord * combinedVec.zCoord)); double yaw = Math.atan2(-combinedVec.zCoord, combinedVec.xCoord); double length = combinedVec.lengthVector(); GlStateManager.pushMatrix();/*from w ww .j a v a2s . co m*/ GlStateManager.disableLighting(); GlStateManager.enableBlend(); GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE); int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC); float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF); GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0); GlStateManager.translate(firstX - TileEntityRendererDispatcher.staticPlayerX, firstY - TileEntityRendererDispatcher.staticPlayerY, firstZ - TileEntityRendererDispatcher.staticPlayerZ); GlStateManager.rotate((float) (180 * yaw / Math.PI), 0, 1, 0); GlStateManager.rotate((float) (180 * pitch / Math.PI), 0, 0, 1); GlStateManager.rotate((float) rot, 1, 0, 0); /*if(r != r2 || g != g2 || b != b2){ render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); Minecraft.getMinecraft().renderEngine.bindTexture(ClientUtil.LIGHT_BEAM_GRADIENT); render.pos(length, -beamWidth, beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, -beamWidth, beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); tessy.draw(); } else{*/ GlStateManager.disableTexture2D(); render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); for (double i = 0; i < 4; i++) { double width = beamWidth * (i / 4.0); render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha) .endVertex(); } tessy.draw(); GlStateManager.enableTexture2D(); //} GlStateManager.alphaFunc(func, ref); GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); }
From source file:ivengine.Util.java
License:Creative Commons License
/** * Stores a variable amount of textures defined by URLS <filenames> into a texture array. Uses a magfilter <magfilter>, a minfilter <minfilter>. * If <mipmap> is true, mipmaps will be activated. * If <anisotropic> is true, anisotropic filtering will be activated, if supported. *///from w w w. j a va 2 s .c om public static int loadTextureAtlasIntoTextureArray(URL[] filenames, int magfilter, int minfilter, boolean mipmap, boolean anisotropic) { int tex = GL11.glGenTextures(); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, tex); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, magfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, minfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); ByteBuffer buf = null; PNGDecoder decoder = null; try { InputStream in = filenames[0].openStream(); decoder = new PNGDecoder(in); buf = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight()); decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA); buf.flip(); in.close(); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } int tileWidth = decoder.getWidth(); System.out.println(tileWidth); int tileHeight = decoder.getHeight(); System.out.println(tileHeight); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, tileWidth, tileHeight, filenames.length, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); for (int i = 0; i < filenames.length; i++) { GL12.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, /*tileWidth*x*/0, /*tileHeight*y*/0, i, tileWidth, tileHeight, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); buf.rewind(); if (i < filenames.length - 1) loadTexture(filenames[i + 1], buf); } if (mipmap) GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY); if (anisotropic) { if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { float maxanis = GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); System.out.println("Anisotropic filtering activated with a resolution of " + maxanis); System.out.println(GL11.glGetError()); GL11.glTexParameterf(GL30.GL_TEXTURE_2D_ARRAY, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxanis); System.out.println(GL11.glGetError()); } else { System.err.println( "WARNING - Anisotropic filtering not supported by this graphics card. Setting it as disabled"); } } GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0); return tex; }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public float getMaxTextureAnisotropy() { return GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); }
From source file:me.thehutch.fusion.engine.render.opengl.gl20.OpenGL20Texture.java
License:Open Source License
@Override public void setAnisotropicFiltering(float value) { ensureCreated("Texture must be created to set the anisotropic filtering."); // Check if the driver is capable of anisotropic filtering if (value > 0.0f && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { final float maxFiltering = GL11.glGetFloat(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); GL11.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, FastMaths.clamp(value, 0.0f, maxFiltering)); }//ww w.ja va 2 s . co m }
From source file:org.blockartistry.mod.DynSurround.client.FogEffectHandler.java
License:MIT License
@SubscribeEvent(priority = EventPriority.LOWEST) public void fogRenderEvent(final EntityViewRenderEvent.RenderFogEvent event) { if (event.getResult() != Result.DEFAULT || event.getFogMode() < 0) return;//from ww w.jav a 2 s. c o m if (currentFogLevel <= 0) return; float level = currentFogLevel; final float factor = 1.0F + level * 100.0F; final float near = (event.getFarPlaneDistance() * 0.75F) / (factor * factor) + insideFogOffset; final float horizon = event.getFarPlaneDistance() / (factor) + insideFogOffset; float start = GL11.glGetFloat(GL11.GL_FOG_START); float end = GL11.glGetFloat(GL11.GL_FOG_END); boolean didFog = false; if (near < start) { GlStateManager.setFogStart(near); didFog = true; } if (horizon < end) { GlStateManager.setFogEnd(horizon); didFog = true; } if (didFog) { event.setResult(Result.ALLOW); } }