Example usage for org.lwjgl.opengl GL11 glClear

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

Introduction

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

Prototype

public static void glClear(@NativeType("GLbitfield") int mask) 

Source Link

Document

Sets portions of every pixel in a particular buffer to the same value.

Usage

From source file:net.codepixl.GLCraft.GLCraft.java

License:Open Source License

public static void renderSplashText(String line1, String line2) {
    if (!getGLCraft().isServer) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        Tesselator.drawString(Constants.getWidth() / 2 - Tesselator.getFontWidth(line1) / 2,
                Constants.getHeight() / 2 - Tesselator.getFontHeight(line1) / 2, line1);
        Tesselator.drawString(Constants.getWidth() / 2 - Tesselator.getFontWidth(line2) / 2,
                Constants.getHeight() / 2 + Tesselator.getFontHeight(line2) / 2 + 10, line2);
        Spritesheet.logo.bind();/*  ww  w. ja v  a  2 s .com*/
        Shape.currentSpritesheet = Spritesheet.logo;
        glBegin(GL_QUADS);
        Shape.createCenteredRect2D(Constants.getWidth() / 2,
                Constants.getHeight() / 2 - Tesselator.getFontHeight() * 2 - 30, Color4f.WHITE,
                new float[] { 0, 0, 1, 1 }, 200f, 100f);
        glEnd();
        TextureImpl.unbind();
        Display.update();
    }
}

From source file:net.fabricmc.base.launch.FabricClientTweaker.java

License:Apache License

private void createEarlyDisplay() {
    File gameDir = new File(args.get("--gameDir"));
    Properties def = new Properties();
    def.setProperty("fullscreen", "false");
    def.setProperty("overrideWidth", "0");
    def.setProperty("overrideHeight", "0");
    Properties props = new Properties(def);
    try {//  w  w  w.  j a  v  a2 s  .c om
        props.load(Files.newReader(new File(gameDir, "options.txt"), StandardCharsets.UTF_8));
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
        e.printStackTrace();
    }
    boolean fullscreen = args.containsKey("--fullscreen")
            || Boolean.parseBoolean(props.getProperty("fullscreen"));
    int overrideWidth = Integer.parseInt(props.getProperty("overrideWidth"));
    int overrideHeight = Integer.parseInt(props.getProperty("overrideHeight"));
    int width = 854;
    int height = 480;
    if (overrideWidth > 0) {
        width = overrideWidth;
    } else if (args.containsKey("--width")) {
        width = Math.max(1, Integer.parseInt(args.get("--width")));
    }
    if (overrideHeight > 0) {
        height = overrideHeight;
    } else if (args.containsKey("--height")) {
        height = Math.max(1, Integer.parseInt(args.get("--height")));
    }
    String ver = args.get("--version");
    if (ver == null) {
        ver = "Unknown";
    } else {
        int index = ver.indexOf('-');
        if (index != -1) {
            ver = ver.substring(0, index);
        }
    }
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setFullscreen(fullscreen);
        Display.setResizable(true);
        Display.setTitle("Minecraft " + ver);
        try {
            Display.create(new PixelFormat().withDepthBits(24));
        } catch (LWJGLException e) {
            e.printStackTrace();
            Display.create();
        }
        GL11.glClearColor(1, 1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        Display.update();
    } catch (LWJGLException e1) {
        e1.printStackTrace();
        Throwables.propagate(e1);
    }
}

From source file:net.kubin.game.StartupManager.java

License:Apache License

public void openMainMenu() {
    MainMenu menu = new MainMenu();

    try {/*from  w w  w . j  a va  2  s .  c om*/
        GUIManager.renderer = new LWJGLRenderer();
    } catch (LWJGLException ex) {
        Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
    }

    GUIManager.gui = new GUI(menu, GUIManager.renderer);

    //menu.efName.requestKeyboardFocus();

    try {
        GUIManager.theme = ThemeManager.createThemeManager(MainMenu.class.getResource("/UITheme/Theme.xml"),
                GUIManager.renderer);
        //MainMenu.class.getResource("menu.xml"), GUIManager.renderer);
    } catch (IOException ex) {
        Logger.getLogger(StartupManager.class.getName()).log(Level.SEVERE, null, ex);
    }

    GUIManager.gui.applyTheme(GUIManager.theme);

    menu.timer = 0;

    if (!Kubin.DISPLAY_SPLASH) {
        menu.splash = false;
        menu.timer = 200;
    }

    while (!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
            && GUIManager.requestStop == false) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        GUIManager.gui.update();

        //Display Splash Screen
        if (menu.timer == 200) {
            menu.splash = false;
            menu.layout();
            menu.timer = -1;
        } else if (menu.timer != -1) {
            menu.timer += 1;
        }

        //Handle Resizing
        if (Display.wasResized()) {
            handleResize();
        }

        Display.update();
    }

    GUIManager.gui.destroy();
    GUIManager.theme.destroy();
    //Display.destroy();
}

From source file:net.kubin.world.characters.Player.java

License:Apache License

@Override
public void render() {

    GL11.glEnable(GL11.GL_DEPTH_TEST);//  w ww  .jav  a  2s  . c o m
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

    if (_aimedBlockPosition.y() != -1) {
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glDisable(GL11.GL_TEXTURE_2D);

        _aimedBlockAABB.render(0.0f, 0.0f, 0.0f, 0.2f);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (_selectedItem != null) {
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_CULL_FACE);

        _body.transformToRightHand();

        /* Prepare the light buffer */
        Chunk c = Game.getInstance().getWorld().getChunkManager().getChunkContaining(
                MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1,
                MathHelper.floor(_position.z()), false, false, false);

        if (c != null) {
            c.getLightBuffer().setReferencePoint(MathHelper.floor(_position.x()),
                    MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z()));

            /* Render the object, with the lightbuffer */
            _selectedItem.renderHoldableObject(c.getLightBuffer());
        }

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:net.minecraft.client.gui.GuiAchievement.java

private void updateAchievementWindowScale() {
    GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight);
    GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
    GL11.glLoadIdentity();/*  w w  w  . j  a  v  a  2  s . c o m*/
    GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
    GL11.glLoadIdentity();
    this.achievementWindowWidth = this.theGame.displayWidth;
    this.achievementWindowHeight = this.theGame.displayHeight;
    ScaledResolution var1 = new ScaledResolution(this.theGame.gameSettings, this.theGame.displayWidth,
            this.theGame.displayHeight);
    this.achievementWindowWidth = var1.getScaledWidth();
    this.achievementWindowHeight = var1.getScaledHeight();
    GL11.glClear(256);
    GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, (double) this.achievementWindowWidth, (double) this.achievementWindowHeight, 0.0D,
            1000.0D, 3000.0D);
    GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
}

From source file:net.neilcsmith.praxis.video.opengl.internal.GLRenderer.java

License:Apache License

public void clear() {
    activate();/*from w  w w.ja va 2 s. c om*/
    tex0 = null;
    idx = 0;
    if (surface == null) {
        LOGGER.finest("Clearing screen");
        GL11.glClearColor(0, 0, 0, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    } else {
        LOGGER.finest("Clearing surface");
        if (surface.hasAlpha()) {
            GL11.glClearColor(0, 0, 0, 0);
        } else {
            GL11.glClearColor(0, 0, 0, 1);
        }
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    }
}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void cls() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:net.slimevoid.tmf.client.tickhandlers.MotionSensorTickHandler.java

License:Open Source License

private void renderHUD(EntityPlayer entityplayer) {
    double playerDeg = entityplayer.rotationYaw % 360;
    if (playerDeg < 0)
        playerDeg = 360 + playerDeg;/*from  w w  w  .jav a 2 s.c  om*/
    playerDeg *= -1;

    float opacity = 0.5f;

    GL11.glPushMatrix();
    ScaledResolution sr = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(256);

    GL11.glPushMatrix();
    // RenderHelper.enableGUIStandardItemLighting();
    // GL11.glDisable(GL11.GL_LIGHTING);
    // GL11.glDisable(GL11.GL_DEPTH_TEST);
    if (drawOnRight) {
        GL11.glTranslatef(sr.getScaledWidth() - 60, sr.getScaledHeight(), 0);
    } else {
        GL11.glTranslatef(60, sr.getScaledHeight(), 0);
    }
    GL11.glRotatef((float) playerDeg, 0, 0, 1.0f);

    renderSprite(-64, -64, 0, 0, 128, 128, ResourceLib.TRACKER_BG, 1);
    // GL11.glEnable(GL11.GL_LIGHTING);
    // GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:net.slimevoid.tmf.client.tickhandlers.MotionSensorTickHandler.java

License:Open Source License

private void renderPing(double deltaTick, double angle, double distSq2d) {
    float opacity = 0.5f;

    GL11.glPushMatrix();/*from  w ww  .  j  ava2 s.c  o  m*/
    ScaledResolution sr = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(256);

    GL11.glPushMatrix();
    // RenderHelper.enableGUIStandardItemLighting();
    // GL11.glDisable(GL11.GL_LIGHTING);
    // GL11.glDisable(GL11.GL_DEPTH_TEST);

    if (drawOnRight) {
        GL11.glTranslatef(sr.getScaledWidth() - 60, sr.getScaledHeight(), 0);
    } else {
        GL11.glTranslatef(60, sr.getScaledHeight(), 0);
    }
    double angdeg = rad2deg(angle);
    angdeg = angdeg - 90;

    GL11.glRotatef((float) angdeg, 0, 0, 1);

    GL11.glTranslatef((float) Math.sqrt(distSq2d) * 3, 0, 0);
    GL11.glScalef(0.0625f, 0.0625f, 1);

    renderSprite(-64, -64, 0, 0, 128, 128, ResourceLib.TRACKER_CONTACT,
            (float) (0.4d + Math.log(3.2d - deltaTick * 3d) * 0.6d));
    // GL11.glEnable(GL11.GL_LIGHTING);
    // GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:net.slimevoid.tmf.client.tickhandlers.MotionSensorTickHandler.java

License:Open Source License

private void renderSweep(EntityPlayer entityplayer, double deltaTick) {
    float opacity = 0.5f;

    GL11.glPushMatrix();//w w  w  .  j  a v  a2  s  . co  m
    ScaledResolution sr = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(256);

    GL11.glPushMatrix();
    // RenderHelper.enableGUIStandardItemLighting();
    // GL11.glDisable(GL11.GL_LIGHTING);
    // GL11.glDisable(GL11.GL_DEPTH_TEST);
    if (drawOnRight) {
        GL11.glTranslatef(sr.getScaledWidth() - 60, sr.getScaledHeight(), 0);
    } else {
        GL11.glTranslatef(60, sr.getScaledHeight(), 0);
    }
    GL11.glScalef((float) deltaTick, (float) deltaTick, 1);

    renderSprite(-64, -64, 0, 0, 128, 128, ResourceLib.TRACKER_SWEEP, (float) (1d - deltaTick / 2d));
    // GL11.glEnable(GL11.GL_LIGHTING);
    // GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}