/** * Ensures that the texture is bound to the given unit * and that the unit is currently active (for modification). * * @param target The texture target, one of GL_TEXTURE_*** * @param img The image texture to bind * @param unit At what unit to bind the texture. */ private void bindTextureAndUnit(int target, Image img, int unit) { if (context.boundTextureUnit != unit) { gl.glActiveTexture(GL.GL_TEXTURE0 + unit); context.boundTextureUnit = unit; } if (context.boundTextures[unit] != img) { gl.glBindTexture(target, img.getId()); context.boundTextures[unit] = img; statistics.onTextureUse(img, true); } else { statistics.onTextureUse(img, false); } }
public void glAttachShader(int program, int shader) { gl.glAttachShader(program, shader); checkError(); }
@Override public void startProfiling(int taskId) { gl.glBeginQuery(GL.GL_TIME_ELAPSED, taskId); }
gl.glEnable(GL.GL_DEPTH_TEST); context.depthTestEnabled = true; } else if (!state.isDepthTest() && context.depthTestEnabled) { gl.glDisable(GL.GL_DEPTH_TEST); context.depthTestEnabled = false; gl.glDepthFunc(convertTestFunction(state.getDepthFunc())); context.depthFunc = state.getDepthFunc(); gl.glDepthMask(true); context.depthWriteEnabled = true; } else if (!state.isDepthWrite() && context.depthWriteEnabled) { gl.glDepthMask(false); context.depthWriteEnabled = false; gl.glColorMask(true, true, true, true); context.colorWriteEnabled = true; } else if (!state.isColorWrite() && context.colorWriteEnabled) { gl.glColorMask(false, false, false, false); context.colorWriteEnabled = false; gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(state.getPolyOffsetFactor(), state.getPolyOffsetUnits()); context.polyOffsetEnabled = true; if (state.getPolyOffsetFactor() != context.polyOffsetFactor || state.getPolyOffsetUnits() != context.polyOffsetUnits) { gl.glPolygonOffset(state.getPolyOffsetFactor(),
if (id == -1) { id = gl.glCreateProgram(); if (id == 0) { throw new RendererException("Invalid ID (" + id + ") received when trying to create shader program."); bindFragDataRequired = true; gl.glAttachShader(id, source.getId()); gl.glLinkProgram(id); gl.glGetProgram(id, GL.GL_LINK_STATUS, intBuf1); boolean linkOK = intBuf1.get(0) == GL.GL_TRUE; String infoLog = null; gl.glGetProgram(id, GL.GL_INFO_LOG_LENGTH, intBuf1); int length = intBuf1.get(0); if (length > 3) { infoLog = gl.glGetProgramInfoLog(id, length);
loc = gl.glGetAttribLocation(context.boundShaderProgram, "in" + vb.getBufferType().name()); for (int i = 0; i < slotsRequired; i++) { if (!context.attribIndexList.moveToNew(loc + i)) { gl.glEnableVertexAttribArray(loc + i); assert bufId != -1; if (context.boundArrayVBO != bufId) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bufId); context.boundArrayVBO = bufId; gl.glVertexAttribPointer(loc, vb.getNumComponents(), convertFormat(vb.getFormat()), gl.glVertexAttribPointer(loc + i, 4, convertFormat(vb.getFormat()),
gl.glGenBuffers(intBuf1); bufId = intBuf1.get(0); vb.setId(bufId); target = GL.GL_ELEMENT_ARRAY_BUFFER; if (context.boundElementArrayVBO != bufId) { gl.glBindBuffer(target, bufId); context.boundElementArrayVBO = bufId; target = GL.GL_ARRAY_BUFFER; if (context.boundArrayVBO != bufId) { gl.glBindBuffer(target, bufId); context.boundArrayVBO = bufId; case Byte: case UnsignedByte: gl.glBufferData(target, (ByteBuffer) vb.getData(), usage); break; case Short: case UnsignedShort: gl.glBufferData(target, (ShortBuffer) vb.getData(), usage); break; case Int: break; case Float: gl.glBufferData(target, (FloatBuffer) vb.getData(), usage); break; default:
@Override public void glBufferData(int target, long data_size, int usage) { gl.glBufferData(target, data_size, usage); checkError(); }
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, bufId); context.boundElementArrayVBO = bufId; count); } else { gl.glDrawRangeElements(elMode, 0, vertCount, count); } else { gl.glDrawRangeElements(convertElementMode(mesh.getMode()), 0, vertCount,
public void glBufferSubData(int target, long offset, FloatBuffer data) { gl.glBufferSubData(target, offset, data); checkError(); }
@Override public void glBlendEquationSeparate(int colorMode, int alphaMode) { gl.glBlendEquationSeparate(colorMode, alphaMode); checkError(); }
public void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dFactorAlpha) { gl.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dFactorAlpha); checkError(); }
public void glBlendFunc(int sfactor, int dfactor) { gl.glBlendFunc(sfactor, dfactor); checkError(); }
public void glActiveTexture(int texture) { gl.glActiveTexture(texture); checkError(); }
public void glBindBuffer(int target, int buffer) { gl.glBindBuffer(target, buffer); checkError(); }
public void glBindTexture(int target, int texture) { gl.glBindTexture(target, texture); checkError(); }
if (id == -1) { id = gl.glCreateProgram(); if (id == 0) { throw new RendererException("Invalid ID (" + id + ") received when trying to create shader program."); bindFragDataRequired = true; gl.glAttachShader(id, source.getId()); gl.glLinkProgram(id); gl.glGetProgram(id, GL.GL_LINK_STATUS, intBuf1); boolean linkOK = intBuf1.get(0) == GL.GL_TRUE; String infoLog = null; gl.glGetProgram(id, GL.GL_INFO_LOG_LENGTH, intBuf1); int length = intBuf1.get(0); if (length > 3) { infoLog = gl.glGetProgramInfoLog(id, length);
loc = gl.glGetAttribLocation(context.boundShaderProgram, "in" + vb.getBufferType().name()); for (int i = 0; i < slotsRequired; i++) { if (!context.attribIndexList.moveToNew(loc + i)) { gl.glEnableVertexAttribArray(loc + i); assert bufId != -1; if (context.boundArrayVBO != bufId) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bufId); context.boundArrayVBO = bufId; gl.glVertexAttribPointer(loc, vb.getNumComponents(), convertFormat(vb.getFormat()), gl.glVertexAttribPointer(loc + i, 4, convertFormat(vb.getFormat()),
gl.glGenBuffers(intBuf1); bufId = intBuf1.get(0); vb.setId(bufId); target = GL.GL_ELEMENT_ARRAY_BUFFER; if (context.boundElementArrayVBO != bufId) { gl.glBindBuffer(target, bufId); context.boundElementArrayVBO = bufId; target = GL.GL_ARRAY_BUFFER; if (context.boundArrayVBO != bufId) { gl.glBindBuffer(target, bufId); context.boundArrayVBO = bufId; case Byte: case UnsignedByte: gl.glBufferData(target, (ByteBuffer) vb.getData(), usage); break; case Short: case UnsignedShort: gl.glBufferData(target, (ShortBuffer) vb.getData(), usage); break; case Int: break; case Float: gl.glBufferData(target, (FloatBuffer) vb.getData(), usage); break; default:
public void glBufferData(int target, ShortBuffer data, int usage) { gl.glBufferData(target, data, usage); checkError(); }