3
votes

I would like to know what kind of limitations can result from using GLFW and OpenGL instead of using a traditional GUI toolkit like Qt or GTK.

Of course, I know that GLFW with OpenGL don't expose the same level of functionality, but if only a few kind of widgets are needed, I think that those could be easily implemented.

The question is, is there some feature that couldn't be implemented on top of GLFW/OpenGL in contrast to Qt or GTK?

For example, I'm worried about drawing menus outside the window region (I guess that an auxiliary non-decorated window could be use in this case).

1

1 Answers

2
votes

I know that GLFW with OpenGL don't expose the same level of functionality, but if only a few kind of widgets are needed

When it comes to OpenGL, there isn't any limit per se. You can draw wherever and whatever you want. The area where you can draw is a limiting factor from the operating system's side of things.

Remember that some "simple" functionality like say a textbox, is already complicated. Not only do you have to handle rendering (and scalable text isn't always fun), but you also have to handle keyboard events. Drawing the cursor and text selection, etc.

For example, I'm worried about drawing menus outside the window region (I guess that an auxiliary non-decorated window could be use in this case).

When it comes to drawing outside the window region, this isn't directly OpenGL related. It's more a question depending on the OS.

For instance using the WinAPI, you can draw anywhere on the screen simply by doing:

#include <Windows.h>

int main(int argc, char **argv)
{
    HWND desktop = GetDesktopWindow();
    HDC dc = GetDC(desktop);

    RECT rect = { 20, 20, 200, 200 };
    HBRUSH brush = CreateSolidBrush(RGB(0, 0, 255));
    FillRect(dc, &rect, brush);

    return 0;
}

Note that the rectangle will disappear immediately when the screen redraws that area.

When you already have a window, then you can use SetWindowRgn() to change the area which your application is allowed to draw within. Note that you can't just change this area, and everything will be fine and dandy.

The question is, is there some feature that couldn't be implemented on top of GLFW/OpenGL in contrast to Qt or GTK?

Bottom line is no. There's isn't any feature you can't implement with OpenGL that is in Qt and GTK. The point is that it isn't just OpenGL, and that a lot of it depends on the operating system, thus needing OS specific code.