android - I receive INVALID OPERATION when I use glBlitFramebuffer to implement MSAA -
perhaps have stupid problems. i'll appreciate if reply them. problems based on android environment , opengl es.
how verified whether has opened msaa or not ? if draw
gl_points
points size 50, there small squares. if enabled 4x msaa, can small squares become round points ?i tried best enable msaa fbo , blitfbo. draw nothing , there error invalid_operation after
glblitframebuffer()
calling.
here complete projects mentioed above:https://github.com/enoch-liu/gl
and following key codes:
void renderer::multisampleantialiasing() { glgenrenderbuffers(1, &m_mscolor); glbindrenderbuffer(gl_renderbuffer, m_mscolor); glrenderbufferstoragemultisample(gl_renderbuffer, 4, gl_rgba8, m_width, m_height); checkglerror("genmscolorbuffer"); glgenframebuffers(1, &m_msfbo); glbindframebuffer(gl_framebuffer, m_msfbo); glframebufferrenderbuffer(gl_framebuffer, gl_color_attachment0, gl_renderbuffer, m_mscolor); checkglerror("fborbo,colorattachment"); glgenrenderbuffers(1, &m_msdepth); glbindrenderbuffer(gl_renderbuffer, m_msdepth); glrenderbufferstoragemultisample(gl_renderbuffer, 4, gl_depth_component16, m_width, m_height); checkglerror("gendepthbuffer"); glframebufferrenderbuffer(gl_framebuffer, gl_depth_attachment, gl_renderbuffer, m_msdepth); checkglerror("depthbuffer,renderbuffer"); glenum drawbufs[] = {gl_color_attachment0}; gldrawbuffers(1, drawbufs); checkglerror("drawbuffer"); if(glcheckframebufferstatus(gl_framebuffer) != gl_framebuffer_complete) { log_error("failed make complete framebuffer object %x", glcheckframebufferstatus(gl_framebuffer)); } } void renderer::drawframe() { //log_info("drawframe %d x %d", width, height); static float r=0.9f; static float g=0.2f; static float b=0.2f; log_info("xxx %d, %d", m_width,m_height); if (openmsaa) { glbindframebuffer(gl_framebuffer, m_msfbo); glbindrenderbuffer(gl_renderbuffer, m_mscolor); checkglerror("bindtwobuffers"); } glviewport(0,0,m_width,m_height); glscissor(0,0,m_width,m_height); glclearcolor(r, g, b, 1.0f); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); gldisable(gl_depth_test); const glfloat landscapeorientationmatrix[16] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; const glfloat color[4] = { 1.0f, 0.0f, 0.0f, 1.0f }; gluseprogram( m_program ); gluniformmatrix4fv(m_umvp, 1, gl_false, landscapeorientationmatrix); gluniform4fv(m_ucolor, 1, color); m_p = glgetattriblocation(m_program, "vposition"); m_p1 = glgetattriblocation(m_program, "vposition1"); glenablevertexattribarray( m_p ); glvertexattribpointer( m_p , 3, gl_float, false, 3 * sizeof( float ), squarecoords); gldrawarrays(gl_points, 0, 4); gldisablevertexattribarray( m_p ); glflush(); checkglerror("before blit"); if (openmsaa) { glbindframebuffer(gl_read_framebuffer, m_msfbo); checkglerror("bindreadbuffer"); glbindframebuffer(gl_draw_framebuffer, 0); checkglerror("bindframebuffer"); glblitframebuffer(0, 0, m_width, m_height, 0, 0, m_width, m_height, gl_color_buffer_bit, gl_nearest); checkglerror("blitframebuffercolor"); glblitframebuffer(0, 0, m_width, m_height, 0, 0, m_width, m_height, gl_depth_buffer_bit, gl_nearest); checkglerror("blitframebufferdepth"); glbindframebuffer(gl_read_framebuffer, 0); glbindframebuffer(gl_draw_framebuffer, 0); } }
the framebuffer complete.
the internal format of depth buffers have match: https://www.opengl.org/discussion_boards/showthread.php/173275-alternative-to-glblitframebuffer%28%29
looking @ github project not configuring depth buffer @ all. project:
const eglint attribs[] = { // egl_surface_type, egl_window_bit, egl_renderable_type, egl_opengl_es2_bit, egl_surface_type, egl_pbuffer_bit, egl_blue_size, 8, egl_green_size, 8, egl_red_size, 8, egl_alpha_size, 8, egl_sample_buffers, 1, egl_samples, 4, egl_none };
Comments
Post a Comment