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

The following examples show how to use org.lwjgl.opengl.GL11#glBegin() . 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 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 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: TunnellerHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void updateCyanList()
{
	GL11.glNewList(displayLists[0], GL11.GL_COMPILE);
	
	GL11.glPushMatrix();
	GL11.glTranslated(start.getX(), start.getY(), start.getZ());
	GL11.glTranslated(0.5, 0.5, 0.5);
	
	GL11.glColor4f(0, 1, 1, 0.5F);
	GL11.glBegin(GL11.GL_LINES);
	RenderUtils.drawNode(new Box(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25));
	GL11.glEnd();
	
	RenderUtils.drawArrow(Vec3d.of(direction.getVector()).multiply(0.25),
		Vec3d.of(direction.getVector()).multiply(Math.max(0.5, length)));
	
	GL11.glPopMatrix();
	GL11.glEndList();
}
 
Example 4
Source File: RenderUtils.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawBorderedRect(float x, float y, float x2, float y2, float l1, int col1, int col2) {
    drawRect(x, y, x2, y2, col2);
    float f = (col1 >> 24 & 0xFF) / 255.0F;
    float f2 = (col1 >> 16 & 0xFF) / 255.0F;
    float f3 = (col1 >> 8 & 0xFF) / 255.0F;
    float f4 = (col1 & 0xFF) / 255.0F;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glPushMatrix();
    GlStateManager.color(f2, f3, f4, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(1);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 5
Source File: GData3.java    From ldparteditor with MIT License 5 votes vote down vote up
@Override
public void drawGL20_RandomColours(Composite3D c3d) {
    if (!visible)
        return;
    if (a < 1f && c3d.isDrawingSolidMaterials() || !c3d.isDrawingSolidMaterials() && a == 1f)
        return;
    if (!isTriangle) {
        drawProtractor_GL20(false, c3d, X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3);
        return;
    }
    final float r = MathHelper.randomFloat(ID, 0);
    final float g = MathHelper.randomFloat(ID, 1);
    final float b = MathHelper.randomFloat(ID, 2);
    GL11.glBegin(GL11.GL_TRIANGLES);
    if (GData.globalNegativeDeterminant) {
        GL11.glColor4f(r, g, b, a);
        GL11.glNormal3f(xn, yn, zn);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x3, y3, z3);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glNormal3f(-xn, -yn, -zn);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glVertex3f(x3, y3, z3);
    } else {
        GL11.glColor4f(r, g, b, a);
        GL11.glNormal3f(xn, yn, zn);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glVertex3f(x3, y3, z3);
        GL11.glNormal3f(-xn, -yn, -zn);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x3, y3, z3);
        GL11.glVertex3f(x2, y2, z2);
    }
    GL11.glEnd();
}
 
Example 6
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 7
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static void drawBorderedRect(double x, double y, double x2, double y2, float l1, int col1, int col2) {

        GLUtils.drawRect((float) x, (float) y, (float) x2, (float) y2, col2);
        float f = (col1 >> 24 & 255) / 255.0f;
        float f1 = (col1 >> 16 & 255) / 255.0f;
        float f2 = (col1 >> 8 & 255) / 255.0f;
        float f3 = (col1 & 255) / 255.0f;
        GL11.glEnable(3042);
        GL11.glDisable(3553);
        GL11.glBlendFunc(770, 771);
        GL11.glEnable(2848);
        GL11.glPushMatrix();
        GL11.glColor4f(f1, f2, f3, f);
        GL11.glLineWidth(l1);
        GL11.glBegin(1);
        GL11.glVertex2d(x, y);
        GL11.glVertex2d(x, y2);
        GL11.glVertex2d(x2, y2);
        GL11.glVertex2d(x2, y);
        GL11.glVertex2d(x, y);
        GL11.glVertex2d(x2, y);
        GL11.glVertex2d(x, y2);
        GL11.glVertex2d(x2, y2);
        GL11.glEnd();
        GL11.glPopMatrix();
        GL11.glEnable(3553);
        GL11.glDisable(3042);
        GL11.glDisable(2848);
    }
 
Example 8
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 9
Source File: FeatureButton.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void drawSeparator(int x3, int y1, int y2)
{
	// separator
	GL11.glBegin(GL11.GL_LINES);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glEnd();
}
 
Example 10
Source File: CaveFinderHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRender(float partialTicks)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glDisable(GL11.GL_LIGHTING);
	
	GL11.glPushMatrix();
	RenderUtils.applyRenderOffset();
	
	// generate rainbow color
	float x = System.currentTimeMillis() % 2000 / 1000F;
	float alpha = 0.25F + 0.25F * MathHelper.sin(x * (float)Math.PI);
	
	GL11.glColor4f(1, 0, 0, alpha);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glCallList(displayList);
	GL11.glEnd();
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 11
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public static void drawStrip(int x, int y, float width, double angle, float points, float radius, int color) {

        int i;
        float yc;
        float a2;
        float xc;
        GL11.glPushMatrix();
        float f1 = (color >> 24 & 255) / 255.0f;
        float f2 = (color >> 16 & 255) / 255.0f;
        float f3 = (color >> 8 & 255) / 255.0f;
        float f4 = (color & 255) / 255.0f;
        GL11.glTranslatef(x, y, 0.0f);
        GL11.glColor4f(f2, f3, f4, f1);
        GL11.glLineWidth(width);
        GL11.glEnable(3042);
        GL11.glDisable(2929);
        GL11.glEnable(2848);
        GL11.glDisable(3553);
        GL11.glDisable(3008);
        GL11.glBlendFunc(770, 771);
        GL11.glHint(3154, 4354);
        GL11.glEnable(32925);
        if (angle > 0.0) {
            GL11.glBegin(3);
            i = 0;
            while (i < angle) {
                a2 = (float) (i * (angle * 3.141592653589793 / points));
                xc = (float) (Math.cos(a2) * radius);
                yc = (float) (Math.sin(a2) * radius);
                GL11.glVertex2f(xc, yc);
                ++i;
            }
            GL11.glEnd();
        }
        if (angle < 0.0) {
            GL11.glBegin(3);
            i = 0;
            while (i > angle) {
                a2 = (float) (i * (angle * 3.141592653589793 / points));
                xc = (float) (Math.cos(a2) * (-radius));
                yc = (float) (Math.sin(a2) * (-radius));
                GL11.glVertex2f(xc, yc);
                --i;
            }
            GL11.glEnd();
        }
        GL11.glDisable(3042);
        GL11.glEnable(3553);
        GL11.glDisable(2848);
        GL11.glEnable(3008);
        GL11.glEnable(2929);
        GL11.glDisable(32925);
        GL11.glDisable(3479);
        GL11.glPopMatrix();
    }
 
Example 12
Source File: Arrow.java    From ldparteditor with MIT License 4 votes vote down vote up
public void drawGL20(float x, float y, float z, float zoom) {
    final float zoom_inv = 1f / zoom;
    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, z);
    GL11.glMultMatrixf(matrix_buf);
    GL11.glScalef(zoom_inv, zoom_inv, zoom_inv);

    GL11.glLineWidth(line_width);
    GL11.glColor3f(r, g, b);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(0f, 0f, 0f);
    GL11.glVertex3f(0f, line_end, 0f);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0f, length, 0f);

    GL11.glVertex3f(cone[0], cone_start, cone[1]);
    GL11.glVertex3f(cone[2], cone_start, cone[3]);
    GL11.glVertex3f(cone[4], cone_start, cone[5]);
    GL11.glVertex3f(cone[6], cone_start, cone[7]);

    GL11.glVertex3f(cone[8], cone_start, cone[9]);
    GL11.glVertex3f(cone[10], cone_start, cone[11]);
    GL11.glVertex3f(cone[12], cone_start, cone[13]);
    GL11.glVertex3f(cone[14], cone_start, cone[15]);

    GL11.glVertex3f(cone[16], cone_start, cone[17]);
    GL11.glVertex3f(cone[18], cone_start, cone[19]);
    GL11.glVertex3f(cone[20], cone_start, cone[21]);
    GL11.glVertex3f(cone[22], cone_start, cone[23]);

    GL11.glVertex3f(cone[24], cone_start, cone[25]);
    GL11.glVertex3f(cone[26], cone_start, cone[27]);
    GL11.glVertex3f(cone[28], cone_start, cone[29]);
    GL11.glVertex3f(cone[30], cone_start, cone[31]);

    GL11.glVertex3f(cone[32], cone_start, cone[33]);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0f, cone_start, 0f);

    GL11.glVertex3f(cone[32], cone_start, cone[33]);

    GL11.glVertex3f(cone[30], cone_start, cone[31]);
    GL11.glVertex3f(cone[28], cone_start, cone[29]);
    GL11.glVertex3f(cone[26], cone_start, cone[27]);
    GL11.glVertex3f(cone[24], cone_start, cone[25]);

    GL11.glVertex3f(cone[22], cone_start, cone[23]);
    GL11.glVertex3f(cone[20], cone_start, cone[21]);
    GL11.glVertex3f(cone[18], cone_start, cone[19]);
    GL11.glVertex3f(cone[16], cone_start, cone[17]);

    GL11.glVertex3f(cone[14], cone_start, cone[15]);
    GL11.glVertex3f(cone[12], cone_start, cone[13]);
    GL11.glVertex3f(cone[10], cone_start, cone[11]);
    GL11.glVertex3f(cone[8], cone_start, cone[9]);

    GL11.glVertex3f(cone[6], cone_start, cone[7]);
    GL11.glVertex3f(cone[4], cone_start, cone[5]);
    GL11.glVertex3f(cone[2], cone_start, cone[3]);
    GL11.glVertex3f(cone[0], cone_start, cone[1]);

    GL11.glEnd();

    GL11.glPopMatrix();
}
 
Example 13
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	
	GL11.glPushMatrix();
	GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX,
		-TileEntityRendererDispatcher.staticPlayerY,
		-TileEntityRendererDispatcher.staticPlayerZ);
	
	for(int displayList : displayLists)
		GL11.glCallList(displayList);
	
	if(currentBlock != null)
	{
		float p = prevProgress
			+ (progress - prevProgress) * event.getPartialTicks();
		float red = p * 2F;
		float green = 2 - red;
		
		GL11.glTranslated(currentBlock.getX(), currentBlock.getY(),
			currentBlock.getZ());
		if(p < 1)
		{
			GL11.glTranslated(0.5, 0.5, 0.5);
			GL11.glScaled(p, p, p);
			GL11.glTranslated(-0.5, -0.5, -0.5);
		}
		
		AxisAlignedBB box2 = new AxisAlignedBB(BlockPos.ORIGIN);
		GL11.glColor4f(red, green, 0, 0.25F);
		GL11.glBegin(GL11.GL_QUADS);
		RenderUtils.drawSolidBox(box2);
		GL11.glEnd();
		GL11.glColor4f(red, green, 0, 0.5F);
		GL11.glBegin(GL11.GL_LINES);
		RenderUtils.drawOutlinedBox(box2);
		GL11.glEnd();
	}
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 14
Source File: ClickGui.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
private void renderCloseButton(int x1, int y1, int x2, int y2,
	boolean hovering)
{
	renderTitleBarButton(x1, y1, x2, y2, hovering);
	
	double xc1 = x1 + 2;
	double xc2 = x1 + 3;
	double xc3 = x2 - 2;
	double xc4 = x2 - 3;
	double xc5 = x1 + 3.5;
	double xc6 = (x1 + x2) / 2.0;
	double xc7 = x2 - 3.5;
	double yc1 = y1 + 3;
	double yc2 = y1 + 2;
	double yc3 = y2 - 3;
	double yc4 = y2 - 2;
	double yc5 = y1 + 3.5;
	double yc6 = (y1 + y2) / 2.0;
	double yc7 = y2 - 3.5;
	
	// cross
	GL11.glColor4f(hovering ? 1 : 0.85F, 0, 0, 1);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2d(xc1, yc1);
	GL11.glVertex2d(xc2, yc2);
	GL11.glVertex2d(xc3, yc3);
	GL11.glVertex2d(xc4, yc4);
	GL11.glVertex2d(xc3, yc1);
	GL11.glVertex2d(xc4, yc2);
	GL11.glVertex2d(xc6, yc5);
	GL11.glVertex2d(xc7, yc6);
	GL11.glVertex2d(xc6, yc7);
	GL11.glVertex2d(xc5, yc6);
	GL11.glVertex2d(xc1, yc3);
	GL11.glVertex2d(xc2, yc4);
	GL11.glEnd();
	
	// outline
	GL11.glColor4f(0.0625F, 0.0625F, 0.0625F, 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2d(xc1, yc1);
	GL11.glVertex2d(xc2, yc2);
	GL11.glVertex2d(xc6, yc5);
	GL11.glVertex2d(xc4, yc2);
	GL11.glVertex2d(xc3, yc1);
	GL11.glVertex2d(xc7, yc6);
	GL11.glVertex2d(xc3, yc3);
	GL11.glVertex2d(xc4, yc4);
	GL11.glVertex2d(xc6, yc7);
	GL11.glVertex2d(xc2, yc4);
	GL11.glVertex2d(xc1, yc3);
	GL11.glVertex2d(xc5, yc6);
	GL11.glEnd();
}
 
Example 15
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 16
Source File: GData3.java    From ldparteditor with MIT License 4 votes vote down vote up
public void drawProtractor_GL20(boolean selected, Composite3D c3d, BigDecimal x1c, BigDecimal y1c, BigDecimal z1c, BigDecimal x2c, BigDecimal y2c, BigDecimal z2c, BigDecimal x3c, BigDecimal y3c, BigDecimal z3c) {
    final java.text.DecimalFormat NUMBER_FORMAT2F = new java.text.DecimalFormat(View.NUMBER_FORMAT2F, new DecimalFormatSymbols(MyLanguage.LOCALE));
    final OpenGLRenderer20 renderer = (OpenGLRenderer20) c3d.getRenderer();
    final float zoom = 1f / c3d.getZoom();

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glLineWidth(View.lineWidthGL[0]);
    if (selected) {
        GL11.glColor4f(View.vertex_selected_Colour_r[0], View.vertex_selected_Colour_g[0], View.vertex_selected_Colour_b[0], 1f);
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glEnd();
    } else {
        final float s = ((r + g + b) / 3 + .5f) % 1f;
        GL11.glColor4f(s, s, s, 1f);
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glEnd();
    }
    GL11.glColor4f(r, g, b, 1f);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glVertex3f(x3, y3, z3);
    GL11.glEnd();

    final Vector4f textOrigin = new Vector4f(x1, y1, z1, 1f);
    Matrix4f.transform(c3d.getRotation(), textOrigin, textOrigin);

    Vector3d va = new Vector3d(x1c, y1c, z1c);
    Vector3d vb = new Vector3d(x2c, y2c, z2c);
    Vector3d vc = new Vector3d(x3c, y3c, z3c);
    vb = Vector3d.sub(va, vb);
    vc = Vector3d.sub(va, vc);
    double angle = Vector3d.angle(vb, vc);
    BigDecimal ang = new BigDecimal(angle);
    String angle_s = NUMBER_FORMAT2F.format(ang) + "°"; //$NON-NLS-1$

    float sx1 = x1 + (x2 - x1) * .2f;
    float sy1 = y1 + (y2 - y1) * .2f;
    float sz1 = z1 + (z2 - z1) * .2f;
    float sx2 = x1 + (x3 - x1) * .2f;
    float sy2 = y1 + (y3 - y1) * .2f;
    float sz2 = z1 + (z3 - z1) * .2f;
    float sx1t = x1 + (x2 - x1) * .25f;
    float sy1t = y1 + (y2 - y1) * .25f;
    float sz1t = z1 + (z2 - z1) * .25f;
    float sx2t = x1 + (x3 - x1) * .25f;
    float sy2t = y1 + (y3 - y1) * .25f;
    float sz2t = z1 + (z3 - z1) * .25f;
    float sx1tt = x1 + (x2 - x1) * .24f;
    float sy1tt = y1 + (y2 - y1) * .24f;
    float sz1tt = z1 + (z2 - z1) * .24f;
    float sx2tt = x1 + (x3 - x1) * .24f;
    float sy2tt = y1 + (y3 - y1) * .24f;
    float sz2tt = z1 + (z3 - z1) * .24f;
    float sx3 = sx1t * .5f + sx2t * .5f;
    float sy3 = sy1t * .5f + sy2t * .5f;
    float sz3 = sz1t * .5f + sz2t * .5f;
    float sx3r = sx1tt * .7f + sx2tt * .3f;
    float sy3r = sy1tt * .7f + sy2tt * .3f;
    float sz3r = sz1tt * .7f + sz2tt * .3f;
    float sx3l = sx1tt * .3f + sx2tt * .7f;
    float sy3l = sy1tt * .3f + sy2tt * .7f;
    float sz3l = sz1tt * .3f + sz2tt * .7f;

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(sx1, sy1, sz1);
    GL11.glVertex3f(sx3r, sy3r, sz3r);
    GL11.glVertex3f(sx3r, sy3r, sz3r);
    GL11.glVertex3f(sx3, sy3, sz3);
    GL11.glVertex3f(sx3, sy3, sz3);
    GL11.glVertex3f(sx3l, sy3l, sz3l);
    GL11.glVertex3f(sx3l, sy3l, sz3l);
    GL11.glVertex3f(sx2, sy2, sz2);
    GL11.glEnd();

    GL11.glPushMatrix();
    GL11.glMultMatrixf(renderer.getRotationInverse());

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    PGData3.beginDrawText();
    GL11.glColor4f(r, g, b, 1f);
    drawNumber(angle_s, textOrigin.x, textOrigin.y, textOrigin.z, zoom);
    PGData3.endDrawText();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 17
Source File: ArrowBlunt.java    From ldparteditor with MIT License 4 votes vote down vote up
public void draw(float x, float y, float z, float zoom) {
    final float zoom_inv = 1f / zoom;
    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, z);
    GL11.glMultMatrixf(matrix);
    GL11.glScalef(zoom_inv, zoom_inv, zoom_inv);

    GL11.glLineWidth(line_width);
    GL11.glColor3f(r, g, b);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(0f, 0f, 0f);
    GL11.glVertex3f(0f, line_end, 0f);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3f(cube_x[3], cube_y[3], cube_z[3]);
    GL11.glVertex3f(cube_x[2], cube_y[2], cube_z[2]);
    GL11.glVertex3f(cube_x[1], cube_y[1], cube_z[1]);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);

    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glVertex3f(cube_x[5], cube_y[5], cube_z[5]);
    GL11.glVertex3f(cube_x[6], cube_y[6], cube_z[6]);
    GL11.glVertex3f(cube_x[7], cube_y[7], cube_z[7]);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUAD_STRIP);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);
    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glVertex3f(cube_x[3], cube_y[3], cube_z[3]);
    GL11.glVertex3f(cube_x[7], cube_y[7], cube_z[7]);
    GL11.glVertex3f(cube_x[2], cube_y[2], cube_z[2]);
    GL11.glVertex3f(cube_x[6], cube_y[6], cube_z[6]);
    GL11.glVertex3f(cube_x[1], cube_y[1], cube_z[1]);
    GL11.glVertex3f(cube_x[5], cube_y[5], cube_z[5]);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);
    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glEnd();

    GL11.glPopMatrix();
}
 
Example 18
Source File: Graphics.java    From AnyaBasic with MIT License 4 votes vote down vote up
public void drawEllipseFilled( int x, int y, int a, int b, int degrees,
                               float red, float green, float blue, float alpha )
{

    // these constants decide the quality of the ellipse
    final float  pi = (float) Math.PI;
    final float  twopi  = 2 * pi;   //        two pi (radians in a circle)
    final int face_length  = 8;     //        approx. face length in pixels
    final int max_faces = 256;      //        maximum number of faces in ellipse
    final int min_faces = 16;       //        minimum number of faces in ellipse

    // approx. ellipse circumference (hudson's method)
    float h = ( a-b*a-b ) / (float)( a+b*a+b );
    float circumference = 0.25f * pi * (a+b) * (3* (1+h*0.25f)+1 / (1-h*0.25f));

    // number of faces in ellipse
    int num_faces = (int) (circumference/(float)face_length);

    // clamp number of faces
    if( num_faces > max_faces ) num_faces = max_faces;
    if( num_faces < min_faces ) num_faces = min_faces;

    // keep number of faces divisible by 4
    num_faces -= (num_faces & 3);

    // precalc cosine theta
    float angle = degrees * pi /180.0f;
    float s   = (float) Math.sin(twopi/(float)num_faces);
    float c   = (float) Math.cos(twopi/(float)num_faces);
    float xx  = 1;
    float yy  = 0;
    float xt;
    float ax  = (float) Math.cos(angle);
    float ay  = (float) Math.sin(angle);


    // draw ellipse
    GL11.glDisable( GL11.GL_TEXTURE_2D );
    GL11.glColor4f( red, green, blue, alpha ) ;

    int i;
    GL11.glBegin( GL11.GL_TRIANGLE_FAN );

        for( i = 0; i < num_faces; i++ )
        {
            xt = xx;
            xx = c * xx - s * yy;
            yy = s * xt + c * yy;
            GL11.glVertex2f( x+a*xx*ax-b*yy*ay, y+a*xx*ay+b*yy*ax );
        }

        GL11.glVertex2f( x+a*ax, y+a*ay );

    GL11.glEnd();

    GL11.glEnable( GL11.GL_TEXTURE_2D );

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

}
 
Example 19
Source File: BlurPane.java    From LWJGUI with MIT License 4 votes vote down vote up
@Override
public void render(Context context, int x, int y, int w, int h) {
	if ( !isVisible() )
		return;
	
	if ( this.quad == null || quadDirty ) {
		if ( this.quad != null ) {
			this.quad.cleanup();
		}
		quad = new TexturedQuad(0, 0, w, h, source.getTexId());
	}
	
	GL11.glViewport(x, y, w, h);
	this.quadDirty = false;
	quadShader.bind();
	quadShader.projectOrtho(0, h, w, -h);
	
	// bind stuff
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId());
	
	if ( internalBackground instanceof BackgroundSolid ) {
		BackgroundSolid bg = (BackgroundSolid)internalBackground;
		GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uColor"),
				bg.getColor().getRed()/255f-0.5f,
				bg.getColor().getGreen()/255f-0.5f,
				bg.getColor().getBlue()/255f-0.5f,
				bg.getColor().getAlpha()/255f);
	}
	GL20.glUniform1f(GL20.glGetUniformLocation(quadShader.getProgram(), "uBlurSize"), blurRadius);
	GL20.glUniform2f(GL20.glGetUniformLocation(quadShader.getProgram(), "uTexelSize"), 1.0f/(float)w, 1.0f/(float)h);
	GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uCornerRadii"), (float)Math.max(BlurPane.this.getBorderRadii()[0], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[1], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[2], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[3], 0.1));
	
	
	// Draw quad
	if ( context.isCoreOpenGL() ) {
		if ( quad != null ) {
			quad.render();
		}
	} else {

		GL13.glActiveTexture(GL13.GL_TEXTURE0);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId());
		
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex2f(0, 0);
	
			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex2f(w, 0);
	
			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex2f(w, h);
	
			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex2f(0, h);
		GL11.glEnd();
	}
}
 
Example 20
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);
}