示例#1
0
// Callback function of window size changing
void onWindowReshape(int w, int h) 
{
    screenWidth = w;
	screenHeight = h;

	// view port matrix
	setViewPortMatrix();	
}
示例#2
0
void AWidget::updateWindow(int w, int h)
{

    screen_offset_x=0;
    screen_offset_y=0;
    scale_factor=w*1.0/ASystem::GetWidth();
    if(ASystem::GetHeight()*scale_factor>h)
    {
        scale_factor=h*1.0/ASystem::GetHeight();
    }
    screen_offset_x=(w-ASystem::GetWidth()*scale_factor)/2;
    screen_offset_y=(h-ASystem::GetHeight()*scale_factor)/2;
          int wi = ASystem::GetWidth()*scale_factor, he = ASystem::GetHeight()*scale_factor;
          glViewport(screen_offset_x,screen_offset_y,wi,he);
    real_width=w;
    real_height=h;
    projection.setToIdentity();
    projection.frustum (0,ASystem::GetWidth(),0,ASystem::GetHeight(),0.01,50);

    ASystem::m_widthOffset = w-wi;
    ASystem::m_heightOffset = h-he;
    setViewPortMatrix(projection);
}