4

I've been working with lwjgl for some time, and recently I've decided to switch from fixed function pipeline to shaders. So, the first thing when I'm starting my program, I set the ContextAttrib(3, 2) so I will be using GL 3.2+. The problem is that when I switch on higher version of GL a lot of functions become unsupported. Before switching to higher GL, I've used Slick's font (TrueTypeFont) to render the text I needed, but now the drawString method of TrueTypeFont has an unsupported function within itself. I've tried to google for solution, but nothing came up.

Does anyone know if it is possible to render text with slick-util library, while using GL version 3.2+ or with some other library? Or any link on the topic. I would appreciate any help, or suggestion.

EDIT: The code for starting openGL 3.2 and newer form the tutorial on the wiki

try
    {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);

        Display.create(pixelFormat, contextAtrributes);
    } catch (LWJGLException e){
        e.printStackTrace();
        return;
    }

By using openGL 3.2 or newer you are forced to use only shaders. The exception appearing when calling drawString on UnicodeFont or TrueTypeFont, or any other fixed function pipeline function like GL11.glMatrixMode(GL11.GL_PROJECTION);:

Exception in thread "Thread-0" java.lang.IllegalStateException: Function is not supported
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
at org.lwjgl.opengl.GL11.glColor4f(GL11.java:881)
at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glColor4f(ImmediateModeOGLRenderer.java:127)
at org.newdawn.slick.Color.bind(Color.java:182)
at org.newdawn.slick.UnicodeFont.drawDisplayList(UnicodeFont.java:443)
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:551)
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:559)
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:555)
at application.Controller.render3D(Controller.java:163)
at Engine.Engine.renderScene3D(Engine.java:230)
at Engine.Engine.render(Engine.java:334)
at Engine.Engine.gameLoop(Engine.java:306)
at Engine.Engine.access$1(Engine.java:246)
at Engine.Engine$1.run(Engine.java:154)

thanks.

LW001
  • 2,452
  • 6
  • 27
  • 36

1 Answers1

0

A similar question popped up on the GameDevSE as well you might want for check it out here

Citing:

It sounds like you probably didn't actually request an appropriately-versioned OpenGL context (that is, one with 3.2 support). To do so, you must provide context attributes requesting the desired version when you call Display.create()

PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
    .withForwardCompatible(true)
    .withProfileCore(true);

try {
      Display.setDisplayMode(new DisplayMode(320, 240));
      Display.setTitle("Version selection");
      Display.create(pixelFormat, contextAtrributes);
} catch (LWJGLException e) {
    e.printStackTrace();
    System.exit(-1);
}
Community
  • 1
  • 1
Dawnkeeper
  • 2,844
  • 1
  • 25
  • 41