-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: OpenGL Main Menu (for systems not supporting WinForms) #595
Conversation
64-bit support (required for OS-X, thanks Apple.....) also depends on the following branch being integrated: This needs to be rebased onto the new TrainManager, but is relatively usable. |
So, we now have a working route image and description display in the new GL main menu. |
This is now at the stage where it'll succesfully launch a routefile, which is actually a major milestone! TODO:
|
Added a slightly hacky rectangle overlay shader. cc @LabRatAndy |
Implemented text shader using the same principles. As an alternative, the text and rectangle shaders could be merged, and add a property UseTextureAtlas (or similar) |
At least you've managed to get rectangles to draw correctly, as I couldn't seam to get the projection matrix correct. I actually only used one VAO and VBO. I then used SubBufferData to replace the vertex positions before the draw call. Whilst in general I think branching program structures in shaders is best avoided, as I understand that they can impact performance. However, as I understand it as long as the shader is able to complete before the rest of the pipeline tasks complete then it shouldn't impact performance; as we are waiting for them not the shader. Also, could a geometry shader help create the vertices for the rectangles? I'm not fully familier with how they fit in the pipeline or there exact usage. |
Good point. However, as I understand it, this really depends on exactly how much the branch prediction can be done in advance. If your shader performs a variable result based calculation within the branch, then a misprediction can be nasty (as the shader can be being run for millions of pixels in paralell esentially) (I'll probably cherry-pick the string / rectangle changes into the mainline branch after the next release) |
UNTESTED: There is also now a command-line switch controlling the GL menu:
|
Train choosing is now complete, and seems to work quite acceptably. The level of polish on this isn't exactly brilliant, and the code could probably do with a complete tidy up, but I think everything important is now primarily functional. @s520 you might be interested in this one too if you're available :) |
When the game start and press ESC key, Station Jump and more menu shows. |
Thanks, fixed that and several other glitches. I've also just discovered that an over-long description will overflow the textbox. |
Fixed a few glitches on GL1.3, and I've also now implemented a complete OpenGL picturebox class, so that we can actually maintain the image aspect ratios nicely, as opposed to stretching them to fit the square box. TODO:
|
Actually managed to do some Apple testing today. Unfortunately, it's not very good news at least at first.... If I understand it right, the 32-bit OpenTK backend is running under Carbon, wheras 64-bit is running under Cocoa. From the looks of the linked issue (old, but I think still valid) WinForms will not play nice with anything else on 64-bit Apple. Plan of action (?!?!):
WinForms usage:Object Viewer
Route Viewer
Main game
Editors
Looks like the main game is going to be the easiest to deal with, at least at the start, although we might have to make some pretty fundamental plumbing changes to split out the main menu. I'm also wondering about OpenTK 4.x |
It appears that if we call Toolkit.Init first before any WinForms code is present, it actually loads. At least though we've got a functional menu. |
Input device plugins also have WinForms config forms. |
Good point. Obviously, for polish reasons at the minute, this is nowhere close (or likely) to be made the default option, and AFAIK is only needed on 64-bit Apple, and presumably mobile (although I haven't even thought about that one yet) |
Yes, just pointing them so we don't forget, as they are external and may not be initially obvious. |
Forward compatible context is going to be a pain.... The commit above solves some of the issues involved, but it's nowhere close to working yet.
|
For GL_Quads, the rectangle and text shaders in my stringshader branch use triangles which I've managed to get to work now. Although, I have used VAOs etc rather than a procedural shader. Feel free to use that if it helps. For the glalphafunc problem, rather than having a switch statement in the shader you could use multiple different shaders and draw all objects with say shader 1 then bind shader 2 and draw all the objects that need to be drawn with this shader. However you would need to sort the objects into which shader to use to draws them which may or may not be slower than the shader with a switch statement. Finally in the last commit there could be a potential problem in the useshader function. it links the shader again which could cause performance issues as useshader is used in the rendering loop to bind the shader and there is no check for this failing to link the shader; I don't know what opengl will do in this case. Also, does glbindfragmentdatalocation need to be called every time the shader is bound, would it not be better to do this in the shader constructor? |
Interesting idea with different alpha shaders. Sorting isn't going to work (see the two pass drawing method used), but testing is needed on that front. I was having problems with this yesterday though; I've got the nasty suspicion the depth test buffer is interacting with the alpha function too. |
Single pass shader unfortunately won't work, as we're using blend.
Terminally stupid mistake, it was falling through cases; Always look at things again a bit later on. If / when this is got working, we probably want to think about a Uniform Buffer Object for storing the projection matrix and the alpha test values in, so that we eliminate a bit of uploading to the shaders. |
So, I've fixed the issue, and done some very rudimentary testing. Using the Plymouth route, FPS with the alpha shader solution is currently down by ~20% Some preliminary thoughts on optimisation:
|
The alpha shader idea unfortunately doesn't work (at least without a redesign somewhere), as we need alpha for the polygon DNB. The performance killer is definitely the discard statements in the shader. Still need to think about eliminating quads in the rectangle / text shader, haven't looked at LabRatAndy's branch yet. Some of this may also be hardware / OS & GL implementation dependant. For reference, I'm testing with a GTX1060 on Windows 10 at the minute. |
Now that's interesting. The geometry shader seems to give us a 20% odd FPS drop, over just doing it with the switch statement in the vertex shader. Google suggests Intel hardware is much better with geometry shaders, but this might not be unexpected. Some stuff on the geometry shader issue, the first suggests that doing it in the vertex shader procedurally as per previously is going to be an order of magnitude faster.... |
Marginally faster in some cases
Some more hacking away. Highlights:
|
Changed to use a forwards compatible context with GL3, although perhaps this wants restricting to OS-X only. |
Only supports GL-3 forward compatible context, thus *must* decomposit to tris
openGL on OS-X appears to be a seriously messed up situation. This has the following caveats / changes / TODOs:
|
In case of filesystem errors, permissions etc. etc.
Change: Hide hidden folders on Linux / Mac
Made a few more improvements, as follows:
Assuming this doesn't crash, it's probably mergable as-is. Further improvements, basic package manager and options etc. really need to be in separate PRs, as this is getting rather oversize. |
Unlikely to be merged / useful at the minute, but this is a WIP attempt to use the in-game menu for route loading etc.
#384
May also be usable on mobile, but needs considerable work to be anything more than a tech-demo.
Also has the problem that it doesn't allow access to any of the configuration etc.
TARGETS:
Release 1.7.5.0 with the new TrainManager setup. (next week or two)Merge 64-bit code and let the community loose on it. (next month?)Release 1.8.0.0 as first 64-bit build.Implement non-default train chooser. Should be able to use the route chooser.Add menu icon option, to use the existing pixel art. Ought to make the folder etc. selection a little clearer.Add command line switch to use the GL menu. Can probably just hook into this in the OS-X launch script.ISSUES:
Aspect ratio of imges isn't respected.Check M1 compatability if possible. Requires a Mac user with an M1.......