1

This is an extremely simple question, but I have no idea what to do.

package typeandscreen;

imports

public class DisplayWindow {
Font f = new Font();

void run(){
    try {
        Display.setDisplayMode(new DisplayMode(1000,560));
        Display.setTitle("Test for Bitmaps / Letters");
        Display.create();
    } catch(LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }
    while(!Display.isCloseRequested()){
        Graphics g;

What do I make Graphics g equal? I just want to draw the subImage f.letters[0] onto the screen, but I don't know what I'm supposed to put there.

Making the lower line Graphics.drawImage(etc) doesn't work, and leaving it how it is, is a null pointer exception. If I do "Graphics g = f.letters[0].getGraphics()" for the above line then it's also a null pointer exception.

        g.drawImage(f.letters[0],0,0,null);
        Display.update();

    }
    Display.destroy();
}

public static void main(String args[]){
    DisplayWindow dw = new DisplayWindow();
    dw.run();
}

}
GlassZee
  • 1,117
  • 2
  • 11
  • 22
  • 1
    If using a BufferedImage, the Graphics context can be obtained from the BufferedImage itself via `BufferedImage#getGraphics()`. Otherwise what gui library are you using because I suspect that this isn't Swing or AWT. – Hovercraft Full Of Eels Jan 31 '12 at 23:59
  • 1
    Are you sure you want to use `java.awt.Graphics` and not OpenGL? I'm sure there is some way to draw with awt on LWJGL display but it misses the point of LWJGL. If you want to draw with awt, it makes more sense to use it for windows and events too. – Piotr Praszmo Feb 01 '12 at 00:50
  • *"This is an extremely simple question"* 'What is the meaning of life?' Is an extremely simple question. It is the ***answer*** that is more tricky. – Andrew Thompson Feb 01 '12 at 03:08
  • Banthar, that's a really good point... I'll look into using LWJGL for it. I'm pretty sure this chapter is relevant to what I'm doing? http://glprogramming.com/red/chapter08.html But see, would I need to change BufferedImage or just Graphics? BufferedImage has subImages, and what I'm doing is taking a sprite sheet and splitting it into smaller subImages, one of which is f.letters[0]. Does LWJGL or OpenGL have subImages or a way of cutting a bigger image into smaller ones? – GlassZee Feb 01 '12 at 03:22
  • If you use my code found [here][1] you can use the the drawString method [1]: http://stackoverflow.com/questions/10860782/error-on-opengl-texture-delete/ – Liam Haworth Jun 07 '12 at 10:30

0 Answers0