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.engine.renderer.world.terrain.TerrainRenderer.java
public void bindTextureAtlas(TerrainMesh mesh, CameraView camera) { float distance = (float) Vector3f.distanceSquare(mesh.getTerrain().getCenter(), camera.getPosition()); BlockManager manager = this.getParent().getResourceManager().getBlockManager(); GLTexture texture = null;/*from ww w . j a va2 s. co m*/ if (distance < (1 << 10)) { texture = manager.getTextureAtlas(BlockManager.RESOLUTION_16x16); } else if (distance < (1 << 12)) { texture = manager.getTextureAtlas(BlockManager.RESOLUTION_8x8); } else if (distance < (1 << 14)) { texture = manager.getTextureAtlas(BlockManager.RESOLUTION_4x4); } else if (distance < (1 << 16)) { texture = manager.getTextureAtlas(BlockManager.RESOLUTION_2x2); } else { texture = manager.getTextureAtlas(BlockManager.RESOLUTION_1x1); } if (texture != null) { texture.bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); } }
From source file:com.grillecube.engine.renderer.world.WorldRenderer.java
private void createReflectionFBO() { this._reflection_fbo = GLH.glhGenFBO(); this._reflection_fbo.bind(); this._reflection_fbo.createDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); this._reflection_texture = GLH.glhGenTexture(); this._reflection_texture.bind(GL11.GL_TEXTURE_2D); this._reflection_texture.bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._reflection_texture.image2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, REFLECTION_FBO_WIDTH, REFLECTION_FBO_HEIGHT, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); this._reflection_texture.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); this._reflection_texture.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); this._reflection_fbo.createTextureAttachment(this._reflection_texture, GL30.GL_COLOR_ATTACHMENT0); this._reflection_depth_buffer = this._reflection_fbo.createRenderBuffer(REFLECTION_FBO_WIDTH, REFLECTION_FBO_HEIGHT, GL30.GL_DEPTH_ATTACHMENT); this._reflection_fbo.unbind(); }
From source file:com.grillecube.engine.renderer.world.WorldRenderer.java
private void createRefractionFBO() { this._refraction_fbo = GLH.glhGenFBO(); this._refraction_fbo.bind(); this._refraction_fbo.createDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); this._refraction_texture = GLH.glhGenTexture(); this._refraction_texture.bind(GL11.GL_TEXTURE_2D); this._refraction_texture.bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._refraction_texture.image2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, REFRACTION_FBO_WIDTH, REFRACTION_FBO_HEIGHT, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); this._refraction_texture.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); this._refraction_texture.parameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); this._refraction_fbo.createTextureAttachment(this._refraction_texture, GL30.GL_COLOR_ATTACHMENT0); this._refraction_depth_buffer = this._reflection_fbo.createRenderBuffer(REFRACTION_FBO_WIDTH, REFRACTION_FBO_HEIGHT, GL30.GL_DEPTH_ATTACHMENT); this._refraction_fbo.unbind(); }
From source file:com.mtbs3d.minecrift.FBOParams.java
License:LGPL
public void bindTexture() { OpenGlHelper.setActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(_textureType, _colorTextureId); }
From source file:com.mtbs3d.minecrift.VRRenderer.java
License:LGPL
private void doDistortionAndSuperSample() { int FBWidth = this.mc.displayFBWidth; int FBHeight = this.mc.displayFBHeight; if (this.mc.vrSettings.useDistortion || this.mc.vrSettings.useSupersample || this.mc.vrSettings.useFXAA) { // Setup ortho projection GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//from w ww . ja v a 2 s . c o m GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -0.7f); } if (this.mc.vrSettings.useSupersample) { FBWidth = (int) ceil(this.mc.displayFBWidth * this.mc.vrSettings.superSampleScaleFactor); FBHeight = (int) ceil(this.mc.displayFBHeight * this.mc.vrSettings.superSampleScaleFactor); } if (mc.vrSettings.useDistortion) { //mc.checkGLError("Before distortion"); preDistortionFBO.bindTexture(); if (this.mc.vrSettings.useFXAA) { //chain into the FXAA FBO fxaaFBO.bindRenderTarget(); } else if (this.mc.vrSettings.useSupersample) { //chain into the superSample FBO postDistortionFBO.bindRenderTarget(); } else { unbindFBORenderTarget(); } GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, FBWidth, FBHeight); // Set the distortion shader as in use ARBShaderObjects.glUseProgramObjectARB(_Distortion_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1iARB(_DistortionShader_RenderTextureUniform, 0); if (this.mc.vrSettings.useDistortionTextureLookupOptimisation) { distortParams.bindTexture_Unit1(); ARBShaderObjects.glUniform1iARB(_DistortionShader_DistortionMapUniform, 1); } ARBShaderObjects.glUniform1iARB(_DistortionShader_half_screenWidthUniform, distortParams.half_screenWidth); ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftLensCenterUniform, distortParams.leftLensCenterX, distortParams.leftLensCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_RightLensCenterUniform, distortParams.rightLensCenterX, distortParams.rightLensCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftScreenCenterUniform, distortParams.leftScreenCenterX, distortParams.leftScreenCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_RightScreenCenterUniform, distortParams.rightScreenCenterX, distortParams.rightScreenCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleUniform, distortParams.scaleX, distortParams.scaleY); ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleInUniform, distortParams.scaleInX, distortParams.scaleInY); ARBShaderObjects.glUniform4fARB(_DistortionShader_HmdWarpParamUniform, distortParams.DistortionK[0], distortParams.DistortionK[1], distortParams.DistortionK[2], distortParams.DistortionK[3]); ARBShaderObjects.glUniform4fARB(_DistortionShader_ChromAbParamUniform, distortParams.ChromaticAb[0], distortParams.ChromaticAb[1], distortParams.ChromaticAb[2], distortParams.ChromaticAb[3]); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); //mc.checkGLError("After distortion"); } if (this.mc.vrSettings.useFXAA) { fxaaFBO.bindTexture(); if (this.mc.vrSettings.useSupersample) { //chain into the superSample FBO postDistortionFBO.bindRenderTarget(); } else { unbindFBORenderTarget(); } GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, FBWidth, FBHeight); // Set the distortion shader as in use ARBShaderObjects.glUseProgramObjectARB(_FXAA_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1iARB(_FXAA_RenderTextureUniform, 0); ARBShaderObjects.glUniform2fARB(_FXAA_RenderedTextureSizeUniform, (float) FBWidth, (float) FBHeight); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); //ShaderHelper.checkGLError("After fxaa"); } if (this.mc.vrSettings.useSupersample) { // Now switch to 1st pass target framebuffer postSuperSampleFBO.bindRenderTarget(); // Bind the FBO postDistortionFBO.bindTexture(); GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, this.mc.displayFBWidth, FBHeight); // Set the downsampling shader as in use ARBShaderObjects.glUseProgramObjectARB(_Lanczos_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform, 1.0f / (3.0f * (float) this.mc.displayFBWidth)); ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform, 0.0f); ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // Pass 1 drawQuad(); // mc.checkGLError("After Lanczos Pass1"); // Pass 2 // Now switch to 2nd pass screen framebuffer unbindFBORenderTarget(); postSuperSampleFBO.bindTexture(); GL11.glViewport(0, 0, this.mc.displayFBWidth, this.mc.displayFBHeight); GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Bind the texture GL13.glActiveTexture(GL13.GL_TEXTURE0); // Set up the fragment shader uniforms for pass 2 ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform, 0.0f); ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform, 1.0f / (3.0f * (float) this.mc.displayFBHeight)); ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); // mc.checkGLError("After Lanczos Pass2"); } }
From source file:com.opengrave.common.world.MaterialList.java
License:Open Source License
public synchronized void bind(int pID, int glTexture) { updateTex();//from www. j ava 2 s. c o m int texMain = GL20.glGetUniformLocation(pID, "arraytexture"); int texData = GL20.glGetUniformLocation(pID, "arraytexturedata"); GL20.glUniform1i(texMain, glTexture - GL13.GL_TEXTURE0); GL20.glUniform1i(texData, (glTexture - GL13.GL_TEXTURE0) + 1); if (!valid()) { return; } textureAtlas.bind(glTexture); textureDataAtlas.bind(glTexture + 1); }
From source file:com.opengrave.og.base.Renderable2D.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { Util.checkErr();// w w w. j av a 2 s .co m dealWithChange(); Util.checkErr(); if (vertexList.size() == 0) { return; } int pID = Resources.loadShader("gui.vs", "gui.fs").getProgram(); GL20.glUseProgram(pID); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); Util.checkErr(); if (texture != null) { texture.bind(GL13.GL_TEXTURE0); } Util.setMatrices(pID, location2d); Util.checkErr(); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); Util.checkErr(); if (texture != null) { texture.unbind(); } GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.Renderable3D.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();// w w w .ja v a 2 s. c o m int pID = Resources.loadShader("model.vs", "model.fs").getProgram(); GL20.glUseProgram(pID); int texture = GL20.glGetUniformLocation(pID, "texture"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(texture, 0); GL20.glUniform1i(shadow, 1); GL30.glBindVertexArray(vao_ID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_Normal"); GL20.glBindAttribLocation(pID, 2, "in_TextureCoord"); Util.checkErr(); if (matList != null && matList.valid()) { matList.bind(pID, GL13.GL_TEXTURE0); Util.loadMaterials(matList, pID); } Util.checkErr(); getContext().setMatrices(pID, matrix); getContext().bindShadowData(GL13.GL_TEXTURE2); getContext().bindLights(pID, GL13.GL_TEXTURE3); Util.setRenderStyle(pID, style); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo_index_ID); GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); getContext().unbindLights(); getContext().unbindShadowData(); if (matList != null && matList.valid()) { matList.unbind(); } Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:com.opengrave.og.base.RenderableBoneAnimated.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { // if (!visible) { // return;/*from w w w . ja v a 2 s . c om*/ // } GL11.glDisable(GL11.GL_CULL_FACE); // TODO Enable Face Culling, and be // absolutely sure that all tris are // facing the correct way dealWithChange(); int pID = Resources.loadShader("animmodel.vs", "animmodel.fs").getProgram(); GL20.glUseProgram(pID); int texture = GL20.glGetUniformLocation(pID, "texture"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(texture, 0); GL20.glUniform1i(shadow, 1); GL30.glBindVertexArray(vao_ID); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_Normal"); GL20.glBindAttribLocation(pID, 2, "in_TextureCoord"); GL20.glBindAttribLocation(pID, 3, "in_BoneID"); GL20.glBindAttribLocation(pID, 4, "in_BoneWeight"); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL20.glEnableVertexAttribArray(4); if (matList != null && matList.valid()) { matList.bind(pID, GL13.GL_TEXTURE0); Util.loadMaterials(matList, pID); } setBonesUniform(pID); getContext().setMatrices(pID, matrix); getContext().bindShadowData(GL13.GL_TEXTURE2); getContext().bindLights(pID, GL13.GL_TEXTURE3); Util.setRenderStyle(pID, style); // GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertCount); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo_index_ID); GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); getContext().unbindLights(); getContext().unbindShadowData(); if (matList != null && matList.valid()) { matList.unbind(); } GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL20.glDisableVertexAttribArray(4); GL20.glUseProgram(0); GL30.glBindVertexArray(0); GL11.glEnable(GL11.GL_CULL_FACE); }
From source file:com.opengrave.og.base.RenderableLiquid.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();/*from ww w . j a va 2s . co m*/ if (vertexList.size() == 0) { return; } int pID = Resources.loadShader("liquid.vs", "liquid.fs").getProgram(); GL20.glUseProgram(pID); int atlas = GL20.glGetUniformLocation(pID, "arraytexture"); int normals = GL20.glGetUniformLocation(pID, "arraytexturedata"); int colours = GL20.glGetUniformLocation(pID, "colours"); int flows = GL20.glGetUniformLocation(pID, "flows"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(atlas, 0); GL20.glUniform1i(normals, 1); GL20.glUniform1i(colours, 2); GL20.glUniform1i(flows, 3); GL20.glUniform1i(shadow, 4); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); getContext().setMatrices(pID, matrix); textureAtlas.bind(GL13.GL_TEXTURE0); normalAtlas.bind(GL13.GL_TEXTURE1); getColourTexture().bind(GL13.GL_TEXTURE2); getFlowTexture().bind(GL13.GL_TEXTURE3); getContext().bindShadowData(GL13.GL_TEXTURE4); getContext().bindLights(pID, GL13.GL_TEXTURE5); Util.setRenderStyle(pID, style); GL11.glDepthMask(false); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); GL11.glDepthMask(true); getContext().unbindLights(); getContext().unbindShadowData(); textureAtlas.unbind(); getFlowTexture().unbind(); getColourTexture().unbind(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }