Greetings!
Help please to me to solve a small problem with streams in JOGL.
I wish to make loading of textures and geometry in a separate stream, for this purpose I use Runnable() and do so:
static GL gl;
static GLUT glut;
static GLU glu;
.....
public void init(GLAutoDrawable drawable) {
gl = drawable.getGL();
glu = new GLU();
glut = new GLUT();
.....
public void run() {
for ( int i = 0;i < 5; i ++){
try {
gl.glBindTexture(GL.GL_TEXTURE_2D, menuTex[i]);
tl.loadTexture("" +i,"menu");
glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, 4, tl.getWidth(),tl.getHeight(), gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, tl.getTextureBuf());
} catch (IOException ex) {
ex.printStackTrace();
}
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP);
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP);
}
}
When I run the program it cast exception:
Exception in thread "Thread-12" javax.media.opengl.GLException: No OpenGL context current on this thread
at javax.media.opengl.glu.GLU.getCurrentGL(GLU.java:234)
at javax.media.opengl.glu.GLU.gluBuild2DMipmapsJava(GLU.java:1525)
at javax.media.opengl.glu.GLU.gluBuild2DMipmaps(GLU.java:1581)
at Metods.renderMenu.run(renderMenu.java:283)
at java.lang.Thread.run(Thread.java:595)
Help me to solve this problem please :-
PS.I ask to forgive my English