Example #1
0
void
motion(int x, int y)
{
    Real32 w = win->getWidth(), h = win->getHeight();


    Real32  a = -2. * ( lastx / w - .5 ),
            b = -2. * ( .5 - lasty / h ),
            c = -2. * ( x / w - .5 ),
            d = -2. * ( .5 - y / h );

    if ( mouseb & ( 1 << GLUT_LEFT_BUTTON ) )
    {
        tball.updateRotation( a, b, c, d );
    }
    else if ( mouseb & ( 1 << GLUT_MIDDLE_BUTTON ) )
    {
        tball.updatePosition( a, b, c, d );
    }
    else if ( mouseb & ( 1 << GLUT_RIGHT_BUTTON ) )
    {
        tball.updatePositionNeg( a, b, c, d );
    }
    lastx = x;
    lasty = y;
}
Example #2
0
    void
    Statistic::realize() {
        Transform::realize();
        WindowPtr myWindow = boost::static_pointer_cast<spark::Window>(getRoot());
        StatisticPtr ptr = boost::static_pointer_cast<Statistic>(shared_from_this());
        spark::EventCallbackPtr myFrameCB = EventCallbackPtr(new StatisticCB(ptr, &Statistic::onFrame));
        myWindow->addEventListener(StageEvent::FRAME, myFrameCB);

        int myStatisticHeight = 0;

        ContainerPtr myContainer = boost::static_pointer_cast<spark::Container>(shared_from_this());
        ComponentPtr myCreated = SparkComponentFactory::get().loadSparkComponentsFromString(myContainer->getApp(),
                "<Text name=\"fps\" y=\"-10\" maxWidth=\"0\" z=\"100\" text=\"fps:\" height=\"-16\" color=\"[1.0,0.0,0.0, 1.0]\" fontsize=\"16\"/>");
        myContainer->addChild(myCreated);
        _myFPSText = boost::static_pointer_cast<spark::Text>(myCreated);

        myCreated = SparkComponentFactory::get().loadSparkComponentsFromString(myContainer->getApp(),
                "<Text name=\"memory_usage\" y=\"-30\" z=\"100\" maxWidth=\"0\" text=\"memory:\" height=\"-16\" color=\"[1.0,0.0,0.0, 1.0]\" fontsize=\"16\"/>");
        myContainer->addChild(myCreated);
        _myMemoryText = boost::static_pointer_cast<spark::Text>(myCreated);

        myStatisticHeight += _myFPSText->getTextSize()[1];

        myCreated = SparkComponentFactory::get().loadSparkComponentsFromString(myContainer->getApp(),
                                                                               "<Text name=\"battery_level\" y=\"-50\" z=\"100\" maxWidth=\"0\" text=\"memory:\" height=\"-16\" color=\"[1.0,0.0,0.0, 1.0]\" fontsize=\"16\"/>");
        myContainer->addChild(myCreated);
        _myBatteryLevelText = boost::static_pointer_cast<spark::Text>(myCreated);
        
        myStatisticHeight += _myFPSText->getTextSize()[1];
        
        setY(myWindow->getSize()[1] - myStatisticHeight);
        setX(10);
    }
Example #3
0
void Canvas::renderWindow(WindowPtr pWindow, MCFBOPtr pFBO, const IntRect& viewport)
{
    GLContext* pContext = pWindow->getGLContext();
    pContext->activate();

    GLContextManager::get()->uploadDataForContext();
    renderFX(pContext);
    glm::mat4 projMat;
    if (pFBO) {
        pFBO->activate(pContext);
        glm::vec2 size = m_pRootNode->getSize();
        projMat = glm::ortho(0.f, size.x, 0.f, size.y);
        glViewport(0, 0, GLsizei(size.x), GLsizei(size.y));
    } else {
        glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
        projMat = glm::ortho(float(viewport.tl.x), float(viewport.br.x), 
                float(viewport.br.y), float(viewport.tl.y));
        IntPoint windowSize = pWindow->getSize();
        glViewport(0, 0, windowSize.x, windowSize.y);
    }
    {
        ScopeTimer Timer(VATransferProfilingZone);
        m_pVertexArray->update(pContext);
    }
    clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
            !pFBO);
    GLContext::checkError("Canvas::renderWindow: glViewport()");
    m_pVertexArray->activate(pContext);
    {
        ScopeTimer timer(RootRenderProfilingZone);
        m_pRootNode->maybeRender(pContext, projMat);
    }
    renderOutlines(pContext, projMat);
}
Example #4
0
int main(int argc, char** argv)
{
    css::CSSStyleSheet defaultStyleSheet;
    Document document;

    // Load the default CSS file
    if (1 < argc) {
        std::ifstream stream(argv[1]);
        if (!stream) {
            std::cerr << "error: cannot open " << argv[1] << ".\n";
            return EXIT_FAILURE;
        }
        defaultStyleSheet = loadStyleSheet(stream);
        getDOMImplementation()->setDefaultStyleSheet(defaultStyleSheet);
    }

    document = loadDocument(htmlDocument);
    assert(document);

    // create the default view
    WindowPtr window = std::make_shared<WindowImp>();
    window->setDocument(std::static_pointer_cast<bootstrap::DocumentImp>(document.self()));
    ViewCSSImp* view = new ViewCSSImp(window);
    view->constructComputedStyles();
    view->calculateComputedStyles();
    printComputedValues(document, view);

    std::cout << "done.\n";
    return 0;
}
Example #5
0
void 
display(void)
{
	Matrix m1, m2;

	m1.setRotate( tball.getRotation() );
	m2.setTranslate( tball.getPosition() );
	
	m1.mult( m2 );
	cam_trans->editSFMatrix()->setValue( m1 );


    // move the object
    
    float t = glutGet(GLUT_ELAPSED_TIME);
    Quaternion q;
    
    q.setValueAsAxisDeg(0, 1, 0, t / 5000);
    
    m1.setTransform(Vec3f(osgsin(t / 500.), 0, osgcos(t / 500)), q);
                    
    tr->setMatrix(m1);
    
	if ( doRender )
		win->render( ract );
	else
		win->draw( dact );
}
Example #6
0
	TexturePtr LinearGradient::createAsTexture(int width, int height)
	{
		const float w = static_cast<float>(width);
		const float h = static_cast<float>(height);
		
		const float sa = std::abs(std::sin(-angle_ / 180.0f * static_cast<float>(M_PI)));
		const float ca = std::abs(std::cos(-angle_ / 180.0f * static_cast<float>(M_PI)));
		//const float length = std::min(ca < FLT_EPSILON ? FLT_MAX : width / ca, sa < FLT_EPSILON ? FLT_MAX : height / sa);
		//const float length = std::min(ca < FLT_EPSILON ? w : 2.0f * ca * w, sa < FLT_EPSILON ? h : 2.0f * sa * h);

		WindowPtr wnd = WindowManager::getMainWindow();
		CameraPtr cam = std::make_shared<Camera>("ortho_lg", 0, width, 0, height);
		auto grad = createRenderable();
		grad->setCamera(cam);
		grad->setScale(ca < FLT_EPSILON ? w : 2.0f * w / ca, sa < FLT_EPSILON ? h : 2.0f * h / sa);
		grad->setPosition(w/2.0f, h/2.0f);


		RenderTargetPtr rt = RenderTarget::create(width, height);
		rt->getTexture()->setFiltering(-1, Texture::Filtering::LINEAR, Texture::Filtering::LINEAR, Texture::Filtering::POINT);
		rt->getTexture()->setAddressModes(-1, Texture::AddressMode::CLAMP, Texture::AddressMode::CLAMP);
		rt->setCentre(Blittable::Centre::TOP_LEFT);
		rt->setClearColor(Color(0,0,0,0));
		{
			RenderTarget::RenderScope rs(rt, rect(0, 0, width, height));
			grad->preRender(wnd);
			wnd->render(grad.get());
		}
		return rt->getTexture();
	}
Example #7
0
void
SpinnerDialog::set_busy(bool busy) throw()
{
    WindowPtr window = get_window();

    if (0 == window)
    {
        return;
    }

    switch (busy)
    {
        case true:
        {
            Gdk::Cursor cursor(Gdk::WATCH);
            window->set_cursor(cursor);
            spinner_.start();
            break;
        }

        case false:
        {
            window->set_cursor();
            spinner_.stop();
            break;
        }
    }
}
Example #8
0
    Window2D::Window2D(WindowPtr ptr) : _ptr(ptr)
    {
        _rend = SDL_CreateRenderer(_ptr->getSDLWindow(), -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
        Image img(glm::ivec2(ptr->getWidth(), ptr->getHeight()));
        SDL_SetRenderDrawColor(_rend, 0, 255, 255, 255);
        SDL_RenderClear(_rend);

    }
Example #9
0
 bool WindowManager::windowDestroyed(WindowPtr window)
 {
   if(mWindows.count(window->getName()) > 0) {
     fireWindowEvent(WindowEvent::CLOSE, window->getWindowHandle());
     mWindows.erase(window->getName());
     return true;
   }
   return false;
 }
	void WindowManager::createWindow(WindowPtr wnd)
	{
		wnd->createWindow();

		// Add a weak_ptr to our window to the list of id versus windows.
		get_window_list()[wnd->getWindowID()] = wnd;
		// We consider the first window created the main one.
		if(get_main_window().lock() == nullptr) {
			get_main_window() = wnd;
		}
	}
void
display(void)
{
    float t = glutGet( GLUT_ELAPSED_TIME );

    win->frameInit();

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    Matrix m;
    Quaternion q;
    q.setValueAsAxisDeg( 0,1,0, -t/20 );
    m.setRotate( q );
    tchunk1->setMatrix( m );

    tchunk1->activate( dact );
    mchunk1->activate( dact );

    glCallList( dlid );

    m.setIdentity();
    m.setTranslate( cos(t/1000), 0, sin(t/1000) );
    tchunk2->setMatrix( m );


    tchunk2->changeFrom( dact, get_pointer(tchunk1));
    mchunk2->changeFrom( dact, get_pointer(mchunk1));
    blchunk->activate( dact );
    blchunk->activate( dact );
    cchunk1->activate( dact );
    gchunk1->activate( dact );

    glCallList( dlid );

    tchunk2->deactivate( dact );
    mchunk2->deactivate( dact );
    blchunk->deactivate( dact );
    cchunk1->deactivate( dact );
    gchunk1->deactivate( dact );

    xchunk1->activate( dact );
    txchunk->activate( dact );

    glCallList( dlid2 );

    xchunk1->deactivate( dact );
    txchunk->deactivate( dact );

    win->frameExit();

    glutSwapBuffers();
}
Example #12
0
void MainCanvas::renderTree()
{
    preRender();
    DisplayEngine* pDisplayEngine = getPlayer()->getDisplayEngine();
    unsigned numWindows = pDisplayEngine->getNumWindows();
    for (unsigned i=0; i<numWindows; ++i) {
        ScopeTimer Timer(RootRenderProfilingZone);
        WindowPtr pWindow = pDisplayEngine->getWindow(i);
        IntRect viewport = pWindow->getViewport();
        renderWindow(pWindow, MCFBOPtr(), viewport);
    }
    GLContextManager::get()->reset();
}
WindowPtr WindowManager::FindWindow(LPCTSTR pszWindowName) throw()
{
   // check root window
   WindowPtr spWindow = m_spRootWindow;

   if (spWindow->GetAttr(WindowAttr::Name) == pszWindowName)
      return spWindow;

   // since the root window is a Panel, ask it
   std::shared_ptr<Panel> spPanel = std::dynamic_pointer_cast<Panel, Window>(spWindow);
   ATLASSERT(spPanel != NULL);

   return spPanel->FindByName(pszWindowName);
}
Example #14
0
void display(void)
{
    Matrix  m1, m2;

    m1.setRotate(tball.getRotation());
    m2.setTranslate(tball.getPosition());

    m1.mult(m2);
    cam_trans->editSFMatrix()->setValue(m1);

    if(doRender)
        win->render(ract);
    else
        win->draw(dact);
}
Example #15
0
	void Canvas::setWindow(WindowPtr wnd)
	{
		window_ = wnd;
		if(wnd) {
			if(size_change_key_ >= 0) {
				wnd->registerSizeChangeObserver(size_change_key_, [this](int w, int h) {
					this->setDimensions(w, h);
				});	
			} else {
				size_change_key_ = wnd->registerSizeChangeObserver([this](int w, int h) {
					this->setDimensions(w, h);
				});	
			}
		}
	}
Example #16
0
void
display(void)
{
    Matrix m1, m2, m3;
    Quaternion q1;

    tball.getRotation().getValue(m3);

    q1.setValue(m3);

    m1.setRotate(q1);

//    std::cout << "TBROT" << std::endl << tball.getRotation() << std::endl;
//    std::cout << "M3" << std::endl << m3 << std::endl;
//    std::cout << "Q1" << std::endl << q1 << std::endl;
//    std::cout << "M1" << std::endl << m1 << std::endl;

//  m1.setRotate( tball.getRotation() );
    m2.setTranslate( tball.getPosition() );

//std::cout << "Pos: " << tball.getPosition() << ", Rot: " << tball.getRotation() << std::endl;

//    std::cout << tball.getRotation() << std::endl;

    m1.mult( m2 );
    cam_trans->editSFMatrix()->setValue( m1 );

    win->draw( ract );
}
Example #17
0
GUI::~GUI() {
	if(window) {
		::DestroyWindow(window->handle());
		window = nullptr;
		Application::uninit();
	}
}
Example #18
0
void DisplayGroupRenderer::_createWindowQmlItem(WindowPtr window)
{
    const auto& id = window->getID();
    auto sync = _context.provider.createSynchronizer(*window, _context.view);
    _windowItems[id].reset(
        new WindowRenderer(std::move(sync), std::move(window),
                           *_displayGroupItem, _qmlContext.get()));
}
Example #19
0
// redraw the window
void display(void)
{
    WindowPtr win = mgr->getWindow();
    
    //mgr->redraw();
    win->activate();
    win->frameInit();
    
    //RenderAction *rAct = (RenderAction*)mgr->getAction();
    
    if (multipass)
    {
        RenderAction *rAct = RenderAction::create();
        
        fbo_vp->setParent(win);
        
        rAct->setWindow(get_pointer(win));
        
        fbo_vp->render(rAct);
        
        fbo_vp->setParent(NullFC);
        
        delete rAct;
        
        //multipass = false;
    }

    win->getPort(0)->render(dynamic_cast<RenderAction *>(mgr->getAction()));
    //win->renderAllViewports(rAct);

    win->swap();
    win->frameExit();
    win->deactivate();
}
Example #20
0
	WindowPtr RenderingAPI::createWindow(const String& windowname, uint32_t width, uint32_t height, bool fullscreen)
	{
		aproassert1(width != 0 && height != 0 && !windowname.isEmpty());
		
		APRO_THREADSAFE_AUTOLOCK
		
		// Call the implementation to create the Window object.
		WindowPtr retwin = _createWindowImpl(windowname, width, height, fullscreen);
		if(!retwin) {
			aprodebug("Couldn't create Appropriate Window !");
			return WindowPtr::Null;
		}
		
		renderingtargets.append(retwin);
		retwin->setActivated(false); // This should be activated when Window::show() is called.
		
		return retwin;
	}
	void setCamera(CameraPtr c)
	{
		_camera = c;
		ViewportPtr vp = _win->getPort(0);
		beginEditCP(vp);
			vp->setCamera(_camera);
		endEditCP(vp);

	}
Example #22
0
void 
display(void)
{
    Matrix m1, m2, m3;
    Quaternion q1;

#ifdef PAR_SCHEDULER
    if(pVSCThread == NULL)
    {
        pVSCThread = ExternalThread::find("VSCScheduler");
    }

    VSC::VSCScheduler::the()->enterSyncBarrier(2);

    pVSCThread->getChangeList()->applyToCurrent();
    pVSCThread->getChangeList()->clearAll();

//    VSC::vsc_sleep(100);

    VSC::VSCScheduler::the()->enterSyncBarrier(2);
#endif

//    tball.getRotation().getValue(m3);

//    q1.setValue(m3);

//    m1.setRotate(q1);
    
//    cout << "TBROT" << endl << tball.getRotation() << endl;
//    cout << "M3" << endl << m3 << endl;
//    cout << "Q1" << endl << q1 << endl;
//    cout << "M1" << endl << m1 << endl;

//  m1.setRotate( tball.getRotation() );
//    m2.setTranslate( tball.getPosition() );
    
//cout << "Pos: " << tball.getPosition() << ", Rot: " << tball.getRotation() << endl;

//    cout << tball.getRotation() << endl;

//    m1.mult( m2 );

    cam_trans->getSFMatrix()->setValue(tball.getFullTrackballMatrix());

/*
    fprintf(stderr, "%d %d %d %d | %d | %d\r",
            glutGet(GLUT_WINDOW_RED_SIZE),
            glutGet(GLUT_WINDOW_GREEN_SIZE),
            glutGet(GLUT_WINDOW_BLUE_SIZE),
            glutGet(GLUT_WINDOW_ALPHA_SIZE),
            glutGet(GLUT_WINDOW_DEPTH_SIZE),
            glutGet(GLUT_WINDOW_STENCIL_SIZE));
*/

    win->draw( ract );
}
Example #23
0
Vector2i WinInput::GetCursorPosition(WindowPtr pWindow) const
{
	POINT point;
	GetCursorPos(&point);
	Vector2i r(point.x, point.y);
	if (pWindow)
	{
		r = pWindow->ScreenToWindow(r);
	}
	return r;
}
	virtual void redraw (void)
	{
		if (_internalRoot == NullFC)
		{
			initialize();
			showAll();
		}

		_win->render(_action);

	}
Example #25
0
void display(void)
{
  Matrix m1, m2, m3;
  Quaternion q1;
  
  tball.getRotation().getValue(m3);
  q1.setValue(m3);
  m1.setRotate(q1);
  m2.setTranslate( tball.getPosition() );
  m1.mult( m2 );
  cam_trans->editSFMatrix()->setValue( m1 );
  window->draw( drAct );
}
void
display(void)
{
    Matrix m1, m2, m3;

    m1=trackball.getMatrix();
//    m1.transpose();

//    m2.setTranslate(0,0,8);
//    m1.mult(m2);

    cam_trans->editSFMatrix()->setValue( m1 );

    win->draw( ract );
}
Example #27
0
void on_application_initialized ()
{
  window_holder.reset (new Window (WindowStyle_Overlapped, 400, 300));

  Window& window = *window_holder;

  window_ptr = &window;

  window.SetTitle ("Test window");

  window.SetPosition (0, 0);

  printf ("title: '%s'\n", window.Title ());
  printf ("is_active: %d\n", window.IsActive ());
  printf ("position: x=%lu y=%lu\n", window.Position ().x, window.Position ().y);
  printf ("width: %lu\n", window.Width ());
  printf ("height: %lu\n", window.Height ());

  window.Show ();

  printf ("after show\n");

  window.SetClientSize (300, 400);

  Rect client_rect = window.ClientRect ();

  printf ("Client width=%u, height=%u\n", client_rect.right - client_rect.left, client_rect.bottom - client_rect.top);

  printf ("is_active: %d\n", window.IsActive ());

  window.Deactivate ();

  printf ("after deactivate\n");
  printf ("is_active: %d\n", window.IsActive ());

  printf ("is multitouch enabled: %d\n", window.IsMultitouchEnabled ());

  window.SetMultitouchEnabled (true);

  printf ("is multitouch enabled: %d\n", window.IsMultitouchEnabled ());

  window.RegisterEventHandler (WindowEvent_OnClose, &destroy);

  printf ("window pointer: %s\n", window_ptr ? "non null" : "null");

  window.Close ();
}
Example #28
0
void on_application_initialized ()
{
  window_holder.reset (new Window (WindowStyle_Overlapped, 400, 300));

  Window& window = *window_holder;

  window.SetPosition (10, 10);
  window.SetTitle ("Test window");

  window.Show ();

  print_window_info (window);

  window.SetStyle (WindowStyle_PopUp);

  print_window_info (window);

  window.RegisterEventHandler (WindowEvent_OnClose, &destroy);

  window.Close ();
}
Example #29
0
boolean RendererD3D11::assembleUnit()
{
    ProcessingUnitPtr windowUnit = ProcessingUnitPtr::null;
    window->getData( windowUnit );
    if( !windowUnit.isNull() )
    {
        WindowPtr wnd = staticCast<Window>( windowUnit );
        RenderDeviceD3D11* rd = static_cast<RenderDeviceD3D11*>( owner );
        IDXGIFactory* dxgiFactory = rd->getDXGIFactory();

        DXGI_SWAP_CHAIN_DESC desc;
        desc.BufferCount = 1;
        desc.BufferDesc.Width = wnd->getWidth();
        desc.BufferDesc.Height = wnd->getHeight();
        desc.BufferDesc.Format = MapperD3D11::mapPixelFormat( Render::PF_RGBA8UN );
        desc.BufferDesc.RefreshRate.Numerator = 60;
        desc.BufferDesc.RefreshRate.Denominator = 1;
        desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
        desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
        desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        desc.OutputWindow = (HWND)wnd->getHandle();
        desc.SampleDesc.Count = 1;
        desc.SampleDesc.Quality = 0;
        desc.Windowed = !wnd->isFullscreen();
        desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
        desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

        IDXGISwapChain* sc = 0;
        HRESULT hr = dxgiFactory->CreateSwapChain( rd->getD3DDevice(), &desc, &sc );
        if( SUCCEEDED( hr ) )
        {
            swapchains.add( sc );
            wnd->setSwapChain( sc );
            return true;
        }
    }

    return false;
}
/** get graphics performance
 * 
 * This is a rough estimation of rendering costst for visible faces,
 * faces outside of the viewport and size dependent rendering costs.
 * <pre>
 * // face cost calculation
 * cost = invisible * invisibleFaceCost +
 *        max( visible * visibleFaceCost + 
 *             pixel * pixelCost)
 * </pre>
 *
 **/
void RenderNode::determinePerformance( WindowPtr &window )
{
    int c;
    double faces=0;
    double A,B,C;
    double t;

    setVendor((const char*)glGetString(GL_VENDOR));
    setRenderer((const char*)glGetString(GL_RENDERER));

    // try to find precalculated values
    for(c=0;_prefefined[c]!=NULL;++c)
    {
        if(_prefefined[c]->getVendor()   == getVendor()  &&
           _prefefined[c]->getRenderer() == getRenderer())
        {
            SLOG << "Predefined performance values used." << endl;
            *this=*_prefefined[c];
            return;
        }
    }

    SLOG << "Start rendering benchmark" << endl;
    window->activate();
    // create display list
    GLuint dList1 = glGenLists(1);
    glNewList(dList1, GL_COMPILE);
    float step = .1;
    int count  = 400;
    for(float y=0;y<(1-step/2);y+=step)
    {        
        glBegin(GL_TRIANGLE_STRIP);
        glVertex3f(0,y     ,-1);
        glVertex3f(0,y+step,-1);
        for(float x=step;x<(1+step/2);x+=step)
        {
            glVertex3f(x,y     ,-1);
            glVertex3f(x,y+step,-1);
            faces+=2;
        }
        glEnd();
    }
    glEndList();
    glFinish();
    GLuint dList2 = glGenLists(1);
    glNewList(dList2, GL_COMPILE);
    for(c=0;c<count;++c)
    {
        glCallList(dList1);
    }        
    glEndList();
    glFlush();
    t=runFaceBench(dList2,128,128,1.0);
    count=(int)(count/t);
    glNewList(dList2, GL_COMPILE);
    for(c=0;c<count;++c)
    {
        glCallList(dList1);
    }
    glEndList();
    runFaceBench(dList2,1,1,1.0);
    glFinish();

    Real32 aSize=2;
    Real32 bSize=2;
    Real32 cSize=128;
    do
    {
        for(A=0,c=0;A<1.0;++c)
        {
            A += runFaceBench(dList2,aSize,aSize,1.000);
        }
        A/=c*count;
        for(B=0,c=0;B<1.0;++c)
        {
            B += runFaceBench(dList2,bSize,bSize,0.001);
        }
        B/=c*count;
        C = runFaceBench(dList2,cSize,cSize,1.000)/count;
    } while(A>C);

    _visibleFaceCost     =A/faces;
    _invisibleFaceCost   =B/faces;
    _drawPixelCost       =C/(cSize*cSize);

    glViewport(0, 0, window->getWidth(), window->getHeight());
    UInt32 width,height;

    // test write performance
    glPixelStorei(GL_PACK_ALIGNMENT,1); 
    glPixelStorei(GL_UNPACK_ALIGNMENT,1); 
    vector<UInt8> pixels;
    width =window->getWidth();
    height=window->getHeight();
    pixels.resize(width*height*4);
    glFlush();
    t=-getSystemTime();
    for(c=0;c<2;++c)
        glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,&pixels[0]);
    glFlush();
    t+=getSystemTime();
    _readPixelCost=t/(c*width*height);

    // test write performance
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluOrtho2D(0,width,0,height);
    glRasterPos2i(0,0);
    glDisable(GL_DEPTH_TEST);
    glFlush();
    t=-getSystemTime();
    for(c=0;c<2;++c)
        glDrawPixels(width,height,GL_RGB,GL_UNSIGNED_BYTE,&pixels[0]);
    glFlush();
    t+=getSystemTime();
    _writePixelCost=t/(c*width*height);
    glEnable(GL_DEPTH_TEST);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    SLOG << "End rendering benchmark" << endl;
    
    glDeleteLists(dList2,1);
    glDeleteLists(dList1,1);
}