| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "WindowContextFactory_win.h" | 9 #include "WindowContextFactory_win.h" |
| 10 #include <GL/gl.h> | 10 #include <GL/gl.h> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 RECT rect; | 89 RECT rect; |
| 90 GetClientRect(fHWND, &rect); | 90 GetClientRect(fHWND, &rect); |
| 91 fWidth = rect.right - rect.left; | 91 fWidth = rect.right - rect.left; |
| 92 fHeight = rect.bottom - rect.top; | 92 fHeight = rect.bottom - rect.top; |
| 93 glViewport(0, 0, fWidth, fHeight); | 93 glViewport(0, 0, fWidth, fHeight); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 | 97 |
| 98 void GLWindowContext_win::onDestroyContext() { | 98 void GLWindowContext_win::onDestroyContext() { |
| 99 wglMakeCurrent(wglGetCurrentDC(), NULL); | |
| 100 wglDeleteContext(fHGLRC); | 99 wglDeleteContext(fHGLRC); |
| 101 fHGLRC = NULL; | 100 fHGLRC = NULL; |
| 102 } | 101 } |
| 103 | 102 |
| 104 | 103 |
| 105 void GLWindowContext_win::onSwapBuffers() { | 104 void GLWindowContext_win::onSwapBuffers() { |
| 106 HDC dc = GetDC((HWND)fHWND); | 105 HDC dc = GetDC((HWND)fHWND); |
| 107 SwapBuffers(dc); | 106 SwapBuffers(dc); |
| 108 ReleaseDC((HWND)fHWND, dc); | 107 ReleaseDC((HWND)fHWND, dc); |
| 109 } | 108 } |
| 110 | 109 |
| 111 | 110 |
| 112 } // anonymous namespace | 111 } // anonymous namespace |
| 113 | 112 |
| 114 namespace sk_app { | 113 namespace sk_app { |
| 115 namespace window_context_factory { | 114 namespace window_context_factory { |
| 116 | 115 |
| 117 WindowContext* NewGLForWin(HWND wnd, const DisplayParams& params) { | 116 WindowContext* NewGLForWin(HWND wnd, const DisplayParams& params) { |
| 118 GLWindowContext_win* ctx = new GLWindowContext_win(wnd, params); | 117 GLWindowContext_win* ctx = new GLWindowContext_win(wnd, params); |
| 119 if (!ctx->isValid()) { | 118 if (!ctx->isValid()) { |
| 120 delete ctx; | 119 delete ctx; |
| 121 return nullptr; | 120 return nullptr; |
| 122 } | 121 } |
| 123 return ctx; | 122 return ctx; |
| 124 } | 123 } |
| 125 | 124 |
| 126 } // namespace window_context_factory | 125 } // namespace window_context_factory |
| 127 } // namespace sk_app | 126 } // namespace sk_app |
| OLD | NEW |