ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
668 stars 151 forks source link

glCheckFramebufferStatus return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT #372

Closed afxgroup closed 2 years ago

afxgroup commented 2 years ago

Im trying GL4ES on AmigaOS4 and everything seems working correctly except when I reach this function that prepare a framebuffer

  GL_CHECK(glGenFramebuffers(1, &m_handle));
  GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_handle));
  GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture.getHandle(), 0));
#ifndef __amigaos4__
  assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
#endif
  GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));

If I remove the #ifdef the assert is fired because the return value of glCheckFramebufferStatus is always GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT

The m_handle and m_texture.getHandle() are valdid What can I check?

ptitSeb commented 2 years ago

And the texture is in a format supported by the framebuffer? I suppose it is. Maybe you can try to unbind/rebind before checking, just to be sure? I also expect AmigaOS4 to support NPOT texture on FBO, but just in case, what is the size of the texture attached?

afxgroup commented 2 years ago

the size is correct (in the example is 640x480). However the data is null. Basically they create an empty texture with this code:

  auto glFormat = getGlFormat(format);
  auto glInternalFormat = format == Format::Alpha ? GL_R8 : glFormat;
  GL_CHECK(glGenTextures(1, &m_img_tex));
  GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_img_tex));
  GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, getAlignment(m_format)));
  GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat, m_size.x, m_size.y, 0, glFormat, GL_UNSIGNED_BYTE, data));

And then they use the texture in this way:

glViewport(viewport.min.x, viewport.min.y, viewport.getWidth(), viewport.getHeight()); // I've cheched and everything is set correctly
  GL_CHECK(glClearColor(color.r, color.g, color.b, color.a));
  GL_CHECK(glClear(GL_COLOR_BUFFER_BIT));
kas1e commented 2 years ago

@afxgroup Can you also post the current output from the console when you run your example? I fear because you choose another route with SDL by using SDL2_OGLES2 renderer and not SDL2 with OpenGL-to-gl4es replace, you may have not enabled a lot of things that should be enabled (like npot, framebuffers things, etc).

afxgroup commented 2 years ago
LIBGL: Initialising gl4es
LIBGL: v1.1.5 built on Feb  6 2022 19:13:15
LIBGL: Using GLES 2.0 backend
LIBGL: Using Warp3DNova.library v1 revision 68
LIBGL: Using OGLES2.library v3 revision 1
LIBGL: OGLES2 Library and Interface open successfuly
LIBGL: Targeting OpenGL 2.1
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
LIBGL: Force texture for Attachment color0 on FBO
LIBGL: Hack to trigger a SwapBuffers when a Full Framebuffer Blit on default FBO is done
LIBGL: Current folder is:/Data/GIOCHI/Engge/nfg
kas1e commented 2 years ago

@Andrea Yeah, half of the things are not initialized. Should be:

LIBGL: Initialising gl4es
LIBGL: v1.1.5 built on Apr 15 2021 11:28:09
LIBGL: Using GLES 2.0 backend
LIBGL: Using Warp3DNova.library v54 revision 9
LIBGL: Using OGLES2.library v3 revision 1
LIBGL: OGLES2 Library and Interface open successfuly
LIBGL: Targeting OpenGL 2.1
LIBGL: NPOT texture handled in hardware
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
LIBGL: Force texture for Attachment color0 on FBO
LIBGL: Hack to trigger a SwapBuffers when a Full Framebuffer Blit on default FBO is done
LIBGL: Current folder is:Work:gl4es_round4/5/frikingshark
LIBGL: Hardware test on current Context...
LIBGL: Hardware Full NPOT detected and used
LIBGL: Extension GL_EXT_blend_minmax  detected and used
LIBGL: FBO are in core, and so used
LIBGL: PointSprite are in core, and so used
LIBGL: CubeMap are in core, and so used
LIBGL: BlendColor is in core, and so used
LIBGL: Blend Substract is in core, and so used
LIBGL: Blend Function and Equation Separation is in core, and so used
LIBGL: Texture Mirrored Repeat is in core, and so used
LIBGL: Extension GL_OES_mapbuffer  detected
LIBGL: Extension GL_OES_element_index_uint  detected and used
LIBGL: Extension GL_OES_packed_depth_stencil  detected and used
LIBGL: Extension GL_EXT_texture_format_BGRA8888  detected and used
LIBGL: Extension GL_OES_texture_float  detected and used
LIBGL: Extension GL_AOS4_texture_format_RGB332 detected
LIBGL: Extension GL_AOS4_texture_format_RGB332REV detected
LIBGL: Extension GL_AOS4_texture_format_RGBA1555REV detected and used
LIBGL: Extension GL_AOS4_texture_format_RGBA8888 detected and used
LIBGL: Extension GL_AOS4_texture_format_RGBA8888REV detected and used
LIBGL: high precision float in fragment shader available and used
LIBGL: Extension GL_EXT_frag_depth  detected and used
LIBGL: Max vertex attrib: 16
LIBGL: Max texture size: 16384
LIBGL: Max Varying Vector: 32
LIBGL: Texture Units: 2/2 (hardware: 32), Max lights: 8, Max planes: 6
LIBGL: Extension GL_EXT_texture_filter_anisotropic  detected and used
LIBGL: Max Anisotropic filtering: 16
LIBGL: Max Color Attachments: 1 / Draw buffers: 1
LIBGL: Hardware vendor is A-EON Technology Ltd. Written by Daniel 'Daytona675x' MьЯener @ GoldenCode.eu
LIBGL: GLSL 300 es supported
LIBGL: GLSL 310 es supported and used 

I can't say 100% sure that this can be your issue, but at least, you surely will have issues with compatibility, speed, and all kind of other issues if your output is not like that i show.

@ptitSeb Can you a bit give us more info if those strings Andrea miss are harmless or that mean he just didn't have some envs enabled for his own build ?

afxgroup commented 2 years ago

well, so we have to find a way to integrate gl4es into sdl2. Do you know the discord channel where all os4 devs are? You can join us

Il giorno lun 7 feb 2022 alle ore 17:32 kas1e @.***> ha scritto:

@Andrea https://github.com/Andrea Yeah, half of the things are not initialized. Should be:

LIBGL: Initialising gl4es

LIBGL: v1.1.5 built on Apr 15 2021 11:28:09

LIBGL: Using GLES 2.0 backend

LIBGL: Using Warp3DNova.library v54 revision 9

LIBGL: Using OGLES2.library v3 revision 1

LIBGL: OGLES2 Library and Interface open successfuly

LIBGL: Targeting OpenGL 2.1

LIBGL: NPOT texture handled in hardware

LIBGL: Not trying to batch small subsequent glDrawXXXX

LIBGL: try to use VBO

LIBGL: Force texture for Attachment color0 on FBO

LIBGL: Hack to trigger a SwapBuffers when a Full Framebuffer Blit on default FBO is done

LIBGL: Current folder is:Work:gl4es_round4/5/frikingshark

LIBGL: Hardware test on current Context...

LIBGL: Hardware Full NPOT detected and used

LIBGL: Extension GL_EXT_blend_minmax detected and used

LIBGL: FBO are in core, and so used

LIBGL: PointSprite are in core, and so used

LIBGL: CubeMap are in core, and so used

LIBGL: BlendColor is in core, and so used

LIBGL: Blend Substract is in core, and so used

LIBGL: Blend Function and Equation Separation is in core, and so used

LIBGL: Texture Mirrored Repeat is in core, and so used

LIBGL: Extension GL_OES_mapbuffer detected

LIBGL: Extension GL_OES_element_index_uint detected and used

LIBGL: Extension GL_OES_packed_depth_stencil detected and used

LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used

LIBGL: Extension GL_OES_texture_float detected and used

LIBGL: Extension GL_AOS4_texture_format_RGB332 detected

LIBGL: Extension GL_AOS4_texture_format_RGB332REV detected

LIBGL: Extension GL_AOS4_texture_format_RGBA1555REV detected and used

LIBGL: Extension GL_AOS4_texture_format_RGBA8888 detected and used

LIBGL: Extension GL_AOS4_texture_format_RGBA8888REV detected and used

LIBGL: high precision float in fragment shader available and used

LIBGL: Extension GL_EXT_frag_depth detected and used

LIBGL: Max vertex attrib: 16

LIBGL: Max texture size: 16384

LIBGL: Max Varying Vector: 32

LIBGL: Texture Units: 2/2 (hardware: 32), Max lights: 8, Max planes: 6

LIBGL: Extension GL_EXT_texture_filter_anisotropic detected and used

LIBGL: Max Anisotropic filtering: 16

LIBGL: Max Color Attachments: 1 / Draw buffers: 1

LIBGL: Hardware vendor is A-EON Technology Ltd. Written by Daniel 'Daytona675x' MьЯener @ GoldenCode.eu

LIBGL: GLSL 300 es supported

LIBGL: GLSL 310 es supported and used

I can't say 100% sure that this can be your issue, but at least, you surely will have issues with compatibility, speed, and all kind of other issues if your output is not like that i show.

— Reply to this email directly, view it on GitHub https://github.com/ptitSeb/gl4es/issues/372#issuecomment-1031667355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADWKQA3Q5LY6V3HPRCKJMTUZ7XY3ANCNFSM5NVVGLHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

-- Saluti, Andrea Palmatè

raziel- commented 2 years ago

@afxgroup

Integrating gl4es into SDL2 (without having to juggle with two different libraries) would be so much nicer to work with...I'm all for it

@ptitSeb

Thank you very much for gl4es

@kas1e

Thank you very much for the port

ptitSeb commented 2 years ago

The missing strings means many things will not be initiaized correctly yes. But I doubt it would be the root cause of the initial issue. But the initial issue is quite strange: creating an empty texture and attaching it to an FBO is correct. Maybe the FBO on GLES2 driver will not work if no depth buffer is attached? (it shouldn't, and FBO with only a texture attached is valid). Also, check the value of Format. it's safer to use GL_RGBA for a start...

afxgroup commented 2 years ago

Sad to say but with correct SDL version it works... So i'll close the issue