I have a problem: I working on a simple game and want to use some GUI (think of simple input for player name, etc). I've googled a lot of GUIs that can be used with SDL, but:
Most of them are using OpenGL while I'm using SDL2 render system. Docs say I can't mix these two, so I need to render GUI in a separate window. I know I can make it borderless and always-on-top, but I still need to manage this as a separate window (e.g. if main window moves, I need to move the gui window, etc, basically, I need to implement the childing myself). That makes me sad.
Those few which are using SDL as render (without OpenGL) either abandoned / unfinished / can't be compiled / etc or I can't figure out how to mix them with my rendering.
What I want to achieve: to render GUI in some place on the screen (think of a sidebar) and game stuff on the rest of the screen. Like:
SDL_Window* w = ...;
SDL_Renderer * r = ...;
while(running)
{
renderGui(r, 0, 0, 100, 100); // Minimap located at 0,0 of size 100
renderGameScreen(r, 100, 100, 100, 100); // Rest of the game located at 100, 100
}
Is there a way to do that? How GUI supposed to be used in alongside the SDL? May be my design is broken.
Sorry, I'm completely novice and may mix the things. Thanks.
Update:
Thanks for your answers. Quick update: I've tried so far:
nanogui-sdl - it uses opengl context, I was not able to mix it with SDL 2d render: it either flickers (because opengl and sdl fight for the screen and over-drawing the contents) or just draws the either thing: ui or game screen. Moreover, it crashes on some controls (like color-picker) and significantly affects rendering time (it drops 2-3 times when I add nanogui rendering with a couple of basic widgets)
nuklear - the same thing as with nanogui
I was not able to compile ToT KiWi - there are some syntax error (like
#elsif
instead of#else if
or#elif
so I'm not ever sure it can be compiled at all).
I'm going to try: imgui, kiss and gwen (gwork).
In the end, I can switch my drawing to opengl (fortunately I need some basic primitives, like circles, rectangles, triangles, etc, nothing complex) if I can't find a UI to work with SDL 2d render.
Update 2:
Sorry for not selecting the answer - was very busy during the week. I marked answer as accepted. I also tried to upvote both answers, since they are both useful, but I don't have enough reputation to do that. Thanks.
For those who wondering is I solve the problem: yes, kind of. I've switched over to SFML. I really like SDL and know it's very stable and mature, but I really need basic graphics for my pet project, so I'm OK with SFML too. It makes working with OpenGL a bit easier, so I can adopt the GUI library.