Пример #1
0
void reshape( int width, int height ) {
	r_windowWidth.SetVal( width );
	r_windowHeight.SetVal( height );
	glViewport( 0, 0, width, height );
	planetFinder.SetSize( r_windowWidth.GetVal(), r_windowHeight.GetVal() );
	glMatrixMode( GL_MODELVIEW );
}
Пример #2
0
	void Console::Draw() {
		if ( font == NULL ) {
			font = r3::CreateStbFont( con_font.GetVal(), con_fontSize.GetVal() ); 			
		}
		if ( ! IsActive() ) {
			return;
		}
		
		int border = 10;
		
		int w = r_windowWidth.GetVal();
		int h = r_windowHeight.GetVal();
		int conW = w - 2 * border;
		int conH = ( h - ( h >> 2 ) ) - border;
		float s = con_fontScale.GetVal();

		static Bounds2f bO;
		static float yAdvance = 0;
		static float sCache = 0;
		if ( s != sCache ) {
			bO = font->GetStringDimensions( "O", s );
			Bounds2f bb = font->GetStringDimensions( "|", s );
			sCache = s;
			yAdvance = std::max( bO.Height(), bb.Height() );
		}
		
		int x0 = border;
		int y = ( h >> 2) + border;
		
		ImColor( 16, 16, 16, con_opacity.GetVal() * 255 );
		BlendFunc( BlendFunc_SrcAlpha, BlendFunc_OneMinusSrcAlpha );
		BlendEnable();

		DrawQuad( x0, y, x0 + conW, y + conH );
		
		string cl = "> " + commandLine;
		int cp = cursorPos + 2;

		Bounds2f b = font->GetStringDimensions( cl, s );
		Bounds2f b2 = font->GetStringDimensions( cl.substr(0, cp ), s );
		
		ImColor( 255, 255, 255, 192 );
		font->Print( cl, x0, y, s );
		
		ImColor( 255, 255, 255, 64 );
		DrawQuad( x0 + b2.Width(), y, x0 + b2.Width() + bO.Width(), y + bO.Height() );
		
		y += yAdvance;

		ImColor( 255, 255, 255, 128 );
		for ( int i = outputBuffer.size() - 1; i >= 0 && y < h; i-- ) {
			string & line = outputBuffer[ i ];
			font->Print( line, x0, y, s );
			y += yAdvance;
		}

		BlendDisable();
	}
Пример #3
0
void display() {
	updateOrientation();
	app_phaseEarthRotation.SetVal( GetPhaseEarthRotation() );
	planetFinder.buildSolarSystemList( solarsystem );
	star3map::Display();

	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, r_windowWidth.GetVal(), 0, r_windowHeight.GetVal(), -1, 1 );
	r3::console.Draw();
	glPopMatrix();
		
	SwapBuffers();
}
Пример #4
0
void touches( int count, int *points ) {
	static int cycle;
	static int maxTouches;
	vector< Vec2f > &p = t[ cycle ];
	cycle = ( cycle + 1 ) & 1;
	vector< Vec2f > &c = t[ cycle ];
	c.clear();

	maxTouches = max( maxTouches, count );
	if ( count == 0 ) {
		maxTouches = 0;
	}
	
	int h = r_windowHeight.GetVal() - 1;

	for ( int i = 0; i < count * 2; i+=2 ) {
		c.push_back( Vec2f( points[ i ], points[ i + 1 ] ) );
	}
	//Output( "%d %d touches", (int)p.size(), (int)c.size() );
	
	if ( maxTouches < 2 ) {
		if ( c.size() == 1 && p.size() < 2 ) {
			ProcessInput( true, c[0].x, h - c[0].y );
		} else if ( c.size() == 0 && p.size() == 1 ) {
			ProcessInput( false, p[0].x, h - p[0].y );
		} else if ( c.size() == 2 && p.size() == 1 ) {
			ProcessInput( false, p[0].x, h - p[0].y );
		}	
	} else if ( c.size() == 2 && p.size() == 2 ) {
		
		float pl = ( p[1] - p[0] ).Length();
		float cl = ( c[1] - c[0] ).Length();
		float s = pl / cl;
		float fov = r_fov.GetVal() * s;
		fov = min( 90.f, max( 20.f, fov ) );
		r_fov.SetVal( fov );
		//Output( "scale = %0.2f, new fov = %.2f", s, fov );
	}
}
Пример #5
0
void Console::Draw() {
    if ( font == NULL ) {
        font = r3::CreateStbFont( con_font.GetVal(), "", con_fontSize.GetVal() );
    }

    ScopedMutex scm( conMutex, R3_LOC );

    if ( ! IsActive() ) {
        return;
    }

    int border = 10;

    int w = r_windowWidth.GetVal();
    int h = r_windowHeight.GetVal();
    int conW = w - 2 * border;
    int conH = ( h - ( h >> 2 ) ) - border;
    float s = con_fontScale.GetVal();

    static Bounds2f bO;
    static float yAdvance = 0;
    static float sCache = 0;
    if ( s != sCache ) {
        bO = font->GetStringDimensions( "O", s );
        Bounds2f bb = font->GetStringDimensions( "|", s );
        sCache = s;
        yAdvance = std::max<int>( bO.Height(), bb.Height() );
    }

    int x0 = border;
    int y = ( h >> 2) + border;

    glColor4ub( 16, 16, 16, con_opacity.GetVal() * 255 );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable( GL_BLEND );

    DrawQuad( x0, y, x0 + conW, y + conH );

    string cl = "> " + commandLine;
    int cp = cursorPos + 2;

    //Bounds2f b = font->GetStringDimensions( cl, s );
    Bounds2f b2 = font->GetStringDimensions( cl.substr(0, cp ), s );

    glColor4ub( 255, 255, 255, 192 );
    font->Print( cl, x0, y, s );


    glColor4ub( 255, 255, 255, 64 );
    DrawQuad( x0 + b2.Width(), y, x0 + b2.Width() + bO.Width(), y + bO.Height() );

    y += yAdvance;

    glColor4ub( 255, 255, 255, 128 );
    for ( int i = (int)outputBuffer.size() - 1 - outputBufferPos; i >= 0 && y < h; i-- ) {
        string & line = outputBuffer[ i ];
        font->Print( line, x0, y, s );
        y += yAdvance;
    }
    glDisable( GL_BLEND );
}