Examples of GLDrawable


Examples of javax.media.opengl.GLDrawable

        }
    }

  @Override
  public void mouseClicked(MouseEvent e) {
    GLDrawable heightmapDrawable = action.getHeightMapDrawable();
    int x = (int)NDCUtil.xScreenParaOrtho(e.getX(), heightmapDrawable.getWidth(), 0, this.terreno.getLargura());
    int z = (int)NDCUtil.yScreenParaOrtho(e.getY(), heightmapDrawable.getHeight(), 0, this.terreno.getProfundidade());
    incrementarAlturaPonto(x, -z);
    atualizaInfo();
  }
View Full Code Here

Examples of javax.media.opengl.GLDrawable

  public void mouseReleased(MouseEvent e) {
  }

  @Override
  public void mouseDragged(MouseEvent e) {
    GLDrawable heightmapDrawable = action.getHeightMapDrawable();
    int x = (int)NDCUtil.xScreenParaOrtho(e.getX(), heightmapDrawable.getWidth(), 0, terreno.getLargura());
    int z = (int)NDCUtil.yScreenParaOrtho(e.getY(), heightmapDrawable.getHeight(), 0, terreno.getProfundidade());
    incrementarAlturaPonto(x, -z);
    atualizaInfo();
  }
View Full Code Here

Examples of javax.media.opengl.GLDrawable

            Context shareCtx, boolean isSharedCtx,
            boolean offScreen) {
        if (VERBOSE) System.err.println("JoglPipeline.createNewContext()");

        checkAppContext();
      GLDrawable  glDrawable   = null;
      GLContext   glContext  = null;

      if (offScreen) {
        glDrawable = drawable(cv.drawable); // cv.drawable != null, set in 'createOffScreenBuffer'
      glContext = glDrawable.createContext(context(shareCtx));
        }
      else {
        // determined in 'getBestConfiguration'
      GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration);
      AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)gcInf0.getPrivateData();

        // JAWTWindow
      JAWTWindow nativeWindow = (JAWTWindow)NativeWindowFactory.getNativeWindow(cv, awtConfig);
      nativeWindow.lockSurface();
        try {
          glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow);
          glContext = glDrawable.createContext(context(shareCtx));
        }
        finally {
          nativeWindow.unlockSurface();
        }

        cv.drawable = new JoglDrawable(glDrawable, nativeWindow);
        }

        // assuming that this only gets called after addNotify has been called
      glDrawable.setRealized(true);

      // Apparently we are supposed to make the context current at this point
        // and set up a bunch of properties

        // Work around for some low end graphics driver bug, such as Intel Chipset.
        // Issue 324 : Lockup J3D program and throw exception using JOGL renderer
        boolean failed = false;
        int failCount = 0;
        int MAX_FAIL_COUNT = 5;
        do {
            failed = false;
            int res = glContext.makeCurrent();
            if (res == GLContext.CONTEXT_NOT_CURRENT) {
                // System.err.println("makeCurrent fail : " + failCount);
                failed = true;
                ++failCount;
                try {
                    Thread.sleep(100);
                }
                catch (InterruptedException e) {
                }
            }
        } while (failed && (failCount < MAX_FAIL_COUNT));

        if (failCount == MAX_FAIL_COUNT) {
            throw new IllegalRenderingStateException("Unable to make new context current after " + failCount + "tries");
        }

        GL2 gl = glContext.getGL().getGL2();

        JoglContext ctx = new JoglContext(glContext);

        try {
            if (!getPropertiesFromCurrentContext(ctx, gl)) {
                throw new IllegalRenderingStateException("Unable to fetch properties from current OpenGL context");
            }

            if(!isSharedCtx){
                // Set up fields in Canvas3D
                setupCanvasProperties(cv, ctx, gl);
            }

            // Enable rescale normal
            gl.glEnable(GL2.GL_RESCALE_NORMAL);

            gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE);
            gl.glDepthFunc(GL.GL_LEQUAL);
            gl.glEnable(GL2.GL_COLOR_MATERIAL);

            /*
            OpenGL specs:
               glReadBuffer specifies a color buffer as the source for subsequent glReadPixels.
               This source mode is initially GL_FRONT in single-buffered and GL_BACK in double-buffered configurations.

            We leave this mode unchanged in on-screen rendering and adjust it in off-screen rendering. See below.
            */
//          gl.glReadBuffer(GL_FRONT);     // off window, default for single-buffered non-stereo window

            // Issue 417: JOGL: Mip-mapped NPOT textures rendered incorrectly
            // J3D images are aligned to 1 byte
            gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);

            // Workaround for issue 400: Enable separate specular by default
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);


            // Mac OS X / JRE 7 : onscreen rendering = offscreen rendering
            // bind FBO
            if (!offScreen && glDrawable instanceof GLFBODrawable) {
              GLFBODrawable fboDrawable = (GLFBODrawable)glDrawable;
              // bind GLFBODrawable's drawing FBObject
              // GL_BACK returns the correct FBOObject for single/double buffering, incl. multisampling
              fboDrawable.getFBObject( GL.GL_BACK ).bind(gl);
            }


            // FBO or pbuffer
            if (offScreen) {

              // Final caps
              GLCapabilitiesImmutable chosenCaps = glDrawable.getChosenGLCapabilities();

              // FBO
              if (glDrawable instanceof GLFBODrawable) {
                  GLFBODrawable fboDrawable = (GLFBODrawable)glDrawable;
                  // bind GLFBODrawable's drawing FBObject
View Full Code Here

Examples of javax.media.opengl.GLDrawable

        if (offScreen) {

           Drawable offDrawable = createOffScreenBuffer(cv, null, width, height);

           GLDrawable glDrawable = drawable(offDrawable);

          glDrawable.setRealized(true);

        GLContext glContext = glDrawable.createContext(null);
            glContext.makeCurrent();

            JoglContext ctx = new JoglContext(glContext);

            GL2 gl = glContext.getGL().getGL2();

            // get current context properties
            getPropertiesFromCurrentContext(ctx, gl);
            // Set up fields in Canvas3D
            setupCanvasProperties(cv, ctx, gl);

            // Done !

            glContext.release();
        glContext.destroy();
        glDrawable.setRealized(false);
      }
        else {

          // TODO can't find an implementation which avoids the use of QueryCanvas
          // JOGL requires a visible Frame for an onscreen context
View Full Code Here

Examples of javax.media.opengl.GLDrawable

    // caps.setPBuffer(true);

    // !! a 'null' capability chooser; JOGL doesn't call a chooser for offscreen drawable

    // If FBO : 'offDrawable' is of type javax.media.opengl.GLFBODrawable
        GLDrawable offDrawable = GLDrawableFactory.getFactory(profile).createOffscreenDrawable(device, offCaps, null, width, height);

// !! these chosen caps are not final as long as the corresponding context is made current
//System.out.println("createOffScreenBuffer chosenCaps = " + offDrawable.getChosenGLCapabilities());

        return new JoglDrawable(offDrawable, null);
View Full Code Here

Examples of javax.media.opengl.GLDrawable

    // This is the native for reading the image from the offscreen buffer
    @Override
    void readOffScreenBuffer(Canvas3D cv, Context ctx, int format, int dataType, Object data, int width, int height) {
        if (VERBOSE) System.err.println("JoglPipeline.readOffScreenBuffer()");

      GLDrawable         glDrawable  = ((JoglDrawable)cv.drawable).getGLDrawable();
        GLCapabilitiesImmutable chosenCaps  = glDrawable.getChosenGLCapabilities();
        GLFBODrawable       fboDrawable = null;

    GL2 gl = context(ctx).getGL().getGL2();

        // If FBO
View Full Code Here

Examples of javax.media.opengl.GLDrawable

  // The native method for swapBuffers - onscreen only
@Override
void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) {
  if (VERBOSE) System.err.println("JoglPipeline.swapBuffers()");
  GLDrawable draw = drawable(drawable);
  draw.swapBuffers();
}
View Full Code Here

Examples of javax.media.opengl.GLDrawable

                    textureId = texture.getTextureIdForContext(context.getGlContextRep());
                    if (textureId == 0) {
                        continue;
                    }
                } else {
                    final GLDrawable drawable = GLContext.getCurrent().getGLDrawable();
                    // forces the rebinding when the drawable uses a frame buffer object
                    final boolean fbo = drawable.getChosenGLCapabilities().isFBO();
                    // texture already exists in OpenGL, just bind it if needed
                    if (!unitRecord.isValid() || unitRecord.boundTexture != textureId || fbo) {
                        checkAndSetUnit(i, record, caps);
                        gl.glBindTexture(getGLType(type), textureId);
                        if (Constants.stats) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.