示例#1
0
 internal void UpdateViewport()
 {
     fbo.Bind();
     fbo.SetTextureBuffer(FrameBufferObject.TargetBuffer.Color, PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float, renderer.Screen.Width, renderer.Screen.Height);
     fbo.DrawBuffers(new[] { DrawBuffersEnum.ColorAttachment0 });
     fbo.UnBind();
 }
示例#2
0
        protected override void Resize(int newWidth, int newHeight)
        {
            Debug.Assert(newWidth > 0 && newHeight > 0);

            FrameBufferObject.Bind();

            BufferWidth  = newWidth;
            BufferHeight = newHeight;

            PositionAttachment.Resize(BufferWidth, BufferHeight);
            ColorAttachment.Resize(BufferWidth, BufferHeight);
            NormalAttachment.Resize(BufferWidth, BufferHeight);
            DepthAttachment.Resize(BufferWidth, BufferHeight);

            GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2DMultisample, PositionAttachment.GetTextureObject, 0);
            GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment1, TextureTarget.Texture2DMultisample, ColorAttachment.GetTextureObject, 0);
            GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment2, TextureTarget.Texture2DMultisample, NormalAttachment.GetTextureObject, 0);
            GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2DMultisample, DepthAttachment.GetTextureObject, 0);

            var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

            Debug.Assert(status == FramebufferErrorCode.FramebufferComplete);

            FrameBufferObject.Unbind();
        }
示例#3
0
        internal Touch(NewRenderer renderer)
        {
            this.renderer = renderer;

            objectStates = new List <ObjectState>();
            touchFaces   = new List <FaceState>();
            try
            {
                pickingShader = new Shader("default", "picking", true);
                pickingShader.Activate();
                pickingShader.Deactivate();
            }
            catch
            {
                Interface.AddMessage(MessageType.Error, false, "Initialising the touch shader failed- Falling back to legacy openGL.");
                Interface.CurrentOptions.IsUseNewRenderer = false;
            }


            fbo = new FrameBufferObject();
            fbo.Bind();
            fbo.SetTextureBuffer(FrameBufferObject.TargetBuffer.Color, PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float, renderer.Screen.Width, renderer.Screen.Height);
            fbo.DrawBuffers(new[] { DrawBuffersEnum.ColorAttachment0 });
            fbo.UnBind();
        }
示例#4
0
 protected void Blit(FrameBufferObject source, FrameBufferObject destination, Material material)
 {
     destination.Bind();
     material.SetScreenSourceTexture("u_Src", source.ColorHandle);
     Renderer.DrawNow(BlitMesh, material);
     destination.Unbind();
 }
示例#5
0
文件: Touch.cs 项目: zbx1425/OpenBVE
        internal Touch(NewRenderer renderer)
        {
            this.renderer   = renderer;
            touchableObject = new List <ObjectState>();

            if (!renderer.ForceLegacyOpenGL)
            {
                fbo = new FrameBufferObject();
                fbo.Bind();
                fbo.SetTextureBuffer(FrameBufferObject.TargetBuffer.Color, PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float, renderer.Screen.Width, renderer.Screen.Height);
                fbo.DrawBuffers(new[] { DrawBuffersEnum.ColorAttachment0 });
                fbo.UnBind();
            }
        }
示例#6
0
 public void Bind()
 {
     FrameBufferObject.Bind();
     PrepareToDraw();
 }
示例#7
0
        public static void GenerateBlockItemIcons()
        {
            const int ICON_SIZE = 64;

            FrameBufferObject fbo = null;

            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.ClearColor(0, 0, 0, 0);

            LightingUniformBufferData lighting = new LightingUniformBufferData();

            lighting.AmbientColour = new Vector4(0.5f, 0.5f, 0.5f, 1);
            lighting.SunColour     = new Vector4(1, 1, 1, 1);
            lighting.SunStrength   = 1;
            lighting.SunDirection  = new Vector4(0.5f, 0.5f, 0.5f, 1);

            Chunk tempChunk = new Chunk(Vector2.Zero);

            tempChunk.Blocks = new Chunk.BlockState[Chunk.WIDTH, Chunk.HEIGHT, Chunk.WIDTH];

            Camera tempCamera = new Camera();

            tempCamera.ProjectionType = CameraProjectionType.Orthographic;
            tempCamera.CameraSize     = new Vector2(0.8f);
            tempCamera.GenerateProjectionMatrix();
            tempCamera.Position = new Vector3(0, 0, 15f);

            UniformBuffers.DirectionLightBuffer.Update(lighting);
            tempCamera.Update();

            var items = ItemDatabase.GetItems();

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i] is BlockItem item)
                {
                    fbo = new FrameBufferObject(ICON_SIZE, ICON_SIZE, FBOType.None);
                    fbo.Bind();
                    GL.Clear(ClearBufferMask.ColorBufferBit);

                    var newState = new Chunk.BlockState(0, 0, 0, tempChunk);
                    newState.id = (short)item.Block.ID;
                    tempChunk.Blocks[0, 0, 0] = newState;
                    tempChunk.GenerateMesh();

                    tempChunk.RenderForIcon();

                    //Render here...
                    Texture icon = new Texture(fbo, true);
                    AssetDatabase.RegisterAsset(icon, "GeneratedIcons/" + item.Key);

                    item.IconLocation = "GeneratedIcons/" + item.Key;
                    item.GenerateGraphics();
                }
            }

            fbo?.Unbind();

            fbo?.DisposeWithoutColorHandle();
            tempChunk.Dispose();

            GL.ClearColor(Window.CLEAR_COLOUR.X, Window.CLEAR_COLOUR.Y, Window.CLEAR_COLOUR.Z, Window.CLEAR_COLOUR.W);

            fbo        = null;
            tempChunk  = null;
            tempCamera = null;
        }
示例#8
0
 public override void Begin()
 {
     FBO.Bind();
     Opengl32.glClear(GLConsts.GL_COLOR_BUFFER_BIT);
 }