I have a problem on a cros-platform application using JOGL and I different things to solve but none of them worked. To begin with, this is some code to show you how I render my scene (without useless code for you) :
The Display Method:
public void display(GLAutoDrawable drawable)
{
// TODO Auto-generated method stub
GL2 gl = drawable.getGL().getGL2();
setLighting(gl);
gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT );
// matrice definition MODELVIEW from camera matrice
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadMatrixf(this.camera.getCameraMatrix());
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glEnable(GL2.GL_NORMALIZE);
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
/*** Voxels Drawing */
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[0]);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[1]);
gl.glColorPointer(4, GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, vbo[2]);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glDrawElements(GL2.GL_QUADS, numberVertToDraw, GL.GL_UNSIGNED_INT, 0);
gl.glDisable(GL.GL_BLEND);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
}
the SetLighting method:
private void setLighting(GL2 gl)
{
gl.glPushMatrix();
gl.glLoadIdentity();
float[] lightPos = new float[4];
lightPos[0] = 15;
lightPos[1] = 25;
lightPos[2] = 15;
lightPos[3] = 1;
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
float[] noAmbient ={ 0.8f, 0.8f, 0.8f, 1f }; // low ambient light
float[] spec = { 0.8f, 0.8f, 0.8f, 1f }; // low ambient light
float[] diffuse ={ 0.2f, 0.2f, 0.2f, 1f };
float[] rgba = {0f, 0f, 0f};
gl.glMaterialfv(GL.GL_FRONT, GL2.GL_AMBIENT, rgba, 0);
gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, rgba, 0);
gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 1f);
FloatBuffer Light1Dir = Buffers.newDirectFloatBuffer(new float[]{-1,-1,-1});
FloatBuffer exponent = Buffers.newDirectFloatBuffer(new float[]{5}); // properties of the light
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_AMBIENT, noAmbient, 0);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_SPECULAR, spec, 0);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_DIFFUSE, diffuse, 0);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_POSITION, lightPos, 0);
gl.glLighti(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_SPOT_CUTOFF, 50);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_SPOT_DIRECTION, Light1Dir);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_SPOT_EXPONENT, exponent);
gl.glLightf(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_CONSTANT_ATTENUATION, 1f);
gl.glLightf(GLLightingFunc.GL_LIGHT0,GLLightingFunc. GL_LINEAR_ATTENUATION, 0f);
gl.glLightf(GLLightingFunc.GL_LIGHT0,GLLightingFunc. GL_QUADRATIC_ATTENUATION, 0f);
gl.glPopMatrix();
}
So here is my problem: I export the jar to have a cross-platform application. I test on my my Linux VM, and on my Linux system, all works like in my IDE (Eclipse). But when I try on Windows, there is no light render.
Actually, I made some test changing the material of the light and when I get close the object to the light, its color change. So the light is here but it lights everywhere with the same intensity. My tests lead to the ATTENUATION function (the tree last of setLighting). This function has no effect on Windows, or it has but Windows reset it at some point, I don't know.
I test on Mac very soon and so, I will edit this post.
Someone has an idea for that ? I don't use shaders because I don't have the time to learn, this is for professionnal purpose, but I know I should someday. I really can't find how to solve this problem and I found nothing on the Net...
Thank you everyone for read this !
PS: This my first post and my french, so sorry if I did something wrong regarding the forum rules, and sorry for my eventually bad english =)
EDIT: I just made the test on Mac, and the attenuation works just like it should work. The problems is just on Windows...
It has nothing to do with the operating system. Please run a simple example of the OpenGL Red Book ported to JOGL, for example this one. I assume that the problem comes from the OpenGL driver.
I advise you to read this as you try to make a fat JAR.
I have at least one old graphics card with no light working properly under GNU Linux.
Please translate your very first line of comment into English, think about the vast majority of StackOverflow users who don't understand our mother tongue.