コード例 #1
0
ファイル: RScreen.cs プロジェクト: polytronicgr/reactor
        public void RenderTexture(RTexture texture, Math.Rectangle bounds, RColor color, Matrix matrix, bool font)
        {
            RViewport viewport = REngine.Instance._viewport;

            UpdateQuad(bounds);
            blendState.PlatformApplyState();

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            defaultShader.Bind();
            defaultShader.SetSamplerValue(RTextureLayer.DIFFUSE, texture);
            vertexQuad2D.Bind();
            vertexQuad2D.BindVertexArray();
            indexQuad2D.Bind();


            defaultShader.SetUniformValue("projection", camera2d.Projection);
            defaultShader.SetUniformValue("view", camera2d.View);
            defaultShader.SetUniformValue("diffuse_color", color.ToVector4());
            defaultShader.SetUniformValue("model", matrix);
            defaultShader.SetUniformValue("font", font);
            vertexQuad2D.VertexDeclaration.Apply(defaultShader, IntPtr.Zero);


            GL.DrawElements(PrimitiveType.Triangles, indexQuad2D.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero);
            REngine.CheckGLError();

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha);
            GL.Disable(EnableCap.Blend);
            indexQuad2D.Unbind();
            vertexQuad2D.UnbindVertexArray();
            vertexQuad2D.Unbind();
            defaultShader.Unbind();
        }
コード例 #2
0
ファイル: RScreen.cs プロジェクト: polytronicgr/reactor
        public void RenderFullscreenQuad(RShader shader)
        {
            RViewport viewport = REngine.Instance._viewport;

            quadVerts[0].Position = new Vector2(-1, -1);
            quadVerts[0].TexCoord = new Vector2(0, 0);
            quadVerts[1].Position = new Vector2(1, -1);
            quadVerts[1].TexCoord = new Vector2(1, 0);
            quadVerts[2].Position = new Vector2(1, 1);
            quadVerts[2].TexCoord = new Vector2(1, 1);
            quadVerts[3].Position = new Vector2(-1, 1);
            quadVerts[3].TexCoord = new Vector2(0, 1);
            vertexQuad2D.SetData <RVertexData2D>(quadVerts);
            shader.Bind();
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            vertexQuad2D.Bind();
            vertexQuad2D.BindVertexArray();
            indexQuad2D.Bind();

            vertexQuad2D.VertexDeclaration.Apply(shader, IntPtr.Zero);


            GL.DrawElements(PrimitiveType.Triangles, indexQuad2D.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero);
            REngine.CheckGLError();

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            indexQuad2D.Unbind();
            vertexQuad2D.UnbindVertexArray();
            vertexQuad2D.Unbind();
            shader.Unbind();
        }
コード例 #3
0
        void RCamera2d_OnUpdate(object sender, EventArgs e)
        {
            RViewport viewport = REngine.Instance._viewport;

            this.Projection = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, Near, Far);
            this.View       = Matrix.Identity;
        }
コード例 #4
0
ファイル: REngine.cs プロジェクト: polytronicgr/reactor
        public REngine()
        {
            RootPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            RLog.Info("Engine startup sequence activated.");


            _stopWatch = new Stopwatch();
            _fpsTimer  = new System.Timers.Timer();

            _fpsTimer.Interval = 1000;
            _fpsTimer.Elapsed += _fpsTimer_Tick;
            _fpsTimer.Start();

            _viewport     = new RViewport(0, 0, 800, 600);
            camera        = new RCamera();
            lastFrameTime = new TimeSpan();
        }
コード例 #5
0
ファイル: RCamera.cs プロジェクト: polytronicgr/reactor
        public RCamera()
        {
            Near        = 1.0f;
            Far         = 100.0f;
            FieldOfView = 70f;
            IsEnabled   = true;
            OnUpdate   += (sender, e) => {
                //ViewDirection = Vector3.Transform(new Vector3(0, 0, -1f), GetRotation());

                /*viewMatrix = new Matrix(
                 *  matrix.M11, matrix.M12, matrix.M13, 0,
                 *  matrix.M21, matrix.M22, matrix.M23, 0,
                 *  matrix.M31, matrix.M32, matrix.M33, 0,
                 *  -Vector3.Dot(Position, matrix.Right), -Vector3.Dot(Position, matrix.Up), -Vector3.Dot(Position, matrix.Forward), 1
                 * );*/
                viewMatrix = Matrix.CreateLookAt(this.Position, this.Position + matrix.Forward, matrix.Up);


                ViewDirection = viewMatrix.Forward;
                RViewport viewport = REngine.Instance._viewport;
                projMatrix = Matrix.Identity * Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(FieldOfView), viewport.AspectRatio, Near, Far);
            };
        }
コード例 #6
0
ファイル: REngine.cs プロジェクト: polytronicgr/reactor
 public void SetViewport(RViewport viewport)
 {
     _viewport = viewport;
 }