void CMMADisplay::SetWindowResources(QWidget* qtWidget)
{
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources +");
    CCoeControl* control = 0;
    if (qtWidget && qtWidget ->winId())
    {
        control = reinterpret_cast<CCoeControl*>(qtWidget->winId());
    }

    CCoeEnv *coeEnv = control->ControlEnv();
    RWsSession * iWs = &(coeEnv->WsSession());
    CWsScreenDevice* iScreenDevice = coeEnv->ScreenDevice();
    RWindowBase* window = static_cast<RWindowBase*>(control->DrawableWindow());
    if (!iWindow)
    {
        return;
    }
    iWindow->ProcureWindowResourcesFromQWidget(iWs,iScreenDevice,window);
    iWindow->SetVisible(ETrue,ETrue);
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources -");
}
Example #2
0
// -----------------------------------------------------------------------------
// CGameController::ConstructL
// Second phase constructor.
// Initializes EGL.
// -----------------------------------------------------------------------------
//
void CGameController::ConstructL()
{    
    CCoeEnv* env = CCoeEnv::Static();
    if( !env )
    {
        User::Leave( KErrCoeEnvNotInitialized );
    }

    // Get the Windows Server Session, screen device and window group.
    iWsSession = env->WsSession();
    iWsScreenDevice = env->ScreenDevice();
    iWindowGroup = env->RootWin();
    if( !iWsScreenDevice )
    {
        User::Leave( KErrCoeEnvNotInitialized );
    }

    // Intializes iWindow to a full screen window.
    CreateNativeWindowL();
    
    // Choose the buffer size based on the Window's display mode.
    TDisplayMode displayMode = iWindow->DisplayMode();
    TInt bufferSize = 0;

    switch( displayMode )
    {
        case(EColor4K):
            bufferSize = 12;
            break;
        case(EColor64K):
            bufferSize = 16;
            break;
        case(EColor16M):
            bufferSize = 24;
            break;
        case(EColor16MU):
	    case(EColor16MA):
            bufferSize = 32;
            break;
        default:
            break;
    }
             
    // Set the desired properties for the EGLSurface
    const EGLint attributeList[] = { 
                                     EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 
                                     EGL_BUFFER_SIZE, bufferSize, 
                                     EGL_NONE 
                                   };
    EGLConfig bestConfig;
    EGLint numConfigs = 0;

    // Choose the best EGLConfig that matches the desired properties. 
    if( eglChooseConfig( iEglDisplay, attributeList, &bestConfig,
                          1, &numConfigs
                        ) == EGL_FALSE
      )
    {
        User::Leave( KErrConfigFailed );
    }
    
    if( numConfigs == 0 )
    {
    	User::Leave( KErrConfigFailed );
    }
        
    // Create a window surface where the graphics are blitted.
    // Pass the Native Window handle to egl.
    iEglSurface = eglCreateWindowSurface( iEglDisplay, bestConfig, 
                                          (void*)iWindow, NULL 
                                        );
    if( iEglSurface == NULL )
    {
        User::Leave( KErrCreateWindowSurfaceFailed );
    }
        
    // Create a rendering context
    iEglContext = eglCreateContext( iEglDisplay, bestConfig,
                                    EGL_NO_CONTEXT, NULL 
                                  );
    if( iEglContext == NULL )
    {
        User::Leave( KErrCreateContextFailed );    
    }
    
    // Make it the current context.
    if( eglMakeCurrent( iEglDisplay, iEglSurface, 
                         iEglSurface, iEglContext 
                      ) == EGL_FALSE
      )
    {
        User::Leave( KErrSetContextFailed );        
    }
    
    // Creates the Active Object that waits for Windows Server events.
    iWsEventReceiver = CWsEventReceiver::NewL( *this );
}