Esempio n. 1
0
        public override void OnRenderFrame(float deltaTime)
        {
            if (updateMap)
            {
                gVertexBuffer.Dispose();
                gDrawIdBuffer.Dispose();
                theMap = TheGameStatus.TheMap;
                GenerateGeometry();
                GenerateArrayTexture();

                Gl.UseProgram(0);
                Gl.BindBuffer(BufferTarget.ArrayBuffer, 0);

                updateMap = false;
            }

            // apply our camera view matrix to the shader view matrix (this can be used for all objects in the scene)
            program.Use();
            program["view_matrix"].SetValue(theCamera.ViewMatrix);
            program["projection_matrix"].SetValue(projectionMatrix);
            program["enable_lighting"].SetValue(theEnvironment.Lighting);
            if (theEnvironment.LightMove)
            {
                program["light_direction"].SetValue(theEnvironment.LightDirection);
            }


            theTextureArray.Use();

            int tempStride = sizeof(Single) * stride;

            Gl.EnableVertexAttribArray(locationPosition);
            Gl.BindBuffer(gVertexBuffer);
            Gl.VertexAttribPointer(locationPosition, 3, VertexAttribPointerType.Float, false, tempStride,
                                   IntPtr.Zero);

            Gl.EnableVertexAttribArray(locationTexCoord);
            Gl.VertexAttribPointer(locationTexCoord, 2, VertexAttribPointerType.Float, false, tempStride,
                                   new IntPtr(3 * sizeof(Single)));

            Gl.EnableVertexAttribArray(locationDrawid);
            Gl.BindBuffer(gDrawIdBuffer);

            Gl.VertexAttribPointer(locationDrawid, 1, VertexAttribPointerType.Float, false, sizeof(Single), IntPtr.Zero);


            Gl.DrawArrays(BeginMode.Triangles, 0, numberOfTiles * 6);

//            Gl.BindTexture(TextureTarget.Texture2DArray, 0);
//
//            Gl.BindBuffer(BufferTarget.ArrayBuffer, 0);
//            Gl.BindBuffer(BufferTarget.DrawIndirectBuffer, 0);
//            Gl.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
//            Gl.UseProgram(0);
        }
Esempio n. 2
0
 private static void OnClose()
 {
     particleVertices.Dispose();
     particleColors.Dispose();
     particlePoints.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
     fontProgram.DisposeChildren = true;
     fontProgram.Dispose();
     font.FontTexture.Dispose();
     information.Dispose();
 }
Esempio n. 3
0
 public void Dispose()
 {
     vertices.Dispose();
     uvs.Dispose();
     normals.Dispose();
     triangles.Dispose();
 }
Esempio n. 4
0
 public void Dispose()
 {
     vertices.Dispose();
     uvs.Dispose();
     triangles.Dispose();
     shader.Dispose();
 }
        static unsafe void Main(string[] args)
        {
            var Options = WindowOptions.Default;

            Options.Size  = new Silk.NET.Maths.Vector2D <int>(800, 600);
            Options.Title = "LearnOpenGL with Silk.NET";
            var window = Window.Create(Options);

            window.Render += (obj) => {
                GL.GetApi(window).ClearColor(Color.Black);
                GL.GetApi(window).Clear((uint)ClearBufferMask.ColorBufferBit);
                vao.Bind();
                shader.Use();
                GL.GetApi(window).DrawElements((GLEnum)PrimitiveType.Triangles, (uint)Indices.Length, GLEnum.UnsignedInt, null);
            };
            window.Load += () => {
                vbo    = new VBO(GL.GetApi(window), Vertices, GLEnum.StaticDraw);
                ebo    = new EBO(GL.GetApi(window), Indices);
                vao    = new VAO(GL.GetApi(window), vbo, ebo);
                shader = new Abstractions.Shader(GL.GetApi(window), "shader.vert", "shader.frag");
                vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 0, 0);
            };
            window.Closing += () => {
                vbo.Dispose();
                ebo.Dispose();
                vao.Dispose();
                shader.Dispose();
            };
            window.Run();
        }
Esempio n. 6
0
        public void Dispose()
        {
            vertices.Dispose();
            uvs.Dispose();
            triangles.Dispose();

            vertices = null;
        }
Esempio n. 7
0
 private static void OnClose()
 {
     star.Dispose();
     starUV.Dispose();
     starQuads.Dispose();
     starTexture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 8
0
        private static void OnClose()
        {
            // dispose of all of the resources that were created
            triangle.Dispose();
            triangleElements.Dispose();

            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 9
0
 private static void OnClose()
 {
     cube.Dispose();
     cubeUV.Dispose();
     cubeQuads.Dispose();
     CrateTexture.Dispose();
     ShaderProgram.DisposeChildren = true;
     ShaderProgram.Dispose();
 }
Esempio n. 10
0
 private static void OnClose()
 {
     panel.Dispose();
     panelUV.Dispose();
     panelTriangles.Dispose();
     ChessboardTexrute.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 11
0
        private static void OnClose()
        {
            //Delete all resources on closing
            cube.Dispose();
            cubeElements.Dispose();
            cubeUV.Dispose();

            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 12
0
        private static void closeProgram()
        {
            // Dump all the data on close
            square.Dispose();
            program.DisposeChildren = true;

            SquareElements.Dispose();
            squareColor.Dispose();
            program.Dispose();
        }
Esempio n. 13
0
 private static void onClose()
 {
     // Dispose all resources ware created
     pyramid.Dispose();
     pyramidTriangles.Dispose();
     cube.Dispose();
     cubeQuads.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 14
0
        private static void OnClose()
        {
            //Delete all resources on closing
            start.Dispose();
            startElements.Dispose();
            startUV.Dispose();

            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 15
0
 private static void OnClose()
 {
     cube.Dispose();
     cubeNormals.Dispose();
     cubeUV.Dispose();
     cubeQuads.Dispose();
     glassTexture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 16
0
 public void Dispose()
 {
     if (!disposed)
     {
         return;
     }
     VBO.Dispose();
     IBO.Dispose();
     disposed = true;
 }
Esempio n. 17
0
 private static void OnClose()
 {
     cube.Dispose();
     cubeUV.Dispose();
     cubeElements.Dispose();
     cubeNormals.Dispose();
     texture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 18
0
 private static void OnClose()
 {
     // dispose of all of the resources that were created
     cube.Dispose();
     cubeUV.Dispose();
     cubeQuads.Dispose();
     crateTexture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 19
0
 private static void OnClose()
 {
     // dispose of all of the resources that were created
     cube.Dispose();
     cubeUV.Dispose();
     glassTexture.Dispose();
     cubeNormals.Dispose();
     cubeElements.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 20
0
 private static void OnClose()
 {
     // dispose of all of the resources that were created
     poly.Dispose();
     polyColor.Dispose();
     polygon3d.Dispose();
     cube.Dispose();
     cubeColor.Dispose();
     cubeQuads.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 21
0
        private static void onClose()
        {
            // dispose of all of the resources that were created
            drawVertices.Dispose();
            drawNormals.Dispose();
            drawElements.Dispose();
            drawEdges.Dispose();
            drawEdgeElements.Dispose();

            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 22
0
 private static void OnClose()
 {
     // dispose of all of the resources that were created
     pyramid.Dispose();
     pyramidColor.Dispose();
     pyramidTriangles.Dispose();
     cube.Dispose();
     cubeColor.Dispose();
     cubeQuads.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
 }
Esempio n. 23
0
 private static void OnClose()
 {
     flagVertices.Dispose();
     flagUVs.Dispose();
     flagTriangles.Dispose();
     flagTexture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
     fontProgram.DisposeChildren = true;
     fontProgram.Dispose();
     font.FontTexture.Dispose();
     information.Dispose();
 }
Esempio n. 24
0
 private static void OnClose()
 {
     star.Dispose();
     starUV.Dispose();
     starQuads.Dispose();
     starTexture.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
     fontProgram.DisposeChildren = true;
     fontProgram.Dispose();
     font.FontTexture.Dispose();
     information.Dispose();
 }
Esempio n. 25
0
        static void drawSquare(Square square)
        {
            Matrix4 scaling     = Matrix4.CreateScaling(square.size);
            Matrix4 translation = Matrix4.CreateTranslation(new Vector3(square.x, square.y, 0));

            program["model_matrix"].SetValue(scaling * translation);
            if (squareColor != null)
            {
                squareColor.Dispose();
            }
            squareColor = new VBO <Vector3>(new Vector3[] { square.color, square.color, square.color, square.color });
            Gl.BindBufferToShaderAttribute(squareColor, program, "vertexColor");
            Gl.DrawElements(BeginMode.Quads, squareElements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);
        }
Esempio n. 26
0
        public void Dispose()
        {
            if (vertexBuffer != null)
            {
                vertexBuffer.Dispose();
            }
            if (uvBuffer != null)
            {
                uvBuffer.Dispose();
            }

            vertexBuffer = null;
            uvBuffer     = null;
        }
Esempio n. 27
0
        private static void OnClose()
        {
            pyramid.Dispose();
            pyramidTriangles.Dispose();

            cube.Dispose();
            cubeNormals.Dispose();
            cubeUV.Dispose();
            cubeTriangles.Dispose();
            brickDiffuse.Dispose();
            brickNormals.Dispose();
            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 28
0
 public void Dispose()
 {
     if (vertices != null)
     {
         vertices.Dispose();
     }
     if (normals != null)
     {
         normals.Dispose();
     }
     if (triangles != null)
     {
         triangles.Dispose();
     }
 }
Esempio n. 29
0
 private static void OnClose()
 {
     cube.Dispose();
     cubeNormals.Dispose();
     cubeUV.Dispose();
     cubeTriangles.Dispose();
     brickDiffuse.Dispose();
     brickNormals.Dispose();
     program.DisposeChildren = true;
     program.Dispose();
     fontProgram.DisposeChildren = true;
     fontProgram.Dispose();
     font.FontTexture.Dispose();
     information.Dispose();
 }
Esempio n. 30
0
 private static void OnClose()
 {
     System.Media.SoundPlayer sh = new System.Media.SoundPlayer(@"C:\Users\DariusziElżbieta\Documents\3D_Rectangles\DDD\bin\Debug\shot.wav");
     sh.Play();
     Thread.Sleep(600);
     cube.Dispose();
     cubeUV.Dispose();
     cubeElements.Dispose();
     cubeNormals.Dispose();
     Texture1.Dispose();
     Texture2.Dispose();
     Texture3.Dispose();
     Texture4.Dispose();
     program.Dispose();
 }