Example usage for org.lwjgl.opengl GL11 glCullFace

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

Introduction

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

Prototype

public static void glCullFace(@NativeType("GLenum") int mode) 

Source Link

Document

Specifies which polygon faces are culled if GL11C#GL_CULL_FACE CULL_FACE is enabled.

Usage

From source file:com.shinoow.abyssalcraft.client.model.entity.ModelDragonMinion.java

License:Apache License

@Override
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
    GL11.glPushMatrix();/*from   w  w w. ja v a 2s  .  c  o  m*/
    EntityDragonMinion entitydragon = (EntityDragonMinion) par1Entity;
    float f6 = entitydragon.prevAnimTime + (entitydragon.animTime - entitydragon.prevAnimTime) * partialTicks;
    jaw.rotateAngleX = (float) (Math.sin(f6 * (float) Math.PI * 2.0F) + 1.0D) * 0.2F;
    float f7 = (float) (Math.sin(f6 * (float) Math.PI * 2.0F - 1.0F) + 1.0D);
    f7 = (f7 * f7 * 1.0F + f7 * 2.0F) * 0.05F;
    GL11.glTranslatef(0.0F, f7 - 2.0F, -3.0F);
    GL11.glRotatef(f7 * 2.0F, 1.0F, 0.0F, 0.0F);
    float f8 = -30.0F;
    float f9 = 0.0F;
    float f10 = 1.5F;
    double[] adouble = entitydragon.getMovementOffsets(6, partialTicks);
    float f11 = updateRotations(entitydragon.getMovementOffsets(5, partialTicks)[0]
            - entitydragon.getMovementOffsets(10, partialTicks)[0]);
    float f12 = updateRotations(entitydragon.getMovementOffsets(5, partialTicks)[0] + f11 / 2.0F);
    f8 += 2.0F;
    float f13 = f6 * (float) Math.PI * 2.0F;
    f8 = 20.0F;
    float f14 = -12.0F;
    float f15;

    for (int i = 0; i < 5; ++i) {
        double[] adouble1 = entitydragon.getMovementOffsets(5 - i, partialTicks);
        f15 = (float) Math.cos(i * 0.45F + f13) * 0.15F;
        neck.rotateAngleY = updateRotations(adouble1[0] - adouble[0]) * (float) Math.PI / 180.0F * f10;
        neck.rotateAngleX = f15 + (float) (adouble1[1] - adouble[1]) * (float) Math.PI / 180.0F * f10 * 5.0F;
        neck.rotateAngleZ = -updateRotations(adouble1[0] - f12) * (float) Math.PI / 180.0F * f10;
        neck.rotationPointY = f8;
        neck.rotationPointZ = f14;
        neck.rotationPointX = f9;
        f8 = (float) (f8 + Math.sin(neck.rotateAngleX) * 10.0D);
        f14 = (float) (f14 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10.0D);
        f9 = (float) (f9 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10.0D);
        neck.render(par7);
    }

    head.rotationPointY = f8;
    head.rotationPointZ = f14;
    head.rotationPointX = f9;
    double[] adouble2 = entitydragon.getMovementOffsets(0, partialTicks);
    head.rotateAngleY = updateRotations(adouble2[0] - adouble[0]) * (float) Math.PI / 180.0F * 1.0F;
    head.rotateAngleZ = -updateRotations(adouble2[0] - f12) * (float) Math.PI / 180.0F * 1.0F;
    head.render(par7);
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-f11 * f10 * 1.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(0.0F, -1.0F, 0.0F);
    body.rotateAngleZ = 0.0F;
    body.render(par7);

    for (int j = 0; j < 2; ++j) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        f15 = f6 * (float) Math.PI * 2.0F;
        wing.rotateAngleX = 0.125F - (float) Math.cos(f15) * 0.2F;
        wing.rotateAngleY = 0.25F;
        wing.rotateAngleZ = (float) (Math.sin(f15) + 0.125D) * 0.8F;
        wingTip.rotateAngleZ = -((float) (Math.sin(f15 + 2.0F) + 0.5D)) * 0.75F;
        rearLeg.rotateAngleX = 1.0F + f7 * 0.1F;
        rearLegTip.rotateAngleX = 0.5F + f7 * 0.1F;
        rearFoot.rotateAngleX = 0.75F + f7 * 0.1F;
        frontLeg.rotateAngleX = 1.3F + f7 * 0.1F;
        frontLegTip.rotateAngleX = -0.5F - f7 * 0.1F;
        frontFoot.rotateAngleX = 0.75F + f7 * 0.1F;
        wing.render(par7);
        frontLeg.render(par7);
        rearLeg.render(par7);
        GL11.glScalef(-1.0F, 1.0F, 1.0F);

        if (j == 0)
            GL11.glCullFace(GL11.GL_FRONT);
    }

    GL11.glPopMatrix();
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glDisable(GL11.GL_CULL_FACE);
    float f16 = -((float) Math.sin(f6 * (float) Math.PI * 2.0F)) * 0.0F;
    f13 = f6 * (float) Math.PI * 2.0F;
    f8 = 10.0F;
    f14 = 60.0F;
    f9 = 0.0F;
    adouble = entitydragon.getMovementOffsets(11, partialTicks);

    for (int k = 0; k < 12; ++k) {
        adouble2 = entitydragon.getMovementOffsets(12 + k, partialTicks);
        f16 = (float) (f16 + Math.sin(k * 0.45F + f13) * 0.05000000074505806D);
        neck.rotateAngleY = (updateRotations(adouble2[0] - adouble[0]) * f10 + 180.0F) * (float) Math.PI
                / 180.0F;
        neck.rotateAngleX = f16 + (float) (adouble2[1] - adouble[1]) * (float) Math.PI / 180.0F * f10 * 5.0F;
        neck.rotateAngleZ = updateRotations(adouble2[0] - f12) * (float) Math.PI / 180.0F * f10;
        neck.rotationPointY = f8;
        neck.rotationPointZ = f14;
        neck.rotationPointX = f9;
        f8 = (float) (f8 + Math.sin(neck.rotateAngleX) * 10.0D);
        f14 = (float) (f14 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10.0D);
        f9 = (float) (f9 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10.0D);
        neck.render(par7);
    }

    GL11.glPopMatrix();
}

From source file:com.voxelplugineering.voxelsniper.render.RenderMain.java

License:Open Source License

private void setupOpenGL() {
    // Setup an OpenGL context with API version 3.2
    try {//from   ww  w  . j av  a2 s .  c  o m
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
                .withProfileCore(true);

        Display.setDisplayMode(new DisplayMode(this.width, this.height));
        Display.setTitle("VoxelGunsmithEngine");
        Display.create(pixelFormat, contextAtrributes);
        GL11.glViewport(0, 0, this.width, this.height);
    } catch (LWJGLException e) {
        if (Standalone.DEBUG) {
            System.out.println("Failed creating display");
        }
        e.printStackTrace();
        System.exit(-1);
    }

    // Setup an XNA like background color
    GL11.glClearColor(RenderingConstants.CLEAR_COLOUR_R, RenderingConstants.CLEAR_COLOUR_G,
            RenderingConstants.CLEAR_COLOUR_B, RenderingConstants.CLEAR_COLOUR_A);
    GL11.glViewport(0, 0, this.width, this.height);

    // cull back faces
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glFrontFace(GL11.GL_CW);

    OpenGLUtilities.checkGLError("setup OpenGL");
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLRendererForward.java

License:Open Source License

public static void clientSetup() {
    // setup opengl
    GL11.glEnable(GL11.GL_DEPTH_TEST);// ww  w  .j a v a  2s . c o  m
    errorCheck("setting up client state GL_DEPTH_TEST");

    GL11.glDepthFunc(GL11.GL_LEQUAL);
    errorCheck("setting depth test function");

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    errorCheck("enabling back face culling");
}

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);/* w  ww  . ja  v a 2 s.  com*/
    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

public void setBackfaceCullingEnabled(boolean backfaceCullingEnabled) {
    this.backfaceCullingEnabled = backfaceCullingEnabled;
    if (backfaceCullingEnabled) {
        GL11.glCullFace(GL11.GL_BACK);
        GL11.glEnable(GL11.GL_CULL_FACE);
    } else//from   w  w w .  j ava2 s  .com
        GL11.glDisable(GL11.GL_CULL_FACE);
}

From source file:eu.over9000.veya.rendering.Shadow.java

License:Open Source License

public void preRender() {
    Veya.program_shadow.use(true);// ww w . ja  v  a  2 s . c  o m
    updateMatrixLightSpaceMatrixLocation();
    GL11.glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glCullFace(GL11.GL_FRONT);

}

From source file:eu.over9000.veya.rendering.Shadow.java

License:Open Source License

public void postRender() {
    GL11.glCullFace(GL11.GL_BACK); // don't forget to reset original culling face
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    Veya.program_normal.use(true);/*from  ww  w  .  j av a  2s. c o m*/
    GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());

    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap);
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glCullFace(int mode) {
    GL11.glCullFace(mode);
}

From source file:jake2.desktop.LWJGLAdapter.java

License:Open Source License

@Override
public void glCullFace(int face) {
    GL11.glCullFace(face);
}

From source file:kuake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_SetupGL/*ww  w.j a v a 2  s  .co m*/
 */
void R_SetupGL() {

    //
    // set up viewport
    //
    //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width);
    int x = r_newrefdef.x;
    //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
    int x2 = r_newrefdef.x + r_newrefdef.width;
    //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height);
    int y = vid.height - r_newrefdef.y;
    //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height);
    int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height);

    int w = x2 - x;
    int h = y - y2;

    GL11.glViewport(x, y2, w, h);

    //
    // set up projection matrix
    //
    float screenaspect = (float) r_newrefdef.width / r_newrefdef.height;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096);

    GL11.glCullFace(GL11.GL_FRONT);

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

    GL11.glRotatef(-90, 1, 0, 0); // put Z going up
    GL11.glRotatef(90, 0, 0, 1); // put Z going up
    GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0);
    GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0);
    GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1);
    GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]);

    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix);
    r_world_matrix.clear();

    //
    // set drawing parms
    //
    if (gl_cull.value != 0.0f)
        GL11.glEnable(GL11.GL_CULL_FACE);
    else
        GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}