Skip to content

Commit

Permalink
Setting the window title of JoltViewer and Samples (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouwe authored Jan 12, 2025
1 parent e030a57 commit fad9c7f
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion JoltViewer/JoltViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ JPH_GCC_SUPPRESS_WARNING("-Wswitch")
#endif

JoltViewer::JoltViewer(const String &inCommandLine) :
Application(inCommandLine)
Application("Jolt Viewer", inCommandLine)
{
// Get file name from command line
Array<String> args;
Expand Down
2 changes: 1 addition & 1 deletion Samples/SamplesApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ static constexpr uint cMaxBodyPairs = 65536;
static constexpr uint cMaxContactConstraints = 20480;

SamplesApp::SamplesApp(const String &inCommandLine) :
Application(inCommandLine)
Application("Jolt Physics Samples", inCommandLine)
{
// Limit the render frequency to our simulation frequency so we don't play back the simulation too fast
// Note that if the simulation frequency > vsync frequency the simulation will slow down as we want
Expand Down
4 changes: 2 additions & 2 deletions TestFramework/Application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
JPH_GCC_SUPPRESS_WARNING("-Wswitch")

// Constructor
Application::Application([[maybe_unused]] const String &inCommandLine) :
Application::Application(const char *inApplicationName, [[maybe_unused]] const String &inCommandLine) :
mDebugRenderer(nullptr),
mRenderer(nullptr),
mKeyboard(nullptr),
Expand Down Expand Up @@ -76,7 +76,7 @@ Application::Application([[maybe_unused]] const String &inCommandLine) :
#else
#error No window defined
#endif
mWindow->Initialize();
mWindow->Initialize(inApplicationName);

// Create renderer
mRenderer = Renderer::sCreate();
Expand Down
2 changes: 1 addition & 1 deletion TestFramework/Application/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Application

public:
/// Constructor
Application(const String &inCommandLine);
Application(const char *inApplicationName, const String &inCommandLine);
virtual ~Application();

/// Create a single string command line
Expand Down
2 changes: 1 addition & 1 deletion TestFramework/Window/ApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApplicationWindow
virtual ~ApplicationWindow() = default;

/// Initialize the window
virtual void Initialize() = 0;
virtual void Initialize(const char *inTitle) = 0;

/// Get window size
int GetWindowWidth() { return mWindowWidth; }
Expand Down
4 changes: 2 additions & 2 deletions TestFramework/Window/ApplicationWindowLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <Window/ApplicationWindowLinux.h>
#include <Utils/Log.h>

void ApplicationWindowLinux::Initialize()
void ApplicationWindowLinux::Initialize(const char *inTitle)
{
// Open connection to X server
mDisplay = XOpenDisplay(nullptr);
Expand All @@ -22,7 +22,7 @@ void ApplicationWindowLinux::Initialize()
XSelectInput(mDisplay, mWindow, ExposureMask | StructureNotifyMask | KeyPressMask);

// Set window title
XStoreName(mDisplay, mWindow, "TestFramework");
XStoreName(mDisplay, mWindow, inTitle);

// Register WM_DELETE_WINDOW to handle the close button
mWmDeleteWindow = XInternAtom(mDisplay, "WM_DELETE_WINDOW", false);
Expand Down
2 changes: 1 addition & 1 deletion TestFramework/Window/ApplicationWindowLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ApplicationWindowLinux : public ApplicationWindow
{
public:
/// Initialize the window
virtual void Initialize() override;
virtual void Initialize(const char *inTitle) override;

/// Access to the window handle
Display * GetDisplay() const { return mDisplay; }
Expand Down
2 changes: 1 addition & 1 deletion TestFramework/Window/ApplicationWindowMacOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ApplicationWindowMacOS : public ApplicationWindow
virtual ~ApplicationWindowMacOS() override;

/// Initialize the window
virtual void Initialize() override;
virtual void Initialize(const char *inTitle) override;

/// Access to the metal objects
MTKView * GetMetalView() const { return mMetalView; }
Expand Down
4 changes: 2 additions & 2 deletions TestFramework/Window/ApplicationWindowMacOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
[mMetalView release];
}

void ApplicationWindowMacOS::Initialize()
void ApplicationWindowMacOS::Initialize(const char *inTitle)
{
// Create metal view
MetalView *view = [[MetalView alloc] init: this];
Expand All @@ -110,7 +110,7 @@ -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
defer: NO];
window.contentView = view;
[window setAcceptsMouseMovedEvents: YES];
[window setTitle: @"TestFramework"];
[window setTitle: [NSString stringWithCString: inTitle encoding: NSUTF8StringEncoding]];
[window makeKeyAndOrderFront: nil];
}

Expand Down
4 changes: 2 additions & 2 deletions TestFramework/Window/ApplicationWindowWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
return 0;
}

void ApplicationWindowWin::Initialize()
void ApplicationWindowWin::Initialize(const char *inTitle)
{
// Prevent this window from auto scaling
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
Expand All @@ -70,7 +70,7 @@ void ApplicationWindowWin::Initialize()
// Create window
RECT rc = { 0, 0, mWindowWidth, mWindowHeight };
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
mhWnd = CreateWindow(TEXT("TestFrameworkClass"), TEXT("TestFramework"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
mhWnd = CreateWindow(TEXT("TestFrameworkClass"), inTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, wcex.hInstance, nullptr);
if (!mhWnd)
FatalError("Failed to create window");
Expand Down
2 changes: 1 addition & 1 deletion TestFramework/Window/ApplicationWindowWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ApplicationWindowWin : public ApplicationWindow
{
public:
/// Initialize the window
virtual void Initialize() override;
virtual void Initialize(const char *inTitle) override;

/// Access to the window handle
HWND GetWindowHandle() const { return mhWnd; }
Expand Down

0 comments on commit fad9c7f

Please sign in to comment.