コード例 #1
0
        /// <summary> Start the class. Pass the GL window control, and the initial lookat/cameradirection and zoom.
        /// Control if registration of mouse and keyboard UI is performed with GL window control
        /// </summary>
        public void Start(GLWindowControl win, Vector3 lookat, Vector3 cameradirdegrees, float zoomn, bool registermouseui = true, bool registerkeyui = true)
        {
            glwin       = win;
            win.Resize += glControl_Resize;
            win.Paint  += glControl_Paint;

            if (registermouseui)
            {
                win.MouseDown  += MouseDown;
                win.MouseUp    += MouseUp;
                win.MouseMove  += MouseMove;
                win.MouseWheel += MouseWheel;
            }

            if (registerkeyui)
            {
                win.KeyDown += KeyDown;
                win.KeyUp   += KeyUp;
            }

            MatrixCalc.ResizeViewPort(this, win.Size);               // inform matrix calc of window size

            PosCamera.SetPositionZoom(lookat, new Vector2(cameradirdegrees.X, cameradirdegrees.Y), zoomn, cameradirdegrees.Z);
            MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
            MatrixCalc.CalculateProjectionMatrix();
        }
コード例 #2
0
        /// <summary>
        /// Construct a control display
        /// </summary>
        /// <param name="items">Items to store GL data to</param>
        /// <param name="win">GLWindowControl to hook to</param>
        /// <param name="mc">Matrix Calc to use</param>
        /// <param name="depthtest">Enable depth test</param>
        /// <param name="startz">Start Z for nearest top level window</param>
        /// <param name="deltaz">Delta Z between each top level window</param>
        /// <param name="arbbufferid">ARB buffer to use for texture bindless storage</param>
        public GLControlDisplay(GLItemsList items, GLWindowControl win, GLMatrixCalc mc,
                                bool depthtest  = true,             // do depth testing or not
                                float startz    = 0.001f,           // z for the deepest window (only will apply if depth testing
                                float deltaz    = 0.001f,           // delta betwwen them
                                int arbbufferid = 10
                                ) : base("displaycontrol", new Rectangle(0, 0, mc.ScreenCoordMax.Width, mc.ScreenCoordMax.Height))
        {
            glwin      = win;
            MatrixCalc = mc;
            context    = GLStatics.GetContext();

            this.items = items;

            vertexes = items.NewBuffer();

            vertexarray = items.NewVertexArray();
            vertexes.Bind(vertexarray, 0, 0, vertexesperentry * sizeof(float));                            // bind to 0, from 0, 2xfloats. Must bind after vertexarray is made as its bound during construction

            vertexarray.Attribute(0, 0, vertexesperentry, OpenTK.Graphics.OpenGL4.VertexAttribType.Float); // bind 0 on attr 0, 2 components per vertex

            GLRenderState rc = GLRenderState.Tri();

            rc.PrimitiveRestart = 0xff;
            rc.DepthTest        = depthtest;

            this.startz = startz;
            this.deltaz = deltaz;

            ri = new GLRenderableItem(PrimitiveType.TriangleStrip, rc, 0, vertexarray); // create a renderable item
            ri.CreateRectangleElementIndexByte(items.NewBuffer(), 255 / 5);             // note this limits top level controls number to 255/5.
            ri.DrawCount = 0;                                                           // nothing to draw at this point

            shader = new GLShaderPipeline(new GLPLVertexShaderScreenTexture(), new GLPLFragmentShaderBindlessTexture(arbbufferid, true, discardiftransparent: true));
            items.Add(shader);

            textures = new Dictionary <GLBaseControl, GLTexture2D>();
            size     = new Dictionary <GLBaseControl, Size>();
            visible  = new Dictionary <GLBaseControl, bool>();

            texturebinds = items.NewBindlessTextureHandleBlock(arbbufferid);

            glwin.MouseMove        += Gc_MouseMove;
            glwin.MouseClick       += Gc_MouseClick;
            glwin.MouseDoubleClick += Gc_MouseDoubleClick;
            glwin.MouseDown        += Gc_MouseDown;
            glwin.MouseUp          += Gc_MouseUp;
            glwin.MouseEnter       += Gc_MouseEnter;
            glwin.MouseLeave       += Gc_MouseLeave;
            glwin.MouseWheel       += Gc_MouseWheel;
            glwin.KeyDown          += Gc_KeyDown;
            glwin.KeyUp            += Gc_KeyUp;
            glwin.KeyPress         += Gc_KeyPress;
            glwin.Resize           += Gc_Resize;
            glwin.Paint            += Gc_Paint;

            suspendLayoutCount = 0;
        }
コード例 #3
0
 /// <summary> Start the class with this matrixcalc. Pass the GL window control, and the initial lookat/cameradirection and zoom.
 /// Control if registration of mouse and keyboard UI is performed with GL window control
 /// </summary>
 public void Start(GLMatrixCalc mc, GLWindowControl win, Vector3 lookat, Vector3 cameradirdegrees, float zoomn,
                   bool registermouseui = true, bool registerkeyui = true)
 {
     MatrixCalc = mc;
     Start(win, lookat, cameradirdegrees, zoomn, registermouseui, registerkeyui);
 }
コード例 #4
0
 /// <summary> Start the class with this matrixcalc and position camera. Pass the GL window control, and the initial lookat/cameradirection and zoom </summary>
 public void Start(GLMatrixCalc mc, PositionCamera pc, GLWindowControl win, Vector3 lookat, Vector3 cameradirdegrees, float zoomn)
 {
     MatrixCalc = mc;
     PosCamera  = pc;
     Start(win, lookat, cameradirdegrees, zoomn);
 }