Font test reviewed
This commit is contained in:
		
							parent
							
								
									0ab51665e5
								
							
						
					
					
						commit
						8b1bc84568
					
				
					 1 changed files with 7 additions and 12 deletions
				
			
		| 
						 | 
					@ -5,16 +5,12 @@
 | 
				
			||||||
//  James Turk (jpt2433@rit.edu)
 | 
					//  James Turk (jpt2433@rit.edu)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Version:
 | 
					// Version:
 | 
				
			||||||
//  $Id: Font_test.cpp,v 1.5 2005/07/17 07:14:09 cozman Exp $
 | 
					//  $Id: Font_test.cpp,v 1.6 2005/07/19 18:47:28 cozman Exp $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "photon.hpp"
 | 
					#include "photon.hpp"
 | 
				
			||||||
using namespace photon;
 | 
					using namespace photon;
 | 
				
			||||||
#include <boost/lexical_cast.hpp>
 | 
					#include <boost/lexical_cast.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This is a simple framework for writing extremely simple Photon applications
 | 
					 | 
				
			||||||
//  it simply displays a blank window and the framerate in the titlebar of
 | 
					 | 
				
			||||||
//  the created window.  This is meant to show basic interaction between the
 | 
					 | 
				
			||||||
//  user and the more common features of the AppCore and the Kernel.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MainTask : public Task
 | 
					class MainTask : public Task
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -25,23 +21,20 @@ public:
 | 
				
			||||||
        app(AppCore::getInstance()),
 | 
					        app(AppCore::getInstance()),
 | 
				
			||||||
        video(video::VideoCore::getInstance())
 | 
					        video(video::VideoCore::getInstance())
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        LogSinkPtr csp( new ConsoleSink("console") );
 | 
					 | 
				
			||||||
        log.addSink(csp);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        video.setOrthoView(800,600);
 | 
					        video.setOrthoView(800,600);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // show two different fonts
 | 
				
			||||||
        video::Font::addResource("font1","data/FreeMono.ttf",32);
 | 
					        video::Font::addResource("font1","data/FreeMono.ttf",32);
 | 
				
			||||||
        video::Font::addResource("font2","data/FreeSerif.ttf",18);
 | 
					        video::Font::addResource("font2","data/FreeSerif.ttf",18);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        font.open("font1");
 | 
					        font.open("font1");
 | 
				
			||||||
        font2.open("font2");
 | 
					        font2.open("font2");
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void update()
 | 
					    void update()
 | 
				
			||||||
    {   
 | 
					    {   
 | 
				
			||||||
 | 
					        // used to measure FPS and display it in the title bar
 | 
				
			||||||
        static double t=0;
 | 
					        static double t=0;
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        if(app.getTime() - t > 1.0)
 | 
					        if(app.getTime() - t > 1.0)
 | 
				
			||||||
        {            
 | 
					        {            
 | 
				
			||||||
            app.setTitle("FPS: " + 
 | 
					            app.setTitle("FPS: " + 
 | 
				
			||||||
| 
						 | 
					@ -49,25 +42,27 @@ public:
 | 
				
			||||||
            t = app.getTime();
 | 
					            t = app.getTime();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // clear screen 
 | 
				
			||||||
        video.clear();
 | 
					        video.clear();
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        // draw the three strings to the screen
 | 
				
			||||||
        font.setColor(video::Color(0,128,128));
 | 
					        font.setColor(video::Color(0,128,128));
 | 
				
			||||||
        font.drawText(0, 0, "Photon");
 | 
					        font.drawText(0, 0, "Photon");
 | 
				
			||||||
        font.setColor(video::Color(255,0,0));
 | 
					        font.setColor(video::Color(255,0,0));
 | 
				
			||||||
        font.drawText(font.calcStringWidth("Photon"), font.getHeight(), 
 | 
					        font.drawText(font.calcStringWidth("Photon"), font.getHeight(), 
 | 
				
			||||||
                    "FPS: %.0f", app.getFramerate() );
 | 
					                    "FPS: %.0f", app.getFramerate() );
 | 
				
			||||||
        font2.beginDraw(200, 200) << "another plain font" << font2.endDraw();
 | 
					        font2.beginDraw(200, 200) << "another (plain) font" << font2.endDraw();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    video::Font font;
 | 
					    video::Font font;
 | 
				
			||||||
    video::Font font2;
 | 
					    video::Font font2;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    Log log;
 | 
					 | 
				
			||||||
    AppCore& app;
 | 
					    AppCore& app;
 | 
				
			||||||
    video::VideoCore& video;
 | 
					    video::VideoCore& video;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// standard application, creates window, registers task and runs
 | 
				
			||||||
class FontTest : public Application
 | 
					class FontTest : public Application
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue