Java Code Examples for org.lwjgl.opengl.GL11#glFlush()

The following examples show how to use org.lwjgl.opengl.GL11#glFlush() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.getDisplayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width * 16D / iconSize, d.height * 16D / iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows * cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for (int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i % cols * 18;
        int y = i / cols * 18;
        GuiHelper.drawItem(x + 1, y + 1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 2
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.displayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width*16D/iconSize, d.height*16D/iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows*cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i%cols * 18;
        int y = i/cols * 18;
        GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 3
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Do the actual drawing of the curve into the currently bound framebuffer.
 * @param color the color of the curve
 * @param borderColor the curve border color
 */
private void renderCurve(Color color, Color borderColor, int from, int to, boolean clearFirst) {
	staticState.initGradient();
	RenderState state = saveRenderState();
	staticState.initShaderProgram();
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, fbo.getVbo());
	GL20.glUseProgram(staticState.program);
	GL20.glEnableVertexAttribArray(staticState.attribLoc);
	GL20.glEnableVertexAttribArray(staticState.texCoordLoc);
	GL20.glUniform1i(staticState.texLoc, 0);
	GL20.glUniform3f(staticState.colLoc, color.r, color.g, color.b);
	GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a);
	//stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w)
	//2*4 is for skipping the first 2 floats (u,v)
	GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4);
	GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0);
	if (clearFirst) {
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
	}
	final int mirrors = OPTION_DANCE_MIRROR.state ? this.mirrors : 1;
	for (int i = 0; i < mirrors; i++) {
		if (pointsToRender == null) {
			renderCurve(from, to, i);
		} else {
			renderCurve(i);
		}
		//from++;
		//to++;
	}
	GL11.glFlush();
	GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
	GL20.glDisableVertexAttribArray(staticState.attribLoc);
	restoreRenderState(state);
}
 
Example 4
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Do the actual drawing of the curve into the currently bound framebuffer.
 * @param color the color of the curve
 * @param borderColor the curve border color
 */
private void renderCurve(Color color, Color borderColor, int from, int to, boolean clearFirst) {
	staticState.initGradient();
	RenderState state = saveRenderState();
	staticState.initShaderProgram();
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, fbo.getVbo());
	GL20.glUseProgram(staticState.program);
	GL20.glEnableVertexAttribArray(staticState.attribLoc);
	GL20.glEnableVertexAttribArray(staticState.texCoordLoc);
	GL20.glUniform1i(staticState.texLoc, 0);
	GL20.glUniform3f(staticState.colLoc, color.r, color.g, color.b);
	GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a);
	//stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w)
	//2*4 is for skipping the first 2 floats (u,v)
	GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4);
	GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0);
	if (clearFirst)
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
	if (pointsToRender == null) {
		for (int i = from * 2; i < to * 2 - 1; ++i) {
			if (spliceFrom <= i && i <= spliceTo)
				continue;
			GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2);
		}
	} else {
		Iterator<Integer> iter = pointsToRender.iterator();
		while (iter.hasNext()) {
			for (int i = iter.next() * 2, end = iter.next() * 2 - 1; i < end; ++i)
				GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2);
		}
	}
	GL11.glFlush();
	GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
	GL20.glDisableVertexAttribArray(staticState.attribLoc);
	restoreRenderState(state);
}
 
Example 5
Source File: CurveRenderState.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Do the actual drawing of the curve into the currently bound framebuffer.
 * @param color the color of the curve
 * @param borderColor the curve border color
 */
private void renderCurve(Color color, Color borderColor, int to) {
	staticState.initGradient();
	RenderState state = saveRenderState();
	staticState.initShaderProgram();
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
	GL20.glUseProgram(staticState.program);
	GL20.glEnableVertexAttribArray(staticState.attribLoc);
	GL20.glEnableVertexAttribArray(staticState.texCoordLoc);
	GL20.glUniform1i(staticState.texLoc, 0);
	GL20.glUniform4f(staticState.colLoc, color.r, color.g, color.b, color.a);
	GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a);

	float lastSegmentX = to == 0 ? curve[1].x - curve[0].x : curve[to].x - curve[to-1].x;
	float lastSegmentY = to == 0 ? curve[1].y - curve[0].y : curve[to].y - curve[to-1].y;
	float lastSegmentInvLen = 1.f/(float)Math.hypot(lastSegmentX, lastSegmentY);
	GL20.glUniform4f(staticState.endPointLoc, curve[to].x, curve[to].y, lastSegmentX * lastSegmentInvLen, lastSegmentY * lastSegmentInvLen);
	//stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w)
	//2*4 is for skipping the first 2 floats (u,v)
	GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4);
	GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0);

	GL11.glColorMask(false,false,false,false);
	GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, pointIndices[to]);
	GL11.glColorMask(true,true,true,true);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glDepthFunc(GL11.GL_EQUAL);
	GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, pointIndices[to]);
	GL11.glDepthFunc(GL11.GL_LESS);

	GL11.glFlush();
	GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
	GL20.glDisableVertexAttribArray(staticState.attribLoc);
	restoreRenderState(state);
}