Beispiel #1
0
        internal BasicLightRenderer(GraphicsDevice device)
        {
            // Piirretään valot omaan tekstuuriin, joka sitten piirretään muiden elementtien päälle.
            RenderTarget = device.CreateRenderTarget((uint)Game.Instance.Window.Size.X, (uint)Game.Instance.Window.Size.Y);

            Game.Instance.Window.Resize += (v) => ResizeRenderTarget();

            int maxAmountOfLights = 1000; // TODO: Mikä olisi hyvä rajoitus?

            lightData    = new LightData[maxAmountOfLights];
            gl           = ((GraphicsDevice)device).Gl;
            vertexbuffer = new BufferObject <VertexPositionColorTexture>(gl, Graphics.TextureVertices, Silk.NET.OpenGL.BufferTargetARB.ArrayBuffer);
            Vao          = new VertexArrayObject <VertexPositionColorTexture, Vector4>(gl, vertexbuffer, null);

            // TODO: Tämä on hieman ruma ja kaipaisi jonkinlaista abstraktiota.
            Vao.VertexAttributePointer(0, 3, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(VertexPositionColorTexture), 0);
            Vao.VertexAttributePointer(1, 4, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(VertexPositionColorTexture), 12);
            Vao.VertexAttributePointer(2, 2, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(VertexPositionColorTexture), 28);

            databuffer = new BufferObject <LightData>(gl, lightData, Silk.NET.OpenGL.BufferTargetARB.ArrayBuffer);
            databuffer.VertexAttributePointer(3, 2, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(LightData), 0);
            databuffer.VertexAttributePointer(4, 1, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(LightData), 8);
            databuffer.VertexAttributePointer(5, 1, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(LightData), 12);
            databuffer.VertexAttributePointer(6, 4, Silk.NET.OpenGL.VertexAttribPointerType.Float, (uint)sizeof(LightData), 16);

            gl.BindBuffer(Silk.NET.OpenGL.BufferTargetARB.ArrayBuffer, 0);
        }
Beispiel #2
0
            public GLModel(Silk.NET.OpenGL.GL _gl, string ModelName, string vertPath, string FragPath, bool isDynamic, TextureType[] texturesToLoad)
            {
                this.vertPath  = vertPath;
                this.fragPath  = FragPath;
                this.isDynamic = isDynamic;
                this.gl        = _gl;
                meshes         = new List <Mesh>();
                objs           = new List <GLObjTextured>();
                var ctx = new AssimpContext();

                model = ctx.ImportFile(ModelName, PostProcessSteps.Triangulate | PostProcessSteps.GenerateSmoothNormals | PostProcessSteps.FlipUVs | PostProcessSteps.CalculateTangentSpace);
                processNode(model.RootNode, model, texturesToLoad);
            }