Comments (47)
Unfortunately, my virtualized Linux doesn't seem to support antialiased visuals, so I can't test this myself.
Could you, for each visual that is processed in GlxContext::CreateContext, add some debug code that prints all their attributes as well as the score they get (and the ID of the chosen one)?
from sfml.
I did a bit of testing. My changes to GlxContext.cpp.
The output of the following gist is this.
Output of glxinfo.
I hope that this could help you a bit.
from sfml.
Thanks, this is exactly what I needed.
Only one visual is found... there's definitely something wrong.
from sfml.
I think I know what happens. The attributes I pass to XGetVisualInfo contain the visual ID, therefore there can only be one match. Should be easy to fix.
Thanks guys for your help.
from sfml.
Any work on this? If I knew how to use XGetVisualInfo properly I'd try to help.
from sfml.
Learn it or wait until Laurent gets to work on this.
from sfml.
I was attempting to rewrite it to use glXChooseVisual instead of the current system. It ended up working okay, but didn't solve the problem. glXChooseVisual still seemed to choose the visual without antialiasing.
from sfml.
Don't try to fix this, it won't work.
Actually it's more complicated than I thought. To solve the problem, the context would have to be created before the window, which is of course not how SFML works.
from sfml.
Could this be solved by creating a dummy context just to grab the info? It may not be proper but it may just work for now.
from sfml.
There is always a context (dummy or not) active when a window is created, it doesn't help because there's no info to grab.
The problem is that we must do this:
- choose a visual according to context settings
- create a window using this visual
- create a context using this visual
... and SFML works like this:
- create a window
- create a context using the context settings
So, the problem is that X11 and GLX are too tied together, while SFML clearly separates these two concepts.
from sfml.
Has there been any progress on this issue so far?
from sfml.
No. It's marked for SFML 2.x, so I won't work on it for SFML 2.0.
from sfml.
I have been looking at the code a bit. What's the purpose of the hidden window created @ /src/SFML/Window/Linux/GlxContext.cpp:95?
If we called createContext(...) before that, and used the determined bestVisual to create that window would that help? Or does the window @ /src/SFML/Window/Linux/WindowImplX11.cpp:157 have to be created with the proper visual to begin with?
EDIT: I see issues #200 and #319 might make the above question irrelevant.
from sfml.
What's the purpose of the hidden window created @ /src/SFML/Window/Linux/GlxContext.cpp:95?
I haven't found any other way to create a context not bound to a real window.
If we called createContext(...) before that, and used the determined bestVisual to create that window would that help?
No, this constructor is used only for sf::RenderTexture. The constructor that constructs a window's context receives a pointer to the window -- which implies that the window is already created.
Or does the window @ /src/SFML/Window/Linux/WindowImplX11.cpp:157 have to be created with the proper visual to begin with?
Yes. That's the problem.
from sfml.
Thank you very much @LaurentGomila. This is a crucial bugfix for us Linux users. I will try it ASAP.
from sfml.
Great, since I run Linux in a virtual machine with very poor OpenGL support (no anti-aliasing), more feedback will be useful.
from sfml.
This works perfectly ๐ (C#):
window = new RenderWindow(new VideoMode(800, 600), "GLTEST", Styles.Default, settings);
This doesn't:
window = new RenderWindow(someExistingHandleFromAWidget, settings);
someExistingHandleFromAWidget being a drawable handle to a Gtk.DrawingArea. Not sure if that's GTK's fault (the widget's context is created without support for AA) or SFML's.
Best way would be to let SFML create the window and Gtk use that, somehow.
from sfml.
Since the context and window must be created with the same GLX visual, there's no way to make it work with an external window on which you have no control.
Thanks for the test.
from sfml.
Yeah, that's what I thought. But couldn't you create a child window with the desired visual?
from sfml.
Hmm I haven't tried that, it could work.
from sfml.
It works :) Kinda... I get 4x multisampling even if I request 8x. O.o But that's better than nothing.
Also, I can't get it to resize. Not sure if I have to resize the parent window everytime or what else the bug could be.
from sfml.
That commit is just for reference. I am sure you can implement it in a cleaner way. Also, as said, it still has bugs.
from sfml.
Thanks :)
from sfml.
I've changed the constructor the same way as you did, but it doesn't work for me, the child windows don't appear at all.
Here is my code: https://gist.github.com/LaurentGomila/5934572
I can't see any major difference with your code.
I'm testing with the X11 SFML example, and all I get is a black window.
And what bugs did you have, by the way? If you were referring to the setSize issue, don't worry about that, this kind of functions are for top-level windows, I won't even bother trying to make them work for child windows :)
from sfml.
The new windows is probably 1x1. Try replacing parentAttributes.width, parentAttributes.height
with 480, 320
or something.
That is the bug I was referring to and trying to solve in setSize.
EDIT: Nevermind. parentAttributes.width, parentAttributes.height
in the X11 example. But I also get a black window. Not sure what the problem is, there.
I get:
Failed to activate the window's context
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 11 requests (6 known processed) with 0 events remaining.
That might be a hint?
from sfml.
No, the size is good. Could you try the X11 example with your implementation, and then with mine, and tell me which one works?
Your problem is probably that you don't call XFlush(display)
before constructing the SFML window, so your parent window has no size yet. I do it in the X11 example so there's no problem.
from sfml.
One more thing: in your code the container window is a GTK window, right? Could you test SFML event handling, and tell me which events work and which don't (with the old implementation, and then with your implementation -- forcing the child window to be created)?
Event handling was the most annoying issue with child windows, that would be so cool if this modification could fix that too.
Thanks.
from sfml.
No, the size is good. Could you try the X11 example with your implementation, and then with mine, and tell me which one works?
Neither works (since they are really the same). But in master the X11 example doesn't work either, for me. A problem with switching contexts, I think:
Failed to activate the window's context
My GTK code works.
from sfml.
One more thing: in your code the container window is a GTK window, right? Could you test SFML event handling, and tell me which events work and which don't (with the old implementation, and then with your implementation -- forcing the child window to be created)?
Event handling was the most annoying issue with child windows, that would be so cool if this modification could fix that too.
In both cases, the HEAD of my x11_experiments branch, and of my master (which points to af81ac6, a commit before your changes), it's the same: only mouse move, mouse enter and mouse left work. Bear in mind that I have been using GTK's events instead of SFML's, so I haven't studied the later and might be doing something wrong.
I do this: window.MouseWheelMoved += delegate { Console.WriteLine("mouse wheel"); };
then this in the main loop: window.DispatchEvents();
.
Events I tested:
Closed,
Resized,
LostFocus,
GainedFocus,
TextEntered, // I made a handler for this one but don't know what it does
KeyPressed,
KeyReleased,
MouseWheelMoved,
MouseButtonPressed,
MouseButtonReleased,
MouseMoved, // works
MouseEntered, // works
MouseLeft // works
from sfml.
But in master the X11 example doesn't work either, for me.
Damn. It works perfectly for me, it will be hard to debug.
it's the same: only mouse move, mouse enter and mouse left work.
Button pressed/released doesn't work, even without the call to XSelectInput in the constructor? Too bad...
After thinking more about it, I don't think it is a good modification. Creating a child window instead of using the container directly can have bad side-effects: no effect if you set the focus to the container, unexpected results if you create other children in the container, etc.
I'll revert my local modifications and leave it like this for now.
from sfml.
// I made a handler for this one but don't know what it does
When you enter text, it gives you the typed characters.
For example, "E" + "^" will give two KeyPressed events but only one TextEntered with the character "รช" on a french keyboard.
from sfml.
Correct behaviour for ^ handling should be you type "^" and then "E" to get an "ร". If you do the contrary you sould see an "E" and a ^ ready for the next modifier, and if you type "^" then "^" you get "^^". (general behaviour i think). The ยจ works the same way.
from sfml.
Yes, I meant "^" + "E". Sorry.
from sfml.
But in master the X11 example doesn't work either, for me.
Damn. It works perfectly for me, it will be hard to debug.
Disregard that. It doesn't even work in "old" SFML. Nothing to do with this issue.
After thinking more about it, I don't think it is a good modification. Creating a child window instead of using the container directly can have bad side-effects: no effect if you set the focus to the container, unexpected results if you create other children in the container, etc.
That's a pity. If you don't mind, I'll sleep over it and maybe later give it another try. I don't know enough about X to say if it makes sense or not. Or maybe I'll just see if the child window can be created in my game, because I haven't found any other way to get AA in the GTK widget.
from sfml.
Disregard that. It doesn't even work in "old" SFML. Nothing to do with this issue.
Ok but it should work (and it has always worked for me), so this is still an issue.
from sfml.
Disregard that. It doesn't even work in "old" SFML. Nothing to do with this issue.
Ok but it should work (and it has always worked for me), so this is still an issue.
Meh. It works now. I was linking it against the debug build of sfml, and not updating that. Sorry. This makes me question my whole test procedure, above.
from sfml.
Good news :) I found a way to "embed" the SFML window into GTK: http://www.gtk.org/api/2.6/gtk/GtkSocket.html
A bit of a hack, but hey! it works. With AA!
Edit: Have added source to the wiki, for future reference.
from sfml.
I'm still facing this problem both with SFML 2.2 under Ubuntu 14.04 with proprietary nvidia drivers. This is code I use:
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::RenderWindow window(sf::VideoMode(width, height), "title", sf::Style::Default, settings);
std::cout << window.getSettings().antialiasingLevel << std::endl;
The last line only prints 0
.
In the package sources of Ubuntu 14.04 there is only version 2.1, so I compiled SFML from source, but the there was still no antialiasing. My graphics card definitely supports antialiasing. Here is my glxinfo.
from sfml.
@konstin Have you used the latest GitHub version (not SFML 2.2)? There have been some recent changes to context handling. Do you see the error message in the console?
from sfml.
With latest git I see these messages:
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 2.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 8 ; core = false ; debug = false
Created: version = 4.5 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false
And btw my program doesn't work anymore because there seems to be an issue with the mouse coordinates. EDIT: The Problem is that I no more get local but only global mouse coordinates.
from sfml.
What is the output of glxinfo
?
from sfml.
https://gist.github.com/konstin/110c4f6dd7f3e22493a6
from sfml.
The tree is at https://github.com/LaurentGomila/SFML/tree/bugfix/pixel_format_evaluation
from sfml.
With #862 the programm crashes on startup with the following message, both with and without antialiasing enabled:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 78 (X_CreateColormap)
Serial number of failed request: 20
Current serial number in output stream: 23
I can't get a stacktrace because the programm exits immediatly after printing the message.
from sfml.
@konstin add a breakpoint on exit and/or abort (not sure which one). that should do the trick.
from sfml.
Thanks, setting breakpoints on two syscalls (exit and exit_group) gave me a stacktrace:
(gdb) bt
#0 0x00007ffff6c291c9 in __GI__exit (status=status@entry=1) at ../sysdeps/unix/sysv/linux/_exit.c:32
#1 0x00007ffff6ba266b in __run_exit_handlers (status=1, listp=<optimized out>, run_list_atexit=run_list_atexit@entry=true) at exit.c:97
#2 0x00007ffff6ba26f5 in __GI_exit (status=<optimized out>) at exit.c:104
#3 0x00007ffff60186b8 in _XDefaultError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4 0x00007ffff60187ed in _XError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#5 0x00007ffff60157e7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#6 0x00007ffff6015895 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#7 0x00007ffff60161d5 in _XEventsQueued () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#8 0x00007ffff6018f25 in _XGetRequest () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#9 0x00007ffff5ffdd42 in _XGetWindowAttributes () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#10 0x00007ffff5ffdf31 in XGetWindowAttributes () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#11 0x00007ffff7981c09 in sf::priv::GlxContext::createContext(sf::priv::GlxContext*, unsigned int, sf::ContextSettings const&) () from /usr/local/lib/libsfml-window.so.2.2
#12 0x00007ffff79825c5 in sf::priv::GlxContext::GlxContext(sf::priv::GlxContext*) () from /usr/local/lib/libsfml-window.so.2.2
#13 0x00007ffff796eed1 in sf::priv::GlContext::globalInit() () from /usr/local/lib/libsfml-window.so.2.2
#14 0x00007ffff796fa47 in sf::GlResource::GlResource() () from /usr/local/lib/libsfml-window.so.2.2
#15 0x00007ffff79718ae in sf::Window::Window() () from /usr/local/lib/libsfml-window.so.2.2
#16 0x00007ffff7bc1e39 in sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) () from /usr/local/lib/libsfml-graphics.so.2.2
#17 0x00000000004030da in main () at Aufgabe2.cpp:90
from sfml.
@konstin can you try again now? I updated the branch.
from sfml.
Related Issues (20)
- WebGL Support HOT 1
- `sf::Keyboard::getDescription` returns "Unknown" for F13+ keys on Win32 HOT 4
- choco package HOT 3
- Android CI jobs have broken HOT 2
- Conflict between SRP and OCP HOT 2
- [2.6.1] segfault in waitEvent on close (Ubuntu/X11/Multithreading) HOT 7
- [2.6.1] Drawing to RenderTexture "fails" after Texture copied from (Windows) HOT 3
- Add a CMake guide for static linking the library in MacOS/Linux HOT 1
- `sf::VideoMode::getDesktopMode()` returning the monitor resolution on macOS HOT 2
- Install prefix not honored HOT 3
- Consider changing `sf::Texture::invalidateMipmap()` from private to public HOT 4
- Creating a window when statically linking on macOS causes a crash HOT 2
- MacOS static release HOT 1
- Cannot disable SFML installation targets when installing a game which includes SFML with fetch content HOT 4
- Revert change to `sf::Drawable::draw` signature which made `sf::RenderStates` a const reference, and make it a copy again HOT 10
- (Linux) Window Close Event not triggered with sf::Style None, Titlebar, Resize
- Cannot create DRM context without X server running. HOT 2
- sfml window example crashes due to acess violation on joystick driver ezfrd64.dll HOT 3
- Add support for QOI (Quite OK Image) and QOA (Quite OK Audio) formats HOT 2
- Store angles internally as radians HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfml.