@ -32,6 +32,7 @@
package com.jme3.renderer.android ;
package com.jme3.renderer.android ;
import com.jme3.asset.TextureKey ;
import com.jme3.light.LightList ;
import com.jme3.light.LightList ;
import com.jme3.material.RenderState ;
import com.jme3.material.RenderState ;
import com.jme3.math.ColorRGBA ;
import com.jme3.math.ColorRGBA ;
@ -57,6 +58,7 @@ import com.jme3.shader.Shader;
import com.jme3.shader.Shader.ShaderSource ;
import com.jme3.shader.Shader.ShaderSource ;
import com.jme3.shader.Shader.ShaderType ;
import com.jme3.shader.Shader.ShaderType ;
import com.jme3.shader.Uniform ;
import com.jme3.shader.Uniform ;
import com.jme3.system.JmeSystem ;
import com.jme3.texture.FrameBuffer ;
import com.jme3.texture.FrameBuffer ;
import com.jme3.texture.FrameBuffer.RenderBuffer ;
import com.jme3.texture.FrameBuffer.RenderBuffer ;
import com.jme3.texture.Image ;
import com.jme3.texture.Image ;
@ -77,6 +79,8 @@ import java.util.List;
import java.util.logging.Level ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
import java.util.logging.Logger ;
import javax.microedition.khronos.opengles.GL10 ;
import javax.microedition.khronos.opengles.GL10 ;
import android.graphics.Bitmap ;
import android.opengl.GLES10 ;
import android.opengl.GLES10 ;
import android.opengl.GLES11 ;
import android.opengl.GLES11 ;
import android.opengl.GLES20 ;
import android.opengl.GLES20 ;
@ -407,7 +411,11 @@ public class OGLESShaderRenderer implements Renderer {
logger . log ( Level . INFO , "Caps: " + caps ) ;
logger . log ( Level . INFO , "Caps: " + caps ) ;
}
}
public void resetGLObjects ( ) {
/ * *
* < code > resetGLObjects < / code > should be called when die GLView gets recreated to reset all GPU objects
* /
public void resetGLObjects ( )
{
objManager . resetObjects ( ) ;
objManager . resetObjects ( ) ;
statistics . clearMemory ( ) ;
statistics . clearMemory ( ) ;
boundShader = null ;
boundShader = null ;
@ -1853,16 +1861,27 @@ public class OGLESShaderRenderer implements Renderer {
img . clearUpdateNeeded ( ) ;
img . clearUpdateNeeded ( ) ;
}
}
public void setTexture ( int unit , Texture tex ) {
public void setTexture ( int unit , Texture tex )
{
Image image = tex . getImage ( ) ;
Image image = tex . getImage ( ) ;
if ( image . isUpdateNeeded ( ) ) {
if ( image . isUpdateNeeded ( ) )
{
Bitmap bmp = ( Bitmap ) image . getEfficentData ( ) ;
// Check if the bitmap got recycled, can happen after wakeup/restart
if ( bmp . isRecycled ( ) )
{
// We need to reload the bitmap
Texture textureReloaded = JmeSystem . newAssetManager ( ) . loadTexture ( ( TextureKey ) tex . getKey ( ) ) ;
image . setEfficentData ( textureReloaded . getImage ( ) . getEfficentData ( ) ) ;
}
updateTexImageData ( image , tex . getType ( ) , tex . getMinFilter ( ) . usesMipMapLevels ( ) ) ;
updateTexImageData ( image , tex . getType ( ) , tex . getMinFilter ( ) . usesMipMapLevels ( ) ) ;
}
}
int texId = image . getId ( ) ;
int texId = image . getId ( ) ;
assert texId ! = - 1 ;
assert texId ! = - 1 ;
if ( texId = = - 1 ) {
if ( texId = = - 1 )
{
logger . warning ( "error: texture image has -1 id" ) ;
logger . warning ( "error: texture image has -1 id" ) ;
}
}
@ -1877,8 +1896,10 @@ public class OGLESShaderRenderer implements Renderer {
// glEnable(type);
// glEnable(type);
}
}
if ( textures [ unit ] ! = image ) {
if ( textures [ unit ] ! = image )
if ( context . boundTextureUnit ! = unit ) {
{
if ( context . boundTextureUnit ! = unit )
{
if ( verboseLogging )
if ( verboseLogging )
logger . info ( "GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + " + unit + ")" ) ;
logger . info ( "GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + " + unit + ")" ) ;
GLES20 . glActiveTexture ( GLES20 . GL_TEXTURE0 + unit ) ;
GLES20 . glActiveTexture ( GLES20 . GL_TEXTURE0 + unit ) ;
@ -1892,7 +1913,9 @@ public class OGLESShaderRenderer implements Renderer {
textures [ unit ] = image ;
textures [ unit ] = image ;
statistics . onTextureUse ( tex . getImage ( ) , true ) ;
statistics . onTextureUse ( tex . getImage ( ) , true ) ;
} else {
}
else
{
statistics . onTextureUse ( tex . getImage ( ) , false ) ;
statistics . onTextureUse ( tex . getImage ( ) , false ) ;
}
}