Example #1
0
        public FirstPersonHeldRenderer(Voxeload voxeload)
        {
            this.voxeload = voxeload;

            // Generate buffers
            vbo    = GL.GenBuffer();
            vao    = GL.GenVertexArray();
            uvbo   = GL.GenBuffer();
            facebo = GL.GenBuffer();

            SetTile(voxeload.player.HeldTile);
        }
Example #2
0
        public ChunkRenderer(Voxeload voxeload)
        {
            for (int i = 0; i < Chunk.LAYER_COUNT; i++)
            {
                vbos[i]    = GL.GenBuffer();
                vaos[i]    = GL.GenVertexArray();
                uvbos[i]   = GL.GenBuffer();
                facebos[i] = GL.GenBuffer();
                bribos[i]  = GL.GenBuffer();
            }

            this.voxeload = voxeload;
        }
Example #3
0
        public Framebuffer(Voxeload voxeload, int width, int height)
        {
            this.voxeload = voxeload;

            // Generate framebuffer
            fbo = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo);

            // Generate framebuffer colour texture
            textureColour = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, textureColour);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            // Generate framebuffer depth texture
            textureDepth = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, textureDepth);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, width, height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);

            // Attach textures to framebuffer
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, textureColour, 0);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, textureDepth, 0);

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

            // Generate screen tris
            if (screenvao == 0)
            {
                screenvbo  = GL.GenBuffer();
                screenvao  = GL.GenVertexArray();
                screenuvbo = GL.GenBuffer();

                GL.BindVertexArray(screenvao);

                GL.BindBuffer(BufferTarget.ArrayBuffer, screenvbo);
                GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * 2 * 6, new Vector2[] { new(-1, -1), new(1, -1), new(-1, 1), new(1, 1), new(-1, 1), new(1, -1) }, BufferUsageHint.StaticDraw);
Example #4
0
 public WaterFramebuffer(Voxeload voxeload, int width, int height, int worldTextureDepth) : base(voxeload, width, height)
 {
     this.worldTextureDepth = worldTextureDepth;
 }