コード例 #1
0
ファイル: font.c プロジェクト: BackupTheBerlios/dri-ex-svn
static void Draw(void)
{

    glClear(GL_COLOR_BUFFER_BIT);

    SetColor(COLOR_WHITE);

    glPushMatrix();

    glTranslatef(shiftX, shiftY, shiftZ);
    glRotatef(angleX, 1.0, 0.0, 0.0);
    glRotatef(angleY, 0.0, 1.0, 0.0);
    glRotatef(angleZ, 0.0, 0.0, 1.0);
    glScalef(scaleX, scaleY, scaleZ);

    glPushMatrix();
    glRasterPos2f(-390.5, 0.5);
    DrawBitmapString(GLUT_BITMAP_9_BY_15, string);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-390.5, -30.5, 0.0);
    DrawStrokeString(GLUT_STROKE_ROMAN, string);
    glPopMatrix();

    glPopMatrix();

    glFlush();

    if (doubleBuffer) {
	glutSwapBuffers();
    }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: danepowell/openhaptics
void DisplayInfo(void)
{
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);

    glPushMatrix();
    glLoadIdentity();

	// switch to 2d orthographic mMode for drawing text
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, mWindW, mWindH, 0);
	glMatrixMode(GL_MODELVIEW);
	
	glColor3f(1.0, 1.0, 1.0);

	int textRowDown = 0; // lines of text already drawn downwards from the top
	int textRowUp = 0; // lines of text already drawn upwards from the bottom

	if (mDrawInfo == drawInfo_All)
		DrawBitmapString(5, 20 + textRowDown * 15, GLUT_BITMAP_9_BY_15, "Surface Resolution: %d", mSurfaceParticles);

	if (mDrawInfo == drawInfo_All || mDrawInfo == drawInfo_FPS)
		DrawBitmapString(mWindW - 10 * 9, 20 + (textRowDown) * 15, GLUT_BITMAP_9_BY_15, "FPS: %4.1f", DetermineFPS());

	textRowDown++;
	
	if (mDrawInfo == drawInfo_All)
	{
		std::string stepLabel;
		
		if (mUseFixedTimeStep)
			DrawBitmapString(mWindW - 24 * 9, 20 + (textRowDown) * 15, GLUT_BITMAP_9_BY_15, "Fixed Step (sec): %1.3f" , mTimeStep);
		else
			DrawBitmapString(mWindW - 18 * 9, 20 + (textRowDown) * 15, GLUT_BITMAP_9_BY_15, "Step (sec): %1.3f" , mTimeStep);

		DrawBitmapString(5, mWindH - 10 - (textRowUp) * 15, GLUT_BITMAP_9_BY_15, "%s", mSurfaceConditionsName.c_str());

		std::string displayingList;
		if (mDrawSurface) displayingList += "surface ";
		if (mDrawNormals) displayingList += "normals ";
		if (mDrawSystem) displayingList += "system ";
		if (displayingList.length() == 0) displayingList = "(nothing)";
		displayingList.insert(0, "Displaying: ");
		DrawBitmapString(mWindW - displayingList.length() * 9, mWindH - 10 - (textRowUp++) * 15, GLUT_BITMAP_9_BY_15, "%s", displayingList.c_str());

		DrawBitmapString(5, mWindH - 10 - (textRowUp) * 15, GLUT_BITMAP_9_BY_15, "kd: %4.1f", mPS.GetSpringDampingConstant());
		DrawBitmapString(5 + 12 * 9, mWindH - 10 - (textRowUp++) * 15, GLUT_BITMAP_9_BY_15, "Gravity:%5.1f", mPS.gravity);
		
		DrawBitmapString(5, mWindH - 10 - (textRowUp) * 15, GLUT_BITMAP_9_BY_15, "ks: %4.1f", mPS.GetSpringConstant());
		DrawBitmapString(5 + 12 * 9, mWindH - 10 - (textRowUp) * 15, GLUT_BITMAP_9_BY_15, "Mass:   %5.1f", mSurface.GetMassProportion());
		DrawBitmapString(5 + 30 * 9, mWindH - 10 - (textRowUp) * 15, GLUT_BITMAP_9_BY_15, "Drag: %5.3f", mPS.drag);
	}

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
	
	// turn depth and lighting back on for 3D rendering
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
}
コード例 #3
0
ファイル: main - backup.cpp プロジェクト: istinj/MedRob_Rob2
/*****************************************************************************
   Function to display text info
 *****************************************************************************/
void DisplayInfo(void)
{
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    glPushMatrix();
    glLoadIdentity();

    int gwidth, gheight;
    gwidth = glutGet(GLUT_WINDOW_WIDTH);
    gheight = glutGet(GLUT_WINDOW_HEIGHT);

// switch to 2d orthographic mMode for drawing text
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    gluOrtho2D(0, gwidth, gheight, 0);
    glMatrixMode(GL_MODELVIEW);

    glColor3f(1.0, 1.0, 1.0);

    int textRowDown = 0;                                    // lines of text already drawn downwards from the top

    int textRowUp = 0;                                      // lines of text already drawn upwards from the bottom

    DrawBitmapString(0 , 80 , GLUT_BITMAP_HELVETICA_18, "INSTRUCTIONS: ");
    DrawBitmapString(0 , 100 , GLUT_BITMAP_HELVETICA_18, "Use Right-click menu to Quit the Demo");

    DrawBitmapString(0 , gheight-100 , GLUT_BITMAP_HELVETICA_18, "LAYER 1 penetrated: ");

    if (probeDop > 0.1 && touchedHole)
        DrawBitmapString(200 , gheight-100 , GLUT_BITMAP_HELVETICA_18, "Yes");
    else
        DrawBitmapString(200 , gheight-100 , GLUT_BITMAP_HELVETICA_18, "No");

    DrawBitmapString(0 , gheight-80 , GLUT_BITMAP_HELVETICA_18, "LAYER 2 penetrated: ");

    if (probeDop > 0.25 && touchedHole)
        DrawBitmapString(200 , gheight-80 , GLUT_BITMAP_HELVETICA_18, "Yes");
    else
        DrawBitmapString(200 , gheight-80 , GLUT_BITMAP_HELVETICA_18, "No");

    DrawBitmapString(0 , gheight-60 , GLUT_BITMAP_HELVETICA_18, "Depth of Penetration: %f ",probeDop );

    DrawBitmapString(gwidth/2, gheight - 300 , GLUT_BITMAP_TIMES_ROMAN_24, "Entry Point");

    DrawBitmapString(gwidth-250, gheight - 80 , GLUT_BITMAP_HELVETICA_12, "Models & Textures courtesy ");

    DrawBitmapString(gwidth-250, gheight - 60 , GLUT_BITMAP_HELVETICA_18, "mySmartSimulations, Inc.");

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

// turn depth and lighting back on for 3D rendering
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_TEXTURE_2D);
}