void WinWindow::deactivateAll() { for (WinWindow* scan = first; scan; scan = scan->next) { scan->freeContext(); scan->inactiveDueToDeactivateAll = true; } }
Window* windowForHandle(HWND hWnd) {// no ranged for in vs yet for (auto i = begin(windowList); i != end(windowList); i++) { WinWindow *w = *i; if (w->handle() == hWnd) return w; } return nullptr; }
LRESULT CALLBACK _WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { WinWindow* currentWindow = (WinWindow*)Application::Instance().Window(); if (currentWindow->WindowHandle() != hWnd) { return DefWindowProc(hWnd, message, wParam, lParam); } else { return currentWindow->WndProc(message, wParam, lParam); } }
void WinWindow::reactivateAll() { bool anyNewChildren = false; for (WinWindow* scan = first; scan; scan = scan->next) { const bool hadChild = (scan->hDCChild != NULL); scan->inactiveDueToDeactivateAll = false; scan->makeContext(); if (!hadChild && scan->hDCChild != NULL) anyNewChildren = true; } // reload context data if (anyNewChildren) OpenGLGState::initContext(); }
bool WinEGLView::Initialize() { RETURN_FALSE_IF_FALSE(BaseRenderView::Initialize()); MEDUSA_ASSERT_TRUE(mParent->IsA<IWindow>(), ""); WinWindow* window = (WinWindow*)(INode*)mParent; EGLNativeWindowType eglNativeWindow = window->WindowHandle(); mEGLNativeWindow = eglNativeWindow; mEGLNativeDisplay = EGL_DEFAULT_DISPLAY; mEGLDisplay = EGL_NO_DISPLAY; mEGLConfig = 0; mEGLSurface = EGL_NO_SURFACE; mEGLContext = EGL_NO_CONTEXT; mPixmapDisplay = 0; mBitmapPixmap = 0; mBitmapPixmapOld = 0; /* Step 0 - Create a NativeWindowType that we can use for OpenGL ES output */ /* Step 1 - Get the default display. EGL uses the concept of a "display" which in most environments corresponds to a single physical screen. Since we usually want to draw to the main screen or only have a single screen to begin with, we let EGL pick the default display. Querying other displays is platform specific. */ mEGLNativeDisplay = GetDC(mEGLNativeWindow); mEGLDisplay = eglGetDisplay(mEGLNativeDisplay); if (mEGLDisplay == EGL_NO_DISPLAY) { mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); } MEDUSA_ASSERT_NOT_EQUAL(mEGLDisplay, EGL_NO_DISPLAY, ""); if (mIsNeedPixmap) { mPixmapDisplay = CreateCompatibleDC(mEGLNativeDisplay); Size2F screenSize = ResolutionAdapter::Instance().WinSize(); mBitmapPixmap = CreateCompatibleBitmap(mEGLNativeDisplay, (uint)screenSize.Width, (uint)screenSize.Height); } /* Step 2 - Initialize EGL. EGL has to be initialized with the display obtained in the previous step. We cannot use other EGL functions except eglGetDisplay and eglGetError before eglInitialize has been called. If we're not interested in the EGL version number we can just pass nullptr for the second and third parameters. */ EGLint majorVersion, minorVersion; EGLBoolean result = eglInitialize(mEGLDisplay, &majorVersion, &minorVersion); MEDUSA_ASSERT_NOT_ZERO(result, ""); //ASSERT_NOT_EQUAL(majorVersion,1); /* Step 3 - Specify the required configuration attributes. An EGL "configuration" describes the pixel format and type of surfaces that can be used for drawing. For now we just want to use a 16 bit RGB surface that is a Window surface, i.e. it will be visible on screen. The list has to contain key/value pairs, terminated with EGL_NONE. */ eglBindAPI(EGL_OPENGL_ES_API); MEDUSA_ASSERT_FALSE(GetEGLError(), ""); /* Step 4 - Find a config that matches all requirements. eglChooseConfig provides a list of all available configurations that meet or exceed the requirements given as the second argument. In most cases we just want the first config that meets all criteria, so we can limit the number of configs returned to 1. */ mEGLConfig = ChooseConfig(); /* Step 5 - Create a surface to draw to. Use the config picked in the previous step and the native window handle when available to create a window surface. A window surface is one that will be visible on screen inside the native display (or full screen if there is no windowing system). Pixmaps and pbuffers are surfaces which only exist in off-screen memory. */ CreateSurface(); /* Step 6 - Create a context. EGL has to create a context for OpenGL ES. Our OpenGL ES resources like textures will only be valid inside this context (or shared contexts) */ CreateContext(); /* Step 7 - Bind the context to the current thread and use our window surface for drawing and reading. Contexts are bound to a thread. This means you don't have to worry about other threads and processes interfering with your OpenGL ES application. We need to specify a surface that will be the target of all subsequent drawing operations, and one that will be the source of read operations. They can be the same surface. */ //ASSERT_NOT_EQUAL(eglSurface,EGL_NO_SURFACE,0); eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); MEDUSA_ASSERT_FALSE(GetEGLError(), ""); /* Step 8 - Draw something with OpenGL ES. At this point everything is initialized and we're ready to use OpenGL ES to draw something on the screen. */ if (mIsNeedPixmap) { mBitmapPixmapOld = (EGLNativePixmapType)SelectObject(mPixmapDisplay, mBitmapPixmap); } //SetForegroundWindow(mEGLNativeWindow); RenderEngine::Instance().Initialize(); return true; }