Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/hydra/display_driver.cpp')
-rw-r--r--intern/cycles/hydra/display_driver.cpp74
1 files changed, 49 insertions, 25 deletions
diff --git a/intern/cycles/hydra/display_driver.cpp b/intern/cycles/hydra/display_driver.cpp
index 6f6ca35cd31..a809ace63e2 100644
--- a/intern/cycles/hydra/display_driver.cpp
+++ b/intern/cycles/hydra/display_driver.cpp
@@ -19,44 +19,66 @@ HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesDisplayDriver::HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi)
: _renderParam(renderParam), _hgi(hgi)
{
+}
+
+HdCyclesDisplayDriver::~HdCyclesDisplayDriver()
+{
+ deinit();
+}
+
+void HdCyclesDisplayDriver::init()
+{
#ifdef _WIN32
- hdc_ = GetDC(CreateWindowA("STATIC",
- "HdCycles",
- WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- 0,
- 0,
- 64,
- 64,
- NULL,
- NULL,
- GetModuleHandle(NULL),
- NULL));
-
- int pixelFormat = GetPixelFormat(wglGetCurrentDC());
- PIXELFORMATDESCRIPTOR pfd = {sizeof(pfd)};
- DescribePixelFormat((HDC)hdc_, pixelFormat, sizeof(pfd), &pfd);
- SetPixelFormat((HDC)hdc_, pixelFormat, &pfd);
-
- TF_VERIFY(gl_context_ = wglCreateContext((HDC)hdc_));
- TF_VERIFY(wglShareLists(wglGetCurrentContext(), (HGLRC)gl_context_));
+ if (!gl_context_) {
+ hdc_ = GetDC(CreateWindowA("STATIC",
+ "HdCycles",
+ WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ 0,
+ 0,
+ 64,
+ 64,
+ NULL,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL));
+
+ int pixelFormat = GetPixelFormat(wglGetCurrentDC());
+ PIXELFORMATDESCRIPTOR pfd = {sizeof(pfd)};
+ DescribePixelFormat((HDC)hdc_, pixelFormat, sizeof(pfd), &pfd);
+ SetPixelFormat((HDC)hdc_, pixelFormat, &pfd);
+
+ TF_VERIFY(gl_context_ = wglCreateContext((HDC)hdc_));
+ TF_VERIFY(wglShareLists(wglGetCurrentContext(), (HGLRC)gl_context_));
+ }
+ if (!gl_context_) {
+ return;
+ }
#endif
- glewInit();
+ if (!gl_pbo_id_) {
+ if (glewInit() != GLEW_OK) {
+ return;
+ }
- glGenBuffers(1, &gl_pbo_id_);
+ glGenBuffers(1, &gl_pbo_id_);
+ }
}
-HdCyclesDisplayDriver::~HdCyclesDisplayDriver()
+void HdCyclesDisplayDriver::deinit()
{
if (texture_) {
_hgi->DestroyTexture(&texture_);
}
- glDeleteBuffers(1, &gl_pbo_id_);
+ if (gl_pbo_id_) {
+ glDeleteBuffers(1, &gl_pbo_id_);
+ }
#ifdef _WIN32
- TF_VERIFY(wglDeleteContext((HGLRC)gl_context_));
- DestroyWindow(WindowFromDC((HDC)hdc_));
+ if (gl_context_) {
+ TF_VERIFY(wglDeleteContext((HGLRC)gl_context_));
+ DestroyWindow(WindowFromDC((HDC)hdc_));
+ }
#endif
}
@@ -192,6 +214,8 @@ void HdCyclesDisplayDriver::draw(const Params &params)
return;
}
+ init();
+
// Cycles 'DisplayDriver' only supports 'half4' format
TF_VERIFY(renderBuffer->GetFormat() == HdFormatFloat16Vec4);