aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/opengl')
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java2
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java (renamed from src/classes/com/sun/opengl/impl/glsl/FixedFuncPipeline.java)114
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.fp9
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.vp22
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorLight.vp70
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorTexture.fp39
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bfpbin0 -> 524 bytes
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bvpbin0 -> 2344 bytes
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorLight.bvpbin0 -> 8787 bytes
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorTexture.bfpbin0 -> 1804 bytes
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/es_precision.glsl14
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_attribute.glsl19
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_const.glsl10
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_lightdef.glsl26
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_settexcoord.vp35
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform.glsl17
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform_light.glsl15
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/shader/mgl_varying.glsl12
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc-ff.bat9
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc.bat9
20 files changed, 358 insertions, 64 deletions
diff --git a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
index 551eb525f..b56c2dc92 100644
--- a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
+++ b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
@@ -2,7 +2,7 @@
package com.sun.opengl.impl.glsl;
import javax.media.opengl.*;
-import javax.media.opengl.util.glsl.ShaderState;
+import javax.media.opengl.glsl.ShaderState;
import java.nio.*;
public class GLSLArrayDataServer extends GLArrayDataServer {
diff --git a/src/classes/com/sun/opengl/impl/glsl/FixedFuncPipeline.java b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
index dc7ebaae6..f9798f48a 100644
--- a/src/classes/com/sun/opengl/impl/glsl/FixedFuncPipeline.java
+++ b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
@@ -1,9 +1,9 @@
-package com.sun.opengl.impl.glsl;
+package com.sun.opengl.impl.glsl.fixed;
import javax.media.opengl.*;
import javax.media.opengl.util.*;
-import javax.media.opengl.util.glsl.*;
+import javax.media.opengl.glsl.*;
import java.nio.*;
public class FixedFuncPipeline {
@@ -63,14 +63,22 @@ public class FixedFuncPipeline {
shaderState.glUseProgram(gl, true);
shaderState.glEnableVertexAttribArray(gl, getArrayIndexName(glArrayIndex));
- textureCoordsEnabled |= (1 << activeTextureUnit);
+ // textureCoordsEnabled |= (1 << activeTextureUnit);
+ if ( textureCoordsEnabled.get(activeTextureUnit) != 1 ) {
+ textureCoordsEnabled.put(activeTextureUnit, 1);
+ textureCoordsEnabledDirty = true;
+ }
}
public void glDisableClientState(GL2ES2 gl, int glArrayIndex) {
shaderState.glUseProgram(gl, true);
shaderState.glDisableVertexAttribArray(gl, getArrayIndexName(glArrayIndex));
- textureCoordsEnabled &= ~(1 << activeTextureUnit);
+ // textureCoordsEnabled &= ~(1 << activeTextureUnit);
+ if ( textureCoordsEnabled.get(activeTextureUnit) != 0 ) {
+ textureCoordsEnabled.put(activeTextureUnit, 0);
+ textureCoordsEnabledDirty = true;
+ }
}
public void glVertexPointer(GL2ES2 gl, GLArrayData data) {
@@ -245,10 +253,9 @@ public class FixedFuncPipeline {
int light = cap - GL.GL_LIGHT0;
if(0 <= light && light < MAX_LIGHTS) {
- if(enable) {
- lightsEnabled |= (1 << light);
- } else {
- lightsEnabled &= ~(1 << light);
+ if ( (lightsEnabled.get(light)==1) != enable ) {
+ lightsEnabled.put(light, enable?1:0);
+ lightsEnabledDirty = true;
}
return;
}
@@ -281,20 +288,22 @@ public class FixedFuncPipeline {
}
}
- ud = shaderState.getUniform(mgl_TexCoordEnabled);
- if(null!=ud) {
- if(textureCoordsEnabled!=ud.intValue()) {
- ud.setData(textureCoordsEnabled);
+ if(textureCoordsEnabledDirty) {
+ ud = shaderState.getUniform(mgl_TexCoordEnabled);
+ if(null!=ud) {
+ // same data object
shaderState.glUniform(gl, ud);
}
+ textureCoordsEnabledDirty=false;
}
- ud = shaderState.getUniform(mgl_LightsEnabled);
- if(null!=ud) {
- if(lightsEnabled!=ud.intValue()) {
- ud.setData(lightsEnabled);
+ if(lightsEnabledDirty) {
+ ud = shaderState.getUniform(mgl_LightsEnabled);
+ if(null!=ud) {
+ // same data object
shaderState.glUniform(gl, ud);
}
+ lightsEnabledDirty=false;
}
if(textureEnabled) {
@@ -334,69 +343,44 @@ public class FixedFuncPipeline {
this.shaderState.setVerbose(verbose);
ShaderCode vertexColor, vertexColorLight, fragmentColor, fragmentColorTexture;
- // FIXME: Proper evaluation for binary format types ..
- int binaryFormat = GLProfile.isGLES2()?GLES2.GL_NVIDIA_PLATFORM_BINARY_NV:-1;
-
- switch(binaryFormat) {
- case GLES2.GL_NVIDIA_PLATFORM_BINARY_NV:
- vertexColor = ShaderCode.create( gl.GL_VERTEX_SHADER, 1, this.getClass(),
- binaryFormat, "binary_nvidia/FixedFuncShaderVertexColor.nvbv",
- vertexColorSrcFile);
+ vertexColor = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, FixedFuncPipeline.class,
+ shaderSrcRoot, shaderBinRoot, vertexColorFile);
- vertexColorLight = ShaderCode.create( gl.GL_VERTEX_SHADER, 1, this.getClass(),
- binaryFormat, "binary_nvidia/FixedFuncShaderVertexColorLight.nvbv",
- vertexColorLightSrcFile);
+ vertexColorLight = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, FixedFuncPipeline.class,
+ shaderSrcRoot, shaderBinRoot, vertexColorLightFile);
- fragmentColor = ShaderCode.create( gl.GL_FRAGMENT_SHADER, 1, this.getClass(),
- binaryFormat, "binary_nvidia/FixedFuncShaderFragmentColor.nvbv",
- fragmentColorSrcFile);
+ fragmentColor = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, FixedFuncPipeline.class,
+ shaderSrcRoot, shaderBinRoot, fragmentColorFile);
- fragmentColorTexture = ShaderCode.create( gl.GL_FRAGMENT_SHADER, 1, this.getClass(),
- binaryFormat, "binary_nvidia/FixedFuncShaderFragmentColorTexture.nvbv",
- fragmentColorTextureSrcFile);
-
- break;
- default:
- vertexColor = ShaderCode.create( gl.GL_VERTEX_SHADER, 1, this.getClass(), -1, null,
- vertexColorSrcFile);
-
- vertexColorLight = ShaderCode.create( gl.GL_VERTEX_SHADER, 1, this.getClass(), -1, null,
- vertexColorLightSrcFile);
-
- fragmentColor = ShaderCode.create( gl.GL_FRAGMENT_SHADER, 1, this.getClass(), -1, null,
- fragmentColorSrcFile);
-
- fragmentColorTexture = ShaderCode.create( gl.GL_FRAGMENT_SHADER, 1, this.getClass(), -1, null,
- fragmentColorTextureSrcFile);
- }
+ fragmentColorTexture = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, FixedFuncPipeline.class,
+ shaderSrcRoot, shaderBinRoot, fragmentColorTextureFile);
-
shaderProgramColor = new ShaderProgram();
shaderProgramColor.add(vertexColor);
shaderProgramColor.add(fragmentColor);
if(!shaderProgramColor.link(gl, System.err)) {
- throw new GLException("Couldn't link VertexColor program");
+ throw new GLException("Couldn't link VertexColor program: "+shaderProgramColor);
}
shaderProgramColorTexture = new ShaderProgram();
shaderProgramColorTexture.add(vertexColor);
shaderProgramColorTexture.add(fragmentColorTexture);
if(!shaderProgramColorTexture.link(gl, System.err)) {
- throw new GLException("Couldn't link VertexColorTexture program");
+ throw new GLException("Couldn't link VertexColorTexture program: "+shaderProgramColorTexture);
}
shaderProgramColorLight = new ShaderProgram();
shaderProgramColorLight.add(vertexColorLight);
shaderProgramColorLight.add(fragmentColor);
if(!shaderProgramColorLight.link(gl, System.err)) {
- throw new GLException("Couldn't link VertexColorLight program");
+ throw new GLException("Couldn't link VertexColorLight program: "+shaderProgramColorLight);
}
shaderProgramColorTextureLight = new ShaderProgram();
shaderProgramColorTextureLight.add(vertexColorLight);
shaderProgramColorTextureLight.add(fragmentColorTexture);
if(!shaderProgramColorTextureLight.link(gl, System.err)) {
- throw new GLException("Couldn't link VertexColorLight program");
+ throw new GLException("Couldn't link VertexColorLight program: "+shaderProgramColorTextureLight);
}
shaderState.attachShaderProgram(gl, shaderProgramColor);
@@ -412,7 +396,7 @@ public class FixedFuncPipeline {
shaderState.glUniform(gl, new GLUniformData(mgl_ColorEnabled, 0));
shaderState.glUniform(gl, new GLUniformData(mgl_ColorStatic, 4, zero4f));
- shaderState.glUniform(gl, new GLUniformData(mgl_TexCoordEnabled, textureCoordsEnabled));
+ shaderState.glUniform(gl, new GLUniformData(mgl_TexCoordEnabled, 1, textureCoordsEnabled));
shaderState.glUniform(gl, new GLUniformData(mgl_ActiveTexture, activeTextureUnit));
shaderState.glUniform(gl, new GLUniformData(mgl_ActiveTextureIdx, activeTextureUnit));
shaderState.glUniform(gl, new GLUniformData(mgl_ShadeModel, 0));
@@ -428,7 +412,7 @@ public class FixedFuncPipeline {
shaderState.glUniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].linearAttenuation", defLinearAtten));
shaderState.glUniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].quadraticAttenuation", defQuadraticAtten));
}
- shaderState.glUniform(gl, new GLUniformData(mgl_LightsEnabled, lightsEnabled));
+ shaderState.glUniform(gl, new GLUniformData(mgl_LightsEnabled, 1, lightsEnabled));
shaderState.glUniform(gl, new GLUniformData(mgl_FrontMaterial+".ambient", 4, defMatAmbient));
shaderState.glUniform(gl, new GLUniformData(mgl_FrontMaterial+".diffuse", 4, defMatDiffuse));
shaderState.glUniform(gl, new GLUniformData(mgl_FrontMaterial+".specular", 4, defMatSpecular));
@@ -443,11 +427,13 @@ public class FixedFuncPipeline {
protected boolean verbose=false;
protected boolean textureEnabled=false;
- protected int textureCoordsEnabled=0;
+ protected IntBuffer textureCoordsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });
+ protected boolean textureCoordsEnabledDirty = false;
protected int activeTextureUnit=0;
protected boolean lightingEnabled=false;
- protected int lightsEnabled=0;
+ protected IntBuffer lightsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });
+ protected boolean lightsEnabledDirty = false;
protected PMVMatrix pmvMatrix;
protected ShaderState shaderState;
@@ -464,11 +450,11 @@ public class FixedFuncPipeline {
protected static final String mgl_LightSource = "mgl_LightSource"; // struct mgl_LightSourceParameters[MAX_LIGHTS]
protected static final String mgl_FrontMaterial = "mgl_FrontMaterial"; // struct mgl_MaterialParameters
- protected static final String mgl_LightsEnabled = "mgl_LightsEnabled"; // 1i bitfield
+ protected static final String mgl_LightsEnabled = "mgl_LightsEnabled"; // int mgl_LightsEnabled[MAX_LIGHTS];
protected static final String mgl_ShadeModel = "mgl_ShadeModel"; // 1i
- protected static final String mgl_TexCoordEnabled = "mgl_TexCoordEnabled"; // 1i bitfield
+ protected static final String mgl_TexCoordEnabled = "mgl_TexCoordEnabled"; // int mgl_TexCoordEnabled[MAX_TEXTURE_UNITS];
protected static final String mgl_ActiveTexture = "mgl_ActiveTexture"; // 1i
protected static final String mgl_ActiveTextureIdx = "mgl_ActiveTextureIdx";// 1i
@@ -491,9 +477,11 @@ public class FixedFuncPipeline {
public static final FloatBuffer defMatEmission= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f});
public static final float defMatShininess = 0f;
- protected static final String[] vertexColorSrcFile = new String[] { "source/FixedFuncShaderVertexColor.vp" };
- protected static final String[] vertexColorLightSrcFile = new String[] { "source/FixedFuncShaderVertexColorLight.vp" };
- protected static final String[] fragmentColorSrcFile = new String[] { "source/FixedFuncShaderFragmentColor.fp" } ;
- protected static final String[] fragmentColorTextureSrcFile = new String[] { "source/FixedFuncShaderFragmentColorTexture.fp" } ;
+ protected static final String vertexColorFile = "FixedFuncColor";
+ protected static final String vertexColorLightFile = "FixedFuncColorLight";
+ protected static final String fragmentColorFile = "FixedFuncColor";
+ protected static final String fragmentColorTextureFile = "FixedFuncColorTexture";
+ protected static final String shaderSrcRoot = "shader" ;
+ protected static final String shaderBinRoot = "shader/bin" ;
}
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.fp b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.fp
new file mode 100644
index 000000000..71b39f45c
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.fp
@@ -0,0 +1,9 @@
+#include es_precision.glsl
+
+#include mgl_varying.glsl
+
+void main (void)
+{
+ gl_FragColor = frontColor;
+}
+
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.vp b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.vp
new file mode 100644
index 000000000..346e40196
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColor.vp
@@ -0,0 +1,22 @@
+#include es_precision.glsl
+
+#include mgl_const.glsl
+#include mgl_uniform.glsl
+#include mgl_attribute.glsl
+#include mgl_varying.glsl
+
+#include mgl_settexcoord.vp
+
+void main(void)
+{
+ if(mgl_ColorEnabled>0) {
+ frontColor=mgl_Color;
+ } else {
+ frontColor=mgl_ColorStatic;
+ }
+
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+
+ setTexCoord(gl_Position);
+}
+
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorLight.vp b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorLight.vp
new file mode 100644
index 000000000..ce203cfb9
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorLight.vp
@@ -0,0 +1,70 @@
+#include es_precision.glsl
+#include mgl_lightdef.glsl
+
+#include mgl_const.glsl
+#include mgl_uniform.glsl
+#include mgl_uniform_light.glsl
+#include mgl_attribute.glsl
+#include mgl_varying.glsl
+
+#include mgl_settexcoord.vp
+
+void main(void)
+{
+ vec4 position;
+ vec3 normal, lightDir, cameraDir, halfDir;
+ vec4 ambient, diffuse, specular;
+ float NdotL, NdotHV, dist, attenuation;
+ int i;
+
+ position = mgl_PMVMatrix[1] * mgl_Vertex; // vertex eye position
+
+ normal = normalize(mgl_NormalMatrix * mgl_Normal);
+ // cameraPosition: (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz
+ cameraDir = normalize( (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz - mgl_Vertex.xyz );
+
+ ambient = vec4(0,0,0,0);
+ diffuse = vec4(0,0,0,0);
+ specular = vec4(0,0,0,0);
+
+ bool lightEnabled = false;
+
+ for(i=0; i<MAX_LIGHTS; i++) {
+ if( 0!= mgl_LightsEnabled[i] ) {
+ lightEnabled = true;
+ ambient += mgl_LightSource[i].ambient;
+ lightDir = mgl_LightSource[i].position.xyz - position.xyz;
+ dist = length(lightDir);
+ lightDir = normalize(lightDir);
+ attenuation = 1.0 / (
+ mgl_LightSource[i].constantAttenuation+
+ mgl_LightSource[i].linearAttenuation * dist +
+ mgl_LightSource[i].quadraticAttenuation * dist * dist );
+ NdotL = max(0.0, dot(normal, lightDir));
+ diffuse += mgl_LightSource[i].diffuse * NdotL * attenuation;
+ if (NdotL != 0.0) {
+ halfDir = normalize (lightDir + cameraDir);
+ NdotHV = max(0.0, dot(normal, halfDir));
+ specular += mgl_LightSource[i].specular *
+ pow(NdotHV,mgl_FrontMaterial.shininess) * attenuation;
+ }
+ }
+ }
+ ambient += mgl_FrontMaterial.ambient;
+ diffuse *= mgl_FrontMaterial.diffuse;
+ specular *= mgl_FrontMaterial.specular;
+
+ if(mgl_ColorEnabled>0) {
+ frontColor=mgl_Color;
+ } else {
+ frontColor=mgl_ColorStatic;
+ }
+ if( lightEnabled ) {
+ frontColor *= ambient + diffuse + specular;
+ }
+
+ gl_Position = mgl_PMVMatrix[0] * position;
+
+ setTexCoord(gl_Position);
+}
+
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorTexture.fp b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorTexture.fp
new file mode 100644
index 000000000..cc4bd0c64
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/FixedFuncColorTexture.fp
@@ -0,0 +1,39 @@
+
+#include es_precision.glsl
+#include mgl_lightdef.glsl
+
+#include mgl_const.glsl
+#include mgl_uniform.glsl
+#include mgl_varying.glsl
+
+vec4 getTexColor(in sampler2D tex, in int idx) {
+ vec4 coord;
+ if(idx==0) {
+ coord= mgl_TexCoords[0];
+ } else if(idx==1) {
+ coord= mgl_TexCoords[1];
+ } else if(idx==2) {
+ coord= mgl_TexCoords[2];
+ } else if(idx==3) {
+ coord= mgl_TexCoords[3];
+ } else if(idx==4) {
+ coord= mgl_TexCoords[4];
+ } else if(idx==5) {
+ coord= mgl_TexCoords[5];
+ } else if(idx==6) {
+ coord= mgl_TexCoords[6];
+ } else {
+ coord= mgl_TexCoords[7];
+ }
+ return texture2D(tex, coord.st);
+}
+
+void main (void)
+{
+ vec4 texColor = getTexColor(mgl_ActiveTexture,mgl_ActiveTextureIdx);
+ if(length(texColor)>0.0) {
+ gl_FragColor = vec4(frontColor.rgb*texColor.rgb, frontColor.a * texColor.a) ;
+ } else {
+ gl_FragColor = frontColor;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bfp b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bfp
new file mode 100755
index 000000000..454354c12
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bfp
Binary files differ
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bvp b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bvp
new file mode 100755
index 000000000..279ef72c7
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColor.bvp
Binary files differ
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorLight.bvp b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorLight.bvp
new file mode 100755
index 000000000..5a9deea71
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorLight.bvp
Binary files differ
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorTexture.bfp b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorTexture.bfp
new file mode 100755
index 000000000..375ea6293
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/bin/nvidia/FixedFuncColorTexture.bfp
Binary files differ
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/es_precision.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/es_precision.glsl
new file mode 100644
index 000000000..fd6abe54e
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/es_precision.glsl
@@ -0,0 +1,14 @@
+#ifndef es_precision_glsl
+#define es_precision_glsl
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+ #define LOWP lowp
+#else
+ #define MEDIUMP
+ #define HIGHP
+ #define LOWP
+#endif
+
+#endif // es_precision_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_attribute.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_attribute.glsl
new file mode 100644
index 000000000..b09bdb05a
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_attribute.glsl
@@ -0,0 +1,19 @@
+
+#ifndef mgl_attribute_glsl
+#define mgl_attribute_glsl
+
+#include es_precision.glsl
+
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec3 mgl_Normal;
+attribute HIGHP vec4 mgl_Color;
+attribute HIGHP vec4 mgl_MultiTexCoord0;
+attribute HIGHP vec4 mgl_MultiTexCoord1;
+attribute HIGHP vec4 mgl_MultiTexCoord2;
+attribute HIGHP vec4 mgl_MultiTexCoord3;
+attribute HIGHP vec4 mgl_MultiTexCoord4;
+attribute HIGHP vec4 mgl_MultiTexCoord5;
+attribute HIGHP vec4 mgl_MultiTexCoord6;
+attribute HIGHP vec4 mgl_MultiTexCoord7;
+
+#endif // mgl_attribute_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_const.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_const.glsl
new file mode 100644
index 000000000..1a464a1cb
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_const.glsl
@@ -0,0 +1,10 @@
+
+#ifndef mgl_const_glsl
+#define mgl_const_glsl
+
+#include es_precision.glsl
+
+const LOWP int MAX_TEXTURE_UNITS = 8; // <=gl_MaxTextureImageUnits
+const LOWP int MAX_LIGHTS = 8;
+
+#endif // mgl_const_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_lightdef.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_lightdef.glsl
new file mode 100644
index 000000000..98e214139
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_lightdef.glsl
@@ -0,0 +1,26 @@
+#ifndef mgl_lightdef_glsl
+#define mgl_lightdef_glsl
+
+struct mgl_LightSourceParameters {
+ vec4 ambient;
+ vec4 diffuse;
+ vec4 specular;
+ vec4 position;
+ // vec4 halfVector; // is computed here
+ vec3 spotDirection;
+ float spotExponent;
+ float spotCutoff; // (range: [0.0,90.0], 180.0)
+ //float spotCosCutoff; // (range: [1.0,0.0],-1.0)
+ float constantAttenuation;
+ float linearAttenuation;
+ float quadraticAttenuation;
+};
+struct mgl_MaterialParameters {
+ vec4 ambient;
+ vec4 diffuse;
+ vec4 specular;
+ vec4 emission;
+ float shininess;
+};
+
+#endif // mgl_lightdef_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_settexcoord.vp b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_settexcoord.vp
new file mode 100644
index 000000000..1efe328d0
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_settexcoord.vp
@@ -0,0 +1,35 @@
+#ifndef mgl_settexcoord_vp
+#define mgl_settexcoord_vp
+
+#include es_precision.glsl
+
+#include mgl_const.glsl
+#include mgl_uniform.glsl
+#include mgl_attribute.glsl
+#include mgl_varying.glsl
+
+void setTexCoord(in vec4 defpos) {
+ /**
+ * bitwise operator not supported on APX 2500 ES 2.0
+ *
+ mgl_TexCoords[0] = ( 0 != (mgl_TexCoordEnabled & 1) ) ? mgl_MultiTexCoord0 : defpos;
+ mgl_TexCoords[1] = ( 0 != (mgl_TexCoordEnabled & 2) ) ? mgl_MultiTexCoord1 : defpos;
+ mgl_TexCoords[2] = ( 0 != (mgl_TexCoordEnabled & 4) ) ? mgl_MultiTexCoord2 : defpos;
+ mgl_TexCoords[3] = ( 0 != (mgl_TexCoordEnabled & 8) ) ? mgl_MultiTexCoord3 : defpos;
+ mgl_TexCoords[4] = ( 0 != (mgl_TexCoordEnabled & 16) ) ? mgl_MultiTexCoord4 : defpos;
+ mgl_TexCoords[5] = ( 0 != (mgl_TexCoordEnabled & 32) ) ? mgl_MultiTexCoord5 : defpos;
+ mgl_TexCoords[6] = ( 0 != (mgl_TexCoordEnabled & 64) ) ? mgl_MultiTexCoord6 : defpos;
+ mgl_TexCoords[7] = ( 0 != (mgl_TexCoordEnabled & 128) ) ? mgl_MultiTexCoord7 : defpos;
+ */
+
+ mgl_TexCoords[0] = ( 0 != mgl_TexCoordEnabled[0] ) ? mgl_MultiTexCoord0 : defpos;
+ mgl_TexCoords[1] = ( 0 != mgl_TexCoordEnabled[1] ) ? mgl_MultiTexCoord1 : defpos;
+ mgl_TexCoords[2] = ( 0 != mgl_TexCoordEnabled[2] ) ? mgl_MultiTexCoord2 : defpos;
+ mgl_TexCoords[3] = ( 0 != mgl_TexCoordEnabled[3] ) ? mgl_MultiTexCoord3 : defpos;
+ mgl_TexCoords[4] = ( 0 != mgl_TexCoordEnabled[4] ) ? mgl_MultiTexCoord4 : defpos;
+ mgl_TexCoords[5] = ( 0 != mgl_TexCoordEnabled[5] ) ? mgl_MultiTexCoord5 : defpos;
+ mgl_TexCoords[6] = ( 0 != mgl_TexCoordEnabled[6] ) ? mgl_MultiTexCoord6 : defpos;
+ mgl_TexCoords[7] = ( 0 != mgl_TexCoordEnabled[7] ) ? mgl_MultiTexCoord7 : defpos;
+}
+
+#endif // mgl_settexcoord_vp
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform.glsl
new file mode 100644
index 000000000..2333e26e2
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform.glsl
@@ -0,0 +1,17 @@
+
+#ifndef mgl_uniform_glsl
+#define mgl_uniform_glsl
+
+#include es_precision.glsl
+
+#include mgl_const.glsl
+
+uniform HIGHP mat4 mgl_PMVMatrix[3]; // P, Mv, and Mvi
+uniform HIGHP mat3 mgl_NormalMatrix; // transpose(inverse(ModelView)).3x3
+uniform LOWP int mgl_ColorEnabled;
+uniform HIGHP vec4 mgl_ColorStatic;
+uniform LOWP int mgl_TexCoordEnabled[MAX_TEXTURE_UNITS];
+uniform sampler2D mgl_ActiveTexture;
+uniform LOWP int mgl_ActiveTextureIdx;
+
+#endif // mgl_uniform_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform_light.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform_light.glsl
new file mode 100644
index 000000000..0dedb5d5d
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_uniform_light.glsl
@@ -0,0 +1,15 @@
+
+#ifndef mgl_uniform_light_glsl
+#define mgl_uniform_light_glsl
+
+#include es_precision.glsl
+
+#include mgl_const.glsl
+#include mgl_lightdef.glsl
+
+uniform LOWP int mgl_LightsEnabled[MAX_LIGHTS];
+
+uniform mgl_LightSourceParameters mgl_LightSource[MAX_LIGHTS];
+uniform mgl_MaterialParameters mgl_FrontMaterial;
+
+#endif // mgl_uniform_light_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/mgl_varying.glsl b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_varying.glsl
new file mode 100644
index 000000000..fc9f735d1
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/mgl_varying.glsl
@@ -0,0 +1,12 @@
+
+#ifndef mgl_varying_glsl
+#define mgl_varying_glsl
+
+#include es_precision.glsl
+
+#include mgl_const.glsl
+
+varying vec4 frontColor;
+varying vec4 mgl_TexCoords[MAX_TEXTURE_UNITS];
+
+#endif // mgl_varying_glsl
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc-ff.bat b/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc-ff.bat
new file mode 100755
index 000000000..b8acba036
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc-ff.bat
@@ -0,0 +1,9 @@
+REM
+REM You have to call it from the 'shader' directory, e.g.:
+REM scripts\nvidia-apx\glslc-ff.bat
+REM
+IF !"%JOGLDIR%"==""! GOTO YESPATH
+set JOGLDIR=..
+:YESPATH
+
+java -cp %JOGLDIR%\jogl.core.jar;%JOGLDIR%\jogl.gles2.jar;%JOGLDIR%\jogl.fixed.jar;%JOGLDIR%\jogl.sdk.jar javax.media.opengl.sdk.glsl.CompileShaderNVidia FixedFuncColor.fp FixedFuncColorTexture.fp FixedFuncColorLight.vp FixedFuncColor.vp
diff --git a/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc.bat b/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc.bat
new file mode 100755
index 000000000..9cbea806f
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/shader/scripts/nvidia-apx/glslc.bat
@@ -0,0 +1,9 @@
+REM
+REM You have to call it from the 'shader' directory, e.g.:
+REM scripts\nvidia-apx\glslc.bat <FileName>
+REM
+IF !"%JOGLDIR%"==""! GOTO YESPATH
+set JOGLDIR=..
+:YESPATH
+
+java -cp %JOGLDIR%\jogl.core.jar;%JOGLDIR%\jogl.gles2.jar;%JOGLDIR%\jogl.fixed.jar;%JOGLDIR%\jogl.sdk.jar javax.media.opengl.sdk.glsl.CompileShaderNVidia %1