Hello Guest

"Function is not supported" Exception

  • 7 Replies
  • 10294 Views
*

Offline Cornix

  • *****
  • 488
"Function is not supported" Exception
« on: April 10, 2013, 21:51:16 »
Hello,

I am writing an application with my own shader. I use the shader for simple Palette Swapping for my sprites.

On my (older) laptop i get the following exception:
Quote
Exception in thread "main" java.lang.IllegalStateException: Function is not supported
     at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
     at org.lwjgl.opengl.ARBShaderObjects.glCreateShaderObjectARB(ARBShaderObjects.java:92)
     ...
I guess this means the laptop does not support an OpenGL version high enough for custom shaders. But i might be wrong.
But even if i guessed right, how could i achieve Palette Swapping in OpenGL without a custom fragment shader?

Thanks in advance!
« Last Edit: April 11, 2013, 12:37:25 by Cornix »

*

Offline dangerdoc

  • **
  • 75
  • Thats right... Nikola Tesla
Re: "Function is not supported" Exception
« Reply #1 on: April 24, 2013, 05:06:53 »
It would be hard to answer this question without code. Can we see some?  
« Last Edit: April 24, 2013, 23:19:54 by dangerdoc »

*

Offline Cornix

  • *****
  • 488
Re: "Function is not supported" Exception
« Reply #2 on: April 24, 2013, 14:26:33 »
The code causing the exception is pretty simple:
Code: [Select]
ARBShaderObjects.glCreateProgramObjectARB();
But the important part of the question is: How do I realize old school palette swapping without a shader (and with good performance)?

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: "Function is not supported" Exception
« Reply #3 on: April 24, 2013, 16:57:46 »
You are using the arb extension there. (Maybe stupid question) Are you sure the core version isn't supported. I don't know this for sure but it might be that the extension wouldn't be supported if the core profile supported it anyway.

*

Offline dangerdoc

  • **
  • 75
  • Thats right... Nikola Tesla
Re: "Function is not supported" Exception
« Reply #4 on: April 24, 2013, 17:03:03 »
Well you *could* run the png image through a pallete function before loading it into OpenGL, but you would have to do that yourself unless there is a library out there somewhere... If you want to change it in real time, just reload the image into the program with ObjectInputStream then perform the pallete swap on it.

It could be as simple as a function for each pixel:
Code: [Select]
public color swapcolor(color[] colorstobeswapped, color[] destinationcolors, color colortobechecked){
    for(x=1, x<colorstobeswabbed.length, x++)
        if(colortobechecked==colortobeswabbed[x]){
            return destinationcolors[x];
        }
    }
    return colortobechecked;
}

This is assuming that you use Java color values to load it... You can do this for each rgb value instead if that is how you prefer it. Just look up java PNG image functions, and the different formats for color values.

Cheers!

*

Offline Cornix

  • *****
  • 488
Re: "Function is not supported" Exception
« Reply #5 on: April 24, 2013, 17:40:51 »
@dangerdoc: That would be a painfully slow method. I have dozens of sprites on the screen which share the same texture and might potentially change their palette every few seconds.

@quew8: You mean i should use:
Code: [Select]
glCreateProgram()instead?
I will give it a try.

Is there any difference between those functions i should be aware of before i try?

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: "Function is not supported" Exception
« Reply #6 on: April 24, 2013, 18:22:17 »
ARB stands for architecture review board. The functions and constants ending in ARB are extensions to the opengl core profile. These don't have to be supported by the hardware but it gives the hardware designers to show off how clever they are and how good their product is. (The architecture review board is a board of the companies that make the hardware, Nvidia, AMD, Intel, Apple etc.)
As far as I can see, most ARB extensions (if not all) become part of the core profile when the next version of opengl is released. So the ARBShaderObjects extension was probably added in opengl 1.3 or something around that then when 2.0 is released, low and behold, shaders are a standard feature. In conclusion, the methods are exactly the same in every aspect but name.

Edit: Said the wrong thing.

*

Offline dangerdoc

  • **
  • 75
  • Thats right... Nikola Tesla
Re: "Function is not supported" Exception
« Reply #7 on: April 24, 2013, 23:21:17 »
Yeah it would be slow but it doesnt use shaders :/