AtomicGameEngine / AtomicExamples

Examples for the Atomic Game Engine
https://www.AtomicGameEngine.com
96 stars 58 forks source link

Adding a simple example for how to use UIOffscreenView #94

Closed Type1J closed 7 years ago

Type1J commented 8 years ago

For AtomicGameEngine/AtomicGameEngine#1165

At first, I wanted a really nice 3D UI example. Then, I realized that such a UI might be pretty, but it would't be easy to understand how it works. These are "examples" after all.

This example should be very easy to follow. It's very short, and is based on the WebTexture3D example. It has a simple UI with a checkbox, a button that saves a PNG of the current UI, and it has a few edit fields.

JoshEngebretson commented 8 years ago

I am getting a black screen when trying the branch + the example, can you verify that it runs when cleanly cloned for you?

Type1J commented 8 years ago

I'll try a clean clone some time today. Was it on a Mac? I was on Windows. I'll try with a Mac as well.

JoshEngebretson commented 8 years ago

I am on Windows here, I meant a clean clone of the example just in case the project is missing something.

Type1J commented 8 years ago

Will do

Type1J commented 8 years ago

On a clean clone of the AtomicExamples repo after switching to this branch I get the correct output. I'll try updating the engine source.

JoshEngebretson commented 8 years ago

Hm, switched to mac and black screen here too...

JoshEngebretson commented 8 years ago

I can make the cube appear if I comment out: // model.material = self.uiOsView.material;

Though, that's not terribly helpful, the scene camera being parented to the node threw me for a little bit :)

Type1J commented 8 years ago

image Clean AtomicGameEngine clone and clean AtomicExamples clone. I also pulled AtomicGameEngine upstream just to make sure that there wasn't a breaking change.

Do you know what might cause it to not work on your machine? Did the log give you any insight? What is your machine's configuration, and can you test it on another machine?

Type1J commented 8 years ago

The material uses an xml file that I assumed was in CoreData, but I'll try creating it in code. I'll try it on another machine as well.

JoshEngebretson commented 8 years ago

Hey, I plan on spending some time on this today. There isn't anything in logs, I'll verify whether I can get rendering here, if not will have a look into it since working for you, screenshot or it didn't happen 📸 😄

Type1J commented 8 years ago

Here's a Windows 10 machine: image It wasn't a dev machine, so I installed VS2015 (with Git), and CMake. I cloned AtomicGameEngine and checked out JLS-UI-TEXTURE, then checked out AtomicExamples and checked out JLS-UI-TEXTURE on it as well. I built the editor, then opened the UITexture.atomic project, and ran it. That got me the screenshot. I was hoping that it wouldn't work so that I'd have a machine to reproduce the problem.

JoshEngebretson commented 8 years ago

If I enable the profiler (which uses SystemUI), I get this:

screen shot 2016-11-19 at 10 11 49 am

Which leads me to think there is some kind of bug, as on 2 different boxes I get a black screen without it enabled. This is on Windows and Mac, so probably not any kind of driver issue.

I plan on refactoring this a bit, so no worries, can see if that knocks issue into place.

Type1J commented 8 years ago

Strange, it looks horizontally flipped, and the text isn't present. Was that on a clean checkout?

JoshEngebretson commented 8 years ago

Yeah, clean clone of both engine/examples repos. I wouldn't worry too much about tracking down the issue, I plan on taking a pass on it now that you've done the diligence of proving/making it work :)

Type1J commented 8 years ago

Awesome. When it works, if you can, please let me know the details of why it didn't work for you on those machines. I'm curious.

Type1J commented 8 years ago

In Windows when you saw the black screen, were you building Atomic with OpenGL?

I reproduced the problem on a Mac. I'll have to look at it later, though. I'm suspecting that since the View.cpp Render() flips the camera when rendering to an OpenGL FBO that I should probably do the same. I've had some good luck proving that to myself, but I don't have all of the camera matrix values corrected just yet. I don't think that anything will need to be done for the input mapper since that's unrelated to the rendering API used.

JoshEngebretson commented 8 years ago

@Type1J Great, and would be good to know. I'd say not to spend a lot of time on it, as going to refactor this in a pretty major way. For example, I think we can maintain a list of root UIView's with the main view always being available... and offscreen ones added (ie. I don't think we need a specific offscreen widget class as this complicates event and rendering handling).

I'll be able to rip this out pretty fast, now that you have figured it out and shown it is possible without blowing apart the UI subsystem... hard to go back and forth on design on GitHub. I'll make a PR against your branch and we can look at changes, once I have a chance to get into them.

JoshEngebretson commented 8 years ago

Oh, and D3D9 on Windows

Type1J commented 8 years ago

Sounds good.

Type1J commented 8 years ago

Just for reference it's 2 different problems.

1) OpenGL currently needs a different camera matrix. 2) When the UI has no batches, it returns. It should at least reset the render targets. That's because if any offscreen views were rendered, then their render target stays active, if it doesn't.

Something else may reset them (like bringing up the debug UI, as you did, or any normal UIView which bypasses problem 2, but not problem 1.

JoshEngebretson commented 8 years ago

Aha! Nice sleuthing 🔍