Hello Guest

Workaround for OpenGL not supported function?

  • 9 Replies
  • 7082 Views
Workaround for OpenGL not supported function?
« on: March 28, 2015, 22:17:56 »
I get the function not supported error in javascript with LWJGL. I am 94.23% sure that my openGL can't support the opengl 3 functions. Is there a workaround, such as GLEW or any other function pointer?
Thanks

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: Workaround for OpenGL not supported function?
« Reply #1 on: March 29, 2015, 03:44:53 »
In Javascript? LWJGL is for Java, not Javascript. Dunno how you got it working in Javascript. The difference between Java and Javascript is like the difference between car and carpenter.

*

Kai

Re: Workaround for OpenGL not supported function?
« Reply #2 on: March 29, 2015, 11:37:23 »
@jdogboy: You can use not only the core GL functions in the respective GLXX (GL11, GL12, GL20, ...) classes but also the OpenGL extensions, such as ARBVertexBufferObject, if these extensions are available.
You can check for availability with the ContextCapabilites class accessible via GLContext.getCapabilities(). Almost every function in OpenGL before becoming core in a specific GL version was part of an extension before.

@SHC: Technically, LWJGL can be used with any JVM language. That is, any language compiling to JVM bytecode, such as Java, Groovy, JRuby or Scala, and also JavaScript (with Node.js, Mozilla's Rhino or Oracle's Nashorn).
« Last Edit: March 29, 2015, 11:40:37 by Kai »

Re: Workaround for OpenGL not supported function?
« Reply #3 on: March 29, 2015, 16:21:11 »
Hi JDogboy! A reliable GLContext must be created, specifying ContextAttribs with the version you requested the function from.
See more about ContextAttribs and version selection on this LWJGL's tutorial : http://wiki.lwjgl.org/wiki/Version_selection !
« Last Edit: March 29, 2015, 16:22:52 by broumbroum »

Re: Workaround for OpenGL not supported function?
« Reply #4 on: April 01, 2015, 22:09:10 »
Whoops! Sorry... I had java, not javascript. Let me give you a little more detail about my situation. I have java 1.6 and I use eclipse. I am now on a mac that says I have openGl 4.1 supported, but when I print out the openGl version in eclipse, it says I have 2.1. With openGl Extension viewer, I realize that some of the functions are not supported. I am on a mac and I am still confused by the difference in openGL.

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: Workaround for OpenGL not supported function?
« Reply #5 on: April 02, 2015, 02:59:52 »
There are two profiles of OpenGL, the Core and the Compatibility. The Compatibility profile has support for deprecated methods, at the cost of low OpenGL version, but is used to support the older applications which are written with old OpenGL. It is also the default. Mac OS supports only upto 2.1 in compatibility mode, so to go to higher versions, you have to request a core profile.

In LWJGL2, you will have to request a core profile by using the ContextAttribs class. This is how you request a core profile context with it.

Code: [Select]
ContextAttribs cattribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
PixelFormat    pformat = new PixelFormat();

Display.create(cattribs, pformat);

But in LWJGL3, the Display class and all the old classes are replaced with GLFW, a C library which provides more features like multi-windowing support. To request a core profile context with GLFW, you have to hint it by setting some window hints. This is how you do in LWJGL3.

Code: [Select]
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);

Also, see that I'm using the version as 3.2 in the above snippets. In Mac OS, asking for 3.2 in core profile gives you the highest available context. But this will limit you to 3.2 on other OSes. So, change those numbers depending on the OS you are using. This is a small difference when on Mac OSX. Guaranteed hickups!

Hope this helps.

Re: Workaround for OpenGL not supported function?
« Reply #6 on: April 02, 2015, 14:39:49 »
Thanks! That worked great! :) Is there any way to get my older mac that has GL2 supported with the GL3 and 4 functions in my script? This method doesn't work when changing the GL to (2,0). Instead, I get this error.

Exception in thread "main" java.lang.IllegalArgumentException: Profiles are only supported on OpenGL version 3.2 or higher.
   at org.lwjgl.opengl.ContextAttribs.withProfileCore(ContextAttribs.java:278)
   at renderEngine.DisplayManager.createDisplay(DisplayManager.java:18)
   at engineTester.MainGameLoop.main(MainGameLoop.java:19)


Re: Workaround for OpenGL not supported function?
« Reply #7 on: June 01, 2015, 11:54:04 »
Just thought I would correct this.

The newest MAC OSX now supports OpenGL 4.0

The previous two versions of MAC OSX support OpenGL 3.2.

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: Workaround for OpenGL not supported function?
« Reply #8 on: June 01, 2015, 12:44:20 »
@JackDawson

You're right, newest macs do support OpenGL 4.1, but you have to request for 3.2 in core profile to get that.

Re: Workaround for OpenGL not supported function?
« Reply #9 on: June 01, 2015, 15:56:38 »
@JackDawson

You're right, newest macs do support OpenGL 4.1, but you have to request for 3.2 in core profile to get that.

Thanks for the heads up.