• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Jan Wassenberg

Wonderfully simple OpenGL UI

3 posts in this topic

Here's a brief writeup of a simple (9 KLOC, 340 KB binary) but capable and portable OpenGL GUI:

http://wassenberg.dreamhosters.com/blog/2014-05-17/wonderfully-simple-gui/

 

Obligatory screenshot: [attachment=21585:ui.png]

 

Header files are attached: [attachment=21584:ui_headers.zip]

 

I'd love to get a discussion going on any perceived shortcomings of this approach, missing features,

alternative libraries that didn't show up in my search, and your thoughts in general.

2

Share this post


Link to post
Share on other sites

Well where are the cpp files that implement all of the features with just the interface there isn't much to discuss to be honest. Also this will only work for 2d UI, what about 3d UI like this: http://www.youtube.com/watch?v=T2l49GtptdU

 

What about controller input?

 

How is the UI constructed, from code, other filed, can I override how a button is drawn easily or which shader is being used to render with?

Edited by NightCreature83
1

Share this post


Link to post
Share on other sites

Let's see how far we can get talking about the interface :)

Ooh, that's a pretty one. Looks like three different modes - main menu as extruded 3d text, then the oblique view, then the white 2d one for actually entering text. It's easy enough to get something like the second one by rendering the UI output to texture and incorporating that into some other scene. I'm more interested in `serious' apps that don't need fancy presentation, though.

Controller button input is easily supported by calling Interaction::OnKeyDown with a real or fake corresponding SDL key code.

"other filed"? You mean whether any data files are necessary? The font renderer has a binary blob that's bundled with the executable (on Linux, it'd be a standalone file), same for the shaders.

If you want ALL buttons to look different, that's an easy change in Painter::DrawButton and Layout::ButtonSize (if you're also changing the default size). This is probably debatable, but I prefer separating size, presentation and control logic. What's the use case for switching shaders?

Here's the code that drives the demo UI. It's simple enough that auto-generation of code is not necessary :D
Note the standard IMGUI if (Button()) { it_was_clicked; } pattern.

static void DoUI(Interaction& p_Interaction, Canvas& p_Canvas, TextPainter& p_TextPainter)
{
    Layout layout(p_Interaction.windowSize);
    Painter painter(p_Canvas, p_TextPainter);
    UI ui(p_Interaction, layout, painter, p_TextPainter);

    layout.BeginGroup(GROUP_LEFT_DOWNWARDS);

    static bool showOptions = true;
    ui.CheckBox(L"Show options", showOptions);
    if (showOptions)
    {
        layout.BeginGroup(GROUP_TOP_RIGHTWARDS | GROUP_NO_MARGIN);

        static bool enableBlending = true;
        ui.CheckBox(L"Enable blending", enableBlending);
        if (enableBlending)
        {
            static float value = 4.0f;
            ui.Slider(1.0f, 16.0f, value);
        }

        layout.EndGroup();

        std::vector<UString> labels;
        labels.push_back(L"YCoCg-DXT5");
        labels.push_back(L"DXT1");
        labels.push_back(L"RGBA");

        static int listSelected = 0;
        ui.ListBox(&labels[0], labels.size(), listSelected);

        layout.BeginGroup(GROUP_TOP_RIGHTWARDS);

        ui.Label(L"Format");
        static int formatIdx;
        ui.ComboBox(&labels[0], labels.size(), formatIdx);

        layout.EndGroup();
    }

    layout.EndGroup();

    if (showOptions)
    {
        layout.BeginGroup(GROUP_RIGHT_DOWNWARDS);

        static bool panelUnfold = true;
        if (ui.BeginPanel(L"Panel", panelUnfold, GROUP_DEFAULT))
        {
            static int selected;
            ui.RadioButton(L"Radio1", 0, selected);
            ui.RadioButton(L"Radio2", 1, selected);
            static bool checked1, checked2; 
            ui.CheckBox(L"Check1", checked1);
            ui.CheckBox(L"Check2", checked2);

            ui.EndPanel();
        }

        if (ui.Button(L"Do things"))
        {
            SDL_Log("clicked\n");
        }

        static UString buf(L"edit box");
        ui.LineEdit(buf);

        layout.EndGroup();
    }

    p_Canvas.Draw();
}
0

Share this post


Link to post
Share on other sites

Minor rendering update per feedback received (thanks!)..

Radio button+slider larger, more corner rounding, different accent color.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0