Example usage for org.lwjgl.opengl GL11 glColor3f

List of usage examples for org.lwjgl.opengl GL11 glColor3f

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glColor3f.

Prototype

public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue);

Source Link

Document

Float version of #glColor3b Color3b

Usage

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderEnchantGlint_Equip() {
    GL11.glColor3f(0.301F, 0.78F, 1.0F);
    renderOverlay_Equip(src_glint);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderEnchantGlint_Inv() {
    GL11.glColor3f(0.301F, 0.78F, 1.0F);
    renderOverlay_Inv(src_glint);
}

From source file:com.acornui.jvm.LwjglHelloWorld.java

License:Apache License

private void draw() {
    // set the color of the quad (R,G,B,A)
    GL11.glColor3f(0.5f, 0.5f, 1.0f);

    // draw quad/*from   w  ww . j a v  a2  s. c  om*/
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(100, 100);
    GL11.glVertex2f(100 + 200, 100);
    GL11.glVertex2f(100 + 200, 100 + 200);
    GL11.glVertex2f(100, 100 + 200);
    GL11.glEnd();
}

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;//from  ww w.j a v  a2s .co m
    data.accumAlphaSize = 8;
    data.accumBlueSize = 8;
    data.accumGreenSize = 8;
    data.accumRedSize = 8;

    final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);

    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    canvas.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            Rectangle bounds = canvas.getBounds();
            float fAspect = (float) bounds.width / (float) bounds.height;
            canvas.setCurrent();
            try {
                GLContext.useContext(canvas);
            } catch (LWJGLException e) {
                e.printStackTrace();
            }
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
        }
    });

    GL11.glLineWidth(1);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glClearDepth(1.0);
    GL11.glLineWidth(2);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);

    shell.setText("SWT/LWJGL Example");
    shell.setSize(640, 480);
    shell.open();

    final Runnable run = new Runnable() {
        float rot = 0;

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }

                int ACSIZE = 8;

                int[] viewport = getViewport();

                GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

                for (int jitter = 0; jitter < ACSIZE; jitter++) {
                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

                    double jit_x = jits[jitter][0];
                    double jit_y = jits[jitter][1];

                    accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y,
                            0.0, 0.0, 1.0);

                    {

                        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                        GL11.glClearColor(.3f, .5f, .8f, 1.0f);
                        GL11.glLoadIdentity();
                        GL11.glTranslatef(0.0f, 0.0f, -10.0f);
                        float frot = rot;
                        GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f);
                        GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f);
                        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
                        GL11.glColor3f(0.9f, 0.9f, 0.9f);
                        drawCylinder(2, 3, 50, 0);
                        drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                    }

                    GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE);
                }

                GL11.glAccum(GL11.GL_RETURN, 1.0f);
                GL11.glFlush();

                rot += 0.1;

                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    };
    canvas.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            run.run();
        }
    });
    display.asyncExec(run);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:com.blogspot.jabelarminecraft.wildanimals.renderers.RenderBigCat.java

License:Open Source License

/**
 * Queries whether should render the specified pass or not.
 *///from   ww w.  j a  v a  2 s.  c  o m
protected int shouldRenderPass(EntityBigCat par1EntityBigCat, int par2, float par3) {
    if (par2 == 0 && par1EntityBigCat.getBigCatShaking()) {
        float f1 = par1EntityBigCat.getBrightness(par3) * par1EntityBigCat.getShadingWhileShaking(par3);
        this.bindTexture(normalTexture);
        GL11.glColor3f(f1, f1, f1);
        return 1;
    } else if (par2 == 1 && par1EntityBigCat.isTamed()) {
        this.bindTexture(collarTexture);
        int j = par1EntityBigCat.getCollarColor();
        GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1],
                EntitySheep.fleeceColorTable[j][2]);
        return 1;
    } else {
        return -1;
    }
}

From source file:com.bluepowermod.client.render.RenderHelper.java

License:Open Source License

/**
 * Draws a colored cube with the size of vector. Every face has a different color This uses OpenGL
 *
 * @author Koen Beckers (K4Unl)// w ww . j a  v  a2  s.  c  o  m
 * @param vector
 */
public static void drawColoredCube(Vec3dCube vector) {

    // Top side
    GL11.glColor3f(1.0F, 0.0F, 0.0F);
    GL11.glNormal3d(0, 1, 0);
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());

    // Bottom side
    GL11.glColor3f(1.0F, 1.0F, 0.0F);
    GL11.glNormal3d(0, -1, 0);
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());

    // Draw west side:
    GL11.glColor3f(0.0F, 1.0F, 0.0F);
    GL11.glNormal3d(-1, 0, 0);
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());

    // Draw east side:
    GL11.glColor3f(0.0F, 1.0F, 1.0F);
    GL11.glNormal3d(1, 0, 0);
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());

    // Draw north side
    GL11.glColor3f(0.0F, 0.0F, 1.0F);
    GL11.glNormal3d(0, 0, -1);
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());

    // Draw south side
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    GL11.glNormal3d(0, 0, 1);
    addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
    addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
    addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
    addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
}

From source file:com.bluepowermod.part.tube.TubeStack.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void render(float partialTick) {
    if (renderMode == RenderMode.AUTO) {
        renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL
                : RenderMode.REDUCED;//from   www  .j  av a 2  s .co  m
    }
    final RenderMode finalRenderMode = renderMode;

    if (customRenderItem == null) {
        customRenderItem = new RenderItem() {

            @Override
            public boolean shouldBob() {

                return false;
            };

            @Override
            public byte getMiniBlockCount(ItemStack stack, byte original) {

                return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original;
            }
        };
        customRenderItem.setRenderManager(RenderManager.instance);

        renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
        renderedItem.hoverStart = 0.0F;
    }

    renderedItem.setEntityItemStack(stack);

    double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;

    GL11.glPushMatrix();
    GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5,
            heading.offsetZ * renderProgress * 0.5);
    if (finalRenderMode != RenderMode.NONE) {
        GL11.glPushMatrix();
        if (stack.stackSize > 5) {
            GL11.glScaled(0.8, 0.8, 0.8);
        }
        if (!(stack.getItem() instanceof ItemBlock)) {
            GL11.glScaled(0.8, 0.8, 0.8);
            GL11.glTranslated(0, -0.15, 0);
        }

        customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    } else {
        float size = 0.02F;
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBegin(GL11.GL_QUADS);
        RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (color != TubeColor.NONE) {

        float size = 0.2F;

        int colorInt = ItemDye.field_150922_c[color.ordinal()];
        float red = (colorInt >> 16) / 256F;
        float green = (colorInt >> 8 & 255) / 256F;
        float blue = (colorInt & 255) / 256F;

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor3f(red, green, blue);
        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
        RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size));
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
    }

    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.blast.entity.slime.RenderSlimeRain.java

/**
 * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
 * entityLiving, partialTickTime//from   w  ww  . j av  a  2s  . c om
 */
protected void preRenderCallback(EntitySlimeRain slime, float partialTickTime) {
    float f1 = (float) slime.getSlimeSize();
    float f2 = (slime.prevSquishFactor + (slime.squishFactor - slime.prevSquishFactor) * partialTickTime)
            / (f1 * 0.5F + 1.0F);
    float f3 = 1.0F / (f2 + 1.0F);
    GL11.glScalef(f3 * f1, 1.0F / f3 * f1, f3 * f1);
    GL11.glColor3f(slime.color.getRed() / 255F, slime.color.getBlue() / 255F, slime.color.getBlue() / 255F);
}

From source file:com.builtbroken.icbm.content.launcher.silo.TileStandardSilo.java

@Override
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data) {
    GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
    GL11.glScaled(.8f, .8f, .8f);/*from w  w w. ja v  a  2 s .  c  om*/
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.SMALL_SILO_TEXTURE);
    GL11.glColor3f(1.0f, 0f, 0f);
    Assets.SMALL_SILO_MODEL.renderOnly("Group_001", "Component_1_001");
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {//from  ww w. jav a 2s  .c  om
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}