Initial directx example.
This commit is contained in:
parent
1dfbcc61c4
commit
92d1f24613
28 changed files with 683 additions and 212 deletions
|
@ -1,33 +1,40 @@
|
|||
#include "Win32Window.h"
|
||||
|
||||
#include "Win32WindowInterface.h"
|
||||
#include "Win32DxInterface.h"
|
||||
#include "Win32DxWindowInterface.h"
|
||||
|
||||
#include <WinUser.h>
|
||||
#include "FileLogger.h"
|
||||
#include "StringUtils.h"
|
||||
#include "Widget.h"
|
||||
|
||||
#include "ui_events\KeyboardEvent.h"
|
||||
#include "KeyboardEvent.h"
|
||||
#include "DesktopManager.h"
|
||||
|
||||
#include <WinUser.h>
|
||||
|
||||
LRESULT CALLBACK FreeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
Win32Window::Win32Window(mt::Window* window)
|
||||
Win32Window::Win32Window(mt::Window* window, Win32DxInterface* dxInterface)
|
||||
: IPlatformWindow(window)
|
||||
{
|
||||
|
||||
if (dxInterface)
|
||||
{
|
||||
mDxInterface = std::make_unique<Win32DxWindowInterface>(dxInterface);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Win32Window> Win32Window::Create(mt::Window* window)
|
||||
std::unique_ptr<Win32Window> Win32Window::Create(mt::Window* window, Win32DxInterface* dxInterface)
|
||||
{
|
||||
return std::make_unique<Win32Window>(window);
|
||||
return std::make_unique<Win32Window>(window, dxInterface);
|
||||
}
|
||||
|
||||
HWND Win32Window::GetHandle() const
|
||||
HWND Win32Window::getHandle() const
|
||||
{
|
||||
return mHandle;
|
||||
}
|
||||
|
||||
void Win32Window::CreateNative(Win32ApplicationContext* context, DesktopManager* desktopManager)
|
||||
void Win32Window::createNative(Win32ApplicationContext* context, DesktopManager* desktopManager)
|
||||
{
|
||||
mDesktopManager = desktopManager;
|
||||
|
||||
|
@ -45,7 +52,7 @@ void Win32Window::CreateNative(Win32ApplicationContext* context, DesktopManager*
|
|||
mHandle = CreateWindowEx(
|
||||
0, // Optional window styles.
|
||||
CLASS_NAME, // Window class
|
||||
"Media Tool", // Window text
|
||||
"Notes TK", // Window text
|
||||
WS_OVERLAPPEDWINDOW, // Window style
|
||||
|
||||
// Size and position
|
||||
|
@ -95,15 +102,22 @@ LRESULT CALLBACK Win32Window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(mHandle, &ps);
|
||||
if (mDxInterface)
|
||||
{
|
||||
mDxInterface->onRender();
|
||||
}
|
||||
else
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(mHandle, &ps);
|
||||
|
||||
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
|
||||
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
|
||||
|
||||
auto text = L"Hello World";
|
||||
auto val = DrawText(hdc, (LPCSTR)(&text[0]), -1, &ps.rcPaint, 0);
|
||||
auto text = L"Hello World";
|
||||
auto val = DrawText(hdc, (LPCSTR)(&text[0]), -1, &ps.rcPaint, 0);
|
||||
|
||||
EndPaint(mHandle, &ps);
|
||||
EndPaint(mHandle, &ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
return DefWindowProc(mHandle, message, wParam, lParam);
|
||||
|
@ -132,9 +146,17 @@ static LRESULT CALLBACK FreeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
if (window)
|
||||
{
|
||||
window->SetHandle(hwnd);
|
||||
window->setHandle(hwnd);
|
||||
return window->WindowProc(uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void Win32Window::beforePaint(mt::Screen* screen)
|
||||
{
|
||||
if (mDxInterface)
|
||||
{
|
||||
mDxInterface->initialize(mWindow);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue