I am working with GL identifier ints, and have a very quick question: is there a why to pass a field/variable identifier to a function for initialization in Java? So far, this gives me errors:
public class ScratchPad
{
public static void main( String[] args )
{
ScratchPad s = new ScratchPad();
int monkey = 0;
s.test( monkey );
System.out.println( monkey );
}
private void test( int ID )
{
ID = 3;
}
}
output = 0, instead of expected 3.
I am just trying to understand why. This little mini program just illustrates the point. In a perfect world I’d like to have something like this:
int vertexShaderID; // declare uninitialized
// or, if necessary, int vertexShaderID = 0 since that int is not used by the GL ( I believe GL ids are > 0 ).
compileShader( vertexShaderID, GL.GL_VERTEX_SHADER, vertexShaderSource );
However, this only works if I have initialized vertexShaderID before passing it into the function. The sample program above encapsulates what is happening. If I don’t assign the ID before calling compileShader OpenGL sends and error.
I’d like the compileShader function to assign the ID with the call to gl.glCreateShader instead of doing that before the function is called.
Thanks for any insights.