Exemplo n.º 1
0
 private void enableStates(final GL2 gl, final boolean enable) {
   if (enable) {
     if (null != tex) {
       tex.bind(gl);
     }
     gl.glEnable(GL.GL_DEPTH_TEST);
     gl.glDepthFunc(GL.GL_LESS); // default
     // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
     // gl.glEnable(GL2.GL_TEXTURE_1D);
     gl.glEnable(GL.GL_TEXTURE_2D);
     gl.glEnable(GL.GL_CULL_FACE);
     gl.glEnable(GLLightingFunc.GL_LIGHTING);
     gl.glEnable(GLLightingFunc.GL_LIGHT0);
     gl.glEnable(GL2.GL_AUTO_NORMAL);
     gl.glEnable(GLLightingFunc.GL_NORMALIZE);
     gl.glFrontFace(GL.GL_CW);
     gl.glCullFace(GL.GL_BACK); // default
     gl.glMaterialf(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 64.0f);
     gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
   } else {
     if (null != tex) {
       gl.glBindTexture(tex.getTarget(), 0);
     }
     gl.glDisable(GL.GL_DEPTH_TEST);
     // gl.glDisable(GL2.GL_TEXTURE_GEN_S);
     // gl.glDisable(GL2.GL_TEXTURE_1D);
     gl.glDisable(GL.GL_TEXTURE_2D);
     gl.glDisable(GL.GL_CULL_FACE);
     gl.glDisable(GLLightingFunc.GL_LIGHTING);
     gl.glDisable(GLLightingFunc.GL_LIGHT0);
     gl.glDisable(GL2.GL_AUTO_NORMAL);
     gl.glDisable(GLLightingFunc.GL_NORMALIZE);
     gl.glFrontFace(GL.GL_CCW); // default
   }
 }
    /**
     * Update the texture if the native WebView window has changed.
     *
     * @param dc Draw context
     */
    @Override
    protected void updateIfNeeded(DrawContext dc) {
      // Return immediately if the native WebViewWindow object isn't initialized, and wait to update
      // until the
      // native object is initialized. This method is called after the texture is bound, so we'll
      // get another
      // chance to update as long as the WebView generates repaint events when it changes.
      long webViewWindowPtr = WindowsWebView.this.webViewWindowPtr;
      if (webViewWindowPtr == 0) return;

      // Return immediately if the texture isn't in the texture cache, and wait to update until the
      // texture is
      // initialized and placed in the cache. This method is called after the texture is bound, so
      // we'll get
      // another chance to update as long as the WebView generates repaint events when it changes.
      Texture texture = this.getTextureFromCache(dc);
      if (texture == null) return;

      // Load the WebViewWindow's current display pixels into the currently bound OGL texture if our
      // update time
      // is different than the WebViewWindow's update time.
      long newUpdateTime = WindowsWebViewJNI.getUpdateTime(webViewWindowPtr);
      if (newUpdateTime != this.updateTime) {
        WindowsWebViewJNI.loadDisplayInGLTexture(webViewWindowPtr, texture.getTarget());
        this.updateTime = newUpdateTime;
      }
    }