Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

If you have any questions, reports, suggestions, or requests about Live2D, please send them to this forum.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
 
Live2D Cubism
Cubism Products and Downloads
Cubism product manuals and tutorials
Cubism Editor Manual    Cubism Editor Tutorial    Cubism SDK Manual    Cubism SDK Tutorial
[Notice of Holidays]
Please note that our staff will not be available from 2024/Dec/28 - 2025/Jan/5 JST.
The Live2D Creators Forum will remain open during the holidays.
Submissions that require a response will be answered after we reopen for business.
Please note that it will take longer than usual to respond to your request.

Is that possible to use Glad instead of Glew ? (C++/OpenGL)

Hi people !

I try to add Cubism 4 R4 to my C++/OpenGL project.
I already use Glad, so I would like to use Cubism Core and Cubism Framework with Glad instead of Glew.

Must I rewrite Framework with Glad or is there another way to switch the lib to Glad ?
Is Core compatible with Glad or is that an obligation to use Glew ?

Thank you for reading me ~

Comments

  • edited August 2022
    Okay, so this night I tried to modify the Native SDK Sample Demo for OpenGL (with CSM_TARGET_WIN_GL i.e. for Windows) and it works, but there are some things I don't understand and I'm afraid it will cause problems later. I am a beginner in OpenGL so maybe my questions are stupid.

    Here what I do to switch the OpenGL Demo sample from Glew to Glad :


    1) Delete glew folder and add glad one in the project include directory.
    2) Replace each #include <GL/glew.h> by #include <glad/glad.h> in Framework and
    Demo project.
    3) Write #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE in CubismRenderer_OpenGLES2.cpp. ( Normally this should be defined in glad.h but I don't know which extension to check in https://glad.dav1d.de to add it to the loader)
    4) In CubismRenderer_OpenGLES2.cpp I remove a part of the GL functions in InitializeGLFunction() Because some macros that begins with PFNGL wasn't found. Here below all the lines I deleted :
     glGenFramebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC)WinGlGetProcAddress("glGenFramebuffers");
        glGenRenderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC)WinGlGetProcAddress("glGenRenderbuffers");
        glBindFramebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC)WinGlGetProcAddress("glBindFramebuffer");
        glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)WinGlGetProcAddress("glFramebufferTexture2D");
        glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC)WinGlGetProcAddress("glDeleteFramebuffers");
        glBindRenderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC)WinGlGetProcAddress("glBindRenderbuffer");
        glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC)WinGlGetProcAddress("glDeleteRenderbuffers");
    
        glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEEXTPROC)WinGlGetProcAddress("glRenderbufferStorage");
        glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)WinGlGetProcAddress("glFramebufferRenderbuffer");
        glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)WinGlGetProcAddress("glCheckFramebufferStatus");


    My questions and worries :


    A ) Why the function InitializeGlFunctions() is needed ? Isn't that the job of Glew or Glad to load and initialize the OpenGL function ?

    B ) Are PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC and other macros I deleted define by Glew, by Windows or by the GPU driver ? What happend if I don't intialize them with WinGlGetProcAddress("gl_function_name") ?

    C ) What are the extension I need to add to glad on the loader website to get GL_TEXTURE_MAX_ANISOTROPY_EXT ? Is That the another name for ARB_texture_filter_anisotropic ?

    Thank you for reading me !
  • @KrankerApfel_
    Thank you for your continued use of our product.

    Since we do not know the specifications of GLAD, please contact GLAD officials or developers for more information.

    A ) Why the function InitializeGlFunctions() is needed ? Isn't that the job of Glew or Glad to load and initialize the OpenGL function ?
    This is necessary because it specifies the setting values during initialization.

    B ) Are PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC and other macros I deleted define by Glew, by Windows or by the GPU driver ? What happend if I don't intialize them with WinGlGetProcAddress("gl_function_name") ?
    In GLEW, macros such as PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC are defined in glew.h.
    If not initialized with WinGlGetProcAddress, the rendering process may fail.
    https://docs.microsoft.com/ja-jp/windows/win32/api/wingdi/nf-wingdi-wglgetprocaddress
    GLAD requires that you prepare the appropriate loader yourself.

    C ) What are the extension I need to add to glad on the loader website to get GL_TEXTURE_MAX_ANISOTROPY_EXT ? Is That the another name for ARB_texture_filter_anisotropic ?
    I think it is possible to use it by adding ARB_texture_filter_anisotropic, but please check the glad.c generated by you for details.

    hope that helps!
    Live2D Cubism Support
Sign In or Register to comment.