本文整理汇总了C++中Window::GetClientSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::GetClientSize方法的具体用法?C++ Window::GetClientSize怎么用?C++ Window::GetClientSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window::GetClientSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
// 初期化。
bool Create(HWND hWnd)
{
if (failed(_window.Create(hWnd)))
{
return false;
}
SIZE sz;
_window.GetClientSize(sz);
{
using namespace std::placeholders;
_window.AddMessageHandler(WM_SIZE, std::bind(&Impl::OnWindowSizeMessage, this, _1, _2, _3, _4));
_window.AddMessageHandler(WM_KEYUP, std::bind(&Impl::OnWindowKeyUpMessage, this, _1, _2, _3, _4));
}
if (failed(_device.Create(hWnd)))
{
return false;
}
if (failed(_renderer.Create(_device)))
{
return false;
}
if (failed(CreateModel()))
{
return false;
}
ResetProjectionTransform(sz);
return true;
}
示例2: main
int main(int argc, char* argv[]) {
// Initialize logger
logFile.open("engine_test.log");
logFilePath = std::experimental::filesystem::current_path();
logFilePath /= "engine_test.log";
cout << "Log files can be found at:\n ";
cout << " " << logFilePath << endl;
if (logFile.is_open()) {
logger.OpenStream(&logFile);
}
else {
logger.OpenStream(&std::cout);
}
// Set exception terminate handler
std::set_terminate(OnTerminate);
// Create the window itself
Window window;
window.SetTitle("QC Simulator");
window.SetSize({ 960, 640 });
// Create GraphicsEngine
systemLogStream.Event("Initializing Graphics Engine...");
std::unique_ptr<IGxapiManager> gxapiMgr;
std::unique_ptr<IGraphicsApi, ReportDeleter> gxapi;
std::unique_ptr<GraphicsEngine> engine;
std::unique_ptr<QCWorld> qcWorld;
std::unique_ptr<InputHandler> inputHandler;
std::unique_ptr<Input> joyInput;
std::unique_ptr<Input> keyboardInput;
try {
// Create manager
systemLogStream.Event("Creating GxApi Manager...");
gxapiMgr.reset(new GxapiManager());
auto adapters = gxapiMgr->EnumerateAdapters();
std::string cardList;
for (auto adapter : adapters) {
cardList += "\n";
cardList += adapter.name;
}
systemLogStream.Event("Available graphics cards:" + cardList);
// Create graphics api
int device = 0;
if (argc == 3 && argv[1] == std::string("--device") && isdigit(argv[2][0])) {
device = argv[2][0] - '0'; // works for single digits, good enough, lol
}
systemLogStream.Event("Creating GraphicsApi...");
gxapi.reset(gxapiMgr->CreateGraphicsApi(adapters[device].adapterId));
std::stringstream ss;
ss << "Using graphics card: " << adapters[device].name;
systemLogStream.Event(ss.str());
// Create graphics engine
systemLogStream.Event("Creating Graphics Engine...");
GraphicsEngineDesc desc;
desc.fullScreen = false;
desc.graphicsApi = gxapi.get();
desc.gxapiManager = gxapiMgr.get();
desc.width = window.GetClientSize().x;
desc.height = window.GetClientSize().y;
desc.targetWindow = window.GetNativeHandle();
desc.logger = &logger;
engine.reset(new GraphicsEngine(desc));
// Load graphics pipeline
std::string pipelineFileName = SelectPipeline(gxapi.get());
std::string exeDir = System::GetExecutableDir();
std::ifstream pipelineFile(INL_PIPELINE_DIRECTORY "\\" + pipelineFileName);
if (!pipelineFile.is_open()) {
throw FileNotFoundException("Failed to open pipeline JSON.");
}
std::string pipelineDesc((std::istreambuf_iterator<char>(pipelineFile)), std::istreambuf_iterator<char>());
engine->LoadPipeline(pipelineDesc);
// Create mini world
qcWorld.reset(new QCWorld(engine.get()));
// Create input handling
inputHandler = std::make_unique<InputHandler>(qcWorld.get());
window.OnResize += Delegate<void(ResizeEvent)>{ &InputHandler::OnResize, inputHandler.get() };
auto joysticks = Input::GetDeviceList(eInputSourceType::JOYSTICK);
if (!joysticks.empty()) {
joyInput = std::make_unique<Input>(joysticks.front().id);
joyInput->SetQueueMode(eInputQueueMode::QUEUED);
joyInput->OnJoystickMove += Delegate<void(JoystickMoveEvent)>{ &InputHandler::OnJoystickMove, inputHandler.get() };
//.........这里部分代码省略.........
示例3: OnResizeWindow
void OnResizeWindow( const Window& pWindow )
{
mRenderWindow->Resize( pWindow.GetClientSize().x, pWindow.GetClientSize().y );
}