Beispiel #1
0
 public FramebufferRL(int width, int height)
 {
     viewport = new RenderStack.Math.Viewport(width, height);
     RL.GenFramebuffers(1, out framebufferObject);
     GhostManager.Gen();
     RL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferObject);
 }
Beispiel #2
0
        private void Initialize()
        {
            RL.GenTextures(1, out textureObject);
            Debug.WriteLine("GenTextures: " + textureObject.ToString());
            GhostManager.Gen();

            SetSize();
        }
        public RenderBufferGL3(int width, int height, RenderbufferStorage internalFormat, int sampleCount)
        {
            viewport            = new RenderStack.Math.Viewport(width, height);
            this.internalFormat = internalFormat;
            this.sampleCount    = sampleCount;

            GL.GenRenderbuffers(1, out renderBufferObject);
            GhostManager.Gen();
            //System.Diagnostics.Debug.WriteLine("GenRenderbuffer " + renderBufferObject);
            SetSize();
Beispiel #4
0
        public void RLGen()
        {
            RL.GenBuffers(1, out bufferObject);
            if (bufferObject == IntPtr.Zero)
            {
                throw new System.InvalidOperationException();
            }
#if DEBUG_BUFFER_OBJECTS
            System.Diagnostics.Debug.WriteLine("RL.GenBuffers(1) = " + bufferObject.ToString("X"));
#endif
            GhostManager.Gen();
        }
Beispiel #5
0
        public void GLGen()
        {
            if (OpenTK.Graphics.GraphicsContext.CurrentContext != null)
            {
                GL.GenBuffers(1, out bufferObject);
                if (bufferObject == 0)
                {
                    throw new System.InvalidOperationException();
                }
#if DEBUG_BUFFER_OBJECTS
                System.Diagnostics.Debug.WriteLine("GL.GenBuffers(1) = " + bufferObject);
#endif
                GhostManager.Gen();
            }
            else
            {
                System.Diagnostics.Trace.WriteLine("GL.GenBuffers(1) skipped - OpenTK.Graphics.GraphicsContext.CurrentContext == null");
            }
        }
Beispiel #6
0
        protected void Gen()
        {
            programObject = GL.CreateProgram();
            GhostManager.Gen();
            //GL.BindAttribLocation(this.programObject, 0, "_position");
            foreach (var mapping in AttributeMappings.Global.Mappings)
            {
                GL.BindAttribLocation(ProgramObject, mapping.Slot, mapping.Name);
            }
            if (RenderStack.Graphics.Configuration.glVersion >= 300)
            {
#if DEBUG_PROGRAM
                Trace.WriteLine("Binding Frag Data Locations " + Name + " " + programObject);
#endif
                GL.BindFragDataLocation(this.programObject, 0, "out_color");
                GL.BindFragDataLocation(this.programObject, 0, "out0");
                GL.BindFragDataLocation(this.programObject, 1, "out1");
            }
        }
Beispiel #7
0
 protected void Gen()
 {
     programObject = RL.CreateProgram();
     GhostManager.Gen();
 }
Beispiel #8
0
 public ShaderRL(ShaderType type)
 {
     shaderObject = RL.CreateShader(type);
     GhostManager.Gen();
     this.type = type;
 }
Beispiel #9
0
        public TextureRL(Image image, bool generateMipmaps)
        {
            size           = new Viewport(image.Width, image.Height);
            bindTarget     = TextureTarget.Texture2D;
            texImageTarget = TextureTarget.Texture2D;
            format         = PixelFormat.Rgba;
            internalFormat = PixelInternalFormat.Rgba;
            textureObject  = IntPtr.Zero;

            RL.GenTextures(1, out textureObject);
            Debug.WriteLine("GenTextures: " + textureObject.ToString());
            GhostManager.Gen();

            RL.BindTexture(bindTarget, textureObject);

            int level  = 0;
            int border = 0;

            if (generateMipmaps)
            {
                image.GenerateMipmaps();

                hasMipmaps = true;
            }
            for (;;)
            {
                if (image.Mipmaps.ContainsKey(level) == false || image.Mipmaps[level] == null)
                {
                    Debug.WriteLine("Warning: No mipmaps");
                    hasMipmaps = false;
                    break;
                }

                GCHandle ptr = GCHandle.Alloc(
                    image.Mipmaps[level].Pixels,
                    GCHandleType.Pinned
                    );
                try
                {
                    RL.TexImage2D(
                        texImageTarget,
                        level,
                        internalFormat,
                        image.Mipmaps[level].Width,
                        image.Mipmaps[level].Height,
                        border,
                        format,
                        PixelType.UnsignedByte,
                        (System.IntPtr)ptr.AddrOfPinnedObject()
                        );
                }
                finally
                {
                    ptr.Free();
                }
                if (
                    (image.Mipmaps[level].Width == 1) &&
                    (image.Mipmaps[level].Height == 1)
                    )
                {
                    break;
                }
                ++level;
            }
        }
Beispiel #10
0
        public TextureGL(Image[] images)
        {
            if (images.Length != 6)
            {
                System.Diagnostics.Trace.TraceError("Error: Need 6 images for cube maps");
                throw new ArgumentException();
            }
            size           = new Viewport(images[0].Width, images[0].Height);
            BindTarget     = TextureTarget.TextureCubeMap;
            TexImageTarget = TextureTarget.TextureCubeMapPositiveX;
            Format         = PixelFormat.Rgba;
            InternalFormat = PixelInternalFormat.Rgba;
            textureObject  = 0;

            GL.GenTextures(1, out textureObject);
            Debug.WriteLine("GenTextures: " + textureObject.ToString());
            GhostManager.Gen();

            GL.BindTexture(BindTarget, textureObject);

            int border = 0;

            for (int face = 0; face < 6; ++face)
            {
                int level = 0;

                //  TODO USE nvtt right for cube textures!!!
                images[face].GenerateMipmaps();
                hasMipmaps = true;
                for (;;)
                {
                    if (
                        (images[face].Mipmaps.ContainsKey(level) == false) ||
                        (images[face].Mipmaps[level] == null)
                        )
                    {
                        Debug.WriteLine("No mipmaps");
                        hasMipmaps = false;
                        break;
                    }
                    GCHandle ptr = GCHandle.Alloc(
                        images[face].Mipmaps[level].Pixels,
                        GCHandleType.Pinned
                        );
                    try
                    {
                        GL.TexImage2D(
                            TextureTarget.TextureCubeMapPositiveX + face,
                            level,
                            InternalFormat,
                            images[face].Mipmaps[level].Width,
                            images[face].Mipmaps[level].Height,
                            border,
                            Format,
                            PixelType.UnsignedByte,
                            (System.IntPtr)ptr.AddrOfPinnedObject()
                            );
                    }
                    finally
                    {
                        ptr.Free();
                    }
                    if (
                        (images[face].Mipmaps[level].Width == 1) &&
                        (images[face].Mipmaps[level].Height == 1)
                        )
                    {
                        break;
                    }
                    ++level;
                }
            }
        }