Jump to content

ULTRA APP KIT


Jules D.
 Share

Recommended Posts

@comanchetrProcess::GetHandle() has now been added. So I think you will do something like this:

const EventID EVENT_PROCESSCLOSE = AllocEventID();

VOID CALLBACK ProcessCloseCallback(
    _In_  PVOID lpParameter,
    _In_  BOOLEAN TimerOrWaitFired
    )
{
	EmitEvent(EVENT_PROCESSCLOSE);
}

void main(blah, blah)
{
	auto process = CreateProcess("C:/Windows/Notepad.exe");
	HANDLE hNewHandle;
	RegisterWaitForSingleObject(&hNewHandle, process->GetHandle() , ProcessCloseCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);	
	...

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

It seemed to be fine the second time you ran it, so what is the problem? The OpenGL context will cover the entire window, so you should create a child window for the area where the 3D rendering occurs. The OpenGL example in the documentation does this.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Josh you are a wizard, just didn't think about re-declaring HWND, everything works thanks)

HWND hwndW = window -> GetHandle(); 
    HDC hdcW = GetDC(hwndW);
    
    HICON icon = LoadIconA(GetModuleHandle(NULL), (LPCSTR)IDI_ICON1);
    SendMessage(hwndW, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));

 HWND hwnd = renderwindow->GetHandle();
 HDC hdc = GetDC(hwnd);

Link to comment
Share on other sites

31 minutes ago, Josh said:

It seemed to be fine the second time you ran it, so what is the problem? The OpenGL context will cover the entire window, so you should create a child window for the area where the 3D rendering occurs. The OpenGL example in the documentation does this.

As soon as you wrote so immediately my brain started working)

  • Haha 1
Link to comment
Share on other sites

I've already started some designs on the backend of my application and I gotta say, UAK fits so well into all of this (I've not stumbled upon any limitations). There is so much room for code abstraction, it can pretty much conform to whatever design an application requires.

The pattern I tend to follow when making a robust system is to have an Application class that contains a list of layers. Layers are my abstraction for other components of my application. I have various interfaces for each layer and my concrete classes derive from those for their implementations. In my applications run loop I simply iterate over all layers in the applications layer stack to execute their code. Following good programming practices such as DRY and SOLID this gives a pretty extendable architecture to your codebase.

Thanks for the video tutorials for some of the code examples in the docs too, very welcomed stuff!

Link to comment
Share on other sites

On 3/31/2021 at 2:08 PM, Cromartie said:

Hello everyone. How can I fix the .ico display problem?

I would recommend to check out post build events in Visual Studio if you wish to add any kind of content that your application will use (that is if you are even using Visual Studio). Post build events allow you to run commands post build (yeah, pretty obvious haha). This gives you the opportunity to do things like copy directories over for resources you have used in your application, for example lets say you used some nice looking icons for your GUI you will want to make sure your release target directory has all the appropriate folders and files for those to be packaged in your final target directory.

Failing to do this will give you some nasty surprises (not really nasty surprises, its fairly obvious that any resources you use within your Visual Studio project won't be present in your built binary folder) when you run your application outside of the Visual Studio environment. If you are trying to change your applications default icon for some branding purposes then I did post an example a few pages from here in this thread

  • Like 1
Link to comment
Share on other sites

49 minutes ago, SlipperyBrick said:

In my applications run loop I simply iterate over all layers in the applications layer stack to execute their code.

I think you can do something similar by adding a lot of ListenEvent() callbacks, using EVENT_NONE and NULL so that all events pass through the callback. I tend to put different tools and windows of my application each in their own code file so the program gets compartmentalized pretty well.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

2 hours ago, Josh said:

I think you can do something similar by adding a lot of ListenEvent() callbacks, using EVENT_NONE and NULL so that all events pass through the callback. I tend to put different tools and windows of my application each in their own code file so the program gets compartmentalized pretty well.

One of the methods I use in my concrete classes (that derives from my Layer base class) is OnEvent(). With the event class UAK provides this gives some amazing flexibility, I pass an UltraEngine::Event as a reference to my OnEvent() methods and now I can iterate through all events in my applications layerstack.

Applications Run():

void Application::Run()
{
	// Initialize applications GUI
	OnInit();	

	while (!m_Window->Closed())
	{
		if (!m_Window->Minimized())
		{
			// Update all the applications layers in the layer stack
			for (Layer* layer : m_LayerStack)
			{
				layer->OnUpdate(m_TimeStep);
			}

			// Check if any events exist in the event queue
			if (UltraEngine::PeekEvent())
			{
				// Return the oldest event from the event queue
				UltraEngine::Event e = UltraEngine::WaitEvent();

				// Process the event (s_Instance is the instance of the application)
				s_Instance->OnEvent(e);
			}
		}
	}
}

Applications OnEvent():

void Application::OnEvent(UltraEngine::Event& e)
{
  	// Event callbacks go here
	UltraEngine::ListenEvent(e.id, s_Instance->GetWindow(), Application::OnWindowResize);

	// Traverse the applications layer stack to handle events
	for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); )
	{
		(*--it)->OnEvent(e);
	}
}

Callback OnWindowResize():

bool Application::OnWindowResize(const UltraEngine::Event& e, std::shared_ptr<UltraEngine::Object> o)
{
	if (e.id == UltraEngine::EVENT_WINDOWSIZE)
	{
		...
	}

	return true;
}

Every layer in the layerstack has an OnEvent() which passes an Ultra Engine event. This allows me to call ListenEvent in each layers class and also allows me to implement the event callback in each layers class too.

void SmartexGUILayer::OnEvent(UltraEngine::Event& e)
{
	UltraEngine::ListenEvent(e.id, Application::Get()->GetWindow(), SmartexGUILayer::OnSomeButtonThatIsPressed);
}

GUI widget events I can handle now in my SmartexGUILayer class by calling ListenEvent in its OnEvent() and implementing the event callback in there too. UAK has made it real easy ?

Link to comment
Share on other sites

Yes, that functionality is built in. You can define the event source and event ID, or just supply NULL and EVENT_NONE to the command and it will call the callback for every event.

In your case you would have a callback that is something like this:

bool callback(const Event& e, shared_ptr<Object> extra)
{
	auto app = extra->As<Application>();
	if (app == NULL) return true;
	return app->OnEvent(e);
}

https://www.ultraengine.com/learn/CPP/ListenEvent

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

On 3/31/2021 at 5:43 PM, Cromartie said:

Josh you are a wizard, just didn't think about re-declaring HWND, everything works thanks)

HWND hwndW = window -> GetHandle(); 
    HDC hdcW = GetDC(hwndW);
    
    HICON icon = LoadIconA(GetModuleHandle(NULL), (LPCSTR)IDI_ICON1);
    SendMessage(hwndW, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));

 HWND hwnd = renderwindow->GetHandle();
 HDC hdc = GetDC(hwnd);

I like Resource Hacker:
http://angusj.com/resourcehacker/

Just select the "Add a new image resource" menu item, select your ICO file, add it and save the EXE.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

11 minutes ago, mdgunn said:

I don't see it in my account. If you joined the KickStarter (as I did) should it be showing now?

Steam key working.

I will set this up for you today.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Update on Steam with some small bug fixes. In the TreeView example, Insert() has been replaced with a new overload of SetParent that accepts an index into the parent's child list.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

On Steam, fixed a bug where a treeview node could be dragged and dropped onto itself, making it disappear. Standalone will be updated before final final release.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...