| 492 | } |
| 493 | |
| 494 | bool RenderViewImpl::initWithRect(std::string_view viewName, const ax::Rect& rect, float frameZoomFactor, bool resizable) |
| 495 | { |
| 496 | setViewName(viewName); |
| 497 | |
| 498 | _frameZoomFactor = frameZoomFactor; |
| 499 | |
| 500 | Vec2 windowSize = rect.size * frameZoomFactor; |
| 501 | |
| 502 | #if AX_GLES_PROFILE |
| 503 | glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); |
| 504 | glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); |
| 505 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, AX_GLES_PROFILE / AX_GLES_PROFILE_DEN); |
| 506 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); |
| 507 | #elif defined(AX_USE_GL) |
| 508 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // We want OpenGL 3.3 |
| 509 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); |
| 510 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // We don't want the old OpenGL |
| 511 | #endif |
| 512 | |
| 513 | glfwWindowHint(GLFW_RESIZABLE, resizable ? GL_TRUE : GL_FALSE); |
| 514 | glfwWindowHint(GLFW_RED_BITS, _gfxContextAttrs.redBits); |
| 515 | glfwWindowHint(GLFW_GREEN_BITS, _gfxContextAttrs.greenBits); |
| 516 | glfwWindowHint(GLFW_BLUE_BITS, _gfxContextAttrs.blueBits); |
| 517 | glfwWindowHint(GLFW_ALPHA_BITS, _gfxContextAttrs.alphaBits); |
| 518 | glfwWindowHint(GLFW_DEPTH_BITS, _gfxContextAttrs.depthBits); |
| 519 | glfwWindowHint(GLFW_STENCIL_BITS, _gfxContextAttrs.stencilBits); |
| 520 | |
| 521 | glfwWindowHint(GLFW_SAMPLES, _gfxContextAttrs.multisamplingCount); |
| 522 | |
| 523 | glfwWindowHint(GLFW_VISIBLE, _gfxContextAttrs.visible); |
| 524 | glfwWindowHint(GLFW_DECORATED, _gfxContextAttrs.decorated); |
| 525 | |
| 526 | #if defined(AX_USE_METAL) |
| 527 | // Don't create gl context. |
| 528 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 529 | #endif |
| 530 | |
| 531 | #if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) |
| 532 | glfwWindowHintPointer(GLFW_WIN32_HWND_PARENT, _gfxContextAttrs.viewParent); |
| 533 | #endif |
| 534 | |
| 535 | _mainWindow = glfwCreateWindow(static_cast<int>(windowSize.width), static_cast<int>(windowSize.height), |
| 536 | _viewName.c_str(), _monitor, nullptr); |
| 537 | |
| 538 | if (_mainWindow == nullptr) |
| 539 | { |
| 540 | std::string message = "Can't create window"; |
| 541 | if (!_glfwError.empty()) |
| 542 | { |
| 543 | message.append("\nMore info: \n"); |
| 544 | message.append(_glfwError); |
| 545 | } |
| 546 | |
| 547 | showAlert(message, "Error launch application"); |
| 548 | utils::killCurrentProcess(); // kill current process, don't cause crash when driver issue. |
| 549 | return false; |
| 550 | } |
| 551 |
no test coverage detected