Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Mar 2007
Offline Last Active Today, 09:21 AM

Posts I've Made

In Topic: Fill custom shape when vertices/edges are provided fails in Directx

Today, 12:25 AM

You can use the stencil buffer. Here are a couple of screenshots from the application I'm working on (Curver, see signature) that may be helpful for demonstrating how to draw filled shapes:




The wireframe shows the geometry drawn in the two-sided stencil buffer, with stencilpass set to increment the buffer and ccw_stencilpass set to decrement it.  Then you draw a quad encompassing the shape with stencil testing enabled and viola.




I hope you find this useful.

In Topic: Shader Node Graph

20 May 2016 - 11:23 AM



Do you just categorize this as another "shader permutation" and take an uber shader approach"?


Yes, mostly. If you notice in UE4, the uber shader is represented as a single node, and the user can create a node network to provide inputs for the main uber shader functions. I wrote a short blog post about such a system here. However, I think it doesn't go into enough details to be very useful to you, and also it was just a prototype rather than a real-world solution.

In Topic: Architecture for a C++ Widget Library

19 May 2016 - 01:28 AM


The library does not handle drawing by itself. It produces 2D geometry in the form of vertex + index arrays which can be passed by the user to OpenGL or DirectX.


That the library doesn't handle drawing itself is not a bad thing. But instead of being geometry based, why not texture based? Why not asking the client to implement a simple rendering interface, or an entire platform interface for gui event handling/triggering as well as drawing:

class GuiPlatform
	// rendering
	virtual void RenderItem( Rectangle rect, TextureId texture, Rectangle texturePortion ) = 0;
	virtual TextureId LoadTexture( const char* fileName ) = 0;
	// system interaction
	virtual point GetCursorPos() = 0;
	virtual size GetWindowSzie() = 0;
	virtual int HanleEvent( EventType, EventData ) = 0;

bool InitGuiLibrary( GuiPlatform* myGuiPlatform );

Then in your SDK provide sample implementations for DX11, OpenGL, Win32, or whatever.


Edit: Personally I'd name it Open Widget Library (OWL), but that's just me... owls are cool [@v@]

In Topic: Custom WinAPI Control: subclass, owner-draw or custom class?

19 May 2016 - 01:13 AM

I'd go with a completely custom class, and I'd not use native buttons inside the control and instead have the control draw the buttons itself, just like a list box draws the items itself. Implementing hit-testing for such a simple item layout is trivial, especially if the buttons are equally sized. The same can be said about drawing the items.


But what you seem to want to implement is exactly a toolbar, but scrollable. How is that better than a native toolbar with a chevron for example?

In Topic: Custom editor undo/redo system

08 May 2016 - 12:33 PM

In my application (Curver, see signature), I use the third approach. However, it doesn't have to be complicated. For example, to modify the properties of an object, the undoable command class looks like this:

class CmdModifyCurveProperties : public Command
	Curve::Properties m_properties;
	Curve* m_pCurve;
	Execute( Curve& curve )
		m_pCurve = &curve;
		m_properties = curve.properties;
	Undo() { SwitchProperties(); }
	Redo() { SwitchProperties(); }
		Curve::Properties p = m_pCurve->properties;
		m_pCurve->properties = m_properties;
		m_properties = p;

pDocument->AddCommand( (new CmdModifyCurveProperties)->Execute( theCurve ) );
// now we can change the properties however we want and the changes will be
// undone when the command is undone.
theCurve.properties.thickness = 0.5;
theCurve.properties.color = black;

Of course, multiple commands can be grouped together for performing multiple tasks that are to be undone and redone as a unit:

auto cmdGroup = new CommandGroup;
cmdGroup->AddCommand( (new CmdCreateCurve( &theCurve ))->Execute() );
cmdGroup->AddCommand( (new CmdSelectCurve( &theCurve ))->Execute() );
cmdGroup->AddCommand( (new CmdCreateCircle( &theCircle))->Execute() );
cmdGroup->AddCommand( (new CmdSplitCurve( &theCircle, 0.5, &theDetachedPart))->Execute() );
pDocument->AddCommand( cmdGroup );

The approach in Maya seems to be complicated because it is used with scripting as well to implement undoable commands, and the interface is intended for plug-in authors instead of for direct use internally.


But there is no approach that is right for all projects. As Alberth mentioned, you will have to think about of object ownership and guaranteeing existence, so it's not without headaches. Good luck.