示例#1
0
        // glx opcode 14 - get visual configs
        public VisualConfig [] visual_configs(int screen_no)
        {
            if (visual_configs_cache [screen_no] != null)
            {
                return(visual_configs_cache [screen_no]);
            }

            Request request = new Request(display, major_opcode, 14, 2);

            request.write4(screen_no);

            Data reply          = display.read_reply(request);
            int  visual_count   = reply.read4(8);
            int  property_count = reply.read4(12);

            VisualConfig [] vcs = new VisualConfig [visual_count];
            for (int i = 0, offset = 32; i < visual_count; i++)
            {
                vcs [i] = new VisualConfig(reply, offset, property_count);
                offset += vcs [i].Length;
            }

            visual_configs_cache [screen_no] = vcs;
            return(vcs);
        }
示例#2
0
        protected Application(String [] args, int event_mask)
            : base(args)
        {
            this.event_mask = event_mask;

            if (help_option) return;
            visual_config = new VisualConfig ();

            try {
              glx = new GLX (display);
            } catch (gnu.x11.extension.NotFoundException e) {
              throw new gnu.x11.Error ("Failed to initialize: " + e);
            }
        }
示例#3
0
        protected Application(String [] args, int event_mask)
            : base(args)
        {
            this.event_mask = event_mask;

            if (help_option)
            {
                return;
            }
            visual_config = new VisualConfig();

            try {
                glx = new GLX(display);
            } catch (gnu.x11.extension.NotFoundException e) {
                throw new gnu.x11.Error("Failed to initialize: " + e);
            }
        }
示例#4
0
        /**
         * @see <a href="glXChooseVisual.html">glXChooseVisual</a>
         */
        public VisualConfig visual_config(int screen_no,
                                          VisualConfig template, bool must)
        {
            VisualConfig [] vcs = visual_configs(screen_no);
            for (int i = 0; i < vcs.Length; i++)
            {
                if (vcs [i].match(template))
                {
                    return(vcs [i]);
                }
            }

            if (!must)
            {
                return(null);
            }
            throw new gnu.x11.Error("No matching: " + template);
        }
示例#5
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);
        }
示例#6
0
 /**
  * @see #visual_config(int, VisualConfig, bool)
  */
 public VisualConfig visual_config(VisualConfig template)
 {
     return(visual_config(display.default_screen_no, template, true));
 }
示例#7
0
文件: GLX.cs 项目: jbnivoit/projects
        // glx opcode 14 - get visual configs
        public VisualConfig[] visual_configs(int screen_no)
        {
            if (visual_configs_cache [screen_no] != null)
              return visual_configs_cache [screen_no];

            Request request = new Request (display, major_opcode, 14, 2);
            request.write4 (screen_no);

            Data reply = display.read_reply (request);
            int visual_count = reply.read4 (8);
            int property_count = reply.read4 (12);

            VisualConfig [] vcs = new VisualConfig [visual_count];
            for (int i=0, offset=32; i<visual_count; i++) {
              vcs [i] = new VisualConfig (reply, offset, property_count);
              offset += vcs [i].Length;
            }

            visual_configs_cache [screen_no] = vcs;
            return vcs;
        }
示例#8
0
文件: GLX.cs 项目: jbnivoit/projects
        /**
           * @see <a href="glXChooseVisual.html">glXChooseVisual</a>
           */
        public VisualConfig visual_config(int screen_no, 
    VisualConfig template, bool must)
        {
            VisualConfig [] vcs = visual_configs (screen_no);
            for (int i=0; i<vcs.Length; i++)
              if (vcs [i].match (template)) return vcs [i];

            if (!must) return null;
            throw new gnu.x11.Error ("No matching: " + template);
        }
示例#9
0
文件: GLX.cs 项目: jbnivoit/projects
 /**
    * @see #visual_config(int, VisualConfig, bool)
    */
 public VisualConfig visual_config(VisualConfig template)
 {
     return visual_config (display.default_screen_no, template, true);
 }
示例#10
0
        public bool match(VisualConfig template) // TODO
        {
            if ((template.bitmask & VISUAL_BIT) != 0 && // exact
                template.visual_id() != visual_id())
            {
                return(false);
            }

            if ((template.bitmask & CLASS_BIT) != 0 && // exact
                template.clazz() != clazz())
            {
                return(false);
            }

            if ((template.bitmask & RGBA_BIT) != 0 && // exact
                !rgba())
            {
                return(false);
            }

            if ((template.bitmask & RED_SIZE_BIT) != 0 && // larger
                template.red_size() > red_size())
            {
                return(false);
            }

            if ((template.bitmask & GREEN_SIZE_BIT) != 0 && // larger
                template.green_size() > green_size())
            {
                return(false);
            }

            if ((template.bitmask & BLUE_SIZE_BIT) != 0 && // larger
                template.blue_size() > blue_size())
            {
                return(false);
            }

            if ((template.bitmask & ALPHA_SIZE_BIT) != 0 && // larger
                template.alpha_size() > alpha_size())
            {
                return(false);
            }

            if ((template.bitmask & ACCUM_RED_SIZE_BIT) != 0 && // larger
                template.accum_red_size() > accum_red_size())
            {
                return(false);
            }

            if ((template.bitmask & ACCUM_GREEN_SIZE_BIT) != 0 && // larger
                template.accum_green_size() > accum_green_size())
            {
                return(false);
            }

            if ((template.bitmask & ACCUM_BLUE_SIZE_BIT) != 0 && // larger
                template.accum_blue_size() > accum_blue_size())
            {
                return(false);
            }

            if ((template.bitmask & ACCUM_ALPHA_SIZE_BIT) != 0 && // larger
                template.accum_alpha_size() > accum_alpha_size())
            {
                return(false);
            }

            if ((template.bitmask & DOUBLE_BUFFER_BIT) != 0 && // exact
                !double_buffer())
            {
                return(false);
            }

            if ((template.bitmask & STERO_BIT) != 0 && // exact
                !stero())
            {
                return(false);
            }

            if ((template.bitmask & BUFFER_SIZE_BIT) != 0 && // larger
                template.buffer_size() > buffer_size())
            {
                return(false);
            }

            if ((template.bitmask & DEPTH_SIZE_BIT) != 0 && // larger
                template.depth_size() > depth_size())
            {
                return(false);
            }

            if ((template.bitmask & STENCIL_SIZE_BIT) != 0 && // larger
                template.stencil_size() > stencil_size())
            {
                return(false);
            }

            if ((template.bitmask & AUX_BUFFERS_BIT) != 0 && // larger
                template.aux_buffers() > aux_buffers())
            {
                return(false);
            }

            if ((template.bitmask & LEVEL_BIT) != 0 && // exact
                template.level() == level())
            {
                return(false);
            }

            return(true);
        }
示例#11
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);
        }
示例#12
0
        public bool match(VisualConfig template)
        {
            // TODO
            if ((template.bitmask & VISUAL_BIT) != 0 // exact
              && template.visual_id () != visual_id ()) return false;

            if ((template.bitmask & CLASS_BIT) != 0 // exact
              && template.clazz () != clazz ()) return false;

            if ((template.bitmask & RGBA_BIT) != 0 // exact
              && !rgba ()) return false;

            if ((template.bitmask & RED_SIZE_BIT) != 0 // larger
              && template.red_size () > red_size ()) return false;

            if ((template.bitmask & GREEN_SIZE_BIT) != 0 // larger
              && template.green_size () > green_size ()) return false;

            if ((template.bitmask & BLUE_SIZE_BIT) != 0 // larger
              && template.blue_size () > blue_size ()) return false;

            if ((template.bitmask & ALPHA_SIZE_BIT) != 0 // larger
              && template.alpha_size () > alpha_size ()) return false;

            if ((template.bitmask & ACCUM_RED_SIZE_BIT) != 0 // larger
              && template.accum_red_size () > accum_red_size ()) return false;

            if ((template.bitmask & ACCUM_GREEN_SIZE_BIT) != 0 // larger
              && template.accum_green_size () > accum_green_size ()) return false;

            if ((template.bitmask & ACCUM_BLUE_SIZE_BIT) != 0 // larger
              && template.accum_blue_size () > accum_blue_size ()) return false;

            if ((template.bitmask & ACCUM_ALPHA_SIZE_BIT) != 0 // larger
              && template.accum_alpha_size () > accum_alpha_size ()) return false;

            if ((template.bitmask & DOUBLE_BUFFER_BIT) != 0 // exact
              && !double_buffer ()) return false;

            if ((template.bitmask & STERO_BIT) != 0 // exact
              && !stero ()) return false;

            if ((template.bitmask & BUFFER_SIZE_BIT) != 0 // larger
              && template.buffer_size () > buffer_size ()) return false;

            if ((template.bitmask & DEPTH_SIZE_BIT) != 0 // larger
              && template.depth_size () > depth_size ()) return false;

            if ((template.bitmask & STENCIL_SIZE_BIT) != 0 // larger
              && template.stencil_size () > stencil_size ()) return false;

            if ((template.bitmask & AUX_BUFFERS_BIT) != 0 // larger
              && template.aux_buffers () > aux_buffers ()) return false;

            if ((template.bitmask & LEVEL_BIT) != 0 // exact
              && template.level () == level ()) return false;

            return true;
        }