I'm trying to add samples on the texture to do antialiasing. I am using the new BoxTest that has the depth texture attachment. I tried creating renderbuffers along with the depth attachment texture.
//multisample
GLuint colorBuffer;
glGenRenderbuffersEXT(1, &colorBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorBuffer);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 8, GL_RGBA, [outputImage width], [outputImage height]);
//multi sample depth
GLuint depthBuffer;
glGenRenderbuffersEXT(1, &depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 8, GL_DEPTH_COMPONENT24, [outputImage width], [outputImage height]);
Then after attaching the depth attachment texture I run this
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorBuffer);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);
Before drawing I call these functions for anti aliasing
glEnable (GL_POLYGON_SMOOTH);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
glLineWidth (1.5);
After which ends until the cube is drawn in code.
What happens is that the cube will be drawin to the renderbuffer in black color, antialiased but I don't know how to get it to the framebuffer.
Then I also tried creating a GL_TEXTURE_2D_MULTISAMPLE texture to replace the renderbuffer
This code is ran before the depth attachment texture is created and binded
GLuint mstext;
glGenTextures(1, &mstext);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mstext);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 0, GL_RGBA, [outTex width], [outTex height], false);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D_MULTISAMPLE, mstext, 0);
What I end up getting here is an error: Error creating depth texture: 0x500
And there wont be anything rendered as well.
I couldn't test this in approach in OpenGL profiler since it always crash whenever I have the glTexImage2DMultisample inthe code.
Any thoughts on this?