Beispiel #1
0
        public void Init()
        {
            a = EPrimitiveMesh.GetPrimitiveMesh(EPrimitiveMesh.PrimitiveType.ScreenPlane);
            b = new EGammaCorrectionMat();

            sceneBuffer = new TextureFrameBuffer();

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, sceneBuffer.frameBuffer);

            GL.BindTexture(TextureTarget.Texture2D, sceneBuffer.texture); // color
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                          EWindow.GLWidth, EWindow.GLHeight,
                          0, (PixelFormat)PixelInternalFormat.Rgba, PixelType.UnsignedByte,
                          IntPtr.Zero);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.BindTexture(TextureTarget.Texture2D, sceneBuffer.texture2); // depth
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent32,
                          EWindow.GLWidth, EWindow.GLHeight,
                          0, (PixelFormat)PixelInternalFormat.DepthComponent, PixelType.Int,
                          IntPtr.Zero);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            ////Create color attachment texture
            GL.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, sceneBuffer.texture, 0);
            GL.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, sceneBuffer.texture2, 0);

            //No need for renderbuffer object since we don't need stencil buffer yet
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
Beispiel #2
0
        public static EScene GetDefaultScene()
        {
            EMaterial e = new EColorMat();
            // Empty scene
            EScene buffer = new EScene();

            // Add render stuff 03
            EActor obj = new EActor("floor");

            obj.position = new Vector3(0, -0.1f, 0);
            obj.scale    = new Vector3(20f, 20f, 20f);

            EMeshFilter meshf = obj.AddComponent <EMeshFilter>();

            meshf.SetMesh(EPrimitiveMesh.GetPrimitiveMesh(EPrimitiveMesh.PrimitiveType.Plane));

            EMeshRenderer meshr = obj.AddComponent <EMeshRenderer>();

            meshr.SetMaterial(e);
            buffer.AddActorToScene(obj);

            return(buffer);
        }