glCapabilities and other stuff

Started by jakethesnake, May 26, 2016, 15:01:34

Previous topic - Next topic

jakethesnake

Hi.

I'm getting ready to test my lwjgl on different hardware and software and I'd like to print helpful information to the user to help debugging the actual rendering. So far I'm printing the basics (the insert code button ain't working, sorry...):

   GlHelper(int viewPortWidth, int viewPortHeight){
       GL.createCapabilities();
         

       glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            
       glEnable(GL_BLEND);
       setBlendNormal();
       glDisable(GL_DEPTH_TEST);
       glDepthMask(false);
       glEnable(GL_STENCIL_TEST);
            //glEnable(GL_CULL_FACE);
       glClearStencil(~0);
       setViewPort(viewPortWidth, viewPortHeight);
       checkErrors();
       System.out.println("OPEN_GL");
       System.out.println("---FB stencil Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE));
       System.out.println("---FB depth Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE));
       System.out.println("---FB Red Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE));
       System.out.println("---FB Green Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE));
       System.out.println("---FB Blue Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE));
       System.out.println("---FB Alpha Bits: " + glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE));
       System.out.println("---OpenGL Version: " + glGetString(GL_VERSION));
       System.out.println("---glRenderer: " + glGetString(GL_VENDOR) + ", " + glGetString(GL_RENDERER));

       System.out.println("---Supported Shader Attributes: " + glGetInteger(GL_MAX_VERTEX_ATTRIBS));
       System.out.println("---Supported Shader Uniforms: " + glGetInteger(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS));
       System.out.println();
       GLCapabilities c = GL.getCapabilities();
       if (!c.GL_ARB_shader_objects && c.GL_ARB_vertex_shader && c.GL_ARB_fragment_shader)
          throw new IllegalStateException("shaders arent Supported. Get 'modern' computer!");
       checkErrors();
   }

But this ins't enough for me and I don't think I cover it all. I'd like more useful information, but don't know which to choose. There's a lot of stuff in GLCapabilities I've noticed, but I don't really know which to pick, nor what they all indicate. I'm assuming the prefix of them are different GPU vendors? It's a shame I can't iterate through all of these Booleans and print all of them.

My question, or proposed discussion is: what are your standard opengl-init checks? What are your tips?


jakethesnake

Yes, sure it helped! Most of it I already knew, but there was some new. I researched my topic last night and couldn't find much. It seems most people check the above link, and perhaps compare the gl-version and glsl-version to see if it matches what they intended. I'm just curious to know if I can use the GlCapabilities to do something a bit more thorough, and I'd like to learn more about its fields.

th3barri3

Honestly I haven't done much with it but what is in the link I posted before.

Only other place to look for more information would be the source code (https://github.com/LWJGL/lwjgl3-generated/blob/master/java/org/lwjgl/opengl/GLCapabilities.java)

spasi

A GLCapabilities instance has two groups of state:

- A boolean flag for each OpenGL core version and OpenGL extension supported by LWJGL. These flags are basically a "cache" of the GL_VERSION and GL_EXTENSION strings, a more convenient way to access the context capabilities programmatically.

- A long pointer for each OpenGL function supported by LWJGL. These are used internally by LWJGL, but they're exposed like that for (advanced) users that want to call OpenGL functions in a way not supported by LWJGL. They can also be used in performance-sensitive situations where the thread-local lookup (that happens in every OpenGL call) has a measurable performance impact.

The way GLCapabilities is supposed to be used:

- An application usually has a minimum required OpenGL version. If the OpenGL context does not support that version -> exit with error.
- For all functionality exposed up to the minimum required OpenGL version, you just use it. You don't have to check the GLCapabilities instance.
- For optional features, or in situations where you have two or more code paths (e.g. on for AMD, another for Nvidia), you use the GLCapabilities instance to know which implementation should be used. Example: GLUtil.setupDebugMessageCallback, GLCapabilities is used to choose one of the debug output extensions (OpenGL43, KHR_debug, ARB_debug_output, AMD_debug_output).

jakethesnake