Hello Guest

[SOLVED] Changing OpenGL version to 3.2 causing error

  • 2 Replies
  • 4473 Views
[SOLVED] Changing OpenGL version to 3.2 causing error
« on: January 27, 2014, 08:39:20 »
I was reading this tutorial on how to set the OpenGL version to 3.2 here:
http://lwjgl.org/wiki/index.php?title=Version_selection

The code in my display creation before this error became a problem was:
Code: [Select]
public static void createDisplay()
{
try
{
Display.setDisplayMode(new DisplayMode(width, height));
Display.setVSyncEnabled(true);
Display.setTitle(Main.title);
Display.create();
}
catch (LWJGLException e)
{
e.printStackTrace();
}

System.out.println("OS: " + System.getProperty("os.name"));
System.out.println("OS Version: " + System.getProperty("os.version"));
System.out.println("LWJGL Version: " + org.lwjgl.Sys.getVersion());
System.out.println("OpenGL Version: " + GL11.glGetString(GL11.GL_VERSION));
}

The only change I made was context attributes and pixel format:
Code: [Select]
public static void createDisplay()
{
PixelFormat pf = new PixelFormat();
ContextAttribs ca = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);

try
{
Display.setDisplayMode(new DisplayMode(width, height));
Display.setVSyncEnabled(true);
Display.setTitle(Main.title);
Display.create(pf, ca);
}
catch (LWJGLException e)
{
e.printStackTrace();
}

System.out.println("OS: " + System.getProperty("os.name"));
System.out.println("OS Version: " + System.getProperty("os.version"));
System.out.println("LWJGL Version: " + org.lwjgl.Sys.getVersion());
System.out.println("OpenGL Version: " + GL11.glGetString(GL11.GL_VERSION));
}

The OpenGL version is printed as 3.2 instead of my driver's 4.3, which is good. The problem is when I start referencing OpenGL functions like glMatrixMode()

Error code:
Code: [Select]
Exception in thread "main" java.lang.IllegalStateException: Function is not supported
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:2075)

This wasn't a problem before the change stated, so I know it has to do with changing the OpenGL context. I haven't been able to find any solutions online after a few days of research. There was one post I read on stackoverflow where a guy had the same problem, but it was completely ignored. Does anyone have any idea what could be causing this? I'm using LWJGL v2.9.1
« Last Edit: January 27, 2014, 09:02:39 by Knokk »

Re: Changing OpenGL version to 3.2 causing error
« Reply #1 on: January 27, 2014, 09:02:14 »
I did some thinking about the error and realized it's probably something to do with deprecated functionality. I could be wrong, but I tried removing my calls to glMatrixMode since I'm using my own matrices anyway, and everything seems to be working fine. Problem solved. :)

*

Offline spasi

  • *****
  • 2198
    • WebHotelier
Re: [SOLVED] Changing OpenGL version to 3.2 causing error
« Reply #2 on: January 27, 2014, 09:45:12 »
You can restore the deprecated functionality by changing:

Code: [Select]
// this
ContextAttribs ca = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
// to this
ContextAttribs ca = new ContextAttribs(3, 2).withProfileCompatibility(true);