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

The following examples show how to use org.lwjgl.opengl.GL11#glVertex2i() . 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: Graphics.java    From AnyaBasic with MIT License 6 votes vote down vote up
public void drawBox( int x1, int y1, int x2, int y2,
              float r, float g, float b, float a )
{
    GL11.glDisable( GL11.GL_TEXTURE_2D );
    GL11.glColor4f( r, g, b, a ) ;

    GL11.glBegin( GL11.GL_LINE_STRIP );
    GL11.glVertex2i( x1, y1 );
    GL11.glVertex2i( x2, y1 );
    GL11.glVertex2i( x2, y2 );
    GL11.glVertex2i( x1, y2 );
    GL11.glVertex2i( x1, y1 );
    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );

    GL11.glColor4f( 1, 1, 1, 1 );

}
 
Example 2
Source File: Graphics.java    From AnyaBasic with MIT License 6 votes vote down vote up
public void drawLine( int x1, int y1, int x2, int y2,
                      float r, float g, float b, float a )
{
    GL11.glDisable( GL11.GL_TEXTURE_2D );
    GL11.glColor4f( r, g, b, a ) ;

    GL11.glBegin( GL11.GL_LINES );
    GL11.glVertex2i( x1, y1 );
    GL11.glVertex2i( x2, y2 );
    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );

    GL11.glColor4f( 1, 1, 1, 1 );

}
 
Example 3
Source File: ComboBoxComponent.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawBox(int x2, int x4, int y1, int y2, boolean hBox)
{
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	// background
	float bgAlpha = hBox ? opacity * 1.5F : opacity;
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], bgAlpha);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x4, y1);
	GL11.glVertex2i(x4, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// outline
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x4, y1);
	GL11.glVertex2i(x4, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 4
Source File: Graphics.java    From AnyaBasic with MIT License 6 votes vote down vote up
public void drawBoxFilled( int x1, int y1, int x2, int y2,
                    float r, float g, float b, float a )
{
    GL11.glDisable( GL11.GL_TEXTURE_2D );
    GL11.glColor4f( r, g, b, a ) ;

    x2++;
    y2++;

    GL11.glBegin( GL11.GL_QUADS );

        GL11.glVertex2i	( x1,y1 );
        GL11.glVertex2i	( x1,y2 );
        GL11.glVertex2i	( x2,y2 );
        GL11.glVertex2i	( x2,y1 );

    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );

    GL11.glColor4f( 1, 1, 1, 1 );

}
 
Example 5
Source File: ClickGui.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void renderTitleBarButton(int x1, int y1, int x2, int y2,
	boolean hovering)
{
	int x3 = x2 + 2;
	
	// button background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hovering ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// background between buttons
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x2, y1);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// button outline
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 6
Source File: SliderComponent.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void drawBackground(int x1, int x2, int x3, int x4, int y1, int y2,
	int y4, int y5)
{
	float[] bgColor = GUI.getBgColor();
	float opacity = GUI.getOpacity();
	
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y4);
	GL11.glVertex2i(x2, y4);
	GL11.glVertex2i(x2, y1);
	
	GL11.glVertex2i(x1, y5);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y5);
	
	GL11.glVertex2i(x1, y4);
	GL11.glVertex2i(x1, y5);
	GL11.glVertex2i(x3, y5);
	GL11.glVertex2i(x3, y4);
	
	GL11.glVertex2i(x4, y4);
	GL11.glVertex2i(x4, y5);
	GL11.glVertex2i(x2, y5);
	GL11.glVertex2i(x2, y4);
	
	GL11.glEnd();
}
 
Example 7
Source File: Graphics.java    From AnyaBasic with MIT License 5 votes vote down vote up
public void drawLine( int x1, int y1, int x2, int y2 )
{
    GL11.glDisable( GL11.GL_TEXTURE_2D );

    GL11.glBegin( GL11.GL_LINES );
    GL11.glVertex2i( x1, y1 );
    GL11.glVertex2i( x2, y2 );
    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );

}
 
Example 8
Source File: CheckboxComponent.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void drawBackground(int x2, int x3, int y1, int y2)
{
	float[] bgColor = GUI.getBgColor();
	float opacity = GUI.getOpacity();
	
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 9
Source File: ClickGui.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
private void renderTitleBarButton(int x1, int y1, int x2, int y2,
	boolean hovering)
{
	int x3 = x2 + 2;
	
	// button background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hovering ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// background between buttons
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x2, y1);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// button outline
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 10
Source File: FeatureButton.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void drawOutline(int x1, int x2, int y1, int y2)
{
	float[] acColor = GUI.getAcColor();
	
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 11
Source File: ComboBoxPopup.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void drawOutline(int x1, int x2, int y1, int y2)
{
	float[] acColor = gui.getAcColor();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 12
Source File: ClickGui.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
public void renderPopupsAndTooltip(MatrixStack matrixStack, int mouseX,
	int mouseY)
{
	// popups
	for(Popup popup : popups)
	{
		Component owner = popup.getOwner();
		Window parent = owner.getParent();
		
		int x1 = parent.getX() + owner.getX();
		int y1 =
			parent.getY() + 13 + parent.getScrollOffset() + owner.getY();
		
		GL11.glPushMatrix();
		GL11.glTranslated(x1, y1, 0);
		
		int cMouseX = mouseX - x1;
		int cMouseY = mouseY - y1;
		popup.render(matrixStack, cMouseX, cMouseY);
		
		GL11.glPopMatrix();
	}
	
	// tooltip
	if(!tooltip.isEmpty())
	{
		String[] lines = tooltip.split("\n");
		TextRenderer fr = MC.textRenderer;
		
		int tw = 0;
		int th = lines.length * fr.fontHeight;
		for(String line : lines)
		{
			int lw = fr.getWidth(line);
			if(lw > tw)
				tw = lw;
		}
		int sw = MC.currentScreen.width;
		int sh = MC.currentScreen.height;
		
		int xt1 = mouseX + tw + 11 <= sw ? mouseX + 8 : mouseX - tw - 8;
		int xt2 = xt1 + tw + 3;
		int yt1 = mouseY + th - 2 <= sh ? mouseY - 4 : mouseY - th - 4;
		int yt2 = yt1 + th + 2;
		
		GL11.glPushMatrix();
		GL11.glTranslated(0, 0, 300);
		
		// background
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], 0.75F);
		GL11.glBegin(GL11.GL_QUADS);
		GL11.glVertex2i(xt1, yt1);
		GL11.glVertex2i(xt1, yt2);
		GL11.glVertex2i(xt2, yt2);
		GL11.glVertex2i(xt2, yt1);
		GL11.glEnd();
		
		// outline
		GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
		GL11.glBegin(GL11.GL_LINE_LOOP);
		GL11.glVertex2i(xt1, yt1);
		GL11.glVertex2i(xt1, yt2);
		GL11.glVertex2i(xt2, yt2);
		GL11.glVertex2i(xt2, yt1);
		GL11.glEnd();
		
		// text
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		for(int i = 0; i < lines.length; i++)
			fr.draw(matrixStack, lines[i], xt1 + 2,
				yt1 + 2 + i * fr.fontHeight, 0xffffff);
		GL11.glEnable(GL11.GL_BLEND);
		
		GL11.glPopMatrix();
	}
}
 
Example 13
Source File: Graphics.java    From AnyaBasic with MIT License 4 votes vote down vote up
public void drawBoxFilled( int x1, int y1, int x2, int y2 )
{
    GL11.glDisable( GL11.GL_TEXTURE_2D );

    x2++;
    y2++;

    GL11.glBegin( GL11.GL_QUADS );

    GL11.glVertex2i	( x1,y1 );
    GL11.glVertex2i	( x1,y2 );
    GL11.glVertex2i	( x2,y2 );
    GL11.glVertex2i	( x2,y1 );

    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );


}
 
Example 14
Source File: BlockListEditButton.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
	float partialTicks)
{
	ClickGui gui = WurstClient.INSTANCE.getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - buttonWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBox = hovering && mouseX >= x3;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	TextRenderer fr = WurstClient.MC.textRenderer;
	String text = setting.getName() + ": " + setting.getBlockNames().size();
	fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0);
	fr.draw(matrixStack, "Edit...", x3 + 2, y1 + 2, 0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 15
Source File: ComboBox.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
	ClickGui gui = ForgeWurst.getForgeWurst().getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - 11;
	int x4 = x3 - popupWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x4;
	boolean hBox = hovering && mouseX >= x4;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x4, y2);
	GL11.glVertex2i(x4, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x4, y1);
	GL11.glVertex2i(x4, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x4, y1);
	GL11.glVertex2i(x4, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// separator
	GL11.glBegin(GL11.GL_LINES);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glEnd();
	
	double xa1 = x3 + 1;
	double xa2 = (x3 + x2) / 2.0;
	double xa3 = x2 - 1;
	double ya1;
	double ya2;
	
	if(popup != null && !popup.isClosing())
	{
		ya1 = y2 - 3.5;
		ya2 = y1 + 3;
		GL11.glColor4f(hBox ? 1 : 0.85F, 0, 0, 1);
	}else
	{
		ya1 = y1 + 3.5;
		ya2 = y2 - 3;
		GL11.glColor4f(0, hBox ? 1 : 0.85F, 0, 1);
	}
	
	// arrow
	GL11.glBegin(GL11.GL_TRIANGLES);
	GL11.glVertex2d(xa1, ya1);
	GL11.glVertex2d(xa3, ya1);
	GL11.glVertex2d(xa2, ya2);
	GL11.glEnd();
	
	// outline
	GL11.glColor4f(0.0625F, 0.0625F, 0.0625F, 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2d(xa1, ya1);
	GL11.glVertex2d(xa3, ya1);
	GL11.glVertex2d(xa2, ya2);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	FontRenderer fr = WMinecraft.getFontRenderer();
	fr.drawString(setting.getName(), x1, y1 + 2, 0xf0f0f0);
	fr.drawString(setting.getSelected().toString(), x4 + 2, y1 + 2,
		0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
}
 
Example 16
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draw a curve to the screen that's tinted with `color`. The first time
 * this is called this caches the image result of the curve and on subsequent
 * runs it just draws the cached copy to the screen.
 * @param color tint of the curve
 * @param borderColor the curve border color
 * @param from index to draw from
 * @param to index to draw to (exclusive)
 */
public void draw(Color color, Color borderColor, int from, int to) {
	float alpha = color.a;

	if (fbo == null)
		initFBO();

	if (lastPointDrawn != to || firstPointDrawn != from) {
		int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
		int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
		//glGetInteger requires a buffer of size 16, even though just 4
		//values are returned in this specific case
		IntBuffer oldViewport = BufferUtils.createIntBuffer(16);
		GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID());
		GL11.glViewport(0, 0, fbo.width, fbo.height);
		GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
		this.renderCurve(color, borderColor, from, to, firstPointDrawn != from);
		lastPointDrawn = to;
		firstPointDrawn = from;
		color.a = 1f;

		GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb);
		GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3));
	}

	// draw a fullscreen quad with the texture that contains the curve
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID());
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha);
	GL11.glTexCoord2f(1.0f, 1.0f);
	GL11.glVertex2i(fbo.width, 0);
	GL11.glTexCoord2f(0.0f, 1.0f);
	GL11.glVertex2i(0, 0);
	GL11.glTexCoord2f(0.0f, 0.0f);
	GL11.glVertex2i(0, fbo.height);
	GL11.glTexCoord2f(1.0f, 0.0f);
	GL11.glVertex2i(fbo.width, fbo.height);
	GL11.glEnd();
}
 
Example 17
Source File: ComboBox.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(int mouseX, int mouseY)
{
	ClickGui gui = ForgeWurst.getForgeWurst().getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	boolean hovering =
		mouseX >= x1 && mouseY >= y1 && mouseX < x2 && mouseY < y2;
	if(hovering)
		gui.setTooltip(null);
	
	// outline
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	Enum<?>[] values = ((ComboBox)getOwner()).setting.getValues();
	int yi1 = y1 - 11;
	for(Enum<?> value : values)
	{
		if(value == ((ComboBox)getOwner()).setting.getSelected())
			continue;
		
		yi1 += 11;
		int yi2 = yi1 + 11;
		boolean hValue = hovering && mouseY >= yi1 && mouseY < yi2;
		
		// background
		GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
			hValue ? opacity * 1.5F : opacity);
		GL11.glBegin(GL11.GL_QUADS);
		GL11.glVertex2i(x1, yi1);
		GL11.glVertex2i(x1, yi2);
		GL11.glVertex2i(x2, yi2);
		GL11.glVertex2i(x2, yi1);
		GL11.glEnd();
		
		// value name
		GL11.glColor4f(1, 1, 1, 1);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		FontRenderer fr = WMinecraft.getFontRenderer();
		fr.drawString(value.toString(), x1 + 2, yi1 + 2, 0xf0f0f0);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
	}
}
 
Example 18
Source File: BlockListEditButton.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
	ClickGui gui = ForgeWurst.getForgeWurst().getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - buttonWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBox = hovering && mouseX >= x3;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	FontRenderer fr = WMinecraft.getFontRenderer();
	String text = setting.getName() + ": " + setting.getBlockNames().size();
	fr.drawString(text, x1, y1 + 2, 0xf0f0f0);
	fr.drawString("Edit...", x3 + 2, y1 + 2, 0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
}
 
Example 19
Source File: ItemListEditButton.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
	float partialTicks)
{
	ClickGui gui = WurstClient.INSTANCE.getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - buttonWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBox = hovering && mouseX >= x3;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	TextRenderer fr = WurstClient.MC.textRenderer;
	String text = setting.getName() + ": " + setting.getItemNames().size();
	fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0);
	fr.draw(matrixStack, "Edit...", x3 + 2, y1 + 2, 0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
}
 
Example 20
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draw a curve to the screen that's tinted with `color`. The first time
 * this is called this caches the image result of the curve and on subsequent
 * runs it just draws the cached copy to the screen.
 * @param color tint of the curve
 * @param borderColor the curve border color
 * @param from index to draw from
 * @param to index to draw to (exclusive)
 */
public void draw(Color color, Color borderColor, int from, int to) {
	float alpha = color.a;

	if (fbo == null) {
		// this should not be null, but issue #106 claims it is possible, at least 3 people had this...
		// debugging shows that the draw was called after discardGeometry was, which does not really make sense
		initFBO();
	}

	if (lastPointDrawn != to || firstPointDrawn != from) {
		int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
		int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
		//glGetInteger requires a buffer of size 16, even though just 4
		//values are returned in this specific case
		IntBuffer oldViewport = BufferUtils.createIntBuffer(16);
		GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID());
		GL11.glViewport(0, 0, fbo.width, fbo.height);
		GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
		this.renderCurve(color, borderColor, from, to, firstPointDrawn != from);
		lastPointDrawn = to;
		firstPointDrawn = from;
		color.a = 1f;

		GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb);
		GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3));
	}

	// draw a fullscreen quad with the texture that contains the curve
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID());
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha);
	GL11.glTexCoord2f(1.0f, 1.0f);
	GL11.glVertex2i(fbo.width, 0);
	GL11.glTexCoord2f(0.0f, 1.0f);
	GL11.glVertex2i(0, 0);
	GL11.glTexCoord2f(0.0f, 0.0f);
	GL11.glVertex2i(0, fbo.height);
	GL11.glTexCoord2f(1.0f, 0.0f);
	GL11.glVertex2i(fbo.width, fbo.height);
	GL11.glEnd();
}