"Function is not supported" Exception

Started by Cornix, April 10, 2013, 21:51:16

Previous topic - Next topic

Cornix

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:
QuoteException 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!

dangerdoc

It would be hard to answer this question without code. Can we see some?  
“We build but to tear down. Most of our work and resource is squandered. Our onward march is marked by devastation. Everywhere there is an appalling loss of time, effort and life. A cheerless view, but true.” - Nikola Tesla

Cornix

The code causing the exception is pretty simple:
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)?

quew8

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.

dangerdoc

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:
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!
“We build but to tear down. Most of our work and resource is squandered. Our onward march is marked by devastation. Everywhere there is an appalling loss of time, effort and life. A cheerless view, but true.” - Nikola Tesla

Cornix

@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:
glCreateProgram()

instead?
I will give it a try.

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

quew8

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.

dangerdoc

Yeah it would be slow but it doesnt use shaders :/
“We build but to tear down. Most of our work and resource is squandered. Our onward march is marked by devastation. Everywhere there is an appalling loss of time, effort and life. A cheerless view, but true.” - Nikola Tesla