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:main.TerrainRenderer.java
private void prepareTerrain(Terrain terrain) { RawModel rawModel = terrain.getModel(); GL30.glBindVertexArray(rawModel.getVaoId()); GL20.glEnableVertexAttribArray(0);/*from w w w .j av a 2 s . c o m*/ GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); ModelTexture texture = terrain.getTexture(); shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity()); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureId()); }
From source file:map.MapVertex.java
License:Open Source License
public void draw(float texScale) { GL11.glNormal3f(norm.x, norm.y, norm.z); GL13.glMultiTexCoord2f(GL13.GL_TEXTURE0, pos.x * texScale, pos.y * texScale); GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, pos.x, pos.y); GL11.glVertex3f(pos.x, pos.y, pos.z); }
From source file:me.sunchiro.game.engine.gl.Graphic.java
License:Open Source License
public void createWindow(int width, int height, String name) { this.width = width; this.height = height; glfwSetErrorCallback(errorCallback = Callbacks.errorCallbackPrint(System.err)); if (glfwInit() != GL11.GL_TRUE) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); // optional, the current window hints are glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay // hidden// ww w .j av a 2 s . c om glfwWindowHint(GLFW_RESIZABLE, GL11.GL_TRUE); // the window will be // resizable window = glfwCreateWindow(width, height, name, NULL, NULL); if (window == NULL) throw new RuntimeException("Failed to create the GLFW window"); // glfwSetKeyCallback(window,this.keyCallback = keyCallback); glfwSetWindowSizeCallback(window, resizeCallback()); ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); glfwSetWindowPos(window, (vidmode.asIntBuffer().get(0) - width) / 2, (vidmode.asIntBuffer().get(1) - height) / 2); glfwMakeContextCurrent(window); Graphic.instance = this; glfwSwapInterval(1); GL.createCapabilities(); setCapabilities(); glfwShowWindow(window); // Setup an XNA like background color GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0); // Map the internal OpenGL coordinate system to the entire screen GL11.glViewport(0, 0, width, height); matBuff = BufferUtils.createFloatBuffer(16); vaoId = GL30.glGenVertexArrays(); vboiId = GL15.glGenBuffers(); vboId = GL15.glGenBuffers(); tid_charmap = texManager.loadTexture("textures/charmap.png", GL13.GL_TEXTURE0); shader.setupShader(); // testQuad(); }
From source file:me.sunchiro.game.engine.gl.Graphic.java
License:Open Source License
public void loadTexture(String[] filename) { for (String file : filename) { texManager.loadTexture(file, GL13.GL_TEXTURE0); } }
From source file:me.sunchiro.game.engine.gl.Graphic.java
License:Open Source License
private synchronized void render() { GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL20.glUseProgram(shader.getPID());// w w w. j av a 2s. co m // GL13.glActiveTexture(GL13.GL_TEXTURE0); GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid)); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); long offset = 0; int shift = 0; GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); for (Drawable object : objects) { Matrix4f finalMVP = new Matrix4f(mvpMat); Matrix4f modelMat = new Matrix4f(); Matrix4f scaler = new Matrix4f(); scaler.scale(object.scale * allScale); modelMat.translate(object.translation); modelMat.rotateXYZ(object.rotation.x, object.rotation.y, object.rotation.z); finalMVP.mul(modelMat); finalMVP.mul(scaler); finalMVP.get(0, matBuff); if (object.isChar) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid_charmap)); } GL20.glUniformMatrix4fv(shader.getMVPLocation(), false, matBuff); GL20.glUniform1i(shader.getInverseLocation(), object.inverseAlpha ? 1 : 0); if (object.isVisible()) GL32.glDrawElementsBaseVertex(GL11.GL_TRIANGLES, object.getIndices().length, GL11.GL_UNSIGNED_BYTE, offset, shift); offset += object.getIndices().length; shift += object.getVertex().length; if (object.isChar) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid)); } } render2d(offset, shift); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); // GL20.glUseProgram(0); glfwSwapBuffers(window); glfwPollEvents(); }
From source file:net.betabears.the2dlibrary.graphics.Image.java
/** * Binds this image and prepares rendering. Make sure to call * glEnable(GL_TEXTURE_2D) before./*w w w .j av a 2s .c om*/ */ public void bind() { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); GL33.glBindSampler(0, samplerID); }
From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void activateTexture(int i) { try {//from w w w. java2s. c om GL13.glActiveTexture(GL13.GL_TEXTURE0 + i); } catch (java.lang.IllegalStateException e) { // Unsupported, ignore. } }
From source file:org.jge.render.RenderEngine.java
License:Open Source License
public RenderEngine bindTexture(Texture texture, int samplerSlot) { assert (samplerSlot >= 0 && samplerSlot <= 31) : "Sampler slot must be >= 0 and <= 31"; GL13.glActiveTexture(GL13.GL_TEXTURE0 + samplerSlot); glBindTexture(texture.getResource().getTarget(), texture.getResource().getID()); this.boundTexture = texture; return this; }
From source file:org.jogamp.glg2d.impl.shader.GL2ES2ImageDrawer.java
License:Apache License
@Override protected void begin(Texture texture, AffineTransform xform, Color bgcolor) { /*//from www . j a va 2 s . c o m * FIXME This is unexpected since we never disable blending, but in some * cases it interacts poorly with multiple split panes, scroll panes and the * text renderer to disable blending. */ g2d.setComposite(g2d.getComposite()); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glEnable(GL11.GL_TEXTURE_2D); texture.bind(); shader.use(true); if (bgcolor == null) { white.clear(); white.put(white_static, 0, 3); white.put(g2d.getUniformsObject().colorHook.getAlpha()); shader.setColor(white); } else { FloatBuffer rgba = g2d.getUniformsObject().colorHook.getRGBA(); shader.setColor(rgba); } if (xform == null) { shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData()); } else { shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData(xform)); } shader.setTextureUnit(0); }
From source file:org.spout.engine.renderer.shader.variables.TextureSamplerShaderVariable.java
License:Open Source License
public void bind(int unit) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + unit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); if (((Client) Spout.getEngine()).getRenderMode() != RenderMode.GL30) { GL20.glUniform1i(location, textureID); } else {/*from w ww . ja va 2s . co m*/ GL30.glUniform1ui(location, textureID); } }