PDA

View Full Version : OpenGL3 Toolkits, C++ and a problem



_ShaderRookie_
07-04-2011, 05:48 PM
I tried SFML first. It can create an OpenGL3 Context, but uses deprecated functions all over the place. Cannot create a core profile.

I tried SDL 1.3. Needs DirectX SDK to be installed for building.
Unnecessary dependency >_>.

Tried GLUT/GLFW:
Thats what I need.
Problem:
The C-Callbacks do not accept user-pointers. So I cannot pass a this-pointer and would end up in using a singleton for my window, which I do not want.

So, what to do?
I am currently implementing myself a solution, but I only know WinAPI and that one not very good to be honest. It works though, but I have to do a lot of research to get some things working like special keys like alt and ctrl. I just never messed around with WinAPI. After that, I have to learn how X works to port it to Linux too since normally my app is/was XPlattform.

I would really be happy if GLUT gets updated to work better with C++.
Not a rant, just trying to voice my opinion.
Tell me yours!
Thanks :).
regards

Alfonse Reinheart
07-04-2011, 06:03 PM
I tried SFML first. It can create an OpenGL3 Context, but uses deprecated functions all over the place. Cannot create a core profile.

Then don't. Just because you create a compatibility context doesn't mean you have to use non-core stuff. Just use an OpenGL header that only has core stuff in it.


I tried SDL 1.3. Needs DirectX SDK to be installed for building.
Unnecessary dependency >_>.

... what's unnecessary about that? How do you think it's going to get input, sound, and other non-graphics stuff without D3D? SDL is not an "OpenGL window creation toolkit"; it's a cross-platform DirectX substitute.

I suggest you suck it up and install DirectX.


The C-Callbacks do not accept user-pointers. So I cannot pass a this-pointer and would end up in using a singleton for my window, which I do not want.

This you can do with some trickery. Well, for FreeGLUT; I don't know enough about GLFW to know.

You can retrieve a number that represents the current window by calling glutGetWindow. You can then make a global std::map that maps between these window IDs and pointers to your class.


I would really be happy if GLUT gets updated to work better with C++.

GLUT isn't being updated, ever. FreeGLUT is a different matter, but I doubt they'll change anything, since multi-window FreeGLUT apps are pretty rare. And it could affect backwards compatibility.

It should be noted that GLFW is primarily intended for games and that sort of thing, not applications that might need multiple windows. So it's more of a design choice.

_ShaderRookie_
07-04-2011, 06:35 PM
I cannot take DirectX as a dependency. Sorry. I am developing something that maybe gets spreaded around (Open Source) and people want to build it themselves, so I really cannot have DirectX as an additional dependency. And Microsoft discourages the use of DirectInput btw.

That put aside, there is no window toolkit for C++.
Thats what I wanted to express. Please do not feel offended.


Just use an OpenGL header that only has core stuff in it.
I use gl3h :).

Alfonse Reinheart
07-04-2011, 08:18 PM
Sorry. I am developing something that maybe gets spreaded around (Open Source) and people want to build it themselves, so I really cannot have DirectX as an additional dependency

SDL is something that gets "spreaded around (Open Source) and people want to build it themselves". It's not like it requires D3D on Linux or something...


That put aside, there is no window toolkit for C++.

There are no good XML parsers that are written for C++ too, but that never stopped me from using LibXML2. One of C++'s greatest strengths is that it can interface almost natively with C code. Use that strength.

Surely if Python users can use GLUT, so can C++ users.


Thats what I wanted to express.

And all I'm saying is that you can either:

1: complain about it.

2: work around the issues you have (as I suggested).

3: write your own.

#1 is the least useful option.

_arts_
07-05-2011, 02:24 AM
Are you really sure SDL on Windows needs directx ? It looks strange for me. I was almost sure they use low-level WIN32 API. But maybe I'm wrong.

The best way is to develop all yourself, on windows using win32 api, on linux using X11 api... This is not very hard as long as you don't need GUI or so. If so, have a look at gtkglext (which I use for GL GUI) or at qt.

Zyx_2000
07-05-2011, 03:33 AM
The version of GLFW under development (3.0) is accepting user-pointers passed to callbacks. Since it is still under development, it might however be unstable.

_ShaderRookie_
07-06-2011, 05:29 PM
The version of GLFW under development (3.0) is accepting user-pointers passed to callbacks. Since it is still under development, it might however be unstable.

Thats awesome to hear :). Thanks for the information.


Are you really sure SDL on Windows needs directx ? It looks strange for me. I was almost sure they use low-level WIN32 API. But maybe I'm wrong.

They use it for the joystick afaik. It requires dinput.h to be present on the system. As I use Visual C++ 2008 Prof., there is no way around the official SDK and that really annoys me. I do not need it and it takes around 1.5GB of space. I just don't want it :D.

_arts_
07-07-2011, 01:30 AM
You can try to build your own sdl version without joystick support. It might be tricky but under my linux distro I have sdl package for every part (graphics, sound, network...), so it is possible.