Here's my code about Noesis GUI:
NOTICE: GLRenderDevice's code is from NoesisApp framwork.
#include <assert.h>
#include <glad.h>
#include <Noesis_pch.h>
#include "local_xml_provider.h"
#include "Render/OpenGL/render_device_openGL.h"
using namespace Noesis;
Ptr<IView> view;
void Noesis_Update(double time)
{
//return;
view->Update(time);
view->GetRenderer()->UpdateRenderTree();
view->GetRenderer()->RenderOffscreen();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, 1440, 900);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearStencil(0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
view->GetRenderer()->Render();
}
void Noesis_SetViewSize(int width, int height)
{
//return;
view->SetSize(width, height);
}
void NoesisLogHandler(const char* filename, uint32_t line, uint32_t level, const char* channel,
const char* message)
{
if (strcmp(channel, "") == 0)
{
// [TRACE] [DEBUG] [INFO] [WARNING] [ERROR]
const char* prefixes[] = { "T", "D", "I", "W", "E" };
const char* prefix = level < NS_COUNTOF(prefixes) ? prefixes[level] : " ";
fprintf(stderr, "[NOESIS/%s] %s\n", prefix, message);
}
}
void Noesis_Init()
{
//return;
if (!gladLoadGL()) {
assert(false);
}
GUI::Init(nullptr, NoesisLogHandler, nullptr);
GUI::SetXamlProvider(MakePtr<LocalXamlProvider>("czerox/resource/xmls"));
//Noesis::GUI::SetFontProvider(MakePtr<LocalFontProvider>("czerox/resource/fonts"));
//GUI::SetTextureProvider(MakePtr<LocalTextureProvider>("czerox/resource/textures"));
Ptr<FrameworkElement> xaml = GUI::LoadXaml<FrameworkElement>("test.xaml");
view = GUI::CreateView(xaml);
view->SetSize(0, 0);
Ptr<RenderDevice> device = *new GLRenderDevice();
view->GetRenderer()->Init(device);
}
void Noesis_Shutdown()
{
view->GetRenderer()->Shutdown();
view.Reset();
GUI::Shutdown();
}
and where they are called:
// Called when client.dll was loaded
int CL_DLLEXPORT Initialize(cl_enginefunc_t *pEnginefuncs, int iVersion)
{
gEngfuncs = *pEnginefuncs;
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
EV_HookEvents();
CL_LoadParticleMan();
Noesis_Init();
// TODO: Get these values from Lua config file
Noesis_SetViewSize(1440, 900);
// get tracker interface, if any
return 1;
}
/*
Called when the game initializes
and whenever the vid_mode is changed
so the HUD can reinitialize itself.
*/
int CL_DLLEXPORT HUD_VidInit()
{
gHUD.VidInit();
Noesis_SetViewSize(ScreenWidth, ScreenHeight);
VGui_Startup();
return 1;
}
// Called by engine every frame that client .dll is loaded
void CL_DLLEXPORT HUD_Frame(double time)
{
Noesis_Update(time);
ServersThink(time);
GetClientVoiceMgr()->Frame(time);
}
NOTICE:
1.Green panel is built by VGUI (SDK built-in GUI library)
2.Background image was made of 12 slices (12 blocks), and this feature was determined by the Engine.
If I skip some functions by using return(commented in code above):
If I don't skip those functions:
