Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: LWJGL Texture Release Problem

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    My Mood
    Love
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default LWJGL Texture Release Problem

    Hello Java community,
    I have developed a code and it seems everything is working, the textures, the input, the display (by now you might've figured out I'm using the LWJGL, Light Weight Java Game Library), but I can't seem to make the texture "release," the texture just stands there the whole time, also wood, is for the texture, I just called it wood because it came with the source code I was using for clarification.

    package AI_Stage2;
     
     
     
     
    import org.lwjgl.LWJGLException;
    import org.lwjgl.input.Keyboard;
    import org.lwjgl.input.Mouse;
    import org.lwjgl.opengl.Display;
    import org.lwjgl.opengl.DisplayMode;
    import org.newdawn.slick.opengl.Texture;
    import org.newdawn.slick.opengl.TextureLoader;
     
     
     
     
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
     
    import static org.lwjgl.opengl.GL11.*;
     
    public class AI {
     
        private static Texture texture = null;
    	public static Texture wood;
     
        public static void main(String args[]) {
            try {
                Display.setDisplayMode(new DisplayMode(640, 480));
                Display.setTitle("Simple Artificial Servant- By Richard Ninness");
                Display.create();
            } catch (LWJGLException e) {
                e.printStackTrace();
                Display.destroy();
                System.exit(1);
            }
            try {
                // Load the wood texture from "res/images/wood.png"
                wood = TextureLoader.getTexture("PNG", new FileInputStream(new File("C:\\Users\\DerpyLlama\\Desktop\\lwjgl-2.8.5\\res\\Capturecmd.png")));
            } catch (IOException e) {
                e.printStackTrace();
                Display.destroy();
                System.exit(1);
            }
            glMatrixMode(GL_PROJECTION);
            glOrtho(0, 640, 480, 0, 1, -1);
            glMatrixMode(GL_MODELVIEW);
            glEnable(GL_TEXTURE_2D);
            while (!Display.isCloseRequested()) {
                glClear(GL_COLOR_BUFFER_BIT);
                wood.bind();
                glBegin(GL_TRIANGLES);
                glTexCoord2f(1, 0);
                glVertex2i(900, 20);
                glTexCoord2f(0, 0);
                glVertex2i(20, 20);
                glTexCoord2f(0, 1);
                glVertex2i(20, 900);
                glTexCoord2f(0, 1);
                glVertex2i(20, 900);
                glTexCoord2f(1, 1);
                glVertex2i(900, 900);
                glTexCoord2f(1, 0);
                glVertex2i(900, 20);
                glEnd();
    //            glBegin(GL_QUADS);
    //            glTexCoord2f(0, 0);
    //            glVertex2i(400, 400); // Upper-left
    //            glTexCoord2f(1, 0);
    //            glVertex2i(450, 400); // Upper-right
    //            glTexCoord2f(1, 1);
    //            glVertex2i(450, 450); // Bottom-right
    //            glTexCoord2f(0, 1);
    //            glVertex2i(400, 450); // Bottom-left
    //            glEnd();
                Display.update();
                Display.sync(60);
            }
     
     
     
            // Release the resources of the wood texture
            wood.release();
            Display.destroy();
            System.exit(0);
        }
     
     
        public void pollInput() {
     
            if (Mouse.isButtonDown(0)) {
    	    int x = Mouse.getX();
    	    int y = Mouse.getY();
     
    	    System.out.println("MOUSE DOWN @ X: " + x + " Y: " + y);
    	}
     
    	if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
    	   System.out.println("SPACE KEY IS DOWN");
     
    	}
     
     
     
    	while (Keyboard.next()) {
    	    if (Keyboard.getEventKeyState()) {
    	        if (Keyboard.getEventKey() == Keyboard.KEY_T) {
     
     
     
    		}
    		if (Keyboard.getEventKeyState()) {
    		    if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {    
     
    	    	Display.destroy();
    	    	System.out.println("Goodbye, master.");
    	        }
     
     
     
     
    		}    
    		if (Keyboard.getEventKey() == Keyboard.KEY_S) {
    		    System.out.println("S Key Pressed");
    		}
    		if (Keyboard.getEventKey() == Keyboard.KEY_D) {
    		    System.out.println("D Key Pressed");
    		}
    	    } else {
    	        if (Keyboard.getEventKey() == Keyboard.KEY_A) {
    		    System.out.println("A Key Released");
    	        }
    	    	if (Keyboard.getEventKey() == Keyboard.KEY_S) {
    		    System.out.println("S Key Released");
    		}
    		if (Keyboard.getEventKey() == Keyboard.KEY_D) {
    		    System.out.println("D Key Released");
    		}
    	    }
    	}
        }
        final String Example = "This is an example";
     
     
     
     
     
     
     
     
     
     
        public static void main11(String[] argv) {
            AI inputExample = new AI();
    	inputExample.start();
        }
    	protected void start() {
    		// TODO Auto-generated method stub
     
    	}


  2. #2
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    My Mood
    Love
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: LWJGL Texture Release Problem

    I would appreciate if anyone could help me, I'm trying to find a solution to this all over.

Similar Threads

  1. [SOLVED] LWJGL Problem - Trouble rendering properly!
    By vividMario52 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 22nd, 2013, 03:25 PM
  2. LWJGL texture applying problem
    By DanielJamesCollier in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 16th, 2012, 01:45 PM
  3. [SOLVED] (LWJGL)openGL arraylist rendering problem
    By DanielJamesCollier in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 11th, 2012, 02:21 PM
  4. [SOLVED] Problem with OpenGL via LWJGL
    By paulo.carabuena in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 6th, 2011, 02:52 PM