aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-14 08:28:08 +0200
committerSven Gothel <[email protected]>2012-10-14 08:28:08 +0200
commit842e9feefc9d1a885a92ad8f0068cbcbcdd0e3c4 (patch)
tree04dd0ca78d319d4caa07556b427dfb0eda973514
parentacdb3d4cbbdd6ade5d347abaaac71a1a8abe48e1 (diff)
FixedFuncPipeline: Use resource efficient texture shader in AUTO mode as well
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index b7097b0fd..d92a73cac 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -582,6 +582,16 @@ public class FixedFuncPipeline {
return false; // ignore!
}
+ private final int textureEnabledCount() {
+ int n=0;
+ for(int i=MAX_TEXTURE_UNITS-1; i>=0; i--) {
+ if( 0 != textureEnabled.get(i) ) {
+ n++;
+ }
+ }
+ return n;
+ }
+
public void validate(GL2ES2 gl) {
if( ShaderSelectionMode.AUTO == shaderSelectionMode) {
final ShaderSelectionMode newMode;
@@ -591,8 +601,14 @@ public class FixedFuncPipeline {
if(lightingEnabled) {
newMode = ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX;
} else {
- // in auto mode, we simply use max texture units
- newMode = ShaderSelectionMode.COLOR_TEXTURE8;
+ final int n = textureEnabledCount();
+ if( 4 < n ) {
+ newMode = ShaderSelectionMode.COLOR_TEXTURE8;
+ } else if ( 2 < n ) {
+ newMode = ShaderSelectionMode.COLOR_TEXTURE4;
+ } else {
+ newMode = ShaderSelectionMode.COLOR_TEXTURE2;
+ }
}
} else {
if(lightingEnabled) {