Example usage for org.lwjgl.opengl GL11 glShadeModel

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

Introduction

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

Prototype

public static native void glShadeModel(@NativeType("GLenum") int mode);

Source Link

Document

Sets the current shade mode.

Usage

From source file:dracocore.handbook.helpers.RenderHelper.java

License:Creative Commons License

public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
    final float var7 = ((par5 >> 24) & 255) / 255F;
    final float var8 = ((par5 >> 16) & 255) / 255F;
    final float var9 = ((par5 >> 8) & 255) / 255F;
    final float var10 = (par5 & 255) / 255F;
    final float var11 = ((par6 >> 24) & 255) / 255F;
    final float var12 = ((par6 >> 16) & 255) / 255F;
    final float var13 = ((par6 >> 8) & 255) / 255F;
    final float var14 = (par6 & 255) / 255F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from  w  ww.j av  a2s  .  c o m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    final Tessellator var15 = Tessellator.instance;
    var15.startDrawingQuads();
    var15.setColorRGBA_F(var8, var9, var10, var7);
    var15.addVertex(par3, par2, z);
    var15.addVertex(par1, par2, z);
    var15.setColorRGBA_F(var12, var13, var14, var11);
    var15.addVertex(par1, par4, z);
    var15.addVertex(par3, par4, z);
    var15.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java

License:Apache License

protected void initializeOpenGl() {
    DisplayMode displayMode = displayManager.getCurrentDisplayMode();

    GL11.glEnable(GL11.GL_DEPTH_TEST);/*  ww w.  j  av a 2 s  . c o m*/
    GL11.glClearDepth(1.0f);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    //GLU.gluPerspective(45.0f, (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 4.0f, 4000.0f);
    GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 100.0f);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    //GL11.glClearDepth(1.0f);

    //GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    //GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
}

From source file:espresso3d.engine.E3DEngine.java

License:Open Source License

private void initGL() {
    logger.writeLine(E3DEngineLogger.SEVERITY_INFO, "Initializing OpenGL");

    GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background  
    GL11.glClearDepth(1.0); // Depth Buffer Setup
    GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
    GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate
}

From source file:eu.over9000.veya.gui.Gui.java

License:Open Source License

private static void setUpStates(final int width, final int height) {
     try {/*  ww  w.j  a v  a  2 s. co  m*/
         Display.setDisplayMode(new DisplayMode(width, height));

         Display.create();
         //Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3));
         Display.setVSyncEnabled(true);
     } catch (final LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
     }

     GL11.glEnable(GL11.GL_TEXTURE_2D);
     GL11.glShadeModel(GL11.GL_SMOOTH);
     GL11.glDisable(GL11.GL_DEPTH_TEST);
     GL11.glDisable(GL11.GL_LIGHTING);

     GL11.glClearColor(0.0f, 0.3f, 0.0f, 0.0f);
     GL11.glClearDepth(1);

     GL11.glEnable(GL11.GL_BLEND);
     GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

     GL11.glViewport(0, 0, width, height);
     GL11.glMatrixMode(GL11.GL_MODELVIEW);

     GL11.glMatrixMode(GL11.GL_PROJECTION);
     GL11.glLoadIdentity();
     GL11.glOrtho(0, width, height, 0, 1, -1);
     GL11.glMatrixMode(GL11.GL_MODELVIEW);
 }

From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java

License:Open Source License

/**
 * Sets up the screen.// w w w .  j  a  v  a 2 s  .co m
 *
 * @see javax.media.openGL11.GLEventListener#init(javax.media.openGL11.GLAutoDrawable)
 */
public void init() {
    try {

        frame = new JFrame("Space agencies");
        //frame.setSize(width,height);
        //frame.setUndecorated(true);  //here
        frame.setVisible(true);
        //frame.setAlwaysOnTop(true);
        frame.setLocation(0, 0);
        Canvas canvas = new Canvas();
        canvas.setMinimumSize(new Dimension(800, 600));
        canvas.setPreferredSize(new Dimension(width, height));
        frame.add(canvas);
        frame.pack();
        frame.addWindowListener(generateWindowListener());

        frame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsListener() {

            @Override
            public void ancestorMoved(HierarchyEvent e) {
            }

            @Override
            public void ancestorResized(HierarchyEvent e) {
                width = frame.getContentPane().getWidth();
                height = frame.getContentPane().getHeight();
                reshape(0, 0, width, height);
            }
        });

        Display.setDisplayMode(new DisplayMode(width, height));
        //Display.setFullscreen(true);
        Display.setVSyncEnabled(false);
        Display.setTitle("Space agencies");
        Display.setParent(canvas);
        Display.create();
        canvas.requestFocus();
    } catch (Exception e) {
        System.out.println("Error setting up display" + e);
        System.exit(0);
    }

    // Enable z- (depth) buffer for hidden surface removal.
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_POINT_SMOOTH);

    if (polygonOffset) {
        GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
        GL11.glPolygonOffset(1.0f, 1.0f);
    }
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);

    // Enable smooth shading.
    GL11.glShadeModel(GL11.GL_SMOOTH);

    // Define "clear" color.
    GL11.glClearColor(0f, 0f, 0.4f, 0f);

    // We want a nice perspective.
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glFlush();

    TextureManager.clearCache();
    initied = true;

    //        new LWJGLBinding();

}

From source file:graphics.Graph.java

@Override
public void draw() {
    //if (this.changed) {
    setMinMax();//from www.  ja  v a  2s  . co m
    float margin = 20;
    // White backdrop...
    GL11.glColor3f(1, 1, 1);
    GL11.glBegin(GL11.GL_POLYGON);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Black lines around...
    GL11.glColor3f(0, 0, 0);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Moves origo where it should be, based on the dataset...
    GL11.glColor4f(0, 0, 0, 0.25f);
    float origo = this.yPos + 2 * margin;
    if (maxValue == 0 && minValue == 0) {
        origo += (this.sizeY - 3 * margin) / 2;
    } else if (maxValue <= 0 && minValue < 0) {
        origo += this.sizeY - 3 * margin;
    } else if (maxValue > 0 && minValue < 0) {
        origo += ((minValue * -1) / (maxValue + (minValue * -1))) * (this.sizeY - 3 * margin);
    }
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(this.xPos + margin, origo);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, origo);
    GL11.glEnd();

    // draws tabs on the origo-line where the values should be put...
    float tabs = 5;
    for (int i = 0; i < dataValues.length; i++) {
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo + tabs);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo - tabs);
        GL11.glEnd();
    }
    Line2D.Double[] lines = new Line2D.Double[dataValues.length - 1];
    for (int i = 0; i < lines.length; i++) {
        if (dataValues[i] == null) {
            continue;
        }
        float x = this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        float x2 = this.xPos + margin + ((i + 1) * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y2 = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i + 1].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        lines[i] = new Line2D.Double(x, y, x2, y2);
    }

    // Draws the value-lines on the graph...
    Line2D.Double origLine = new Line2D.Double(this.xPos + margin, origo,
            this.xPos + margin + (this.sizeX - 2 * margin), origo);
    GL11.glLineWidth(2);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (Line2D.Double line : lines) {
        if (line == null) {
            continue;
        }
        if (line.intersectsLine(origLine)) {
            Point2D interSect = getIntersection(line, origLine);
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        } else {
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        }
    }
    GL11.glEnd();
    GL11.glLineWidth(1);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    // Black lines around box inside the graph...
    GL11.glColor4f(0, 0, 0, 1);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos + margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + this.sizeY - margin);
    GL11.glVertex2f(this.xPos + margin, this.yPos + this.sizeY - margin);
    GL11.glEnd();

    //this.changed = false;
    origLine = null;
    //}
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void renderLightRayEffects(double x, double y, double z, Color effectColor, long seed,
        long continuousTick, int dstJump, float scale, int countFancy, int countNormal) {
    rand.setSeed(seed);/*  w w  w.ja v a 2  s  .  com*/
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);

    int fancy_count = !FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? countNormal
            : countFancy;

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    RenderHelper.disableStandardItemLighting();
    float f1 = continuousTick / 400.0F;
    float f2 = 0.4F;

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(false);
    GL11.glPushMatrix();
    for (int i = 0; i < fancy_count; i++) {
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F + f1 * 360.0F, 0.0F, 0.0F, 1.0F);
        vb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float fa = rand.nextFloat() * 20.0F + 5.0F + f2 * 10.0F;
        float f4 = rand.nextFloat() * 2.0F + 1.0F + f2 * 2.0F;
        fa /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        f4 /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        vb.pos(0, 0, 0).color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(),
                (int) (255.0F * (1.0F - f2))).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.0D, fa, 1.0F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        tes.draw();
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    RenderHelper.enableStandardItemLighting();

    GL11.glPopMatrix();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void drawGradientRect(int x, int y, float z, int toX, int toY, Color color, Color colorFade) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from   ww  w . j  ava  2 s . com
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    vb.pos(toX, y, z).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
    vb.pos(x, y, z).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
    vb.pos(x, toY, z).color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha())
            .endVertex();
    vb.pos(toX, toY, z)
            .color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha())
            .endVertex();
    tes.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:hexagonalminesweeper.HexagonalMinesweeper.java

public static void renderGL() {
    try {/*from w w w  .j a v  a2  s.  co m*/
        Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600));
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, 800, 600);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Display.setVSyncEnabled(true);
}

From source file:io.flob.clicker.DisplayDriver.java

License:Open Source License

private void init_GL() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();// w w  w .j  a va  2  s  .c  o  m
    GL11.glOrtho(0, width, height, 0, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}