Beispiel #1
0
        public Teapot(GLUT glut, double scale)
        {
            this.glut = glut;
            gl = glut.gl;

            display_list = gl.gen_lists (1);
            gl.new_list (display_list, GL.COMPILE);
            glut.solid_teapot (scale);
            gl.end_list ();
        }
Beispiel #2
0
        /**
           * {@link GLU.perspective} with anti-aliasing.
           *
           * <p>Other arguments are identical to {@link GLU.perspective}. Set
           * both `pixdx' and `pixdy' equal to 0.0 for no anti-alias jitter. Set
           * both `eyex' and `eyey' equal to 0.0 for no depth of field effects.
           *
           * @param pixdx x of anti-alias jitter in pixels
           * @param pixdy y of anti-alias jitter in pixels
           * @param eyedx x of depth-of field jitter in pixels
           * @param eyedy y of depth-of field jitter in pixels
           * @param focus distance from eye to plane in focus, must be greater
           * than, but not equal to 0.0
           */
        public static void perspective(GL gl, int window_width, int window_height,
    double fovy, double aspect, double near, double far, 
    double pixdx, double pixdy, double eyedx, double eyedy, double focus)
        {
            // identical to code of `GLU.perspective'
            double ymax = near * Math.Tan (gnu.util.Math.toRadians (fovy/2));
            double ymin = -ymax;
            double xmin = ymin * aspect;
            double xmax = ymax * aspect;

            frustum (gl, window_width, window_height,
              xmin, xmax, ymin, ymax, near, far,
              pixdx, pixdy, eyedx, eyedy, focus);
        }
Beispiel #3
0
        /**
           * {@link GLU.frustum} with anti-aliasing.
           *
           * <p>Other arguments are identical to {@link GLU.frustum}. Set
           * both `pixdx' and `pixdy' equal to 0.0 for no anti-alias jitter. Set
           * both `eyex' and `eyey' equal to 0.0 for no depth of field effects.
           *
           * @param pixdx x of anti-alias jitter in pixels
           * @param pixdy y of anti-alias jitter in pixels
           * @param eyedx x of depth-of field jitter in pixels
           * @param eyedy y of depth-of field jitter in pixels
           * @param focus distance from eye to plane in focus, must be greater
           * than, but not equal to 0.0
           */
        public static void frustum(GL gl, int window_width, int window_height, 
    double left, double right, double bottom, double top, 
    double near, double far, double pixdx, double pixdy, 
    double eyedx, double eyedy, double focus)
        {
            double xwsize = right - left;
            double ywsize = top - bottom;
            double dx = pixdx*xwsize/window_width + eyedx*near/focus;
            double dy = pixdy*ywsize/window_height + eyedy*near/focus;

            gl.matrix_mode (GL.PROJECTION);
            gl.load_identity ();
            gl.frustum (left-dx, right-dx, bottom-dy, top-dy, near, far);

            gl.matrix_mode (GL.MODELVIEW);
            gl.load_identity ();
            gl.translatef ((float) -eyedx, (float) -eyedy, 0.0f);
        }
Beispiel #4
0
 public GLU(GL gl)
 {
     this.gl = gl;
 }
Beispiel #5
0
 /**
    * @see GL#GL(GLX, int, int, GL)
    */
 public GL create_context(int visual_id, int screen_no, GL share_list)
 {
     return new GL (this, visual_id, screen_no, share_list);
 }
Beispiel #6
0
 public Quadric(GL gl)
 {
     this.gl = gl;
 }
Beispiel #7
0
 public GLUT(GLU glu)
 {
     this.glu = glu;
     gl = glu.gl;
 }
Beispiel #8
0
        // glx opcode 3 - create context
        /**
           * @see <a href="glXCreateContext.html">glXCreateContext</a>
           */
        public GL(GLX glx, int visual_id, int screen_no,
    GL share_list)
            : base(glx.display)
        {
            this.glx = glx;

            Request request = begin_command_request (3, 6);
            request.write4 (id);
            request.write4 (visual_id);
            request.write4 (screen_no);
            request.write4 (share_list.id);
            request.write1 (false);     // is_direct
            display.send_request (request);
        }
Beispiel #9
0
 // glx opcode 10 - copy context
 /**
    * @see <a href="glXCopyContext.html">glXCopyContext</a>
    */
 public void copy(GL dst, int mask)
 {
     Request request = begin_command_request (10, 5);
     request.write4 (id);
     request.write4 (dst.id);
     request.write4 (mask);
     request.write4 (tag);
     display.send_request (request);
 }
Beispiel #10
0
        protected void init_window(int width, int height)
        {
            visual_config = glx.visual_config (visual_config);
            int vid = visual_config.visual_id ();
            gl = glx.create_context (vid, display.default_screen_no, GL.NONE0);

            // FIXME share colormap
            Colormap colormap = new Colormap (display.default_root, vid, false);

            Window.Attributes attr = new Window.Attributes ();
            attr.set_colormap (colormap);

            // TODO use depth of x visual config instead of
            // `visual_config.buffer_size'?
            int depth = visual_config.buffer_size ();

            int more = Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK; // compulsory

            /* Bugs? Whenever button motion events are selected, it is required to
             * select button press event as well.
             */
             if ((event_mask & ANY_BUTTON_MOTION_BITS) != 0)
               more |= Event.BUTTON_PRESS_MASK;
             attr.set_event_mask (event_mask | more);

            window = new Window (display.default_root, 10, 10, width, height);
            window.create (5, depth, Window.INPUT_OUTPUT, vid, attr);

            window.set_wm (this, "main");
            window.set_wm_delete_window ();

            gl.make_current (window);
            glu = new GLU (gl);
            glut = new GLUT (glu);
        }