skip to Main Content

I want to get a GLFW window’s pixel format. I’m using ubuntu so win32 functions are out of the picture. I’ve stumbled upon this question but there are only win32 answers and there is an answer that uses HDC and PIXELFORMATDESCRIPTOR which I don’t have access to (Since I will not be using the function permanently I rather not install a new library for this.)

I want to get the format in the form of YUV420P or RGB24.

2

Answers


  1. That is outside the scope of GLFW as can be read here:

    Framebuffer related attributes

    GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer attached to the window) as these can be queried directly with either OpenGL, OpenGL ES or Vulkan.

    If you are using version 3.0 or later of OpenGL or OpenGL ES, the glGetFramebufferAttachmentParameteriv function can be used to retrieve the number of bits for the red, green, blue, alpha, depth and stencil buffer channels. Otherwise, the glGetIntegerv function can be used.

    Hint:

    Don’t rely on (if you’ve created the window with the videomode of the specified monitor and didn’t tinkered with framebuffers):

    GLFWvidmode *vid_mode = glfwGetVideoMode(glfwGetWindowMonitor(win));
    vid_mode->redBits;
    vid_mode->greenBits;
    vid_mode->blueBits;
    

    because in glfwCreateWindow we read the following:

    The created window, framebuffer and context may differ from what you requested, as not all parameters and hints are hard constraints. This includes the size of the window, especially for full screen windows. To query the actual attributes of the created window, framebuffer and context, see glfwGetWindowAttrib, glfwGetWindowSize and glfwGetFramebufferSize.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search