- KalenClark
- Posts: 3
- Joined:
How to draw Noesis GUI over SDL2 window?
Currently working on a game mod with HL1 SDK,
I'v been thinking for about a week but just can't figure out how to do that,
please help me
I'v been thinking for about a week but just can't figure out how to do that,
please help me
- KalenClark
- Posts: 3
- Joined:
Re: How to draw Noesis GUI over SDL2 window?
Here's my code about Noesis GUI:
NOTICE: GLRenderDevice's code is from NoesisApp framwork.
and where they are called:
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:
NOTICE: GLRenderDevice's code is from NoesisApp framwork.
Code: Select all
#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();
}
Code: Select all
// 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);
}
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:
Re: How to draw Noesis GUI over SDL2 window?
Not sure we can provide much help here. You probably want to post this in SDL2 or GL generic forums. Our IntegrationGLUT sample is very clear about GL usage.
- KalenClark
- Posts: 3
- Joined:
Re: How to draw Noesis GUI over SDL2 window?
OK, thanks for your reply~Not sure we can provide much help here. You probably want to post this in SDL2 or GL generic forums. Our IntegrationGLUT sample is very clear about GL usage.
Who is online
Users browsing this forum: No registered users and 6 guests