egl/sfegltest/src/main.cpp
branchbug235_bringup_0
changeset 215 097e92a68d68
parent 213 deb2534f581f
equal deleted inserted replaced
213:deb2534f581f 215:097e92a68d68
    14 
    14 
    15 #include <e32std.h>
    15 #include <e32std.h>
    16 #include <w32std.h>
    16 #include <w32std.h>
    17 #include <e32math.h>
    17 #include <e32math.h>
    18 #include <e32keys.h>
    18 #include <e32keys.h>
       
    19 #include <bacline.h>
       
    20 #include "gles1cube.h"
    19 #include "vgline.h"
    21 #include "vgline.h"
    20 
    22 
    21 #define KDefaultScreenNo 0
    23 #define KDefaultScreenNo 0
    22 
    24 
    23 class CWsCanvas: public CBase
    25 class CWsCanvas: public CBase
   222 	self->ConstructL();
   224 	self->ConstructL();
   223 	CleanupStack::Pop(self);
   225 	CleanupStack::Pop(self);
   224 	return self;
   226 	return self;
   225 	}
   227 	}
   226 
   228 
       
   229 _LIT(KOptionScreen, "-screen");
       
   230 
       
   231 typedef CEGLRendering* (*RendererFactoryFunctionL)(RWindow&);
       
   232 
   227 /**
   233 /**
   228  * Constructor for CWsApp
   234  * Constructor for CWsApp
   229  *
   235  *
   230  * @note This constructor looks at the command line argument, if any, supplied when
   236  * @note This constructor looks at the command line argument, if any, supplied when
   231  *		 launching the application.  If specified, its used as the screen number to
   237  *		 launching the application.  If specified, its used as the screen number to
   234 void CWsApp::ConstructL()
   240 void CWsApp::ConstructL()
   235     {
   241     {
   236 	RDebug::Printf("[EBT] CWsApp::ConstructL");
   242 	RDebug::Printf("[EBT] CWsApp::ConstructL");
   237 
   243 
   238 	iScrId = KDefaultScreenNo;
   244 	iScrId = KDefaultScreenNo;
   239 	if (User::CommandLineLength() > 0)
   245 	HBufC* rendererName = 0;
   240 		{
   246 	CCommandLineArguments* args = CCommandLineArguments::NewLC();
   241 		TBuf<1> arg;
   247 	for (TInt i=1; i<args->Count(); ++i)
   242 		User::CommandLine(arg);
   248 		{
   243 		iScrId = (TInt)(arg[0]-'0');
   249 		const TPtrC arg = args->Arg(i);
   244 		}
   250 		if (!arg.Compare(KOptionScreen))
   245 
   251 			{
   246 	RDebug::Printf("[EBT] CWsApp::ConstructL 1");
   252 			if (++i < args->Count())
       
   253 				{
       
   254 				TLex lex(args->Arg(i));
       
   255 				User::LeaveIfError(lex.Val(iScrId));
       
   256 				RDebug::Printf("[EBT] CWsApp::ConstructL screenId %d", iScrId);
       
   257 				}
       
   258 			}
       
   259 		else if (!rendererName)
       
   260 			{
       
   261 			RDebug::Print(_L("[EBT] CWsApp::ConstructL rendererName %S"), &arg);
       
   262 			rendererName = HBufC::NewL(arg.Length());
       
   263 			rendererName->Des() = arg;
       
   264 			}
       
   265 		else
       
   266 			{
       
   267 			RDebug::Print(_L("[EBT] CWsApp::ConstructL ignoring argument %S"), &arg);
       
   268 			}
       
   269 		}
       
   270 
       
   271 	CleanupStack::PopAndDestroy(args);
       
   272 	if (rendererName)
       
   273 		{
       
   274 		CleanupStack::PushL(rendererName);
       
   275 		}
       
   276 
   247 	iAppView = CWsCanvas::NewL(iScrId, iPos);
   277 	iAppView = CWsCanvas::NewL(iScrId, iPos);
   248 	RDebug::Printf("[EBT] CWsApp::ConstructL 2");
   278     iSz = iAppView->ScreenSize();
   249 	iEventHandler = new (ELeave) CWsEventHandler(iAppView->Session(), iAppView->Window(), *this);
   279 	iEventHandler = new (ELeave) CWsEventHandler(iAppView->Session(), iAppView->Window(), *this);
   250 	RDebug::Printf("[EBT] CWsApp::ConstructL 3");
   280 
   251 	iDemo = CVGLine::NewL(iAppView->Window());
   281 	RendererFactoryFunctionL factoryFunctionL = CVGLine::NewL;
   252 	RDebug::Printf("[EBT] CWsApp::ConstructL 4");
   282 	if (rendererName)
   253 	iSz = iAppView->ScreenSize();
   283 		{
   254 	RDebug::Printf("[EBT] CWsApp::ConstructL 5");
   284 		if (!rendererName->Des().Compare(CGLES1Cube::Name()))
       
   285 			{
       
   286 			factoryFunctionL = CGLES1Cube::NewL;
       
   287 			}
       
   288 		if (!rendererName->Des().Compare(CVGLine::Name()))
       
   289 			{
       
   290 			factoryFunctionL = CVGLine::NewL;
       
   291 			}
       
   292 		CleanupStack::PopAndDestroy(rendererName);
       
   293 		}
       
   294 	iDemo = (*factoryFunctionL)(iAppView->Window());
   255 	}
   295 	}
   256 
   296 
   257 void CWsApp::Start()
   297 void CWsApp::Start()
   258 	{
   298 	{
   259 	RDebug::Printf("[EBT] CWsApp::Start");
   299 	RDebug::Printf("[EBT] CWsApp::Start");
   272     Stop();
   312     Stop();
   273     }
   313     }
   274 
   314 
   275 CWsApp::~CWsApp()
   315 CWsApp::~CWsApp()
   276 	{
   316 	{
   277     RDebug::Printf("[EBT] CWsApp::~CWsApp");
       
   278 	delete iDemo;
   317 	delete iDemo;
   279 	RDebug::Printf("[EBT] CWsApp::~CWsApp 1");
       
   280 	delete iEventHandler;
   318 	delete iEventHandler;
   281     RDebug::Printf("[EBT] CWsApp::~CWsApp 2");
       
   282 	delete iAppView;
   319 	delete iAppView;
   283     RDebug::Printf("[EBT] CWsApp::~CWsApp 3");
       
   284 	}
   320 	}
   285 
   321 
   286 /**
   322 /**
   287  * Application second level entry point.
   323  * Application second level entry point.
   288  *
   324  *