Ejemplo n.º 1
0
void Win32Window::reposition(int top, int left)
{	
	if (mHWnd && !mIsFullScreen)
	{
		SetWindowPos(mHWnd, 0, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

		windowMovedOrResized();
	}
}
Ejemplo n.º 2
0
 void AndroidEGLWindow::_createInternalResources(NativeWindowType window, AConfiguration* config)
 {
     mWindow = window;
     
     int minAttribs[] = {
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
         EGL_BUFFER_SIZE, 16,
         EGL_DEPTH_SIZE, 16,
         EGL_NONE
     };
     
     int maxAttribs[] = {
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
         EGL_BUFFER_SIZE, mMaxBufferSize,
         EGL_DEPTH_SIZE, mMaxDepthSize,
         EGL_STENCIL_SIZE, mMaxStencilSize,
         EGL_NONE
     };
     
     mEglDisplay = mGLSupport->getGLDisplay();
     mEglConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs);
     
     EGLint format;
     eglGetConfigAttrib(mEglDisplay, mEglConfig, EGL_NATIVE_VISUAL_ID, &format);
     EGL_CHECK_ERROR
     
     ANativeWindow_setBuffersGeometry(mWindow, 0, 0, format);
     
     mEglSurface = createSurfaceFromWindow(mEglDisplay, mWindow);
     
     if(config)
     {
         bool isLandscape = (int)AConfiguration_getOrientation(config) == 2;
         mGLSupport->setConfigOption("Orientation", isLandscape ? "Landscape" : "Portrait");
     }
     
     eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, (EGLint*)&mWidth);
     eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, (EGLint*)&mHeight);
     EGL_CHECK_ERROR
     
     if(mContext)
     {
         mActive = true;
         mVisible = true;
         mClosed = false;
         
         mContext->_createInternalResources(mEglDisplay, mEglConfig, mEglSurface, NULL);
         mContext->setCurrent();
         
         windowMovedOrResized();
         static_cast<GLESRenderSystem*>(Ogre::Root::getSingletonPtr()->getRenderSystem())->resetRenderer(this);
     }
 }
Ejemplo n.º 3
0
void Win32Window::resize(unsigned int width, unsigned int height)
{	
	if (mHWnd && !mIsFullScreen)
	{
		RECT rc = { 0, 0, width, height };
		AdjustWindowRect(&rc, GetWindowLong(mHWnd, GWL_STYLE), false);
		width = rc.right - rc.left;
		height = rc.bottom - rc.top;
		SetWindowPos(mHWnd, 0, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);

		windowMovedOrResized();
	}
}
Ejemplo n.º 4
0
void Win32Window::setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
{
	if (mIsFullScreen != fullScreen || mWidth != width || mHeight != height)
	{
		mIsFullScreen = fullScreen;
		DWORD dwStyle = WS_VISIBLE | WS_CLIPCHILDREN;

		if (mIsFullScreen)
		{
			dwStyle |= WS_POPUP;

			DEVMODE dm;
			dm.dmSize = sizeof(DEVMODE);
			dm.dmBitsPerPel = mColorDepth;
			dm.dmPelsWidth = width;
			dm.dmPelsHeight = height;
			dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
			if (mDisplayFrequency)
			{
				dm.dmDisplayFrequency = mDisplayFrequency;
				dm.dmFields |= DM_DISPLAYFREQUENCY;
				if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN | CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
				{
					MessageBox(nullptr, "ChangeDisplaySettings with user display frequency failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
					dm.dmFields ^= DM_DISPLAYFREQUENCY;
				}
			}
			else
			{
				// try a few
				dm.dmDisplayFrequency = 100;
				dm.dmFields |= DM_DISPLAYFREQUENCY;
				if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN | CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
				{
					dm.dmDisplayFrequency = 75;
					if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN | CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
					{
						dm.dmFields ^= DM_DISPLAYFREQUENCY;
					}
				}

			}
			if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
				MessageBox(nullptr, "ChangeDisplaySettings failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION);

			SetWindowLong(mHWnd, GWL_STYLE, dwStyle);
			SetWindowPos(mHWnd, HWND_TOPMOST, 0, 0, width, height,
				SWP_NOACTIVATE);
			mWidth = width;
			mHeight = height;
		}
		else
		{
			dwStyle |= WS_OVERLAPPEDWINDOW;

			// drop out of fullscreen
			ChangeDisplaySettings(nullptr, 0);

			// calculate overall dimensions for requested client area
			RECT rc = { 0, 0, width, height };
			AdjustWindowRect(&rc, dwStyle, false);
			unsigned int winWidth = rc.right - rc.left;
			unsigned int winHeight = rc.bottom - rc.top;

			int screenw = GetSystemMetrics(SM_CXSCREEN);
			int screenh = GetSystemMetrics(SM_CYSCREEN);
			int left = (screenw - winWidth) / 2;
			int top = (screenh - winHeight) / 2;

			SetWindowLong(mHWnd, GWL_STYLE, dwStyle);
			SetWindowPos(mHWnd, HWND_NOTOPMOST, left, top, winWidth, winHeight,
				SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOACTIVATE);
			mWidth = width;
			mHeight = height;

			windowMovedOrResized();
		}
	}
}
    void AndroidEGLWindow::_createInternalResources(NativeWindowType window, AConfiguration* config)
    {
        mWindow = window;
        
        int minAttribs[] = {
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_BUFFER_SIZE, mMinBufferSize,
            EGL_DEPTH_SIZE, 16,
            EGL_NONE
        };
        
        int maxAttribs[] = {
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
			EGL_BUFFER_SIZE, mMaxBufferSize,
            EGL_DEPTH_SIZE, mMaxDepthSize,
            EGL_STENCIL_SIZE, mMaxStencilSize,
            EGL_NONE
        };

		bool bAASuccess = false;
		if (mCSAA)
		{
			try
			{
				int CSAAminAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMinBufferSize,
					EGL_DEPTH_SIZE, 16,
					EGL_COVERAGE_BUFFERS_NV, 1,
					EGL_COVERAGE_SAMPLES_NV, mCSAA,
					EGL_NONE
				};
				int CSAAmaxAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMaxBufferSize,
					EGL_DEPTH_SIZE, mMaxDepthSize,
					EGL_STENCIL_SIZE, mMaxStencilSize,
					EGL_COVERAGE_BUFFERS_NV, 1,
					EGL_COVERAGE_SAMPLES_NV, mCSAA,
					EGL_NONE
				};
				mEglConfig = mGLSupport->selectGLConfig(CSAAminAttribs, CSAAmaxAttribs);
				bAASuccess = true;
			}
			catch (Exception& e)
			{
				LogManager::getSingleton().logMessage("AndroidEGLWindow::_createInternalResources: setting CSAA failed");
			}
		}

		if (mMSAA && !bAASuccess)
		{
			try
			{
				int MSAAminAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMinBufferSize,
					EGL_DEPTH_SIZE, 16,
					EGL_SAMPLE_BUFFERS, 1,
					EGL_SAMPLES, mMSAA,
					EGL_NONE
				};
				int MSAAmaxAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMaxBufferSize,
					EGL_DEPTH_SIZE, mMaxDepthSize,
					EGL_STENCIL_SIZE, mMaxStencilSize,
					EGL_SAMPLE_BUFFERS, 1,
					EGL_SAMPLES, mMSAA,
					EGL_NONE
				};
				mEglConfig = mGLSupport->selectGLConfig(MSAAminAttribs, MSAAmaxAttribs);
				bAASuccess = true;
			}
			catch (Exception& e)
			{
				LogManager::getSingleton().logMessage("AndroidEGLWindow::_createInternalResources: setting MSAA failed");
			}
		}
        
        mEglDisplay = mGLSupport->getGLDisplay();
        if (!bAASuccess) mEglConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs);
        
        EGLint format;
        eglGetConfigAttrib(mEglDisplay, mEglConfig, EGL_NATIVE_VISUAL_ID, &format);
        EGL_CHECK_ERROR
        
        ANativeWindow_setBuffersGeometry(mWindow, 0, 0, format);
        
        mEglSurface = createSurfaceFromWindow(mEglDisplay, mWindow);
        
        if(config)
        {
            bool isLandscape = (int)AConfiguration_getOrientation(config) == 2;
            mGLSupport->setConfigOption("Orientation", isLandscape ? "Landscape" : "Portrait");
        }
        
        if(mContext)
        {
            mActive = true;
            mVisible = true;
            mClosed = false;
            
            mContext->_createInternalResources(mEglDisplay, mEglConfig, mEglSurface, NULL);
            mContext->setCurrent();
            
            windowMovedOrResized();
            static_cast<GLES2RenderSystem*>(Ogre::Root::getSingletonPtr()->getRenderSystem())->resetRenderer(this);
        }
    }