In one program of mine I got a null exception and debugging the code I found out it was because one of my String array (java):
val FRAGMENTS = arrayOf("phong-lighting", "phong-only", "blinn-lighting", "blinn-only")
was not yet initialized when I needed it in a successive class method (java):
fun initializePrograms(gl: GL3) {
programs = Array(LightingModel.MAX, {
ProgramPairs(
ProgramData(gl, "pn.vert", FRAGMENTS[it] + ".frag"),
ProgramData(gl, "pcn.vert", FRAGMENTS[it] + ".frag"))
})
unlit = UnlitProgData(gl, "pos-transform.vert", "uniform-color.frag")
}
If I move it inside:
fun initializePrograms(gl: GL3) {
val FRAGMENTS = arrayOf("phong-lighting", "phong-only", "blinn-lighting", "blinn-only")
...
}
Then everything fine.. why?
Ps: same code and same behavious also in java
Edit: don't get confused, that init is not the class init, it extends the Framework method here
Edit2: initializePrograms() doesn't get called from the super constructor. It's called from init(GL3 gl) which override Framework.init(GL3 gl) which gets called from Framework.init(GLAutoDrawable autoDrawable), which shall be called from the Animator just once at begin which should be another thread.
initializePrograms()gets called frominit(GL3 gl)which overrideFramework.init(GL3 gl)which gets called fromFramework.init(GLAutoDrawable autoDrawable), which shall be called from theAnimatorjust once at begin which should be another thread.