Adam's Lair Forum

game development and casual madness
It is currently 2017/12/13, 18:40

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 2017/11/08, 04:28 
Member
Member

Joined: 2016/08/03, 22:07
Posts: 50
Location: Florida
Role: Hobbyist
Hey All,

I'm working on integrating Noesis GUI into Duality. I've gotten the dependencies added, the project is building and I've built a basic renderer component. I'm not able to see the Noesis GUI elements and I also noticed that some of the UI elements in the editor (mouse coordinates for example) disappear.

The OpenGL example has a bunch of GL configuration that are either missing or different from what's in the GraphicsBackend.cs file (see below).

So my question is, do I need to create my own GraphicsBackend as well to comply with the settings Noesis requires and if so, are there going to be changes required elsewhere in Duality for normal operations?

Code:
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glClearDepth(1.0f);
    glDepthMask(GL_TRUE);

    glDisable(GL_CULL_FACE);
    glDisable(GL_ALPHA_TEST);
    glDisable(GL_STENCIL_TEST);
    glDisable(GL_BLEND);
    glDisable(GL_SCISSOR_TEST);

    glUseProgram(0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glViewport(0, 0, width, height);
    glColorMask(true, true, true, true);

    /* Clear the buffer, clear the matrix */
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();


Top
 Profile  
 
PostPosted: 2017/11/08, 21:14 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2031
Location: Germany
Role: Professional
I'm not familiar with Noesis and its integrations into other frameworks, but in general there should be two paths for that: One by handing over direct (OpenGL) rendering control to Noesis and one by giving Noesis something it can use to draw stuff, i.e. implementing an interface that will act as a bridge.

The first path means that you will have to implement (clone-and-modify) your own graphics backend for Duality and add the necessary code to set up OpenGL the way Noesis needs it, and revert it afterwards so it's back to what Duality expects.

The second path might actually be possible to do as a regular Duality plugin with no backend changes required, if you could implement a bridge interface for doing the UI rendering using an ICmpRenderer and pass along user input as needed. Judging from the feature list on the Noesis website, this path should be doable in some way:
Quote:
Just link against our library and hook your own Renderer, Allocator and Filesystem.


Depending on how easily doable the second approach is, I'd probably check out that one first, but whichever way you choose, let me know how it works out! Would definitely be nice to see a proof of concept for this.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/11/08, 22:27 
Member
Member

Joined: 2016/08/03, 22:07
Posts: 50
Location: Florida
Role: Hobbyist
Thanks Adam - that's helpful.

I have gone down the path of integrating directly into the core Duality project but it's been a false start so I'm going to pull a clean version from the repo and start down the path of a plugin.

I was already heading (and hoping xD) towards the ICmpRenderer route. My concern with this approach is that Noesis requires, for example, that the GL_SCISSOR_TEST be disabled:
Code:
glDisable(GL_SCISSOR_TEST);


but regardless of what render mode Duality is in, it has the ScissorTest enabled:

GraphicsBackend.cs
Code:
if (options.RenderMode == RenderMatrix.OrthoScreen)
{
     GL.Enable(EnableCap.ScissorTest);
     GL.Enable(EnableCap.DepthTest);
     GL.DepthFunc(DepthFunction.Always);
}
else
{
     GL.Enable(EnableCap.ScissorTest);
     GL.Enable(EnableCap.DepthTest);
     GL.DepthFunc(DepthFunction.Lequal);
}


This is leading me to believe that I will have to either create a customer GraphicsBackend or experiment with which of these settings is actually required to be as they are in the default backend.


Top
 Profile  
 
PostPosted: 2017/11/09, 18:43 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2031
Location: Germany
Role: Professional
RollerJesus wrote:
I was already heading (and hoping xD) towards the ICmpRenderer route. My concern with this approach is that Noesis requires, for example, that the GL_SCISSOR_TEST be disabled:
Code:
glDisable(GL_SCISSOR_TEST);


There's a good chance that this will turn out to be irrelevant, since the scissors region in Duality is simply the entire rendered-to area, which is usually the entire window area / screen / target texture.

Additionally, if you're building a bridge component that Noesis will call, you will probably be in a position where you translate the intended high-level drawcalls from Noesis to Duality, in which case any low level rendering state should no longer matter.

Could be wrong though, would be interested in your progress on this.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/11/27, 17:36 
Member
Member

Joined: 2016/08/03, 22:07
Posts: 50
Location: Florida
Role: Hobbyist
Just wanted to provide a brief update on this. Over the weekend, I was able to get the example UI showing within the Duality Editor when in sandbox mode.

https://imgur.com/a/zmYC6

The UI files are being loaded from hard-coded locations atm but I plan on either passing that to the component via the editor or specifying a file path via an editor plugin.

The display isn't perfect and I regularly get an Access Violation exception from the rendering call from Noesis but it certainly proves the concept that Duality and Noesis can work together. This exception has been the primary holdup in making progress as the issue seems to occur randomly.

I'm going to take a break from the rendering side and work on input and will check back in.


Top
 Profile  
 
PostPosted: 2017/11/28, 21:28 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2031
Location: Germany
Role: Professional
Nice work :) :1+: Great to hear it works and you got a proof of concept.

Quote:
The display isn't perfect and I regularly get an Access Violation exception from the rendering call from Noesis but it certainly proves the concept that Duality and Noesis can work together. This exception has been the primary holdup in making progress as the issue seems to occur randomly.


I have no idea how your setup looks like, but if this is about unmanaged C++ Noesis somehow calling into managed C# using a delegate pointer thing, then be aware of accidentally not storing a reference to that delegate anywhere in your C# world. Otherwise, the delegate instance can be garbage collected whenever the CLR feels like it and you end up with a pointer into nowhere that is getting invoked by the unmanaged C++ side of things.

Again, I'm really just throwing around random stuff here, but who knows.

RollerJesus wrote:
I'm going to take a break from the rendering side and work on input and will check back in.


Please do! Also, does that part of your project happen to be Open Source and available online somewhere? Pretty sure this could prove to be very interesting for others who might try to integrate unmanaged libs with Duality :)

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/11/28, 23:13 
Member
Member

Joined: 2016/08/03, 22:07
Posts: 50
Location: Florida
Role: Hobbyist
I've been able to bring some stability to the integration by bringing the NoesisManaged source into my solution so I could see where it was failing. It seems to be related to the drawing of things outside the Duality view so I hard coded some more realistic sizes, etc and it's much more workable now.

The whole project is open source but I (embarrassingly) have been working off a pull that I did from the main Duality repo and (rightly so) can't sync to the server. I'm hoping to move my changes into my fork tonight and I'll push to my github repo.

Edit: Cleaned up the sloppy hardcoded references and pushed into a branch in a current repo that actually belongs to me (Noesis branch): https://github.com/padesso/duality

Critiques and pull requests are always welcome.


Top
 Profile  
 
PostPosted: 2017/11/30, 20:21 
Member
Member

Joined: 2016/08/03, 22:07
Posts: 50
Location: Florida
Role: Hobbyist
This project is in a place that's worth looking at if anyone is interested. :D

Known Issues:
Restarting the game within the editor causes access violation exceptions
UI flickers when selecting dropdown menu
Key modifiers (shift, ctrl, etc) not implemented
Duality Debug (mouse position) not displaying in Editor

Edit: Implemented basic Command (MVVM style) example.

Not sure where I'll go next but input is always welcome.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group