Class ImGuiImplGl3

java.lang.Object
de.luckymcdev.foundryengine.client.imgui.backend.ImGuiImplGl3

@Internal public class ImGuiImplGl3 extends Object
This class is a straightforward port of the imgui_impl_opengl3.cpp.

It does support a backup and restoring of the GL state in the same way the original Dear ImGui code does. Some of the very specific OpenGL variables may be ignored here, yet you can copy-paste this class in your codebase and modify the rendering routine in the way you'd like.

This implementation has an ability to use a GLSL version provided during the initialization. Please read the documentation for the init(String).

  • Field Details

    • OS

      protected static final String OS
    • IS_APPLE

      protected static final boolean IS_APPLE
    • data

      protected ImGuiImplGl3.Data data
  • Constructor Details

    • ImGuiImplGl3

      public ImGuiImplGl3()
  • Method Details

    • newData

      protected ImGuiImplGl3.Data newData()
    • init

      public boolean init()
      Method to do an initialization of the ImGuiImplGl3 state. It SHOULD be called before calling of the renderDrawData(ImDrawData) method.

      Unlike in the init(String) method, here the glslVersion argument is omitted. Thus, a "#version 130" string will be used instead.

      Returns:
      true when initialized
    • init

      public boolean init(String glslVersion)
      Method to do an initialization of the ImGuiImplGl3 state. It SHOULD be called before calling of the renderDrawData(ImDrawData) method.

      Method takes an argument, which should be a valid GLSL string with the version to use.

      ----------------------------------------
      OpenGL    GLSL      GLSL
      version   version   string
      ---------------------------------------
       2.0       110       "#version 110"
       2.1       120       "#version 120"
       3.0       130       "#version 130"
       3.1       140       "#version 140"
       3.2       150       "#version 150"
       3.3       330       "#version 330 core"
       4.0       400       "#version 400 core"
       4.1       410       "#version 410 core"
       4.2       420       "#version 410 core"
       4.3       430       "#version 430 core"
       ES 3.0    300       "#version 300 es"   = WebGL 2.0
      ---------------------------------------
      

      If the argument is null, then a "#version 130" (150 for APPLE) string will be used by default.

      Parameters:
      glslVersion - string with the version of the GLSL
      Returns:
      true when initialized
    • shutdown

      public void shutdown()
    • newFrame

      public void newFrame()
    • setupRenderState

      protected void setupRenderState(imgui.ImDrawData drawData, int fbWidth, int fbHeight, int gVertexArrayObject)
    • renderDrawData

      public void renderDrawData(imgui.ImDrawData drawData)
      OpenGL3 Render function. Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. This is in order to be able to run within an OpenGL engine that doesn't do so.
      Parameters:
      drawData - draw data to render
    • createFontsTexture

      public boolean createFontsTexture()
    • destroyFontsTexture

      public void destroyFontsTexture()
    • checkShader

      protected boolean checkShader(int handle, String desc)
    • checkProgram

      protected boolean checkProgram(int handle, String desc)
    • parseGlslVersionString

      protected int parseGlslVersionString(String glslVersion)
    • createDeviceObjects

      protected boolean createDeviceObjects()
    • destroyDeviceObjects

      public void destroyDeviceObjects()
    • initPlatformInterface

      protected void initPlatformInterface()
    • shutdownPlatformInterface

      protected void shutdownPlatformInterface()
    • vertexShaderGlsl120

      protected String vertexShaderGlsl120()
    • vertexShaderGlsl130

      protected String vertexShaderGlsl130()
    • vertexShaderGlsl410Core

      protected String vertexShaderGlsl410Core()
    • fragmentShaderGlsl120

      protected String fragmentShaderGlsl120()
    • fragmentShaderGlsl130

      protected String fragmentShaderGlsl130()
    • fragmentShaderGlsl300es

      protected String fragmentShaderGlsl300es()
    • fragmentShaderGlsl410Core

      protected String fragmentShaderGlsl410Core()