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:fable.framework.ui.views.chiPlotView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it./* w  ww.  j  av a  2s.c  o  m*/
 */
/*
 * (non-Javadoc)
 * 
 * @see
 * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
 * .Composite)
 */
/*
 * (non-Javadoc)
 * 
 * @see
 * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
 * .Composite)
 */
public void createPartControl(Composite parent) {

    // logger = FableLogger.getLogger();
    console = new FableMessageConsole("Peaksearch console");
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
    console.displayOut("Welcome to chiplotview " + ToolBox.getPluginVersion(Activator.PLUGIN_ID));

    IOConsoleOutputStream stream = console.newOutputStream();

    // console_debug = new ConsoleLineTracker();

    System.setOut(new PrintStream(stream, true));
    System.setErr(new PrintStream(stream));

    thisView = this;
    parent.setLayout(new GridLayout());
    Composite controlPanelComposite = new Composite(parent, SWT.NULL);
    GridLayout controlGridLayout = new GridLayout();
    controlGridLayout.numColumns = 8;
    controlPanelComposite.setLayout(controlGridLayout);
    controlPanelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    freezeButton = new Button(controlPanelComposite, SWT.CHECK);
    freezeButton.setText("Freeze");
    freezeButton.setToolTipText("freeze 3d relief, disable rotation");
    freezeButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (freezeButton.getSelection())
                freeze = true;
            else
                freeze = false;
        }
    });
    resetButton = new Button(controlPanelComposite, SWT.NULL);
    resetButton.setText("Reset");
    resetButton.setToolTipText("reset 3d projection to be flat and fill the canvas");
    resetButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            grip.init();
        }
    });
    autoscaleButton = new Button(controlPanelComposite, SWT.CHECK);
    autoscaleButton.setText("Autoscale");
    autoscaleButton.setToolTipText("autoscale 3d relief between minimum and mean");
    autoscaleButton.setSelection(true);
    autoscaleButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (autoscaleButton.getSelection()) {
                if (!autoscale) {
                    autoscale = true;
                    scaleImage();
                    drawReliefList();
                }
                minimumSpinner.setEnabled(false);
                maximumSpinner.setEnabled(false);
            } else {
                if (autoscale) {
                    autoscale = false;
                    scaleImage();
                    drawReliefList();
                }
                minimumSpinner.setEnabled(true);
                maximumSpinner.setEnabled(true);
            }
        }
    });
    Label minLabel = new Label(controlPanelComposite, SWT.NULL);
    minLabel.setText("Minimum");
    minimumSpinner = new Spinner(controlPanelComposite, SWT.NULL);
    minimumSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    minimumSpinner.setMinimum(0);
    minimumSpinner.setMaximum(Integer.MAX_VALUE);
    minimumSpinner.setEnabled(false);
    Label maxLabel = new Label(controlPanelComposite, SWT.NULL);
    maxLabel.setText("Maximum");
    maximumSpinner = new Spinner(controlPanelComposite, SWT.NULL);
    maximumSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    maximumSpinner.setMinimum(0);
    maximumSpinner.setMaximum(Integer.MAX_VALUE);
    maximumSpinner.setEnabled(false);
    updateButton = new Button(controlPanelComposite, SWT.NULL);
    updateButton.setText("Update");
    updateButton.setToolTipText("redraw 3d relief plot");
    updateButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            scaleImage();
            drawReliefList();
            drawRelief();
        }
    });
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new GLCanvas(comp, SWT.NONE, data);
    canvas.setSize(comp.getSize());
    canvas.setCurrent();
    // context =
    // GL11.GLDrawableFactory.getFactory().createExternalGLContext();
    canvas.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            Rectangle bounds = canvas.getBounds();
            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 glu = new GLU();
            // aspect = (float) imageWidth / (float) imageHeight;
            // gl.glMatrixMode(GL.GL_MODELVIEW);
            // gl.glLoadIdentity();
            drawRelief();
            canvas.swapBuffers();
        }
    });
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    // gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
    // gl.glClearDepth(1.0);
    // gl.glLineWidth(2);
    // / gl.glEnable(GL.GL_DEPTH_TEST);
    GL11.glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);

    // create the grip for users to change the orientation, translation and
    // zoom
    grip = new SceneGrip();
    canvas.addMouseListener(grip);
    canvas.addMouseMoveListener(grip);
    canvas.addListener(SWT.MouseWheel, grip);
    canvas.addKeyListener(grip);
    // apparently opengl has to be redrawn constantly (why ?)
    Display.getCurrent().asyncExec(new Runnable() {

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                // Rectangle bounds = canvas.getBounds();
                /*
                 * canvasWidth = bounds.width; canvasHeight = bounds.height;
                 */
                // context.makeCurrent();
                // GL gl = context.getGL ();
                // gl.glClear(GL.GL_COLOR_BUFFER_BIT |
                // GL.GL_DEPTH_BUFFER_BIT);
                // gl.glClearColor(.0f, .0f, .0f, 1.0f); // black
                // background*/
                drawRelief();
                canvas.swapBuffers();

            }
        }
    });
}

From source file:fable.framework.ui.views.chiPlotView.java

License:Open Source License

/**
 * Build the list to display here//from w  w w. j av a2s. c  o m
 */
private static void drawReliefList() {

    if (!reliefListFirst) {
        GL11.glDeleteLists(reliefList, 1);
    }
    reliefListFirst = false;
    reliefList = GL11.glGenLists(1);
    GL11.glNewList(reliefList, GL11.GL_COMPILE);
    GL11.glColor3f(1.0f, 1.0f, 1.0f); // white
    GL11.glPointSize(pointSize);
    for (int i = 0; i < imageWidth - 1; i++) {
        GL11.glBegin(GL11.GL_LINE_STRIP);
        int j = i + 1;
        int color_index = (int) image[i];
        if (color_index < 0)
            color_index = 0;
        if (color_index > COLOR_INDEX_MAX)
            color_index = COLOR_INDEX_MAX;
        GL11.glColor3f(red[color_index], green[color_index], blue[color_index]); // temperature lut
        GL11.glVertex3f(i, image[i], image[j]);
        // System.out.println("i=" + i + ", j=" + j + " image[i]=" +
        // image[i] + " image[j]=" + image[j]);
        GL11.glEnd();
    }
    /*
     * gl.glBegin(GL.GL_TRIANGLES);
     * 
     * gl.glVertex3f(-1.0f, -0.5f, 0.0f); // lower left vertex
     * gl.glVertex3f( 1.0f, -0.5f, 0.0f); // lower right vertex
     * gl.glVertex3f( 0.0f, 0.5f, 0.0f); // upper vertex
     * 
     * gl.glEnd();
     */
    GL11.glEndList();
    GL11.glFlush();
}

From source file:fable.imageviewer.views.ReliefView.java

License:Open Source License

private void drawReliefList() {
    // long started = System.currentTimeMillis();
    if (!reliefListFirst) {
        GL11.glDeleteLists(reliefList, 1);
    }/*from   w  ww.  jav  a  2s.  c om*/
    reliefListFirst = false;
    reliefList = GL11.glGenLists(1);
    GL11.glNewList(reliefList, GL11.GL_COMPILE);
    GL11.glColor3f(1.0f, 1.0f, 1.0f); // white
    GL11.glPointSize(pointSize);
    for (int i = 0; i < imageWidth; i++) {
        GL11.glBegin(GL11.GL_LINE_STRIP);
        for (int j = 0; j < imageHeight; j++) {
            int color_index;
            color_index = (int) image[j * imageWidth + i];
            if (color_index < 0)
                color_index = 0;
            if (color_index > colorIndexMax)
                color_index = colorIndexMax;
            GL11.glColor3f(red[color_index], green[color_index], blue[color_index]); // temperature lut
            GL11.glVertex3f(i, j, image[j * imageWidth + i]);
        }
        GL11.glEnd();
    }
    for (int i = 0; i < imageHeight; i++) {
        GL11.glBegin(GL11.GL_LINE_STRIP);
        for (int j = 0; j < imageWidth; j++) {
            int color_index;
            color_index = (int) image[i * imageWidth + j];
            if (color_index < 0)
                color_index = 0;
            if (color_index > colorIndexMax)
                color_index = colorIndexMax;
            GL11.glColor3f(red[color_index], green[color_index], blue[color_index]); // temperature lut
            GL11.glVertex3f(j, i, image[i * imageWidth + j]);
        }
        GL11.glEnd();
    }
    GL11.glEndList();
    // long elapsed = System.currentTimeMillis()-started;
    // logger.debug("time to draw relief list "+elapsed+" ms");
}

From source file:fable.imageviewer.views.ReliefView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {

    thisView = this;
    parent.setLayout(new GridLayout(1, false));
    GridUtils.removeMargins(parent);/*ww w  .j av  a2s  .co m*/

    createActions();

    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new GLCanvas(comp, SWT.NONE, data);
    canvas.setSize(comp.getSize());
    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException ex) {
        FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex);
    }
    // context = GLDrawableFactory.getFactory().createExternalGLContext();
    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 ex) {
                FableUtils.excMsg(ReliefView.class, "Error in resize listener using GLContext.useContext", ex);
            }
            // context.makeCurrent();
            // GL11 gl = context.getGL ();
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            // GLU glu = new GLU();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
            drawRelief();
            canvas.swapBuffers();
            // context.release();
        }
    });
    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException ex) {
        FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex);
    }
    // GL11 gl = context.getGL ();
    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);
    // context.release();
    // create the grip for users to change the orientation, translation and
    // zoom
    grip = new SceneGrip(canvas, this);
    canvas.addMouseListener(grip);
    canvas.addMouseMoveListener(grip);
    canvas.addListener(SWT.MouseWheel, grip);
    canvas.addKeyListener(grip);
    // apparently opengl has to be redrawn constantly (why ?)
    Display.getCurrent().asyncExec(new Runnable() {
        // int rot = 0;
        public void run() {
            if (canvas == null)
                return;
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                Rectangle bounds = canvas.getBounds();
                grip.setBounds(bounds);
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException ex) {
                    FableUtils.excMsg(ReliefView.class,
                            "Error in createPartControl using " + "GLContext.useContext", ex);
                }
                // GL11 gl = context.getGL ();
                GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                GL11.glClearColor(.0f, .0f, .0f, 1.0f); // black background
                drawRelief();
                canvas.swapBuffers();
                // context.release();
                Display.getCurrent().timerExec(200, this);
            }
        }
    });

    createImageInformationPanel(parent);
}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void drawAxes() {
    GL11.glBegin(GL11.GL_LINES);//from w  w  w .  ja  v  a  2 s. co  m
    GL11.glColor3f(1, 0, 0);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(1, 0, 0);

    GL11.glColor3f(0, 1, 0);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(0, 1, 0);

    GL11.glColor3f(0, 0, 1);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(0, 0, 1);
    GL11.glEnd();
}

From source file:forestry.energy.render.RenderEngine.java

License:Open Source License

private void render(TemperatureState state, float progress, ForgeDirection orientation, double x, double y,
        double z) {

    GL11.glPushMatrix();/*from   www.  j av a 2  s. c  o m*/
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor3f(1, 1, 1);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    float step;

    if (progress > 0.5) {
        step = 5.99F - (progress - 0.5F) * 2F * 5.99F;
    } else {
        step = progress * 2F * 5.99F;
    }

    float tfactor = step / 16;

    float[] angle = { 0, 0, 0 };
    float[] translate = { orientation.offsetX, orientation.offsetY, orientation.offsetZ };

    switch (orientation) {
    case EAST:
    case WEST:
    case DOWN:
        angle[2] = angleMap[orientation.ordinal()];
        break;
    case SOUTH:
    case NORTH:
    default:
        angle[0] = angleMap[orientation.ordinal()];
        break;
    }

    boiler.rotateAngleX = angle[0];
    boiler.rotateAngleY = angle[1];
    boiler.rotateAngleZ = angle[2];

    trunk.rotateAngleX = angle[0];
    trunk.rotateAngleY = angle[1];
    trunk.rotateAngleZ = angle[2];

    piston.rotateAngleX = angle[0];
    piston.rotateAngleY = angle[1];
    piston.rotateAngleZ = angle[2];

    extension.rotateAngleX = angle[0];
    extension.rotateAngleY = angle[1];
    extension.rotateAngleZ = angle[2];

    float factor = (float) (1.0 / 16.0);

    Proxies.common.bindTexture(textures[Textures.BASE.ordinal()]);
    boiler.render(factor);

    Proxies.common.bindTexture(textures[Textures.PISTON.ordinal()]);
    GL11.glTranslatef(translate[0] * tfactor, translate[1] * tfactor, translate[2] * tfactor);
    piston.render(factor);
    GL11.glTranslatef(-translate[0] * tfactor, -translate[1] * tfactor, -translate[2] * tfactor);

    ResourceLocation texture;

    switch (state) {
    case OVERHEATING:
        texture = textures[Textures.TRUNK_HIGHEST.ordinal()];
        break;
    case RUNNING_HOT:
        texture = textures[Textures.TRUNK_HIGHER.ordinal()];
        break;
    case OPERATING_TEMPERATURE:
        texture = textures[Textures.TRUNK_HIGH.ordinal()];
        break;
    case WARMED_UP:
        texture = textures[Textures.TRUNK_MEDIUM.ordinal()];
        break;
    case COOL:
    default:
        texture = textures[Textures.TRUNK_LOW.ordinal()];
        break;

    }
    Proxies.common.bindTexture(texture);
    trunk.render(factor);

    Proxies.common.bindTexture(textures[Textures.EXTENSION.ordinal()]);
    float chamberf = 2F / 16F;

    if (step > 0) {
        for (int i = 0; i <= step + 2; i += 2) {
            extension.render(factor);
            GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
        }
    }

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DCircle.java

License:Open Source License

private void drawCircle() {
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);//from ww  w .  j av  a  2s. c  o m

    if (customColor) {
        GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor3f(innerColor.r, innerColor.g, innerColor.b);
    }
    GL11.glVertex3f(0.0f, 0.0f, 0.0f); // center

    float step = 2f * (float) Math.PI / (float) quality;
    if (customColor) {

        GL11.glColor4f(outerColor.r, outerColor.g, outerColor.b, outerColor.a);
    }

    for (int i = 0; i <= quality; i++) {
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }

    if (customColor) {

        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glPopAttrib();
    }

    GL11.glEnd();

}

From source file:fr.ign.cogit.geoxygene.appli.render.primitive.MillPrimitiveRenderer.java

License:Open Source License

/**
 * Render one drawing primitive//from w w w. j  av a  2 s.co m
 * @param primitive
 * @throws RenderingException
 */
private void render(final DrawingPrimitive primitive) throws RenderingException {
    // TODO: create a class PrimitiveManipulatorEngine that do the job

    // compute parameter value to cut in world space coordinates
    double stroke = 5 * this.getViewport().getScale();
    //    ResamplerOperator resampler = new ResamplerOperator(0.5);
    CutterOperator cutter = new CutterOperator(15, 10);
    try {
        cutter.addInput(primitive);
    } catch (InvalidOperatorInputException e) {
        throw new RenderingException(e);
    }
    DrawingPrimitive resultingPrimitive = cutter.apply();

    RotateOperator rotator = new RotateOperator(Math.PI / 4.);
    try {
        rotator.addInput(resultingPrimitive);
    } catch (InvalidOperatorInputException e) {
        throw new RenderingException(e);
    }
    resultingPrimitive = rotator.apply();

    GL11.glColor3f(0.f, 0.f, 0.f);
    GL11.glLineWidth(1.f);
    this.chainedRenderer.removeAllPrimitives();
    this.chainedRenderer.addPrimitive(resultingPrimitive);
    this.chainedRenderer.render();

    //    GLPrimitivePointRenderer pointRenderer = new GLPrimitivePointRenderer();
    //    pointRenderer.setViewport(this.getViewport());
    //
    //    pointRenderer.removeAllPrimitive();
    //    pointRenderer.addPrimitive(primitive);
    //    pointRenderer.render();
}

From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderTheDeath.java

License:Creative Commons License

protected void renderTheDeathEquippedItems(MobThedeath living, float par2) {
    float f1 = 1.0F;
    GL11.glColor3f(f1, f1, f1);
    super.renderEquippedItems(living, par2);
    ItemStack itemstack = living.getHeldItem();
    float f2;//from   w w  w . j  a  va  2s  . c o  m

    if (itemstack != null) {
        GL11.glPushMatrix();

        if (this.mainModel.isChild) {
            f2 = 0.5F;
            GL11.glTranslatef(0.0F, 0.625F, 0.0F);
            GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F);
            GL11.glScalef(f2, f2, f2);
        }

        GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);

        IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED);
        boolean is3D = (customRenderer != null
                && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D));

        if (itemstack.getItem().equals(NanotechItem.scythe)) {
            GL11.glRotatef(120F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(160F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(-15F, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0.5F, 1.0F, 1.3F);
        } else if (itemstack.getItem().isFull3D()) {
            f2 = 0.625F;

            if (itemstack.getItem().shouldRotateAroundWhenRendering()) {
                GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
                GL11.glTranslatef(0.0F, -0.125F, 0.0F);
            }

            GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
            GL11.glScalef(f2, -f2, f2);
            GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        } else {
            f2 = 0.375F;
            GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
            GL11.glScalef(f2, f2, f2);
            GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
        }

        this.renderManager.itemRenderer.renderItem(living, itemstack, 0);

        if (itemstack.getItem().requiresMultipleRenderPasses()) {
            for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) {
                this.renderManager.itemRenderer.renderItem(living, itemstack, x);
            }
        }

        GL11.glPopMatrix();
    }
}

From source file:fr.theshark34.sharkengine.ui.components.Checkbox.java

License:Apache License

/**
 * Draw the checkbox//from  ww w.ja v  a2  s .com
 */
public void draw() {
    // Enabling blending
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // Being sure that texturing is disabled
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    // Picking white color
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    // Drawing the checkbox
    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glVertex2f(x, y);
        GL11.glVertex2f(x + width, y);
        GL11.glVertex2f(x + width, y + height);
        GL11.glVertex2f(x, y + height);
    }
    GL11.glEnd();

    // Drawing the text
    this.font.drawString(x + 25, y + (this.height - this.font.getHeight(text)) / 2, text);

    // Being sure that texturing is enabled
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    // If the mouse is on the checkbox
    if (Mouse.getX() > this.x && Mouse.getX() < this.x + this.width
            && Mouse.getY() < Display.getHeight() - this.y
            && Mouse.getY() > Display.getHeight() - this.y - this.height)
        // If the mouse clicked and clicked is false, setting coched
        // to its oposite and setting clicked to true, so it will do
        // it one time
        if (Mouse.isButtonDown(0)) {
            if (!clicked) {
                clicked = true;
                coched = !coched;
            }
        } else
            // If mouse isn't on it, setting clicked to false
            clicked = false;

    // Checking if the checkbox is coched
    if (coched) {
        // Drawing coched checkbox texture
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, cochedcb.getTextureID());

        // Drawing the image
        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glTexCoord2f(0.0f, 0.0f);
            GL11.glVertex2f(x, y);
            GL11.glTexCoord2f(1.0f, 0.0f);
            GL11.glVertex2f(x + width, y);
            GL11.glTexCoord2f(1.0f, 1.0f);
            GL11.glVertex2f(x + width, y + height);
            GL11.glTexCoord2f(0.0f, 1.0f);
            GL11.glVertex2f(x, y + height);
        }
        GL11.glEnd();
    }

    // Disabling texture
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    // Disabling blending
    GL11.glDisable(GL11.GL_BLEND);
}