void ANGLETest::SetUp() { // Resize the window before creating the context so that the first make current // sets the viewport and scissor box to the right size. bool needSwap = false; if (mOSWindow->getWidth() != mWidth || mOSWindow->getHeight() != mHeight) { if (!mOSWindow->resize(mWidth, mHeight)) { FAIL() << "Failed to resize ANGLE test window."; } needSwap = true; } if (!createEGLContext()) { FAIL() << "egl context creation failed."; } if (needSwap) { // Swap the buffers so that the default framebuffer picks up the resize // which will allow follow-up test code to assume the framebuffer covers // the whole window. swapBuffers(); } // This Viewport command is not strictly necessary but we add it so that programs // taking OpenGL traces can guess the size of the default framebuffer and show it // in their UIs glViewport(0, 0, mWidth, mHeight); const auto &info = testing::UnitTest::GetInstance()->current_test_info(); angle::WriteDebugMessage("Entering %s.%s\n", info->test_case_name(), info->name()); }
void ANGLETest::SetUp() { ReizeWindow(mWidth, mHeight); if (!createEGLContext()) { FAIL() << "egl context creation failed."; } }
void RaspberryPiApplicationRunner::run( Application* application, int argc, char** argv ) { ApplicationContext applicationContext; createEGLContext( applicationContext ); std::vector< std::pair<std::string, std::string> > parameters; parseCommandLineParameters( argc, argv, parameters ); applicationContext.parameters = parameters; const ApplicationContext& ac = applicationContext; printf("ctx:%d disp:%d surf:%d w:%d h:%d\n", (int)ac.context, (int)ac.display, (int)ac.surface, ac.width, ac.height ); if ( application ) { if ( application->initialize( applicationContext ) ) { while ( true ) { application->draw( applicationContext ); usleep( 1 * 1000 ); } } } }
void AndroidEGLWindow::create(const String& name, uint width, uint height, bool fullScreen, const NameValuePairList *miscParams) { mName = name; mWidth = width; mHeight = height; mLeft = 0; mTop = 0; mIsFullScreen = fullScreen; void* eglContext = NULL; AConfiguration* config = NULL; if (miscParams) { NameValuePairList::const_iterator opt; NameValuePairList::const_iterator end = miscParams->end(); if ((opt = miscParams->find("currentGLContext")) != end && StringConverter::parseBool(opt->second)) { eglContext = eglGetCurrentContext(); if (eglContext) { OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "currentGLContext was specified with no current GL context", "EGLWindow::create"); } eglContext = eglGetCurrentContext(); mEglSurface = eglGetCurrentSurface(EGL_DRAW); } if((opt = miscParams->find("externalWindowHandle")) != end) { mWindow = (ANativeWindow*)(Ogre::StringConverter::parseInt(opt->second)); } if((opt = miscParams->find("androidConfig")) != end) { config = (AConfiguration*)(Ogre::StringConverter::parseInt(opt->second)); } int ctxHandle = -1; if((miscParams->find("externalGLContext")) != end) { mIsExternalGLControl = true; ctxHandle = Ogre::StringConverter::parseInt(opt->second); } if((opt = miscParams->find("maxColourBufferSize")) != end) { mMaxBufferSize = Ogre::StringConverter::parseInt(opt->second); } if((opt = miscParams->find("maxDepthBufferSize")) != end) { mMaxDepthSize = Ogre::StringConverter::parseInt(opt->second); } if((opt = miscParams->find("maxStencilBufferSize")) != end) { mMaxStencilSize = Ogre::StringConverter::parseInt(opt->second); } if((opt = miscParams->find("minColourBufferSize")) != end) { mMinBufferSize = Ogre::StringConverter::parseInt(opt->second); if (mMinBufferSize > mMaxBufferSize) mMinBufferSize = mMaxBufferSize; } if((opt = miscParams->find("MSAA")) != end) { mMSAA = Ogre::StringConverter::parseInt(opt->second); } if((opt = miscParams->find("CSAA")) != end) { mCSAA = Ogre::StringConverter::parseInt(opt->second); } } initNativeCreatedWindow(miscParams); if (mEglSurface) { mEglConfig = mGLSupport->getGLConfigFromDrawable (mEglSurface, &width, &height); } if (!mEglConfig && eglContext) { mEglConfig = mGLSupport->getGLConfigFromContext(eglContext); if (!mEglConfig) { // This should never happen. OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unexpected failure to determine a EGLFBConfig", "EGLWindow::create"); } } mIsExternal = (mEglSurface != 0); if (!mEglConfig) { _createInternalResources(mWindow, config); mHwGamma = false; } mContext = createEGLContext(); mContext->setCurrent(); eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, (EGLint*)&mWidth); eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, (EGLint*)&mHeight); EGL_CHECK_ERROR mActive = true; mVisible = true; mClosed = false; }
void Win32EGLWindow::create(const String& name, uint width, uint height, bool fullScreen, const NameValuePairList *miscParams) { String title = name; uint samples = 0; int gamma; short frequency = 0; bool vsync = false; ::EGLContext eglContext = 0; int left = 0; int top = 0; getLeftAndTopFromNativeWindow(left, top, width, height); mIsFullScreen = fullScreen; if (miscParams) { NameValuePairList::const_iterator opt; NameValuePairList::const_iterator end = miscParams->end(); if ((opt = miscParams->find("currentGLContext")) != end && StringConverter::parseBool(opt->second)) { eglContext = eglGetCurrentContext(); if (eglContext) { OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "currentGLContext was specified with no current GL context", "EGLWindow::create"); } eglContext = eglGetCurrentContext(); mEglSurface = eglGetCurrentSurface(EGL_DRAW); } // Note: Some platforms support AA inside ordinary windows if ((opt = miscParams->find("FSAA")) != end) { samples = StringConverter::parseUnsignedInt(opt->second); } if ((opt = miscParams->find("displayFrequency")) != end) { frequency = (short)StringConverter::parseInt(opt->second); } if ((opt = miscParams->find("vsync")) != end) { vsync = StringConverter::parseBool(opt->second); } if ((opt = miscParams->find("gamma")) != end) { gamma = StringConverter::parseBool(opt->second); } if ((opt = miscParams->find("left")) != end) { left = StringConverter::parseInt(opt->second); } if ((opt = miscParams->find("top")) != end) { top = StringConverter::parseInt(opt->second); } if ((opt = miscParams->find("title")) != end) { title = opt->second; } if ((opt = miscParams->find("externalGLControl")) != end) { mIsExternalGLControl = StringConverter::parseBool(opt->second); } } initNativeCreatedWindow(miscParams); if (mEglSurface) { mEglConfig = mGLSupport->getGLConfigFromDrawable (mEglSurface, &width, &height); } if (!mEglConfig && eglContext) { mEglConfig = mGLSupport->getGLConfigFromContext(eglContext); if (!mEglConfig) { // This should never happen. OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unexpected failure to determine a EGLFBConfig", "EGLWindow::create"); } } mIsExternal = (mEglSurface != 0); if (!mEglConfig) { int minAttribs[] = { EGL_LEVEL, 0, EGL_DEPTH_SIZE, 16, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; int maxAttribs[] = { EGL_SAMPLES, samples, EGL_STENCIL_SIZE, INT_MAX, EGL_NONE }; mEglConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs); mHwGamma = false; } if (!mIsTopLevel) { mIsFullScreen = false; left = top = 0; } if (mIsFullScreen) { mGLSupport->switchMode (width, height, frequency); } if (!mIsExternal) { createNativeWindow(left, top, width, height, title); } mContext = createEGLContext(); ::EGLSurface oldDrawableDraw = eglGetCurrentSurface(EGL_DRAW); ::EGLSurface oldDrawableRead = eglGetCurrentSurface(EGL_READ); ::EGLContext oldContext = eglGetCurrentContext(); int glConfigID; mGLSupport->getGLConfigAttrib(mEglConfig, EGL_CONFIG_ID, &glConfigID); LogManager::getSingleton().logMessage("EGLWindow::create used FBConfigID = " + StringConverter::toString(glConfigID)); mName = name; mWidth = width; mHeight = height; mLeft = left; mTop = top; mActive = true; mVisible = true; mClosed = false; }
//================================================================= EGLint GLESWrapper::createWindow() { createWindowX11(); createEGLContext(); }