Example usage for org.lwjgl.opengl GL11 glRotatef

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

Introduction

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

Prototype

public static native void glRotatef(@NativeType("GLfloat") float angle, @NativeType("GLfloat") float x,
        @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a rotation matrix.

Usage

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;//  ww  w.  j av a2s.  c o  m
    data.accumAlphaSize = 8;
    data.accumBlueSize = 8;
    data.accumGreenSize = 8;
    data.accumRedSize = 8;

    final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);

    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    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 e) {
                e.printStackTrace();
            }
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
        }
    });

    GL11.glLineWidth(1);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    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);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);

    shell.setText("SWT/LWJGL Example");
    shell.setSize(640, 480);
    shell.open();

    final Runnable run = new Runnable() {
        float rot = 0;

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }

                int ACSIZE = 8;

                int[] viewport = getViewport();

                GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

                for (int jitter = 0; jitter < ACSIZE; jitter++) {
                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

                    double jit_x = jits[jitter][0];
                    double jit_y = jits[jitter][1];

                    accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y,
                            0.0, 0.0, 1.0);

                    {

                        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                        GL11.glClearColor(.3f, .5f, .8f, 1.0f);
                        GL11.glLoadIdentity();
                        GL11.glTranslatef(0.0f, 0.0f, -10.0f);
                        float frot = rot;
                        GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f);
                        GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f);
                        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
                        GL11.glColor3f(0.9f, 0.9f, 0.9f);
                        drawCylinder(2, 3, 50, 0);
                        drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                    }

                    GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE);
                }

                GL11.glAccum(GL11.GL_RETURN, 1.0f);
                GL11.glFlush();

                rot += 0.1;

                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    };
    canvas.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            run.run();
        }
    });
    display.asyncExec(run);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

public final void glRotatef(float angle, float x, float y, float z) {
    GL11.glRotatef(angle, x, y, z);
}

From source file:com.blogspot.jabelarminecraft.magicbeans.renderers.RenderGiant.java

License:Open Source License

@Override
protected void rotateCorpse(EntityLivingBase parEntityLivingBase, float parNotUsed, float p_77043_3_,
        float p_77043_4_) {
    GL11.glRotatef(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F);

    if (parEntityLivingBase.deathTime > 0) {
        GL11.glRotatef(cycleDeathFall[parEntityLivingBase.deathTime], 0.0F, 0.0F, 1.0F);
    }//from  w ww  .  j  a  v a 2  s.  c o m
}

From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelRendererWildAnimals.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void render(float par1) {
    if (!this.isHidden) {
        if (this.showModel) {
            if (!this.compiled) {
                this.compileDisplayList(par1);
            }/*from  w w w. j  a  v  a 2 s.c  o m*/

            GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
            int i;

            if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
                if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) {
                    GL11.glCallList(this.displayList);

                    if (this.childModels != null) {
                        for (i = 0; i < this.childModels.size(); ++i) {
                            ((ModelRendererWildAnimals) this.childModels.get(i)).render(par1);
                        }
                    }
                } else {
                    GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
                            this.rotationPointZ * par1);
                    GL11.glCallList(this.displayList);

                    if (this.childModels != null) {
                        for (i = 0; i < this.childModels.size(); ++i) {
                            ((ModelRendererWildAnimals) this.childModels.get(i)).render(par1);
                        }
                    }

                    GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1,
                            -this.rotationPointZ * par1);
                }
            } else {
                GL11.glPushMatrix();
                GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
                        this.rotationPointZ * par1);

                if (this.rotateAngleZ != 0.0F) {
                    GL11.glRotatef(this.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
                }

                if (this.rotateAngleY != 0.0F) {
                    GL11.glRotatef(this.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
                }

                if (this.rotateAngleX != 0.0F) {
                    GL11.glRotatef(this.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
                }

                GL11.glCallList(this.displayList);

                if (this.childModels != null) {
                    for (i = 0; i < this.childModels.size(); ++i) {
                        ((ModelRendererWildAnimals) this.childModels.get(i)).render(par1);
                    }
                }

                GL11.glPopMatrix();
            }

            GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ);
        }
    }
}

From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelRendererWildAnimals.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void renderWithRotation(float par1) {
    if (!this.isHidden) {
        if (this.showModel) {
            if (!this.compiled) {
                this.compileDisplayList(par1);
            }/*from  ww w  .  j  a v  a2 s .co  m*/

            GL11.glPushMatrix();
            GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
                    this.rotationPointZ * par1);

            if (this.rotateAngleY != 0.0F) {
                GL11.glRotatef(this.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
            }

            if (this.rotateAngleX != 0.0F) {
                GL11.glRotatef(this.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
            }

            if (this.rotateAngleZ != 0.0F) {
                GL11.glRotatef(this.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
            }

            GL11.glCallList(this.displayList);
            GL11.glPopMatrix();
        }
    }
}

From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelRendererWildAnimals.java

License:Open Source License

/**
 * Allows the changing of Angles after a box has been rendered
 *///from  w  w w .  j  a v a2  s  . c  o  m
@SideOnly(Side.CLIENT)
public void postRender(float par1) {
    if (!this.isHidden) {
        if (this.showModel) {
            if (!this.compiled) {
                this.compileDisplayList(par1);
            }

            if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
                if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) {
                    GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
                            this.rotationPointZ * par1);
                }
            } else {
                GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
                        this.rotationPointZ * par1);

                if (this.rotateAngleZ != 0.0F) {
                    GL11.glRotatef(this.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
                }

                if (this.rotateAngleY != 0.0F) {
                    GL11.glRotatef(this.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
                }

                if (this.rotateAngleX != 0.0F) {
                    GL11.glRotatef(this.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
                }
            }
        }
    }
}

From source file:com.blogspot.jabelarminecraft.wildanimals.renderers.RenderThrowableSpawnEgg.java

License:Open Source License

/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
 *//*from w  w w.ja v  a2  s  .c o m*/
public void doRender(EntityWildAnimalsEgg parEntityWildAnimalsEgg, double parPosX, double parPosY,
        double parPosZ, float p_76986_8_, float parTweenFactor) {
    bindEntityTexture(parEntityWildAnimalsEgg);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) parPosX, (float) parPosY, (float) parPosZ);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationYaw
            + (parEntityWildAnimalsEgg.rotationYaw - parEntityWildAnimalsEgg.prevRotationYaw) * parTweenFactor
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationPitch
            + (parEntityWildAnimalsEgg.rotationPitch - parEntityWildAnimalsEgg.prevRotationPitch)
                    * parTweenFactor,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = 0.0F;
    float f5 = 5 / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = 5 / 32.0F;
    float f9 = 10 / 32.0F;
    float scaleFactor = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float f11 = -parTweenFactor;

    if (f11 > 0.0F) {
        float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
        GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
    }

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f9);
    tessellator.draw();
    GL11.glNormal3f(-scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, scaleFactor);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderEngine.java

License:Open Source License

@SuppressWarnings("cast")
@Override/*from w  w  w  .  ja va2  s.  co  m*/
public void renderTileEntityAt(TileEntity engine, double x, double y, double z, float f) {

    if (engine instanceof TileEngine) {

        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_LIGHTING);
        TileEngine tile = (TileEngine) engine.getWorldObj().getTileEntity(engine.xCoord, engine.yCoord,
                engine.zCoord);

        ForgeDirection direction = tile.getOrientation();

        GL11.glTranslated(x, y, z);
        GL11.glScaled(.0315, .0315, .0315);

        if (direction == ForgeDirection.UP) {
            GL11.glTranslated(16, 28, 16);
            GL11.glRotatef(180, 1, 0, 0);
        }
        if (direction == ForgeDirection.DOWN) {
            GL11.glTranslated(16, 4, 16);
            GL11.glRotatef(0, 0, 0, 0);
        }
        if (direction == ForgeDirection.EAST) {
            GL11.glTranslated(28, 16, 16);
            GL11.glRotatef(90, 0, 0, 1);
        }
        if (direction == ForgeDirection.WEST) {
            GL11.glTranslated(4, 16, 16);
            GL11.glRotatef(90, 0, 0, -1);
        }
        if (direction == ForgeDirection.NORTH) {
            GL11.glTranslated(16, 16, 4);
            GL11.glRotatef(90, 1, 0, 0);
        }
        if (direction == ForgeDirection.SOUTH) {
            GL11.glTranslated(16, 16, 28);
            GL11.glRotatef(90, -1, 0, 0);
        }
        if (tile.isActive) {
            bindTexture(textureLocationOn);
        } else {
            bindTexture(textureLocationOff);
        }
        engineModel.renderAllExcept("gear", "glider");

        if (tile.isActive) {
            f += tile.pumpTick;
            if (tile.pumpSpeed > 0) {
                f /= tile.pumpSpeed;
            }
        } else {
            f = 0;
        }
        f = (float) ((float) 6 * (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)));
        GL11.glTranslatef(0, f, 0);

        engineModel.renderPart("glider");

        GL11.glTranslatef(0, -f, 0);

        if (tile.isActive) {
            if (tile.getWorldObj().isRemote) {
                rotateAmount++;

                GL11.glRotated(tile.gearTick * 19, 0, 1.5707963267948966D * (double) f, 0);
            }
        }
        engineModel.renderPart("gear");

        GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.client.render.RenderHelper.java

License:Open Source License

/**
 * ???//from  w  w  w  . jav a 2  s.co  m
 *
 * @author amadornes
 * @param d
 */
public static void rotateRenderMatrix(ForgeDirection d) {

    switch (d) {
    case UP:
        GL11.glRotatef(1, 0, 0, -90);
        break;
    case DOWN:
        GL11.glRotatef(1, 0, 0, 90);
        break;
    case NORTH:
        GL11.glRotatef(1, 0, -90, 0);
        break;
    case SOUTH:
        GL11.glRotatef(1, 0, 90, 0);
        break;
    case WEST:
        GL11.glRotatef(1, 0, 0, 180);
        break;
    case EAST:
        GL11.glRotatef(1, 0, 0, 0);
        break;
    default:
        break;
    }
}

From source file:com.bluepowermod.client.render.RenderItemEngine.java

License:Open Source License

private void renderEngine(float x, float y, float z, float rotateAmount, float rotatex, float rotatey,
        float rotatez) {

    GL11.glPushMatrix();//from w ww  .  j av  a2s.  co m
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glScalef(.034F, .034F, .034F);
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(rotateAmount, rotatex, rotatey, rotatez);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureLocation);

    model.renderAll();

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