QPlatformGLContext *QDirectFbWindow::glContext() const { if (!m_context) { IDirectFBSurface *surface; DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&surface); if (result != DFB_OK) { qWarning("could not retrieve surface in QDirectFbWindow::glContext()"); return 0; } IDirectFBGL *gl; result = surface->GetGL(surface,&gl); if (result != DFB_OK) { qWarning("could not retrieve IDirectFBGL in QDirectFbWindow::glContext()"); return 0; } const_cast<QDirectFbWindow *>(this)->m_context = new QDirectFbGLContext(gl); } return m_context; }
int main( int argc, char *argv[] ) { DFBResult ret; int i; int quit = 0; const int num = 2; Context contexts[num]; DFBCHECK(DirectFBInit( &argc, &argv )); /* create the super interface */ DFBCHECK(DirectFBCreate( &dfb )); DFBCHECK(dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer )); /* create the default font */ DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); for (i=0; i<num; i++) { IDirectFBWindow *window; IDirectFBSurface *surface; IDirectFBGL *gl; DFBWindowDescription desc; desc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT; desc.posx = (i%3) * 200 + 10; desc.posy = (i/3) * 200 + 10; desc.width = 180; desc.height = 180; DFBCHECK(layer->CreateWindow( layer, &desc, &window )); DFBCHECK(window->GetSurface( window, &surface )); DFBCHECK(surface->GetGL( surface, &gl )); contexts[i].window = window; contexts[i].surface = surface; contexts[i].gl = gl; contexts[i].last_time = get_millis(); contexts[i].frames = 0; contexts[i].fps = 0; setup( &contexts[i] ); if (events) DFBCHECK(window->AttachEventBuffer( window, events )); else DFBCHECK(window->CreateEventBuffer( window, &events )); DFBCHECK(surface->SetFont( surface, font )); window->SetOpacity( window, 0xff ); } while (!quit) { DFBWindowEvent evt; for (i=0; i<num; i++) update( &contexts[i] ); while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { switch (evt.type) { case DWET_KEYDOWN: switch (evt.key_symbol) { case DIKS_ESCAPE: quit = 1; break; default: break; } break; default: break; } } } events->Release( events ); for (i=0; i<num; i++) { contexts[i].gl->Release( contexts[i].gl ); contexts[i].surface->Release( contexts[i].surface ); contexts[i].window->Release( contexts[i].window ); } font->Release( font ); layer->Release( layer ); dfb->Release( dfb ); return 0; }