public void onSurfaceCreated(GL10 $gl, EGLConfig eglConfig) { Log.i(Min3d.TAG, "Renderer.onSurfaceCreated()"); RenderCaps.setRenderCaps($gl); setGl($gl); reset(); _scene.init(); }
private void drawObject_textures(Object3d $o) { // iterate thru object's textures for (int i = 0; i < RenderCaps.maxTextureUnits(); i++) { _gl.glActiveTexture(GL10.GL_TEXTURE0 + i); _gl.glClientActiveTexture(GL10.GL_TEXTURE0 + i); if ($o.hasUvs() && $o.texturesEnabled()) { $o.vertices().uvs().buffer().position(0); _gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, $o.vertices().uvs().buffer()); TextureVo textureVo = ((i < $o.textures().size())) ? textureVo = $o.textures().get(i) : null; if (textureVo != null) { // activate texture int glId = _textureManager.getGlTextureId(textureVo.textureId); _gl.glBindTexture(GL10.GL_TEXTURE_2D, glId); _gl.glEnable(GL10.GL_TEXTURE_2D); _gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); int minFilterType = _textureManager.hasMipMap(textureVo.textureId) ? GL10.GL_LINEAR_MIPMAP_NEAREST : GL10.GL_NEAREST; _gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, minFilterType); _gl.glTexParameterf( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); // (OpenGL default) // do texture environment settings for (int j = 0; j < textureVo.textureEnvs.size(); j++) { _gl.glTexEnvx( GL10.GL_TEXTURE_ENV, textureVo.textureEnvs.get(j).pname, textureVo.textureEnvs.get(j).param); } // texture wrapping settings _gl.glTexParameterx( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, (textureVo.repeatU ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE)); _gl.glTexParameterx( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, (textureVo.repeatV ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE)); // texture offset, if any if (textureVo.offsetU != 0 || textureVo.offsetV != 0) { _gl.glMatrixMode(GL10.GL_TEXTURE); _gl.glLoadIdentity(); _gl.glTranslatef(textureVo.offsetU, textureVo.offsetV, 0); _gl.glMatrixMode(GL10.GL_MODELVIEW); // .. restore matrixmode } } else { _gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); _gl.glDisable(GL10.GL_TEXTURE_2D); _gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); } } else { _gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); _gl.glDisable(GL10.GL_TEXTURE_2D); _gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); } } }