Example usage for org.lwjgl.opengl GL11 GL_NEAREST

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

Introduction

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

Prototype

int GL_NEAREST

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

Click Source Link

Document

TextureMagFilter

Usage

From source file:game.states.State_MENU_MULTIPLAYER.java

License:Open Source License

@Override
protected void Init() {
    int ButtonStartX = 930;
    int ButtonStartY = 224;
    int Spacing = 90;
    try {//w  w  w.ja v a 2 s  . c o m
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        Texture button1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ConnectButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 0, button1.getImageWidth(),
                button1.getImageHeight(), button1);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/HostButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 1, button2.getImageWidth(),
                button2.getImageHeight(), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 2, button3.getImageWidth(),
                button3.getImageHeight(), button3);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Backgrounds/MenuBackground2.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:game.states.State_MENU_PREFAB_EDITOR.java

License:Open Source License

@Override
protected void Init() {
    int ButtonStartX = 930;
    int ButtonStartY = 224;
    int Spacing = 90;
    try {/*from w w w.j av  a2 s . co m*/
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        Texture button1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/NewButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 0, button1.getImageWidth(),
                button1.getImageHeight(), button1);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 1, button2.getImageWidth(),
                button2.getImageHeight(), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 2, button3.getImageWidth(),
                button3.getImageHeight(), button3);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Backgrounds/MenuBackground2.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:game.states.State_MENU_VICTORY.java

License:Open Source License

@Override
protected void Init() {
    int ButtonStartX = 930;
    int ButtonStartY = 224;
    int Spacing = 90;
    try {//  w ww.ja va2 s.co m
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/MenuButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 1, button2.getImageWidth(),
                button2.getImageHeight(), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/QuitButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 2, button3.getImageWidth(),
                button3.getImageHeight(), button3);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Backgrounds/VictoryScreen.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:game.states.State_PREFAB_EDITOR.java

License:Open Source License

@Override
protected void Init() {
    ButtonGUILayer = new GUI_Layer();
    ButtonGUILayer.SetEnabled(true);/*www  .ja v  a2  s. c  o  m*/
    MenuGUILayer = new GUI_Layer();
    MenuGUILayer.SetEnabled(false);
    int ButtonStartX = 712;
    int ButtonStartY = 600;
    float xScale = 1.5f;
    float yScale = 1.5f;
    int Spacing = 145;
    int menuButtonStartX = 640 - 128;
    int menuButtonStartY = 150;
    float menuXScale = 1f;
    float menuYScale = 1f;
    int menuSpacing = 110;
    try {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIPrefab.png"));
        Texture button1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/SaveIconButton.png"), false,
                GL11.GL_NEAREST);
        ButtonGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY,
                (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/LoadIconButton.png"), false,
                GL11.GL_NEAREST);
        ButtonGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY,
                (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false,
                GL11.GL_NEAREST);
        ButtonGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY,
                (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3);
        Texture button4 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/HelpIconButton.png"), false,
                GL11.GL_NEAREST);
        ButtonGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY,
                (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4);

        Texture mButton0 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0,
                (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale),
                mButton0);
        Texture mButton1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1,
                (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale),
                mButton1);
        Texture mButton2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2,
                (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale),
                mButton2);
        Texture mButton3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3,
                (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale),
                mButton3);

    } catch (IOException e) {
        e.printStackTrace();
    }

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_LIGHT0);
    GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f);
    GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

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

From source file:game.states.State_SINGLEPLAYER.java

License:Open Source License

private void CreateGUI() {
    MainGUILayer = new GUI_Layer();
    MenuGUILayer = new GUI_Layer();
    MenuGUILayer.SetEnabled(false);/*from   w  w w.j  av  a  2 s .  c  o m*/
    int ButtonStartX = 405;
    int ButtonStartY = 650;
    float xScale = 0.8f;
    float yScale = 0.8f;
    int Spacing = 140;
    int menuButtonStartX = 640 - 128;
    int menuButtonStartY = 150;
    float menuXScale = 1f;
    float menuYScale = 1f;
    int menuSpacing = 110;
    try {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIBaseLayer.png"));
        Texture button1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false,
                GL11.GL_NEAREST);
        MainGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY,
                (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/InvIconButton.png"), false,
                GL11.GL_NEAREST);
        MainGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY,
                (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/StatsIconButton.png"), false,
                GL11.GL_NEAREST);
        MainGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY,
                (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3);
        Texture button4 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/ConsoleIconButton.png"), false,
                GL11.GL_NEAREST);
        MainGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY,
                (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4);

        Texture mButton0 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0,
                (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale),
                mButton0);
        Texture mButton1 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1,
                (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale),
                mButton1);
        Texture mButton2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2,
                (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale),
                mButton2);
        Texture mButton3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false,
                GL11.GL_NEAREST);
        MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3,
                (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale),
                mButton3);

    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:game.states.State_SPRITER.java

License:Open Source License

@Override
protected void Init() {
    GUI_Layer Layer_DropdownBar = new GUI_Layer();
    GUI_Layer Layer_SideBar = new GUI_Layer();
    GUI_Layer Layer_BottomBar = new GUI_Layer();
    GUI_Layer Layer_SpriteEditor = new GUI_Layer();
    GUI_Layer Layer_Floating = new GUI_Layer();
    WIDTH = Game.Width;//from   w w  w  .  ja  v a 2s  .  c  om
    HEIGHT = Game.Height;
    font = LoadFont("ABEAKRG");
    float ButtonStartRX = (5f / 19f);
    float ButtonRWidth = (14f / 171f);
    int DropDownHeight = (int) (HEIGHT * 1f / 20f);
    int BaseBarHeight = (int) (HEIGHT * 1f / 15f);
    int Dropdowns = 8;

    try {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        Texture playButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Play.png"), false,
                GL11.GL_NEAREST);
        Texture firstButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_First.png"), false,
                GL11.GL_NEAREST);
        Texture backButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Back.png"), false,
                GL11.GL_NEAREST);
        Texture forwardButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Next.png"), false,
                GL11.GL_NEAREST);
        Texture pauseButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Pause.png"),

                false, GL11.GL_NEAREST);
        Texture SwitchButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Switch.png"), false,
                GL11.GL_NEAREST);
        Texture PaletteButton = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Button_Palette.png"), false,
                GL11.GL_NEAREST);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/DefaultButton.png"), false,
                GL11.GL_NEAREST);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/DefaultButton.png"), false,
                GL11.GL_NEAREST);
        Texture tab = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/Tab.png"), false,
                GL11.GL_NEAREST);
        Texture grabBar = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/GrabBar.png"), false,
                GL11.GL_NEAREST);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Backgrounds/DefaultBackground.png"));

        FrameCount = new GUI_Text_Field(new RelativeDimensions(ButtonStartRX + ButtonRWidth * 4,
                1 - BaseBarHeight / (float) HEIGHT, ButtonRWidth, BaseBarHeight / (float) HEIGHT), "0", font);

        GUI_List_DropDown_ANIMATIONS AnimationList = new GUI_List_DropDown_ANIMATIONS(
                (int) (ButtonStartRX * WIDTH) + (int) (ButtonRWidth * WIDTH) * 6, HEIGHT - BaseBarHeight,
                WIDTH - ((int) (ButtonStartRX * WIDTH) + (int) (ButtonRWidth * WIDTH) * 6), BaseBarHeight,
                new GUI_Object_Element(new RelativeDimensions(0, 0, 0, 0), button2, "Animation"),
                new GUI_Object_Element[] {}, font);
        ProjectScrollList = new GUI_List_Scroll_Project(new RelativeDimensions(0, 3f / 4f, 5f / 19f, 1 / 4f),
                button3, 5, font);
        ColorRenderer = new GUI_Renderer_ColorArray(
                new RelativeDimensions(5f / 19f, 1f / 10f, 1 - 5f / 19f, 4f / 5f), CreateColorArray(32, 32),
                FrameCount, AnimationList);
        ProjectName = new GUI_Text_Field(new RelativeDimensions(0, 20f / 30f, 5f / 19f, 5f / 60f), "No project",
                font);
        ///////////////////////////////LAYER FLOATING////////////////////////////////////////////
        Layer_Floating.addObject("ProjectProperties", new GUI_Window_Project_Properties(
                new RelativeDimensions(0.3f, 0.3f, 0.2f, 0.5f), tab, grabBar, font));

        ///////////////////////////////SPRITE WINDOW////////////////////////////////////////////
        Layer_SpriteEditor.addObject("SpriteWindow", ColorRenderer);

        ///////////////////////////////SIDE BAR//////////////////////////////////////////////
        Layer_SideBar.addObject("ToolColours",
                new GUI_Renderer_ColorInterface(
                        new RelativeDimensions(0, DropDownHeight / (float) HEIGHT, 5f / 19f, 1f / 4f),
                        ColorRenderer, SwitchButton, PaletteButton));
        Layer_SideBar.addObject("SpriteScrollList", ProjectScrollList);

        Layer_SideBar.addObject("Palette",
                new GUI_Renderer_Palette(new RelativeDimensions(0, 5f / 20f + DropDownHeight / (float) HEIGHT,
                        5f / 19f, 3f / 10f + DropDownHeight / (float) HEIGHT), ColorRenderer, 126, 9));
        Layer_SideBar.addObject("SpriteLabel", ProjectName);

        ///////////////////////////////BOTTOM BAR////////////////////////////////////////////
        Layer_BottomBar.AddButton("Start",
                new RelativeDimensions(5f / 19f, 1f - (float) BaseBarHeight / (float) HEIGHT, 14f / 171f,
                        (float) BaseBarHeight / (float) HEIGHT),
                firstButton);
        Layer_BottomBar.AddButton("Pause",
                new RelativeDimensions(5f / 19f + 14f / 171f, 1f - (float) BaseBarHeight / (float) HEIGHT,
                        14f / 171f, (float) BaseBarHeight / (float) HEIGHT),
                pauseButton);
        Layer_BottomBar.AddButton("Play",
                new RelativeDimensions(5f / 19f + 14f / 171f * 2, 1f - (float) BaseBarHeight / (float) HEIGHT,
                        14f / 171f, (float) BaseBarHeight / (float) HEIGHT),
                playButton);
        Layer_BottomBar.AddButton("PrevFrame",
                new RelativeDimensions(5f / 19f + 14f / 171f * 3, 1f - (float) BaseBarHeight / (float) HEIGHT,
                        14f / 171f, (float) BaseBarHeight / (float) HEIGHT),
                backButton);
        Layer_BottomBar.AddButton("NextFrame",
                new RelativeDimensions(5f / 19f + 14f / 171f * 5, 1f - (float) BaseBarHeight / (float) HEIGHT,
                        14f / 171f, (float) BaseBarHeight / (float) HEIGHT),
                forwardButton);
        Layer_BottomBar.addObject("FrameLabel", FrameCount);
        Layer_BottomBar.addObject("AnimList", AnimationList);

        ///////////////////////////////DROPDOWN BAR//////////////////////////////////////////
        Layer_DropdownBar.addObject("File",
                new GUI_List_DropDown(0, 0, (int) (WIDTH * 1f / Dropdowns), DropDownHeight,
                        new GUI_Object_Element(new RelativeDimensions(0, 0, 0, 0), button2, "File"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "New project.."),
                                new GUI_Object_Element(button2, "Load project.."),
                                new GUI_Object_Element(button2, "Save project.."),
                                new GUI_Object_Element(button2, "Export project.."),
                                new GUI_Object_Element(button2, "Export animation GIF.."),
                                new GUI_Object_Element(button2, "Export sprite PNG.."),
                                new GUI_Object_Element(button2, "Import GIF..") },
                        font));
        Layer_DropdownBar.addObject("New",
                new GUI_List_DropDown((int) (WIDTH * 1f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "New"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Sprite.."),
                                new GUI_Object_Element(button2, "Animation..") },
                        font));
        Layer_DropdownBar.addObject("Edit",
                new GUI_List_DropDown((int) (WIDTH * 2f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "Edit"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Delete"),
                                new GUI_Object_Element(button2, "Properties"),
                                new GUI_Object_Element(button2, "Copy frame"),
                                new GUI_Object_Element(button2, "Paste frame"),
                                new GUI_Object_Element(button2, "Paste clipboard image") },
                        font));
        Layer_DropdownBar.addObject("View",
                new GUI_List_DropDown((int) (WIDTH * 3f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "View"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Zoom in"),
                                new GUI_Object_Element(button2, "Zoom out"),
                                new GUI_Object_Element(button2, "Center view") },
                        font));
        Layer_DropdownBar.addObject("Frame",
                new GUI_List_DropDown((int) (WIDTH * 4f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "Frame"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Element 0"),
                                new GUI_Object_Element(button2, "Element 1") },
                        font));
        Layer_DropdownBar.addObject("Sprite",
                new GUI_List_DropDown((int) (WIDTH * 5f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "Sprite"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Element 0"),
                                new GUI_Object_Element(button2, "Element 1") },
                        font));
        Layer_DropdownBar.addObject("Effects",
                new GUI_List_DropDown((int) (WIDTH * 6f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "Effects"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Element 0"),
                                new GUI_Object_Element(button2, "Element 1") },
                        font));
        Layer_DropdownBar.addObject("Project",
                new GUI_List_DropDown((int) (WIDTH * 7f / Dropdowns), 0, (int) (WIDTH * 1f / Dropdowns),
                        DropDownHeight, new GUI_Object_Element(button2, "Project"),
                        new GUI_Object_Element[] { new GUI_Object_Element(button2, "Element 0"),
                                new GUI_Object_Element(button2, "Element 1") },
                        font));

        picker = new ColorPicker(ColorRenderer);

        //////Layer ordering//////
        //0 is frontmost element//
        Layer_Floating.setUseDelay(false);
        GUI_Controller.addLayer(Layer_Floating, "Floating");
        //Layer_DropdownBar.setAutoFlush(true);
        GUI_Controller.addLayer(Layer_DropdownBar, "DropDownBar");
        GUI_Controller.addLayer(Layer_SideBar, "SideBar");
        GUI_Controller.addLayer(Layer_BottomBar, "BottomBar");
        GUI_Controller.addLayer(Layer_SpriteEditor, "SpriteEditor");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:go.graphics.swing.opengl.LWJGLDrawContext.java

License:Open Source License

/**
 * Sets the texture parameters, assuming that the texture was just created and is bound.
 *//* w  w  w  . j ava 2  s.c o  m*/
private void setTextureParameters() {
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f); // prevent writing of transparent pixels to z buffer
}

From source file:group.project.unknown.utils.TexLoader.java

License:Apache License

public static Texture loadTexture(String url) {
    Texture texture = null;/*from w ww. j a  v  a2 s  .  co  m*/

    try {
        texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(url));
        texture.setTextureFilter(GL11.GL_NEAREST);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return texture;
}

From source file:illarion.graphics.lwjgl.TextureAtlasLWJGL.java

License:Open Source License

/**
 * Activate the texture and prepare it for usage by OpenGL.
 * //from w w  w. j av a 2  s  .com
 * @param resizeable true in case the texture shall be loaded with advanced
 *            rescaling methods, that are more calculation intensive but
 *            look better then the normal ones
 * @param allowCompression true if the texture is compressed at default
 *            settings, false if not. Best disallow compression for static
 *            images such as tiles, since the effects of the compression
 *            will be quite visible there
 */
@Override
@SuppressWarnings("nls")
public void activateTexture(final boolean resizeable, final boolean allowCompression) {

    if (!hasTextureData()) {
        throw new IllegalStateException("No texturedata loaded");
    }

    final int quality = Graphics.getInstance().getQuality();

    if (getTextureID() != 0) {
        removeTexture();
    }

    // generate new texture ID
    final int texID = getNewTextureID();
    setTextureID(texID);

    // bind texture ID
    DriverSettingsLWJGL.getInstance().enableTexture(texID);

    // prepare texture data
    if (resizeable) { // Textures will be resized -> smoothing would be good
        if (quality <= Graphics.QUALITY_LOW) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        } else if ((quality <= Graphics.QUALITY_NORMAL) || isNoMipMaps()) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        } else {
            if (GLContext.getCapabilities().OpenGL14) {
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
            } else {
                setNoMipMaps(true);
            }
            if (!isNoMipMaps()) {
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
                        GL11.GL_LINEAR_MIPMAP_LINEAR);
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
            } else {
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
            }
        }
    } else {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    }
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

    if (GLContext.getCapabilities().OpenGL13) {
        GL11.glHint(GL13.GL_TEXTURE_COMPRESSION_HINT, GL11.GL_NICEST);
    }

    // setup texture compression
    final boolean activateCompression = GLContext.getCapabilities().OpenGL13
            && ((allowCompression && (quality < Graphics.QUALITY_MAX)) || (quality <= Graphics.QUALITY_LOW));
    if (isTextureRGBA()) {
        internalFormat = GL11.GL_RGBA;
        sourceFormat = GL11.GL_RGBA;
        if (activateCompression) {
            internalFormat = GL13.GL_COMPRESSED_RGBA;
        }
    } else if (isTextureRGB()) {
        internalFormat = GL11.GL_RGB;
        sourceFormat = GL11.GL_RGB;
        if (activateCompression) {
            internalFormat = GL13.GL_COMPRESSED_RGB;
        }
    } else if (isTextureGrey()) {
        internalFormat = GL11.GL_LUMINANCE;
        sourceFormat = GL11.GL_LUMINANCE;
        if (activateCompression) {
            internalFormat = GL13.GL_COMPRESSED_LUMINANCE;
        }
    } else if (isTextureGreyAlpha()) {
        internalFormat = GL11.GL_LUMINANCE_ALPHA;
        sourceFormat = GL11.GL_LUMINANCE_ALPHA;
        if (activateCompression) {
            internalFormat = GL13.GL_COMPRESSED_LUMINANCE_ALPHA;
        }
    }

    final ByteBuffer texData = getTextureData();

    final int texWidth = getTextureWidth();
    final int texHeight = getTextureHeight();

    // produce a texture from the byte buffer
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0, sourceFormat,
            GL11.GL_UNSIGNED_BYTE, texData);

    if (quality < Graphics.QUALITY_MAX) {
        texIDBuffer.rewind();
        GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED, texIDBuffer);

        texData.rewind();
        if (texIDBuffer.get(0) == GL11.GL_FALSE) {
            int newInternalFormat = internalFormat;
            if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE_ALPHA) {
                newInternalFormat = GL13.GL_COMPRESSED_RGBA;
            } else if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE) {
                newInternalFormat = GL13.GL_COMPRESSED_RGB;
            }
            final int orgSize = texData.remaining();
            if (newInternalFormat != internalFormat) {
                GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, newInternalFormat, texWidth, texHeight, 0,
                        sourceFormat, GL11.GL_UNSIGNED_BYTE, texData);
                GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
                        texIDBuffer);
                final int newSize = texIDBuffer.get(0);
                if (newSize > orgSize) {
                    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0,
                            sourceFormat, GL11.GL_UNSIGNED_BYTE, texData);
                }
            }
        }
    }

    texIDBuffer.rewind();
    GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_INTERNAL_FORMAT, texIDBuffer);
    internalFormat = texIDBuffer.get();

    discardImageData();
}

From source file:ion2d.INTexture2D.java

License:Open Source License

/**
 * Both AntiAlias and Alias need OpenGL 1.2 or greater to work properly
 *///  w  ww. j  a  v  a2  s.co  m
public void setAlias() {
    this.setTextureParameters(GL11.GL_NEAREST, GL11.GL_NEAREST, GL12.GL_CLAMP_TO_EDGE, GL12.GL_CLAMP_TO_EDGE);
}