Example usage for org.lwjgl.opengl GL13 GL_MULTISAMPLE

List of usage examples for org.lwjgl.opengl GL13 GL_MULTISAMPLE

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL13 GL_MULTISAMPLE.

Prototype

int GL_MULTISAMPLE

To view the source code for org.lwjgl.opengl GL13 GL_MULTISAMPLE.

Click Source Link

Document

Accepted by the cap parameter of Enable, Disable, and IsEnabled, and by the pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.

Usage

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawStrip(int x, int y, float width, double angle, float points, float radius, int color) {
    GL11.glPushMatrix();//from   w  w  w. j a v a 2  s .  co  m
    float f1 = (float) (color >> 24 & 255) / 255.0F;
    float f2 = (float) (color >> 16 & 255) / 255.0F;
    float f3 = (float) (color >> 8 & 255) / 255.0F;
    float f4 = (float) (color & 255) / 255.0F;
    GL11.glTranslatef(x, y, 0);
    GL11.glColor4f(f2, f3, f4, f1);
    GL11.glLineWidth(width);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL13.GL_MULTISAMPLE);

    if (angle > 0) {
        GL11.glBegin(GL11.GL_LINE_STRIP);

        for (int i = 0; i < angle; i++) {
            float a = (float) (i * (angle * Math.PI / points));
            float xc = (float) (Math.cos(a) * radius);
            float yc = (float) (Math.sin(a) * radius);
            GL11.glVertex2f(xc, yc);
        }

        GL11.glEnd();
    }

    if (angle < 0) {
        GL11.glBegin(GL11.GL_LINE_STRIP);

        for (int i = 0; i > angle; i--) {
            float a = (float) (i * (angle * Math.PI / points));
            float xc = (float) (Math.cos(a) * -radius);
            float yc = (float) (Math.sin(a) * -radius);
            GL11.glVertex2f(xc, yc);
        }

        GL11.glEnd();
    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL13.GL_MULTISAMPLE);
    GL11.glDisable(GL11.GL_MAP1_VERTEX_3);
    GL11.glPopMatrix();
}

From source file:com.samrj.devil.game.Game.java

License:Open Source License

/**
 * Creates a new game object. Initializes the window with the given config.
 * /*from  ww w . ja v  a  2s.c o  m*/
 * @param title The title of the window.
 * @param hints The window hints to use.
 * @param config The configuration to use.
 */
public Game(String title, HintSet hints, GameConfig config) {
    if (title == null || config == null)
        throw new NullPointerException();
    if (!initialized)
        throw new IllegalStateException("Game.init() not called.");
    ensureMainThread();

    // <editor-fold defaultstate="collapsed" desc="Initialize Window">
    {
        GLFW.glfwDefaultWindowHints();
        GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GL11.GL_FALSE);
        GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GL11.GL_FALSE);
        GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, config.borderless ? GL11.GL_FALSE : GL11.GL_TRUE);
        GLFW.glfwWindowHint(GLFW.GLFW_FLOATING, GL11.GL_FALSE);
        GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 0);
        if (config.msaa > 0)
            GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, config.msaa);
        if (hints != null)
            hints.glfw();

        GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GL11.GL_TRUE);

        monitor = config.fullscreen ? GLFW.glfwGetPrimaryMonitor() : 0;
        window = GLFW.glfwCreateWindow(config.resolution.x, config.resolution.y, title, monitor, 0);

        GLFW.glfwMakeContextCurrent(window);
        GLFW.glfwSwapInterval(config.vsync ? 1 : 0);
        GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);
    }

    if (!config.fullscreen) //Center window
    {
        Vec2i windowSize = GLFWUtil.getWindowSize(window);
        GLFWVidMode mode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());

        GLFW.glfwSetWindowPos(window, (mode.width() - windowSize.x) / 2, (mode.height() - windowSize.y) / 2);
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Initialize OpenGL Context">
    {
        capabilities = GL.createCapabilities();
        GL11.glViewport(0, 0, config.resolution.x, config.resolution.y);
        GL11.glDisable(GL13.GL_MULTISAMPLE);
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Initialize Sync">
    {
        if (!config.vsync && config.fps > 0) {
            sync = new Sync(config.fps, config.sleeper);
            frameTime = sync.getFrameTime();
        } else {
            sync = null;
            GLFWVidMode mode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
            frameTime = Math.round(1_000_000_000.0 / mode.refreshRate());
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Initialize Input">
    {
        mouse = new Mouse(window, this::onMouseMoved, this::onMouseButton, this::onMouseScroll);
        mouse.setGrabbed(false);
        keyboard = new Keyboard(this::onKey);
        eventBuffer = new EventBuffer(window, mouse, keyboard);
    }
    // </editor-fold>
    stepper = config.stepper;
}

From source file:com.xrbpowered.gl.examples.GLLights.java

License:Open Source License

@Override
protected void setupResources() {
    super.setupResources();
    postProc = new PostProcessShader("post_hdr_f.glsl");

    diffuse = BufferTexture.createPlainColor(4, 4, new Color(0x99bbdd));
    specular = BufferTexture.createPlainColor(4, 4, new Color(0xaaaaaa));
    normal = new Texture("normal.jpg");
    globeShader = new GlobeShader();

    plane = FastMeshBuilder.plane(PLANE_SIZE, 1, 4, StandardShader.standardVertexInfo, null);
    planeActor = StaticMeshActor.make(scene, plane, StandardShader.getInstance(), diffuse, specular, normal);
    planeActor.position.y = PLANE_Y;//from w  ww .j av a  2  s .c  om
    planeActor.updateTransform();

    Random random = new Random();
    objects = new StaticMesh[NUM_OBJECTS];
    objectActors = new StaticMeshActor[NUM_OBJECTS];
    for (int i = 0; i < NUM_OBJECTS; i++) {
        float r = random.nextFloat() + 0.5f;
        objects[i] = FastMeshBuilder.sphere(r, 16, StandardShader.standardVertexInfo, null);
        objectActors[i] = StaticMeshActor.make(scene, objects[i], StandardShader.getInstance(), diffuse,
                specular, normal);
        float d = PLANE_SIZE / 2f - r;
        objectActors[i].position.x = random.nextFloat() * d * 2f - d;
        objectActors[i].position.y = PLANE_Y + r;
        objectActors[i].position.z = random.nextFloat() * d * 2f - d;
        objectActors[i].updateTransform();
    }
    lightGlobes = new StaticMesh[NUM_LIGHTS];
    lightActors = new StaticMeshActor[NUM_LIGHTS];
    lightColors = new Vector4f[NUM_LIGHTS];
    for (int i = 0; i < NUM_LIGHTS; i++) {
        lightGlobes[i] = FastMeshBuilder.sphere(0.1f, 8, StandardShader.standardVertexInfo, null);
        lightActors[i] = StaticMeshActor.make(scene, lightGlobes[i], StandardShader.getInstance(), specular,
                specular, plainNormalTexture);
        lightActors[i].setShader(globeShader);
        lightActors[i].position.x = random.nextFloat() * PLANE_SIZE - PLANE_SIZE / 2f;
        lightActors[i].position.y = -1f + random.nextFloat() * 2f;
        lightActors[i].position.z = random.nextFloat() * PLANE_SIZE - PLANE_SIZE / 2f;
        lightActors[i].updateTransform();
        Color color = Color.getHSBColor(i / (float) NUM_LIGHTS, 1f, 1f);
        lightColors[i] = new Vector4f(color.getRed() * LIGHT_POWER / 255f,
                color.getGreen() * LIGHT_POWER / 255f, color.getBlue() * LIGHT_POWER / 255f, 1f);
    }

    StandardShader.environment.ambientColor.set(0, 0, 0);
    StandardShader.environment.lightColor.set(0.2f, 0.2f, 0.2f);
    lightController = new Controller().setActor(lightActors[0]);

    GL11.glEnable(GL13.GL_MULTISAMPLE);
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public void updateMSAAState(boolean msaa) {
    if (msaa) {// ww w  .  j ava2 s  .  c om
        GL11.glEnable(GL13.GL_MULTISAMPLE);
    } else {
        GL11.glDisable(GL13.GL_MULTISAMPLE);
    }
}

From source file:org.jogamp.glg2d.impl.gl2.GL2ShapeDrawer.java

License:Apache License

@Override
public void setHint(Key key, Object value) {
    super.setHint(key, value);

    if (key == RenderingHints.KEY_ANTIALIASING) {
        if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
            GL11.glEnable(GL13.GL_MULTISAMPLE);
        } else {/*from   w ww  .j  a v  a 2  s. c om*/
            GL11.glDisable(GL13.GL_MULTISAMPLE);
        }
    }
}

From source file:tk.wurst_client.features.mods.TrajectoriesMod.java

License:Open Source License

@Override
public void onRender() {
    EntityPlayerSP player = mc.player;/*from  ww w .  ja  va  2  s  .c  o  m*/

    // check if player is holding item
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null)
        return;

    // check if item is throwable
    Item item = stack.getItem();
    if (!(item instanceof ItemBow || item instanceof ItemSnowball || item instanceof ItemEgg
            || item instanceof ItemEnderPearl || item instanceof ItemSplashPotion
            || item instanceof ItemLingeringPotion || item instanceof ItemFishingRod))
        return;

    boolean usingBow = player.inventory.getCurrentItem().getItem() instanceof ItemBow;

    // calculate starting position
    double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks
            - MathHelper.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    double arrowPosY = player.lastTickPosY
            + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks
            + player.getEyeHeight() - 0.1;
    double arrowPosZ = player.lastTickPosZ
            + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks
            - MathHelper.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;

    // calculate starting motion
    float arrowMotionFactor = usingBow ? 1F : 0.4F;
    float yaw = (float) Math.toRadians(player.rotationYaw);
    float pitch = (float) Math.toRadians(player.rotationPitch);
    float arrowMotionX = -MathHelper.sin(yaw) * MathHelper.cos(pitch) * arrowMotionFactor;
    float arrowMotionY = -MathHelper.sin(pitch) * arrowMotionFactor;
    float arrowMotionZ = MathHelper.cos(yaw) * MathHelper.cos(pitch) * arrowMotionFactor;
    double arrowMotion = Math
            .sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
    arrowMotionX /= arrowMotion;
    arrowMotionY /= arrowMotion;
    arrowMotionZ /= arrowMotion;
    if (usingBow) {
        float bowPower = (72000 - player.getItemInUseCount()) / 20F;
        bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;

        if (bowPower > 1F)
            bowPower = 1F;

        if (bowPower <= 0.1F)
            bowPower = 1F;

        bowPower *= 3F;
        arrowMotionX *= bowPower;
        arrowMotionY *= bowPower;
        arrowMotionZ *= bowPower;
    } else {
        arrowMotionX *= 1.5D;
        arrowMotionY *= 1.5D;
        arrowMotionZ *= 1.5D;
    }

    // GL settings
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glDisable(2929);
    GL11.glEnable(GL13.GL_MULTISAMPLE);
    GL11.glDepthMask(false);
    GL11.glLineWidth(1.8F);

    RenderManager renderManager = mc.getRenderManager();

    // draw trajectory line
    double gravity = usingBow ? 0.05D
            : item instanceof ItemPotion ? 0.4D : item instanceof ItemFishingRod ? 0.15D : 0.03D;
    Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    GL11.glColor3d(0, 1, 0);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (int i = 0; i < 1000; i++) {
        GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY,
                arrowPosZ - renderManager.renderPosZ);

        arrowPosX += arrowMotionX * 0.1;
        arrowPosY += arrowMotionY * 0.1;
        arrowPosZ += arrowMotionZ * 0.1;
        arrowMotionX *= 0.999D;
        arrowMotionY *= 0.999D;
        arrowMotionZ *= 0.999D;
        arrowMotionY -= gravity * 0.1;

        if (mc.world.rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
            break;
    }
    GL11.glEnd();

    // draw end of trajectory line
    double renderX = arrowPosX - renderManager.renderPosX;
    double renderY = arrowPosY - renderManager.renderPosY;
    double renderZ = arrowPosZ - renderManager.renderPosZ;
    AxisAlignedBB bb = new AxisAlignedBB(renderX - 0.5, renderY - 0.5, renderZ - 0.5, renderX + 0.5,
            renderY + 0.5, renderZ + 0.5);
    GL11.glColor4f(0F, 1F, 0F, 0.15F);
    RenderUtils.drawColorBox(bb, 0F, 1F, 0F, 0.15F);
    GL11.glColor4d(0, 0, 0, 0.5F);
    RenderUtils.drawSelectionBoundingBox(bb);

    // GL resets
    GL11.glDisable(3042);
    GL11.glEnable(3553);
    GL11.glEnable(2929);
    GL11.glDisable(GL13.GL_MULTISAMPLE);
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}