Skip to content

Conversation

@VelorumS
Copy link
Contributor

@VelorumS VelorumS commented Mar 1, 2017

Try to init GUI as usual, fallback to the shared context mode if it fails.

@VelorumS VelorumS changed the title GUI: Also try a separate-context mode GUI: Also try a separate-shared-context mode Mar 1, 2017

current_context = glXGetCurrentContext();
assert(current_context);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this if is skipped, we should abort, right? (same above in the old function i think)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a good unification.

if (QThread::currentThread() != QCoreApplication::instance()->thread())
this->callback_processor.processEvents();
#else
this->callback_processor.processEvents();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does apple need a special treatment here? (maybe even add a comment about the reason)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it out and see what mac users say. Can't really test this part.

virtual void post_render() override;
};

class GuiSeparateRenderingContext : public CtxExtractionMode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation for those classes pls


namespace qtsdl {

class CtxExtractionException : public std::runtime_error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be a good job for the error::Error so we had nice backtraces etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's too deep to include the error. Replace the exception with an assert?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you catch it yourself it should be ok like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's done. They won't escape.

assert(std::this_thread::get_id() == this->owner);
#ifndef __APPLE__
this->app.processEvents();
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment about the reason pls, and where does apple process its events then?


class GuiRenderingCtxActivator;

class GuiRenderingSetupRoutines {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation pls

switch (debugMessage.source()) {
case QOpenGLDebugMessage::APISource:
source = GL_DEBUG_SOURCE_API;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have that in libopenage/error/gl_debug.cpp, we should not duplicate it. any idea how we could unify them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove the switch.

@TheJJ TheJJ added lang: c++ Done in C++ code improvement Enhancement of an existing component area: ui Related to the graphical user interface (Qt) labels Mar 2, 2017
@VelorumS VelorumS force-pushed the gui-gl-context branch 2 times, most recently from 25733ef to f66d9e8 Compare March 3, 2017 21:30

void apply_opengl_debug_parameters(gl_debug_parameters params, QOpenGLContext &current_dest_context) {
#ifndef __APPLE__
if (params.is_debug && params.callback) {
Copy link
Member

@TheJJ TheJJ Mar 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate a bit why apple needs this special treatment of debug function config? I want to understand/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have cleaned this up like in that other place.

AFAIK, apple doesn't support this GL version, so there may be some problems. Maybe Qt can deal with them by itself without the ifdefs.

@TheJJ
Copy link
Member

TheJJ commented Mar 4, 2017

Simple question: what is the separate-shared-context mode? 😁 Is it to have the gui opengl context separately?

@VelorumS
Copy link
Contributor Author

VelorumS commented Mar 4, 2017

Yes, that creates another context just for gui.

try {
this->ctx_extraction_mode = std::make_unique<GuiSeparateRenderingContext>(window);
} catch (const CtxExtractionException&) {
assert(false && "setting up context for GUI failed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a debugging leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole assert or the comment in it?

That's what I called "replace the exception with an assert".

It's kind of a spiritual successor to this one:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i was just confused by the false &&, but it seems alright :)

@@ -1,4 +1,4 @@
// Copyright 2015-2016 the openage authors. See copying.md for legal info.
// Copyright 2015-2017 the openage authors. See copying.md for legal info.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw why does the cocoa extraction have to be a .mm file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid question. With current approach there is probably no need to do ObjC there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you wanna fix that? Would be good :)

QVariant::fromValue<QGLXNativeContext>(
QGLXNativeContext(current_context,
wm_info.info.x11.display,
wm_info.info.x11.window)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

@Birch-san
Copy link
Contributor

I tried to compile this on latest Sierra, but there were some missing #defines. To fix this: I provide a pull request for your pull request:

VelorumS#2

@Birch-san
Copy link
Contributor

Good news

launches (with my pull request):

➜  openage git:(gui-gl-context) make run
[  1%] Automatic moc for target libopenage
[  1%] compiling .py files to .pyc files
[1/1] Compiling /Users/anon/git/openage/openage/convert/hdlanguagefile.py to /Users/anon/git/openage/openage/convert/__pycache__/hdlanguagefile.cpython-36.pyc
./run game
INFO [py] launching openage v0.3.0-861-g85e62658
INFO [py] compiled by AppleClang 8.0.0.8000042
INFO [py] running in DEVMODE
INFO launching engine with Path(Union(Directory(/Users/anon/git/openage/cfg).root @ (b'cfg',), Directory(/Users/anon/git/openage/assets).root @ (b'assets',)):) and fps limit 0
INFO SDL audio subsystems initialized
INFO Using audio device: default [freq=48000, format=32784, channels=2, samples=4096]
INFO Initialized SDL video subsystems.
INFO Compiled with Qt 5.8.0 and run with Qt 5.8.0
INFO Falling back to separate render context for GUI
INFO loading configuration files...
INFO [py] loading config file [Union(Directory(/Users/anon/git/openage/cfg).root @ (b'cfg',), Directory(/Users/anon/git/openage/assets).root @ (b'assets',))]:cfg/keybinds.oac...
INFO Loading time [engine]: 0.531 s
INFO Loading time   [game]: 0.613 s
INFO [T1] Loading game specification files...
INFO [T1] Loaded multi-csv file: 99984 sub-files
INFO [T1] Loading textures...
INFO [T1] Loading sounds...
INFO [T1] Loading time  [data]: 19.449 s

And it doesn't do the infinite stack trace thing. CPU usage is 0%, so that's good.

Bad news

Can't kill it with Ctrl-C.

Nothing renders, ever. Nor are any sounds made.

image

@Birch-san
Copy link
Contributor

Birch-san commented Apr 8, 2017

is there a way to run openage with placeholder assets? since maybe the black screen just indicates that my assets weren't extracted correctly. admittedly my assets/converted/graphics looks legit, but still it would be nice to rule it out as a problem.

@TheJJ
Copy link
Member

TheJJ commented Apr 9, 2017

Unfortunately not, if the log doesn't say anything about load-failures they should be loaded correctly. I guess that the separate gui context fails to be displayed.

@VelorumS
Copy link
Contributor Author

VelorumS commented Apr 9, 2017

@Birch-san, we also discussed in this PR some changes to the input handling (in outdated comments): libopenage/gui/guisys/private/gui_application_impl.cpp and libopenage/gui/guisys/private/gui_event_queue_impl.cpp.

Dropped that commit because it was unexplainable. I've put it here:

VelorumS@d577f56

@Birch-san
Copy link
Contributor

that commit d577f56 certainly helps!

image

image

@Birch-san
Copy link
Contributor

Birch-san commented Apr 9, 2017

Encountered these errors whilst using the game (looks like it's just complaining about audio format):

https://gist.github.com/Birch-san/cc9220818094b61cc9b817925da1e036

@Birch-san
Copy link
Contributor

Here's a gameplay video.

https://youtu.be/9GmwKreWg6I

Colours are off in a strange way. I wonder if it's an endianness problem? I saw color shifts like this once when compiling a Game Boy Advance emulator for Mac, and it was totally endianness.

I wasn't able to interact with anything in the game, but the HUD buttons seemed to be clickable (though they spent a lot of their time disappearing).

@Birch-san
Copy link
Contributor

The exact code I was running is here:
Birch-san@e83a4e3

Which (at the time of writing) is the HEAD of this branch:
https://github.com/Birch-san/openage/tree/gui-gl-context-fix-3

@VelorumS
Copy link
Contributor Author

VelorumS commented Apr 9, 2017

A theory about the disappearing buttons: it's probably related to that input handling fix - some events can't pass through if there is not enough real input activity (so the GUI isn't updated).

The debug overlay (the one with the graph) has correct colors. The GUI too.

  • do the asset png files look correctly?
  • is the ingame HUD ok? (the one with the population and resource count)

You can't interact because the game isn't in the Action mode. Press M several times or the 'change mode' button.

@Birch-san
Copy link
Contributor

oh, I was able to see the HUD by clicking "change mode" a few times. it's a bit damaged.

image

@Birch-san
Copy link
Contributor

when I changed into a different mode, I was able to select units:

image

@Birch-san
Copy link
Contributor

action mode:

image

@Birch-san
Copy link
Contributor

some events can't pass through if there is not enough real input activity (so the GUI isn't updated).

certainly I found that sometimes I had to click buttons several times before they would work.

@Birch-san
Copy link
Contributor

I fixed the color problem. I was able to confirm in Photoshop that it was just a case of "red & blue channels' being swapped". I was able to fix the pixel output format.

See my pull request:

VelorumS#3

@TheJJ
Copy link
Member

TheJJ commented Apr 22, 2017

@ChipmunkV Do you still want to get rid of the objective C file?

@VelorumS
Copy link
Contributor Author

@TheJJ, yes, but I only see how to remove a part of it.

@VelorumS
Copy link
Contributor Author

Added missing GL_DEBUG definitions to fix compile on Mac and minimized the ObjC file to just getting the current context and putting it into Qt.

Copy link
Member

@TheJJ TheJJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coal!

@TheJJ TheJJ merged commit cc76276 into SFTtech:master Apr 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui Related to the graphical user interface (Qt) improvement Enhancement of an existing component lang: c++ Done in C++ code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants