List of usage examples for org.lwjgl.opengl GL13 GL_TEXTURE0
int GL_TEXTURE0
To view the source code for org.lwjgl.opengl GL13 GL_TEXTURE0.
Click Source Link
From source file:com.grillecube.client.renderer.particles.ParticleRenderer.java
/** * render every given billoaded particles with the given camera (billboarded * = textured quad facing the camera)//w w w.java 2s .c o m */ public final void renderBillboardedParticles(CameraProjective camera, ArrayList<ParticleBillboarded> particles) { if (particles.size() == 0) { return; } GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); // Texture unit 0 GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.programBillboardedParticles.useStart(); this.getMainRenderer().getDefaultVAO().bind(); this.programBillboardedParticles.loadGlobalUniforms(camera); HashMap<ParticleBillboarded, Double> distances = new HashMap<ParticleBillboarded, Double>( particles.size() * 4); for (ParticleBillboarded particle : particles) { distances.put(particle, Vector3f.distanceSquare(particle.getPosition(), camera.getPosition())); } particles.sort(new Comparator<ParticleBillboarded>() { @Override public int compare(ParticleBillboarded a, ParticleBillboarded b) { double da = distances.get(a); double db = distances.get(b); if (da < db) { return (1); } else if (da > db) { return (-1); } return (0); } }); int i = 0; while (i < particles.size()) { ParticleBillboarded particle = particles.get(i); float radius = Maths.max(Maths.max(particle.getSizeX(), particle.getSizeY()), particle.getSizeZ()); if (particle != null && distances.get(particle) < camera.getSquaredRenderDistance() && camera.isSphereInFrustum(particle.getPosition(), radius)) { this.programBillboardedParticles.loadInstanceUniforms(particle); this.getMainRenderer().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1); } ++i; } }
From source file:com.grillecube.client.renderer.particles.ProgramParticleBillboarded.java
/** load particle instance uniforms */ public void loadInstanceUniforms(ParticleBillboarded particle) { particle.getSprite().getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); if (particle.isGlowing()) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); } else {/*from w w w. j av a2s. co m*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } super.loadUniformInteger(this._lines, particle.getSprite().getLines()); super.loadUniformInteger(this._cols, particle.getSprite().getCols()); super.loadUniformInteger(this._maxhealth, particle.getMaxHealth()); super.loadUniformInteger(this._health, particle.getHealth()); super.loadUniformVec(this._color, particle.getColor()); super.loadUniformVec(this._position, particle.getPosition()); super.loadUniformVec(this._scale, particle.getSize()); }
From source file:com.grillecube.client.renderer.world.TerrainRenderer.java
private final void bindTextureAtlas(TerrainMesh mesh, CameraView camera) { float distance = (float) Vector3f.distance(camera.getPosition(), mesh.getTerrain().getWorldPosCenter()); BlockRendererManager manager = this.getMainRenderer().getResourceManager().getBlockTextureManager(); GLTexture texture = null;// w w w . j a va2 s . c o m if (distance < Terrain.SIZE_DIAGONAL3 * 1) { texture = manager.getTextureAtlas(BlockRendererManager.RESOLUTION_16x16); } else if (distance < Terrain.SIZE_DIAGONAL3 * 2.0f) { texture = manager.getTextureAtlas(BlockRendererManager.RESOLUTION_8x8); } else if (distance < Terrain.SIZE_DIAGONAL3 * 3.0f) { texture = manager.getTextureAtlas(BlockRendererManager.RESOLUTION_4x4); } else if (distance < Terrain.SIZE_DIAGONAL3 * 4.0f) { texture = manager.getTextureAtlas(BlockRendererManager.RESOLUTION_2x2); } else { texture = manager.getTextureAtlas(BlockRendererManager.RESOLUTION_1x1); } if (texture != null) { texture.bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); } this.breakAtlas.bind(GL13.GL_TEXTURE1, GL11.GL_TEXTURE_2D); }
From source file:com.grillecube.client.renderer.world.WorldRenderer.java
private void renderPostProcessingEffects() { if (this.postProcessingProgram != null) { // bind the fbo texture to texture attachment 0 this.getFBOTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this.postProcessingProgram.useStart(); this.postProcessingProgram.loadUniforms((float) super.getTimer().getTime()); this.getMainRenderer().getDefaultVAO().bind(); GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1); this.postProcessingProgram.useStop(); }/*from w ww . ja v a 2 s.c om*/ }
From source file:com.grillecube.engine.opengl.object.GLTexture.java
/** set pixels data */ public void setData(BufferedImage img) { if (img == null) { return;//from w ww . j a v a 2 s.c om } byte[] pixels = ImageUtils.getImagePixels(img); ByteBuffer buffer = BufferUtils.createByteBuffer(pixels.length); buffer.put(pixels); buffer.flip(); this.bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this.image2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, img.getWidth(), img.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); this.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); this.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); this.unbind(GL11.GL_TEXTURE_2D); this._width = img.getWidth(); this._height = img.getHeight(); }
From source file:com.grillecube.engine.renderer.gui.font.FontModel.java
/** render this font model */ public void render() { if (this.hasState(FontModel.STATE_INITIALIZED) == false) { this.initialize(); }/*from w w w . j av a 2 s .c o m*/ if (this.hasState(FontModel.STATE_TEXT_UP_TO_DATE) == false) { this.updateText(); } if (this._vertex_count == 0 || this._font == null) { return; } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this._vao.bind(); this._font.getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._vao.draw(GL11.GL_TRIANGLES, 0, this._vertex_count); }
From source file:com.grillecube.engine.renderer.MainRenderer.java
private void renderFinalImage() { // bind the fbo texture to texture attachment 0 this.getFBOTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._final_process_program.useStart(); this._final_process_program.loadUniforms(this); this._default_vao.bind(); GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1); this._final_process_program.useStop(); }
From source file:com.grillecube.engine.renderer.MainRenderer.java
private void renderPostProcessingEffects() { if (this._post_processing_program != null) { // bind the fbo texture to texture attachment 0 this.getFBOTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._post_processing_program.useStart(); this._post_processing_program.loadUniforms(this); this._default_vao.bind(); GLH.glhDrawArrays(GL11.GL_POINTS, 0, 1); this._post_processing_program.useStop(); }//from w w w . j a va2s .c o m }
From source file:com.grillecube.engine.renderer.world.particles.ParticleRenderer.java
/** render every quad particles */ private void renderBillboardedParticles(World world, CameraProjectiveWorld camera) { if (this._billboarded_particles.size() == 0) { return;//from w w w . jav a2 s . c o m } GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); // Texture unit 0 GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this._program_billboarded_particle.useStart(); this.getParent().getDefaultVAO().bind(); this._program_billboarded_particle.loadGlobalUniforms(camera); this._billboarded_particles.sort(this._particle_comparator); int i = 0; while (i < this._billboarded_particles.size()) { ParticleBillboarded particle = this._billboarded_particles.get(i); float radius = Maths.max(particle.getScale().x, particle.getScale().y); if (particle != null && particle.getCameraSquareDistance() < camera.getSquaredRenderDistance() && camera.isSphereInFrustum(particle.getPosition(), radius)) { this._program_billboarded_particle.loadInstanceUniforms(particle); this.getParent().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1); } ++i; } }
From source file:com.grillecube.engine.renderer.world.particles.ProgramParticleBillboarded.java
/** load particle instance uniforms */ public void loadInstanceUniforms(ParticleBillboarded particle) { particle.getSprite().getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); if (particle.isGlowing()) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); } else {//from w w w.java2 s . c o m GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } super.loadUniformInteger(this._lines, particle.getSprite().getLines()); super.loadUniformInteger(this._cols, particle.getSprite().getCols()); super.loadUniformInteger(this._maxhealth, particle.getMaxHealth()); super.loadUniformInteger(this._health, particle.getHealth()); super.loadUniformVec(this._color, particle.getColor()); super.loadUniformVec(this._position, particle.getPosition()); super.loadUniformVec(this._scale, particle.getScale()); }