Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Render2Texture with anti-aliasing (OpenTK/OpenGL)

This topic is 2223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone!

I want to render my scene to a texture. Right now I'm using FBO and initializing it the in following way:
[source lang="cpp"]
GL.BindTexture(TextureTarget.Texture2D, glRefColorTexture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
GL.TexImage2D(TextureTarget.Texture2D, 0, intPixFormat, resX, resY, 0, pixFormat, pixType, IntPtr.Zero);
GL.BindTexture(TextureTarget.Texture2D, 0);

GL.GenRenderbuffers(1, out glRefDepthTexture);
GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, glRefDepthTexture);
GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.DepthComponent16, resX, resY);

GL.GenFramebuffers(1, out glRefFrameBufferObj);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, glRefFrameBufferObj);
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, glRefColorTexture, 0);
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, glRefFrameBufferObj);

This works. Without anti-aliasing of course, but I have to use AA too. So I googled it and found the funftion: glRenderbufferStorageMultisample(...).
But in my case it is not working, and have no idea why. FramebufferErrorCode shows that it's inclomplete.
Does anyone have any idea why is it not working and how should I make it work?

Many thanks for any post!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!