Example usage for org.lwjgl.opengl GL11 GL_MODELVIEW

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

Introduction

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

Prototype

int GL_MODELVIEW

To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.

Click Source Link

Document

MatrixMode

Usage

From source file:mwisbest.openbase.Common.java

License:Open Source License

/**
 * Common code for rendering the Widgets to the screen. After this, customRender() is used from OpenBASE or OpenBASEApplet (whatever is calling this method).
 *//*  www.  j  a  va 2  s . c  o  m*/
protected static void render(int framerateLimit) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    Map<String, Widget> theWidgets = ResourceManager.getWidgets();
    for (RenderPriority priority : RenderPriority.values()) {
        for (Entry<String, Widget> widget : theWidgets.entrySet()) {
            if (widget.getValue().getRenderPriority() == priority && widget.getValue().getVisible())
                widget.getValue().render();
        }
    }
    if (framerateLimit > 0)
        Display.sync(framerateLimit);
}

From source file:myfirstgame.Window.java

public void init(int width, int height) {

    Window.width = width;/*www  .j a  v a2 s  .co  m*/
    Window.height = height;

    try { //Look for a displaymode with matching width and height that supports fullscreen, set it to the displaymode we want to use.
        DisplayMode displayMode = null;
        DisplayMode[] modes = Display.getAvailableDisplayModes();

        for (int i = 0; i < modes.length; i++) {
            if (modes[i].getWidth() == width && modes[i].getHeight() == height
                    && modes[i].isFullscreenCapable()) {
                displayMode = modes[i];
            }
        }
        Display.setDisplayMode(displayMode);
        Display.setFullscreen(true);
        Display.create();

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 0, 600, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    try {
        Mouse.create();
        Keyboard.create();
    } catch (LWJGLException ex) {
        Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Mouse.setGrabbed(true);
}

From source file:name.martingeisse.minimal.simulation.lwjgl.LwjglWindow.java

License:Open Source License

/**
 * Constructor.// w ww  .  java 2s  .c  o m
 * @param width the window width
 * @param height the window height
 */
public LwjglWindow(int width, int height) {
    try {
        LwjglNativeLibraryHelper.prepareNativeLibraries();
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setTitle("Minimal");
        Display.setFullscreen(true);
        Display.create(new PixelFormat(0, 24, 0));
        Keyboard.create();
    } catch (Exception e) {
        throw new RuntimeException("could not open LWJGL window", e);
    }
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:name.martingeisse.stackd.client.gui.Gui.java

License:Open Source License

/**
 * Fires the specified event.//from www .j a va  2 s . co  m
 * @param event the event
 */
public void fireEvent(GuiEvent event) {
    if (rootElement == null) {
        return;
    }
    if (event == GuiEvent.DRAW) {
        if (layoutRequested) {
            rootElement.requestSize(widthUnits, HEIGHT_UNITS);
            rootElement.setPosition(0, 0);
            layoutRequested = false;
        }
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glOrtho(0, widthUnits, HEIGHT_UNITS, 0, -1, 1);
    }
    time = (int) System.currentTimeMillis();
    rootElement.handleEvent(event);
}

From source file:name.martingeisse.swtlib.canvas.AbstractOpenGlBlockCanvas.java

License:Open Source License

/**
 * //from w ww  .  ja  v  a 2  s.c o  m
 */
private void setupOpenGl() {
    prepareOpenGl();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    matrixBuffer.rewind();
    GL11.glLoadMatrix(matrixBuffer);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
}

From source file:net.adam_keenan.voxel.hud.HUD.java

License:Creative Commons License

public static void drawCrosshairs() {

    float screenx = (float) Display.getWidth() / 2, screeny = (float) Display.getHeight() / 2;
    float x1, y1, x2, y2, width1 = 4, height1 = 20, width2 = height1, height2 = width1;
    x1 = screenx - width1 / 2;//  www .  j av a  2s.c o m
    y1 = screeny - height1 / 2;
    x2 = screenx - width2 / 2;
    y2 = screeny - height2 / 2;

    FloatBuffer perspectiveProjectionMatrix;
    FloatBuffer orthographicProjectionMatrix;
    perspectiveProjectionMatrix = BufferUtils.createFloatBuffer(16);
    orthographicProjectionMatrix = BufferUtils.createFloatBuffer(16);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix);
    //      GL11.glLoadMatrix(perspectiveProjectionMatrix);

    GL11.glMatrixMode(GL11.GL_PROJECTION); // For text drawing
    GL11.glLoadMatrix(orthographicProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glLoadIdentity(); // Clears matrix

    GL11.glColor4f(0, 0, 0, .5f);
    GL11.glRectf(x1, y1, x1 + width1, y1 + height1);
    GL11.glRectf(x2, y2, x2 + (width2 - width1) / 2, y2 + height2);
    GL11.glRectf(x2 + (width2 + width1) / 2, y2, x2 + width2, y2 + height2);

    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadMatrix(perspectiveProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

public static void createTextures() throws LWJGLException {
    Display.setDisplayMode(new DisplayMode(width, height));
    Display.create();//  w w  w.ja  v a  2s  .c o  m
    Display.setVSyncEnabled(true);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

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

    // enable alpha blending
    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);

    Font awtFont = new Font("Times New Roman", Font.BOLD, 18);
    font = new TrueTypeFont(awtFont, true);

    try {
        textureMapping.put("SMALLLET",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("SMALLLET.png")));
        textureMapping.put("healthbar",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("healthbar.png")));
        textureMapping.put("score",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("score.png")));
        textureMapping.put("arrow",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("arrow.png")));
        textureMapping.put("dirt",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("dirt.png")));
        textureMapping.put("rangerD",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerD.png")));
        textureMapping.put("rangerL",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerL.png")));
        textureMapping.put("rangerR",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerR.png")));
        textureMapping.put("rangerU",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerU.png")));
        textureMapping.put("skele",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("skele.png")));
        textureMapping.put("slime",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("slime.png")));
        textureMapping.put("hp", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("hp.png")));
        textureMapping.put("pb", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("pb.png")));
        textureMapping.put("wall",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("wall.png")));
        textureMapping.put("exit",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("exit.png")));
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:net.awairo.mcmod.spawnchecker.client.marker.RenderingSupport.java

License:Minecraft Mod Public

/**
 * ????GL./*from  w w w. j a  v a2s . c o  m*/
 */
public static void beginRendering() {
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glDepthMask(false);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
}

From source file:net.BiggerOnTheInside.Binder.Binder.java

License:Open Source License

/**
 * <p>Sets up OpenGL.</p>/*from  w w w.  j  a  v a  2s  .c  om*/
 */
public void initGL() {
    int width = displayMode.getWidth();
    int height = displayMode.getHeight();

    /* Enable 2D texturing. */
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    /* Make all models smoothly textured. */
    GL11.glShadeModel(GL11.GL_SMOOTH);

    /* Set the background color to that signature blue. */
    GL11.glClearColor(0.9f, 1.0f, 1.0f, 0.0f);

    /* Set the clear depth to all-the-way */
    GL11.glClearDepth(1.0);

    /* Enable the depth system. */
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    /* Set the function for depth to GL_LEQUAL. */
    GL11.glDepthFunc(GL11.GL_LEQUAL);

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

    /* Enable face culling, basically don't render this face relative to the camera's position. */
    GL11.glEnable(GL11.GL_CULL_FACE);

    /* Set OpenGL to cull the back face of our spatials. */
    GL11.glCullFace(GL11.GL_BACK);

    /* Set the matrix mode to projection. */
    GL11.glMatrixMode(GL11.GL_PROJECTION);

    /* Reset the OpenGL configuration, loading our above prefrences. */
    //GL11.glLoadIdentity();

    /* Set the perspective. */
    GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f);

    /* Set the matrix mode to be model view. */
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    /* Set the perspective correction hint to finest quality. */
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}

From source file:net.malisis.doors.door.renderer.ForcefieldRenderer.java

License:Open Source License

@Override
public void render() {
    tileEntity = MultiBlock.getOriginProvider(ForcefieldTileEntity.class, world, x, y, z);
    if (tileEntity == null || tileEntity.isOpened() || !MultiBlock.isOrigin(world, x, y, z))
        return;/*from   w  w w .  j av a  2s  .  com*/

    enableBlending();

    tileEntity = (ForcefieldTileEntity) super.tileEntity;
    direction = ForgeDirection.getOrientation(tileEntity.getDirection());

    model.resetState();

    //ar.setStartTime(tileEntity.getStartNanoTime());
    if (tileEntity.getMovement() == null)
        return;

    AxisAlignedBB aabb = tileEntity.getMovement().getBoundingBox(tileEntity, false, BoundingBoxType.COLLISION);
    if (aabb == null)
        return;

    aabb.offset(-x, -y, -z);
    rp.renderBounds.set(aabb);
    direction = ForgeDirection.NORTH;
    if ((int) aabb.minY == (int) aabb.maxY) {
        direction = ForgeDirection.UP;
        model.rotate(90, 1, 0, 0, 0, 0, 0);
    } else if ((int) aabb.minX == (int) aabb.maxX) {
        direction = ForgeDirection.EAST;
        model.rotate(90, 0, 1, 0, 0, 0, 0);
    }

    setTextureMatrix();
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glDisable(GL11.GL_CULL_FACE);

    model.render(this, rp);
    next();

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
}