aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-07-25 17:56:12 +0000
committerSven Gothel <[email protected]>2008-07-25 17:56:12 +0000
commit659b59dd072d8b22d0d516770fd6864796ab89db (patch)
tree2e622c09bdfd18e8b18dcb6f5879190900d94600 /src
parentdb40249b86a14c2178be8a2f61dc97f4ac1f1424 (diff)
ES2 FixedFunction w. texture (demo.es1.cubefbo.Main) working
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1736 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/opengl/impl/es2/FixedFuncShader.java35
-rw-r--r--src/classes/com/sun/opengl/impl/es2/FixedFuncShaderVertexColorTexture.java17
2 files changed, 33 insertions, 19 deletions
diff --git a/src/classes/com/sun/opengl/impl/es2/FixedFuncShader.java b/src/classes/com/sun/opengl/impl/es2/FixedFuncShader.java
index b0fe47b11..f6bf964a7 100644
--- a/src/classes/com/sun/opengl/impl/es2/FixedFuncShader.java
+++ b/src/classes/com/sun/opengl/impl/es2/FixedFuncShader.java
@@ -148,11 +148,12 @@ public class FixedFuncShader {
public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) {
if(!shaderOk) return;
light -=GL.GL_LIGHT0;
- if(0 <= light && light <= 7 && 0<=shaderLightsPos[light] ) {
- glUseProgram(gl, true);
- gl.glUniform4fv(shaderLightsPos[light], 1, params);
- if(0<=shaderLightsSrc[light]) {
- gl.glUniform1i(shaderLightsSrc[light], pname);
+ if(0 <= light && light <= 7) {
+ if(gl.GL_POSITION==pname && 0<=shaderLightsSource[light]) {
+ glUseProgram(gl, true);
+ gl.glUniform4fv(shaderLightsSource[light], 1, params);
+ } else if(gl.GL_AMBIENT==pname && 0<=shaderLigthsAmbient[light]) {
+ gl.glUniform4fv(shaderLigthsAmbient[light], 1, params);
}
}
}
@@ -163,6 +164,13 @@ public class FixedFuncShader {
gl.glUniform1i(shaderShadeModel, mode);
}
+ public void glActiveTexture(GL2ES2 gl, int texture) {
+ if(!shaderOk || 0>shaderShadeModel) return;
+ glUseProgram(gl, true);
+ texture-=gl.GL_TEXTURE0;
+ gl.glUniform1i(shaderActiveTexture, 0);
+ }
+
protected void init(GL2ES2 gl, PMVMatrix pmvMatrix, ShaderData shaderData) {
if(shaderOk) return;
@@ -207,12 +215,12 @@ public class FixedFuncShader {
// optional parameter ..
for(int i=0; i<7; i++) {
- shaderLightsPos[i] = gl.glGetUniformLocation(shaderProgram, "mgl_LightPos"+i);
- shaderLightsSrc[i] = gl.glGetUniformLocation(shaderProgram, "mgl_LightSrc"+i);
+ shaderLightsSource[i] = gl.glGetUniformLocation(shaderProgram, "mgl_LightSource"+i);
+ shaderLigthsAmbient[i] = gl.glGetUniformLocation(shaderProgram, "mgl_LightAmbient"+i);
}
shaderShadeModel = gl.glGetUniformLocation(shaderProgram, "mgl_ShadeModel");
- shaderActiveTexture = gl.glGetUniformLocation(shaderProgram, "mgl_activeTexture");
+ shaderActiveTexture = gl.glGetUniformLocation(shaderProgram, "mgl_ActiveTexture");
if(0<=shaderActiveTexture) {
gl.glUniform1i(shaderActiveTexture, 0);
}
@@ -236,11 +244,10 @@ public class FixedFuncShader {
protected static final int TEXCOORD_ARRAY = 3; // mgl_MultiTexCoord0
// uniforms ..
- protected int shaderPMVMatrix=-1;
- protected int[] shaderLightsPos = new int[] { -1, -1, -1, -1, -1, -1, -1 };
- protected int[] shaderLightsSrc = new int[] { -1, -1, -1, -1, -1, -1, -1 };
- protected int shaderShadeModel = -1;
- protected int shaderActiveTexture = -1;
-
+ protected int shaderPMVMatrix=-1; // mgl_PMVMatrix mat4
+ protected int[] shaderLightsSource = new int[] { -1, -1, -1, -1, -1, -1, -1 }; // vec4f mgl_LightSourcei
+ protected int[] shaderLigthsAmbient = new int[] { -1, -1, -1, -1, -1, -1, -1 }; // vec4f mgl_LightAmbienti
+ protected int shaderShadeModel = -1; // mgl_ShadeModel int
+ protected int shaderActiveTexture = -1; // mgl_ActiveTexture int
}
diff --git a/src/classes/com/sun/opengl/impl/es2/FixedFuncShaderVertexColorTexture.java b/src/classes/com/sun/opengl/impl/es2/FixedFuncShaderVertexColorTexture.java
index 039479c78..2c33c9c07 100644
--- a/src/classes/com/sun/opengl/impl/es2/FixedFuncShaderVertexColorTexture.java
+++ b/src/classes/com/sun/opengl/impl/es2/FixedFuncShaderVertexColorTexture.java
@@ -19,12 +19,13 @@ public class FixedFuncShaderVertexColorTexture extends ShaderData {
"uniform MEDIUMP mat4 mgl_PMVMatrix[2];\n"+
"attribute HIGHP vec4 mgl_Vertex;\n"+
"attribute HIGHP vec4 mgl_Color;\n"+
- "attribute HIGHP vec4 gl_MultiTexCoord0;\n"+
+ "attribute HIGHP vec4 mgl_MultiTexCoord0;\n"+
+ "varying HIGHP vec4 gl_TexCoord[7];\n"+
"varying HIGHP vec4 frontColor;\n"+
"void main(void)\n"+
"{\n"+
" frontColor=mgl_Color;\n"+
- " gl_TexCoord[0] = gl_MultiTexCoord0;\n"+
+ " gl_TexCoord[0] = mgl_MultiTexCoord0;\n"+
" gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;\n"+
"}\n" } } ;
@@ -37,12 +38,18 @@ public class FixedFuncShaderVertexColorTexture extends ShaderData {
" #define HIGHP\n"+
"#endif\n"+
"\n"+
- "uniform HIGHP sampler2D mgl_activeTexture;\n"+
+ "uniform HIGHP sampler2D mgl_ActiveTexture;\n"+
"varying HIGHP vec4 frontColor;\n"+
+ "const HIGHP vec4 one = vec4(1.0, 1.0, 1.0, 1.0);\n"+
+ "const HIGHP vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);\n"+
"void main (void)\n"+
"{\n"+
- " vec4 texColor = texture2D(mgl_activeTexture,gl_TexCoord[0].st);\n"+
- " gl_FragColor = frontColor+texColor;\n"+
+ " vec4 texColor = texture2D(mgl_ActiveTexture,gl_TexCoord[0].st);\n"+
+ " if(greaterThan(texColor, zero)) {\n"+
+ " gl_FragColor = vec4(frontColor.rgb*texColor.rgb, frontColor.a*texColor.a);\n"+
+ " } else {\n"+
+ " gl_FragColor = frontColor;\n"+
+ " }\n"+
"}\n" } } ;
public FixedFuncShaderVertexColorTexture() {