Giter Club home page Giter Club logo

game-gui's Introduction

Game GUI - A Simple GUI with skin-support for OpenGL Games

License : MIT

Summary

After trying several gui's more or less suited for games (LibRocket, Qt, NVWidgets, CEgui, etc), I found that none of them was really light weight, easy to use and fully skinable at the same time. This was the reason I started to write my own GUI / C++. The project was completed in about one month.

Screenshot1

Features

  • Advanced skin scaling: define how the inner and borders of a texture shall be scaled ( simple scale, repeating inner pattern or constant outer frame )
  • UTF8 Support
  • TTF Support
  • Easy skinning support
  • Alpha support (RGBA), so you can have transparent windows/widgets etc
  • direct access to all controls and their members
  • Non-blocking visualization
  • Callback support
  • No need to mess with inheritance and virtual functions
  • Different from most GUIs, Widgets and windows are stored completely inside the GUI, so no need to define any window or widget variables in your code.
  • Directory: Controls are stored and accessed by a tree structure that is rendered every time like a scene graph
  • No event loop, show function or update function
  • No need to have a timer that calls an update function
  • Lightweight: Only Depends on GL and libFreetype and DevIL
  • Can easily be used in SDL, Qt and other environments. Just plug in the keyboard and mouse events and call the gui's draw function from your main render loop.
  • Config file support for default variables (font,padding etc) and skin textures+scaling parameters
  • Only 2000 lines of code for the entire Gui class including all widgets. Therefore easy to modify and extend.
  • Comes with a simple file-browser (See screenshot1)
  • MIT license
  • Multi-screen support (same as multiple Desktops). You can have a title screen, loading screen, ingame screen etc. Simply create them at the beginning and the switch between by setting gui.active_screen=number;
  • Window manager
  • Context menu
  • Custom mouse pointer
  • Widget Classes : Window, Menu, Label, Button, CheckBox, Tab, Combo, Textedit, Radio
  • Controls have support for custom user variables like control.var.string["myvar"]="hello"

Most important is the access by the directory structure and using simple assigns '=' to create a new instance of a widget or window.

The usage is basically as follows:

Create (and instantly show) a window:

gui.window["id1"]=Gui::Window("Title",100,100,250,350);

Adding a button :

gui.window["id1"].button["load"] = Gui::Button("Load",20,20,50,30); 

Adding a simple callback

gui.window["id1"].button["load"].callback_pressed=
    [](Gui::Window *window,Gui::Button* control,int index)
    {
        window->close();
    };

Setting a custom skin:

gui.window["id1"].button["load"].skin=Skin("normal.png","hover.png","pressed.png");

Also you have direct access to a skin's texture to use it as output of a FBO e.g. The 3D viewer of the screenshot below uses that.

gui.window["id1"].button["load"].skin.texture_normal=fbo.texture_id;

Duplicating a window is easy: The duplicate is instantaneously visible (works also for controls)

gui.window["id2"] = gui.window["id1"]

The GUI is not fully optimized, yet you have like 700 fps with 20 simple windows on the screen on a notebook PC. Controls are stored in a std vector as share ptr. For rendering, it is not necessary to evaluate the string keys.

Mathlib included from http://sourceforge.net/projects/nebuladevice/

(C) by Sven Forstmann in 2015

Screenshot1
Screenshot2

Screenshot3

game-gui's People

Contributors

sp4cerat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

game-gui's Issues

relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object

Hi. i'm on void linux and try to compile your SDL_gui/tests/0100_GUI_App sample via cmake. first create makefiles via: cmake ., and then make:

╰ make
Scanning dependencies of target app
[  2%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/tests/0100_GUI_App/src/main.cpp.o
[  5%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_ttf_HarfBuzz/SDL_ttf.cpp.o
[  8%] Building C object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gfx/SDL2_gfxPrimitives.c.o
[ 11%] Building C object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gfx/SDL2_rotozoom.c.o
[ 14%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/SDL_gui.cpp.o
[ 17%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Utils.cpp.o
[ 20%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_shapes.cpp.o
[ 23%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_View.cpp.o
[ 26%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_ImageView.cpp.o
[ 29%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_image.cpp.o
[ 32%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_TextView.cpp.o
[ 35%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Fonts.cpp.o
[ 38%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_IconView.cpp.o
[ 41%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Label.cpp.o
[ 44%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Button.cpp.o
[ 47%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_CheckBox.cpp.o
[ 50%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_RadioButton.cpp.o
[ 52%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_RadioButtonGroup.cpp.o
[ 55%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_List.cpp.o
[ 58%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_ScrollView.cpp.o
[ 61%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_EditText.cpp.o
[ 64%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_TextUtil.cpp.o
[ 67%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_App.cpp.o
[ 70%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_TopBar.cpp.o
[ 73%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_StatusBar.cpp.o
[ 76%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Menu.cpp.o
[ 79%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_MenuBar.cpp.o
[ 82%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_PopupView.cpp.o
[ 85%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_MessageBox.cpp.o
[ 88%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Switch.cpp.o
[ 91%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_ComboBox.cpp.o
[ 94%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Slider.cpp.o
[ 97%] Building CXX object CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gui/GUI_Config.cpp.o
[100%] Linking CXX executable app
/bin/ld: CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gfx/SDL2_gfxPrimitives.c.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/bin/ld: CMakeFiles/app.dir/home/linarcx/Temp/SDL_gui/SDL2_gfx/SDL2_rotozoom.c.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/app.dir/build.make:569: app] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/app.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Current Status

What's the status of the framework? Is there a plan to keep working on it?

I spent quite a bit of time to get it working on Windows 10 and I can report the following:

  1. You need Visual Studio 2012 Express Edition to compile the code.
  2. Visual C++ Redistributable 2012 needs to be installed (all those missing DLL files); VS 2013 redistributable might be necessary as well.
  3. It does not work on Hyper-V VM with windows 10 installed. I don't think it is an issue, because it uses video card and Hyper-V might not expose one. (I did not want to mess with RemoteFX)
  4. On VS 2017 community edition it compiles source files, but it does NOT link. I think it has to deal with lib files included and built against an older VS version. Newer version does not have some internal objects.

How does it compare to https://blogs.gnome.org/clutter/ ? If one was to add widgets to cluter, what would be the difference? I am mostly interested to compare ease of use from a "business" level application perspective, not a game.

I think all in all it is a very nice library. Very easy to follow even if I my OpenGL background is very weak.

Thanks

Problem with extend_rect

Hello - I have a problem with a code of extend_rect method, I think: it causes second and third Radio to be drawn very large. I have changed the code as below:
void extend_rect(Rect &r)
{
r.sx = std::max(r.sx, /_x + */sx);
r.sy = std::max(r.sy, /_y + */sy);
}
and it is now ok, but I wondering how does it worked before?

Regards
Pawel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.