I am working with an existing OpenGL library which needs to be augmented with other UI functions (better keyboard input, mouse handling, etc). I was hoping to use SDL, SFML or GLFW with the existing OpenGL API to facilitate this. Using any of these frameworks, is it possible to hook UI functions from any of these frameworks into an existing window, rather than a window directly created from these frameworks?
-The existing OpenGL window is already created by the library I'm forced to use.
-I'm aware of the SDL_WINDOW_FOREIGN bit set but am not sure how this is supposed to work.
-Is there a better strategy for simply detecting mouse/keyboard input?
The SDL 2.0 function SDL_CreateWindowFrom() can set up SDL for input and rendering from a given native window.
https://wiki.libsdl.org/SDL_CreateWindowFrom
Related
I'm making an editor for 3d worlds in opengl using the windows forms UI. I'm developing on visual studio 2012 express and i would like to embed a GLFW window/context inside a windows form. just like done in this tutorial http://www.codeproject.com/Articles/16051/Creating-an-OpenGL-view-on-a-Windows-Form except working. And with GLFW for opengl context.
Is this possible? should i use Qt instead? and how would i got about doing this? I'm not bound to using windows forms i just need a simple good-looking functional UI for my project.
That are three different frameworks (Windows Forms, GLFW, Qt) which can all do the same thing, i.e. creating a window and an OpenGL context in it.
See here for an easy example how to create a window with OpenGL context with GLFW.
Or see here for the Qt example.
So, you have to choose between one of them. GLFW and Qt have the advantages that your code will also work on MacOSX and on Linux; with some work even on iPhone.
If you want to do the window creation and event handling and other stuff with GLFW but the GUI still with Qt, there is some way to do offline drawing (some ref here or here or here) the Qt widgets and then draw it onto some OpenGL texture. Or you might also be able to directly draw them via OpenGL (not exactly sure).
What I'm trying to achieve is something like this - that is, an OpenGL view contained in a standard window, alongside some buttons, menus, etc.
However, I'm trying to use non-managed C++ and WinAPI to accomplish that (project requirements), and, if possible, (free)GLUT.
However, it seems to me that the only thing possible using GLUT is to create a separate window. Am I right, or is there actually a way to pass a window handle to GLUT for rendering? Or am I completely off the track?
Yeah, as far as I am aware GLUT only lets you do full-blown windows and will not let you paint into an arbitrary rectangle. There are a number of tutorials on setting up a render context in Windows using nothing but the Win32 and WGL APIs. Once you get your context setup, you can effectively do everything the same way you would with GLUT, but use the appropriate WGL function for swapping buffers.
Here's a high-level overview of what would be involved, though it's really text-heavy and related to MFC it outlines the whole process. You should be able to lookup the appropriate WGL API reference to implement this.
There's really no point in using GLUT if you've already decided to use the Win32 API to be honest, it is going to try to hide everything from you including the message pump that you'll need to handle dialog initialization and button events. If your requirements weren't limited to Win32 API, I would suggest something a little more portable like Qt for a framework that's dialog-friendly and supports OpenGL.
I have a bare-bones Linux distro running on a machine connected to a laser. I want to develop an interface which allows me to:
Configure settings for the laser (e.g. toolbars and buttons)
Display the current path of the laser (e.g. graphics window)
Since these are bare-bones machines, I don't have X11 installed. I figured that perhaps I could use ncurses to develop a cross-platform interface to configure the settings for the laser, and use SDL to draw arcs and lines to represent the path of the laser.
While I'm comfortable using ncurses and SDL independently, I'm having trouble figuring out how to embed the SDL graphics within an ncurses window.
Is it possible to embed a graphics window (not necessarily SDL) into an ncurses application? If not, is there a cross-platform alternative to ncurses which will do what I need without X11?
The Ncurses project appears focused on developing a library for the construction of text-based user interfaces. As such, I do not believe there currently is, nor is planned to be, support for embedding an SDL graphical context.
I would suggest looking into other options such as the AGAR library which enables the creation of graphical user interfaces within SDL.
Anyone can tell me what's the relationship between SDL library and OpenGL library?
OpenGL is a graphics library that doesn't provide any feature in addition to drawing. It is neither able to embed an OpenGL view inside a window of any modern OS.
That's where SDL comes right into place and provides all the required functions needed to create an OpenGL window in a cross-platform manner in which you then draw by using OpenGL library itself. SDL also has a lot of facilities that are almost always necessary when working with games or graphical applications like timers, management of keyboard and mouse and whatever.
In any case you could use any other OpenGL wrapper like GLUT library or GLFW to achieve the same thing: creating an OpenGL view inside an application.
I was wondering what is the difference between the windows that will render images on the screen (such as SDL, SFML or OpenGL) and the classic GUI window (with the gray background by default) where you can implement buttons like in Qt for C++ or AWT/Swing in Java?
What is going on in the background code? Are they the same type? Is there a rendering layer over the graphics window allowing to display such images?
Well first of all they are different APIs. SDL and SFML are libraries directed at making games and quite possibly other applications. OpenGL is a graphics API, it is not a full suite of libraries.
Note also that SFML pretty much uses OpenGL to render to the window. The actual window its self is created via platform specific functions. The Win32 API is used for windows and the X11 Window System is generally used on Linux.
The "classic GUI window" is pretty much the platform specific APIs. The differences in background code is really just defined by the purpose of the API. Note that in the end of the line Qt/SFML/SDL all go down to the platform specific API. OpenGL even requires you to interface with the platform specific API. SFML/SDL/QT essentially do the lower level work for you.
I hope I gave what you are looking for as this question really has a wide range of answers.