Proper handling of texture environment mode in A3D

This commit is contained in:
codeanticode
2010-06-24 04:41:18 +00:00
parent 342bb2eaf0
commit caf4cfe3d5
4 changed files with 20 additions and 17 deletions
+1 -5
View File
@@ -707,11 +707,7 @@ public class PFont implements PConstants {
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
// This is the right texture environment mode to use the current fill color to tint the fonts:
// http://www.khronos.org/opengles/documentation/opengles1_0/html/glTexEnv.html
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, texWidth, texHeight, 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, null);
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
currentTexID = -1; // No texture is currently bound.
@@ -485,10 +485,6 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
// This is the right texture environment mode to ignore the fill color when drawing the texture:
// http://www.khronos.org/opengles/documentation/opengles1_0/html/glTexEnv.html
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);
int[] buf = new int [screenTexWidth * screenTexHeight];
for (int i = 0; i < buf.length; i++) buf[i] = 0xFF000000;
@@ -517,10 +513,14 @@ public class PGraphicsAndroid3D extends PGraphics {
// any geometry latter drawn by the user.
gl.glDepthMask(false);
gl.glDisable(GL10.GL_BLEND);
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);
gl11.glTexParameteriv(GL10.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, screenTexCrop, 0);
gl11x.glDrawTexiOES(0, 0, 0, width, height);
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
gl.glDisable(GL10.GL_TEXTURE_2D);
gl.glDepthMask(true);
if (blend) {
@@ -570,10 +570,17 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glDepthMask(false);
gl.glDisable(GL10.GL_BLEND);
// This is the right texture environment mode to ignore the fill color when drawing the texture:
// http://www.khronos.org/opengles/documentation/opengles1_0/html/glTexEnv.html
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);
gl11.glTexParameteriv(tex.getGLTarget(), GL11Ext.GL_TEXTURE_CROP_RECT_OES, drawTexCrop, 0);
gl11x.glDrawTexiOES(0, 0, 0, width, height);
// Returning to the default texture environment mode, GL_MODULATE. This allows tinting a texture
// with the current fill color.
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
gl.glDisable(tex.getGLTarget());
gl.glDepthMask(true);
if (blend) {
@@ -863,16 +870,16 @@ public class PGraphicsAndroid3D extends PGraphics {
pushFramebuffer();
setFramebuffer(drawFramebuffer);
drawFramebuffer.addColorBuffer(drawTextures[drawIndex]);
gl.glClearColor(0, 0, 0, 0);
if (clear) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
} else {
gl.glClear(GL10.GL_DEPTH_BUFFER_BIT);
gl.glClear(GL10.GL_DEPTH_BUFFER_BIT);
// Render previous draw texture as background.
renderDrawTexture((drawIndex + 1) % 2);
}
// Render previous draw texture as background.
renderDrawTexture((drawIndex + 1) % 2);
} else {
// We cannot ever end up here if the surface is not primary,
// because a non-primary A3D surface is possible only
@@ -884,7 +891,6 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
drawScreenTexture();
}
}
report("bot beginDraw()");
@@ -1899,7 +1899,7 @@ public class PShape3D extends PShape implements PConstants {
// Binding texture units.
gl.glActiveTexture(GL11.GL_TEXTURE0);
gl.glBindTexture(GL11.GL_TEXTURE_2D, tex.getGLTextureID());
gl.glBindTexture(texTarget, tex.getGLTextureID());
if (pointSprites) {
// Texturing with point sprites.
@@ -727,7 +727,8 @@ public class PTexture implements PConstants {
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_MIN_FILTER, glMinFilter);
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_MAG_FILTER, glMagFilter);
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
gl.glTexImage2D(glTarget, 0, glInternalFormat, glWidth, glHeight, 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, null);
gl.glDisable(glTarget);