示例#1
0
        Texture GetPatternTexture(OpenGlDevice Device)
        {
            Texture Save = Device.texture;

            if (Pattern == null)
            {
                return(null);
            }
            Rectangled R           = new Rectangled(Pattern.PatternX, Pattern.PatternY, Pattern.PatternWidth, Pattern.PatternHeight);
            FBO        FrameBuffer = new FBO();

            FrameBuffer.BackGround = System.Drawing.Color.Transparent;
            Device.PushMatrix();
            xyz   RU  = new xyz(R.Width, R.Height, 0);
            xyz   RD  = new xyz(R.X, R.Y, 0);
            Point _RU = Device.ToScr(RU);
            Point _RD = Device.ToScr(RD);

            FrameBuffer.Init((int)(_RU.X - _RD.X), (int)(_RD.Y - _RU.Y));
            FrameBuffer.EnableWriting();
            Pattern.Paint(Device);
            Device.PopMatrix();
            FrameBuffer.DisableWriting();
            Texture result = FrameBuffer.Texture;

            Device.texture     = Save;
            result.WorldWidth  = R.Width;
            result.WorldHeight = R.Height;
            result.Translation = new xy(R.X, R.Y);
            FrameBuffer.Dispose(true);
            return(result);
        }
示例#2
0
        private void InitializeOgl(Control WinControl)
        {
            if (RenderingContext != null)
            {
                if (!RenderingContext.IsDisposed)
                {
                    DisposeOglObjects();
                }
            }


            /* private OpenTK.Platform.IWindowInfo*/
            WindowsInfo = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(WinControl.Handle);

            OpenTK.Graphics.GraphicsMode GraphicMode = new OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(PfdColorBits), PfdDepthBits, PfdStencilBits, PfdAuxBits, new OpenTK.Graphics.ColorFormat(PfdAccumBits), PfdBuffers, PfdStereo);

            OpenTK.Graphics.GraphicsMode GraphicMode2 = OpenTK.Graphics.GraphicsMode.Default;
            RenderingContext = new OpenTK.Graphics.GraphicsContext(GraphicMode2, WindowsInfo);
            RenderingContext.LoadAll();
            FBO.LoadMethods();
            RenderingContext.SwapInterval = 1;
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.CullFace(CullFaceMode.Back);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.Enable(EnableCap.Normalize);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Lighting);

            ShadowMapSampler = GL.GenSampler();
            //  Texture.Sampler= GL.GenSampler();
            ActivateShader();
            Lights[0].Position     = new xyzwf(3, 4, 10, 0);
            FieldOfView            = 0;
            Selector.PickingShader = PickingShader;
            //System.Diagnostics.ConsoleTraceListener myWriter = new
            //System.Diagnostics.ConsoleTraceListener();

            //System.Diagnostics.Debug.Listeners.Clear();
            //System.Diagnostics.Debug.Listeners.Add(myWriter);
            CheckError();


            ClockWise = true;
            Culling   = false;

            SwapBuffers();
            CheckError();
        }
示例#3
0
        /// <summary>
        /// plays the scene in Bitmap.
        /// </summary>
        /// <returns></returns>
        public Bitmap ScreenShot()
        {
            FBO     FrameBuffer = new FBO((int)ViewPort.Width, (int)ViewPort.Height);
            Texture Save        = texture;

            FrameBuffer.EnableWriting();
            Refresh();
            FrameBuffer.DisableWriting();
            texture = Save;
            Bitmap Result = FrameBuffer.ReadBitmap();

            FrameBuffer.Dispose();
            return(Result);
        }