Rise
The Vieneo Province
Loading...
Searching...
No Matches
Window11.h
Go to the documentation of this file.
1#pragma once
2#include "DrawContext11.h"
3#include <functional>
4
5namespace Rendering
6{
8 {
9 HINSTANCE instance=nullptr;
10 std::wstring title=L"Rise: The Vieneo Province";
11 UINT width=1280,height=720,samples=1;
12 bool debugLayer=false,warp=false,visible=true;
13 bool borderless=false,centered=false;
14 bool vsync=true;
15 };
16 // The game owns its callbacks and data. This host owns Win32, presentation,
17 // resize/minimize and device recreation without a DXUT message loop.
19 {
20 public:
21 struct Callbacks
22 {
23 std::function<HRESULT()> create;
24 std::function<HRESULT(UINT,UINT)> resize;
25 std::function<void()> releaseSizeDependent;
26 std::function<void()> destroy;
27 // Called only after a successful, visible presentation.
28 std::function<HRESULT()> presented;
29 std::function<void(double,float)> move;
30 std::function<HRESULT(double,float)> draw;
31 std::function<LRESULT(HWND,UINT,WPARAM,LPARAM,bool&)> message;
32 std::function<void(UINT,bool,bool)> keyboard;
33 std::function<void(const std::string&,HRESULT)> report;
34 };
36 int Run();
37 HRESULT Frame();
38 HRESULT Resize(UINT width,UINT height);
40 HRESULT SetFullscreen(bool value);
41 HRESULT SetSamples(UINT samples);
42 void SetVSync(bool value){options.vsync=value;}
43 bool VSync() const {return options.vsync;}
44 void Close(int result=0);
45 // Detach game callbacks while retaining the device for remaining
46 // game-owned resources. Destroy completes device teardown afterward.
48 void Destroy();
50 HWND Handle() const {return window;}
51 Device11& Device() {return device;}
53 bool Fullscreen() const {return fullscreen;}
54 bool Recovering() const {return recovering;}
55 bool Suspended() const {return minimized || device.Suspended();}
56 double Time() const;
57 void ResetFrameClock(){QueryPerformanceCounter(&previous);}
58 void ResetClock(){QueryPerformanceCounter(&started);previous=started;fpsStart=0;frames=0;fps=0;}
59 float FPS() const {return fps;}
60 const std::string& Status() const {return status;}
61 private:
62 static LRESULT CALLBACK Procedure(HWND,UINT,WPARAM,LPARAM);
63 LRESULT Message(HWND,UINT,WPARAM,LPARAM);
65 HRESULT Failure(const char* operation,HRESULT result);
68 HWND window=nullptr;
71 LARGE_INTEGER frequency{},started{},previous{};
72 double fpsStart=0;
73 unsigned frames=0;
74 float fps=0;
75 UINT width=0,height=0;
76 int exitCode=0;
77 bool initialized=false,running=false,minimized=false,fullscreen=false,creating=false,inFrame=false,occluded=false;
78 bool callbacksLive=false,recovering=false;
79 std::string status;
80 };
81}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
bool Suspended() const
Definition Device11.h:73
double Time() const
Definition Window11.cpp:19
LARGE_INTEGER started
Definition Window11.h:71
HRESULT Failure(const char *operation, HRESULT result)
Definition Window11.cpp:13
DrawContext11 & Draws()
Definition Window11.h:52
bool Recovering() const
Definition Window11.h:54
void StopCallbacksAndWindow()
Definition Window11.cpp:220
bool Fullscreen() const
Definition Window11.h:53
HRESULT Create(const WindowOptions11 &options, Callbacks callbacks)
Definition Window11.cpp:24
DrawContext11 draws
Definition Window11.h:70
HRESULT SetSamples(UINT samples)
Definition Window11.cpp:90
WindowOptions11 options
Definition Window11.h:66
void SetVSync(bool value)
Definition Window11.h:42
HRESULT Resize(UINT width, UINT height)
Definition Window11.cpp:74
float FPS() const
Definition Window11.h:59
HWND Handle() const
Definition Window11.h:50
bool VSync() const
Definition Window11.h:43
static LRESULT CALLBACK Procedure(HWND, UINT, WPARAM, LPARAM)
Definition Window11.cpp:238
const std::string & Status() const
Definition Window11.h:60
std::string status
Definition Window11.h:79
bool Suspended() const
Definition Window11.h:55
LARGE_INTEGER previous
Definition Window11.h:71
Callbacks callbacks
Definition Window11.h:67
LARGE_INTEGER frequency
Definition Window11.h:71
void ResetFrameClock()
Definition Window11.h:57
HRESULT SetFullscreen(bool value)
Definition Window11.cpp:120
Device11 & Device()
Definition Window11.h:51
HRESULT CreateDevice()
Definition Window11.cpp:61
HRESULT RecreateDevice()
Definition Window11.cpp:105
void Close(int result=0)
Definition Window11.cpp:216
typedef void(S_CALLTYPE *SteamAPIWarningMessageHook_t)(int
std::function< HRESULT(UINT, UINT)> resize
Definition Window11.h:24
std::function< void()> destroy
Definition Window11.h:26
std::function< void(double, float)> move
Definition Window11.h:29
std::function< LRESULT(HWND, UINT, WPARAM, LPARAM, bool &)> message
Definition Window11.h:31
std::function< HRESULT()> presented
Definition Window11.h:28
std::function< void(const std::string &, HRESULT)> report
Definition Window11.h:33
std::function< HRESULT()> create
Definition Window11.h:23
std::function< void(UINT, bool, bool)> keyboard
Definition Window11.h:32
std::function< void()> releaseSizeDependent
Definition Window11.h:25
std::function< HRESULT(double, float)> draw
Definition Window11.h:30