Creating a simple window with simple controls in c++ and OpenGL - c++

How do i just create a window with just some controls like menus , check button , radio button , scroll bar ..just with c++ and OpenGL?

It depends.
1) You can't use any external libraries.
In this case you would need to create whole framework for creating controls, handling events, hit tests, state changes... Shortly speaking, you would need to write a GUI library like Qt or wxWidgets, but with all controls drawing implemented in OpenGL.
2) You can use 3rd party libs.
Well, simply read the spec and use them. Examples:
GiGi
GLUI
Also, you may want to read this: OpenGL Forum
However, if you don't have to use OpenGL-based solution, I would suggest you use wxWidgets. I've been using it for years. It's my favourite cross-platform GUI library with solid support, quite big community and reliable, up-to-date online/offline documentation.

Related

How to get started on custom GUI widgets

I would like to exercise programming software with non-standard graphical interfaces such as the ones in the following images. I know how to create a GUI using basic widgets, but I have no idea on how to create my own custom widgets. I am familiar with GTK 3.0 and Qt. The GTK tutorial, for instance, has a link on how to do custom drawing. I just don't know if this is the usual and correct way to create custom widgets. There's also things such as: selections, mouse handling, zoom, scrolling, animations and so on that tutorials do not teach.
So here is my question: what kind of documentation, keywords, tutorials and algorithms should I look for? For my first project, I would like to start with something similar to the first and second images below. My current knowledge is C/C++ and Qt and GTK, but I can learn new languages and tools if necessary.
http://hobby-electrons.sourceforge.net/tutorials/gEDA/simple-schematic-in-gschem.png
http://www.cburch.com/logisim/docs/2.7/pt/html/images/screen-shot.png
http://eeweb.poly.edu/labs/nanovlsi/tutorials/soctutorials/figures/ENCFinalDesign.gif
http://www.ccm.ece.vt.edu:8088/etextiles/projects/arch_images/simulation.jpg
http://j-algo.binaervarianz.de/images/avl_avltest.png
The Qt Graphics view Framework is what you should use if you go with Qt. There are several examples covering the basics of creating components.
To be able to mimic those samples, most of the work is going to be on implementing custom graphic view items. Like widgets it means providing a paint method, specialized event handlers and properties.

How to create custom skin like WinAmp

I guess this question has been ask before, but I have not found sufficient answer to even start poking around. Most answer refers to catching WM_PAINT method directly and do custom rendering, or use a onwer draw object. However, I did not see a centralized place that has the info. to start researching. Hence, the question.
My goal is to create a very simple GUI program with custom look into it. I prefer the way winamp does their custom look that is customizable through "skins". However, I am not interested in using some cross-platform library like GTK+, QT or wxWidget.
I have some experience in system programming, but not much for GUI. I spent most of my time developing console applications, and I just started doing some QT development. If you can point me in the right direction, I'd be very appreciated.
PS: I am interested in both windows and linux environment.
Everybody,
Sorry for the late reply. I had a chance to have a quick talk with the original developer for winamp, and this is the quick answers I have:
Using skins: Artists create skins, developer will render the skins
To the OS (Windows), winamp is just one pretty box, nothing else. There is a container windows, and that's about it
All controls (button, label, list, etc) are implemented by winamp team themselves. All messages and stuffs are passed as relative position to the container window. WinAmp and the GUI engine has to decide if a button is clicked or if the label next to it is the target, etc.
Rendering artists skins created in XML
I do not have the details on if they use any libraries to do all that, but I am suspecting they do hook a window call directly, and do custom rendering themselves.
GUI skin usually using plug-in mechanism
I guess this is exactly what you are looking for:
https://www.linux.com/learn/tutorials/428800:weekend-project-creating-qt-interfaces-with-gimp?utm_medium=twitter&utm_source=twitterfeed
I also interested in creating custom look of window and widgets.
Speaking about widgets it's not hard, just need to create subclass (if you are using C++) or some widget and implement some methods like draw, handle etc. But this solution is good only if you use some high-level library like GTK, QT, etc. If you want to implement all controls by your own, you may get any graphics library, which can create window and do any graphics inside. For example, SDL2 + Cairo. SDL2 for creating window, Cairo for vector rendering controls/widgets. Both of this libraries are for win and linux. Another option is take opengl/vulkan + some lib for rendering window. It could be SDL2, SFML, GLFW.
If you really interested how it works on low level, then search Windows API for Windows and XLib or XCB for Linux/X.Org.
Speaking about window, I still investigate it. However I have one thought: you may create an empty window and then draw whatever you want. Then you need to add handlers for resizing window on the borders. But I am not sure if it's good solution, and if it won't freezes.

Common game controls/ User interface libraries or source code?

Sorry for the ackward title, but i don't know what to call it exactly. I'm looking for code or libraries that allow easy creation of commonly used user input devices, and code/libs that make gaming controls easy to set up (i'm using SFML and Box2D at the moment)
I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items such as "controls settings" or even being able to drag objects around with the mouse.
More specifically i want source code for interfaces that....
Makes Buttons and Textboxes easy to create
allows mouse input to press buttons or drag objects in games
has "Focuses" (like a textbox being able to gain focus and be typed in)
Is compatable with SFML/Box2D
and code for common game mechanics/controls that....
Allows easy setup of controls for a game
Makes events like clicking and holding on an object easy to setup, as so objects can be dragged around afterward
Are there any simple libraries or resources out there that i can use to avoid spending much of my time coding these now standard input devices/tecniques?
I think CEGUI is the type of thing you are looking for:
http://www.cegui.org.uk/wiki/index.php/Main_Page
It is a GUI framework to work with OpenGL. Some others can be found in this list.
Still, if I were you, I would just use a major toolkit, such as GTK, Qt, or wxWidgets combined with SFML instead of dealing with CEGUI.
SFML has guides for Qt and wxWidgets with the rest of them at http://www.sfml-dev.org/tutorials/1.6/.
I have created my own little guide for GTK here: http://lalaland.github.com/gtkGuide.html

Gui library for game

I'm making a game with OpenGL render api. Now I need in level editor. It should consist of lots of widgets parents/children etc, so it's hard to write need widgets by hands.
Any ideas about good gui-system which can be easilly connected with opengl? The most important part is gui editing. I really need some editing-tool for it.
Thanks
You should have a look to http://qt.nokia.com/ .
It is very easy to inject the OpenGL rendering into Qt widgets.
To easily edit your GUI, you can use Qt Creator ( http://qt.nokia.com/products/developer-tools ).
You have several options (and this has been answered before, but probably not exactly like this):
SDL: very good abstraction layer for audio, graphics and anything related. It will force you to write your widget stuff by hand.
Qt: has an OpenGL module that makes it easy to set up an OpenGL context. It will make widgets and everything very easy.
wxWidgets: same as Qt, but has slightly worse documentation and tools (if I might be so blunt)
I'd go with number two: it has a beautiful Designer tool to create Widgets with all the fancyness you'll need. OpenGL is also built right in.
If you're running Windows (can't confirm Mono will do it), another option would be to use C# and WinForms to make your life significantly easier.
Check out CEGUI:
http://www.cegui.org.uk/wiki/index.php/Main_Page
It defines its GUIs in XML and has editors for it.

C++ OpenGL Window Kit

Besides Qt, GTK, wxWidgets... What are the recommendations for a cross platform, open source GUI framework library that works with OpenGL?
Its not quite a GUI framework. But GLFW is good for an OpenGL window with some extra features like keyboard and joystick handling.
I found the other framework I was looking for. It is SFML. I only used it briefly but I do remember liking it very much. It does contain a lot of nice extras going a step further than GLFW. If I recall correctly the documentation was stellar.
For a full featured cross-platform GUI framework I think you would be hard pressed to beat QT, GTK, or wx.
I'm not sure, but at a guess, the other framework mfperzel was trying to think of might have been fltk (the "fast light tool kit"). Where glfw is mostly an OpenGL window with some ability to read the mouse and keyboard, fltk is a GUI framework that supports OpenGL (but as the name implies it's still quite a bit smaller and faster than most GUI frameworks). I haven't tried it yet, but there's a new GUI builder program for it (FLUID) that looks fairly promising as well. One warning though: FLTK uses its own widgets, which tend to look at least a little foreign to most users.