示例#1
0
void CGame::Draw()
{
	Vector vecForward = m_hPlayer->GetGlobalView();
	Vector vecUp(0, 1, 0);

	// Cross-product http://www.youtube.com/watch?v=FT7MShdqK6w
	Vector vecRight = vecUp.Cross(vecForward).Normalized();

	CRenderer* pRenderer = GetRenderer();

	// Tell the renderer how to set up the camera.
	pRenderer->SetCameraPosition(m_hPlayer->GetGlobalOrigin() - vecForward * 6 + vecUp * 3 - vecRight * 0.5f);
	pRenderer->SetCameraDirection(vecForward);
	pRenderer->SetCameraUp(Vector(0, 1, 0));
	pRenderer->SetCameraFOV(90);
	pRenderer->SetCameraNear(0.1f);
	pRenderer->SetCameraFar(1000);

	// This rendering context is a tool for rendering things to the screen.
	// All of our drawing commands are part of it.
	CRenderingContext r(pRenderer);

	// Clear the depth buffer and set a background color.
	r.ClearDepth();
	r.ClearColor(Color(210, 230, 255));

	// CRenderer::StartRendering() - This function sets up OpenGL with the
	// camera information that we passed it before.
	pRenderer->StartRendering(&r);

	m_oFrameFrustum = CFrustum(r.GetProjection() * r.GetView());

	// First tell OpenGL what "shader" or "program" to use.
	r.UseProgram("model");

	// Set the sunlight direction. The y component is -1 so the light is pointing down.
	Vector vecSunlight = Vector(1, -1, 1).Normalized();

	// Uncomment this code to make the sunlight rotate:
	//Vector vecSunlight = Vector(cos(Game()->GetTime()), -1, sin(Game()->GetTime())).Normalized();

	r.SetUniform("vecSunlight", vecSunlight);

	r.SetUniform("bLighted", false);
	r.SetUniform("bDiffuse", false);

	// Render the ground.
	r.SetUniform("vecColor", Vector4D(0.6f, 0.7f, 0.9f, 1));
	r.SetUniform("vecCameraPosition", GetRenderer()->GetCameraPosition());
	r.BeginRenderTriFan();
		r.Normal(Vector(0, 1, 0));
		r.Tangent(Vector(1, 0, 0));
		r.Bitangent(Vector(0, 0, 1));
		r.TexCoord(Vector2D(0, 1));
		r.Vertex(Vector(-30, 0, -30));
		r.TexCoord(Vector2D(0, 0));
		r.Vertex(Vector(-30, 0, 30));
		r.TexCoord(Vector2D(1, 0));
		r.Vertex(Vector(30, 0, 30));
		r.TexCoord(Vector2D(1, 1));
		r.Vertex(Vector(30, 0, -30));
	r.EndRender();

	r.SetUniform("bLighted", true);

	// Prepare a list of entities to render.
	m_apRenderOpaqueList.clear();
	m_apRenderTransparentList.clear();

	for (size_t i = 0; i < MAX_CHARACTERS; i++)
	{
		CCharacter* pCharacter = GetCharacterIndex(i);
		if (!pCharacter)
			continue;

		// We need to scale the AABB using the character's scale values before we can use it to calculate our center/radius.
		AABB aabbSizeWithScaling = pCharacter->m_aabbSize * pCharacter->m_vecScaling;
		Vector vecCharacterCenter = pCharacter->GetGlobalOrigin() + aabbSizeWithScaling.GetCenter();
		float flCharacterRadius = aabbSizeWithScaling.GetRadius();

		// If the entity is outside the viewing frustum then the player can't see it - don't draw it.
		// http://youtu.be/4p-E_31XOPM
		if (!m_oFrameFrustum.SphereIntersection(vecCharacterCenter, flCharacterRadius))
			continue;

		if (pCharacter->m_bDrawTransparent)
			m_apRenderTransparentList.push_back(pCharacter);
		else
			m_apRenderOpaqueList.push_back(pCharacter);
	}

	// Draw all opaque characters first.
	DrawCharacters(m_apRenderOpaqueList, false);

	for (size_t i = 0; i < MAX_CHARACTERS; i++)
	{
		CCharacter* pCharacter = GetCharacterIndex(i);
		if (!pCharacter)
			continue;

		if (!pCharacter->m_bEnemyAI)
			continue;

		float flRadius = 3.5f;

		Vector vecIndicatorOrigin = NearestPointOnSphere(m_hPlayer->GetGlobalOrigin(), flRadius, pCharacter->GetGlobalOrigin());

		float flBoxSize = 0.1f;

		r.SetUniform("vecColor", Color(255, 0, 0, 255));
		r.RenderBox(vecIndicatorOrigin - Vector(1, 1, 1)*flBoxSize, vecIndicatorOrigin + Vector(1, 1, 1)*flBoxSize);
	}

	// Sort the transparent render list so that we paint the items farther from the camera first. http://youtu.be/fEjZrwDKdi8
	MergeSortTransparentRenderList();

	// Now draw all transparent characters, sorted by distance from the camera.
	DrawCharacters(m_apRenderTransparentList, true);

	r.SetUniform("bDiffuse", false);

	// Render any bullet tracers that may have been created.
	float flBulletTracerTime = 0.1f;
	for (size_t i = 0; i < Game()->GetTracers().size(); i++)
	{
		if (Game()->GetTime() < Game()->GetTracers()[i].flTimeCreated + flBulletTracerTime)
		{
			Vector vecStart = Game()->GetTracers()[i].vecStart;
			Vector vecEnd = Game()->GetTracers()[i].vecEnd;

			r.SetUniform("vecColor", Vector4D(1, 0.9f, 0, 1));
			r.BeginRenderLines();
				r.Normal(Vector(0, 1, 0));
				r.Vertex(vecStart);
				r.Vertex(vecEnd);
			r.EndRender();
		}
	}

	// Render any puffs that may have been created.
	float flPuffTime = 0.3f;
	for (size_t i = 0; i < Game()->GetPuffs().size(); i++)
	{
		if (Game()->GetTime() < Game()->GetPuffs()[i].flTimeCreated + flPuffTime)
		{
			float flTimeCreated = Game()->GetPuffs()[i].flTimeCreated;
			float flTimeOver = Game()->GetPuffs()[i].flTimeCreated + flPuffTime;
			float flStartSize = 0.2f;
			float flEndSize = 2.0f;

			float flSize = Remap(Game()->GetTime(), flTimeCreated, flTimeOver, flStartSize, flEndSize);

			Vector vecOrigin = Game()->GetPuffs()[i].vecOrigin;

			int iOrange = (int)Remap(Game()->GetTime(), flTimeCreated, flTimeOver, 0, 255);
			r.SetUniform("vecColor", Color(255, iOrange, 0, 255));
			r.RenderBox(vecOrigin - Vector(1, 1, 1)*flSize, vecOrigin + Vector(1, 1, 1)*flSize);
		}
	}

	GraphDraw();

	pRenderer->FinishRendering(&r);

	// Call this last. Your rendered stuff won't appear on the screen until you call this.
	Application()->SwapBuffers();
}
示例#2
0
void TXKDTree::Build(float3* points, const int& pnum, TXKDTree* const ctr, const int& depth, const int& max, int cdepth=0)
{
	Application().LogMessage(L" Build KD Tree Called with Depth : "+(CString)cdepth);

	if(cdepth==depth || pnum<=max)
	{
		CString accum = L"";
		Application().LogMessage(L"This is a leaf, with "+(CString)pnum+L" points...");
		ctr->m_points.clear();
		for(int i= 0;i<pnum;i++)
		{
			ctr->m_points.push_back(points[i].id);
			accum += (CString)points[i].id+L",";
		}
		Application().LogMessage(L"IDs : "+accum);
		ctr->m_numPoints = pnum;
		ctr->m_leaf = true;
		return;
	}
	else
		ctr->m_leaf = false;

	//splits along the axis of who the tree's bound is largest
	int splitx = (ctr->m_max.GetX()-ctr->m_min.GetX() > ctr->m_max.GetY()-ctr->m_min.GetY()) ? 0:(ctr->m_max.GetY()-ctr->m_min.GetY() > ctr->m_max.GetZ()-ctr->m_min.GetZ())?1:2;
	ctr->m_axis = splitx;

	// sort points in order along the axis
	QuickSort(points,0,pnum-1,splitx);

	int numl = pnum>>1;
	int numr = pnum-numl;

	CVector3f vmin, vmax;

	//calculate bound for each split
	if(splitx==0)
	{
		float px;
		if(numl != numr)
			px= points[numl].x;
		else
			px = (points[numl-1].x+points[numl].x)*0.5f;

		vmin.Set(ctr->m_min.GetX(),ctr->m_min.GetY(),ctr->m_min.GetZ());
		vmax.Set(px,ctr->m_max.GetY(),ctr->m_max.GetZ());
		ctr->m_left = new TXKDTree(vmin,vmax);

		vmin.Set(px,ctr->m_min.GetY(),ctr->m_min.GetZ());
		vmax.Set(ctr->m_min.GetX(),ctr->m_max.GetY(),ctr->m_max.GetZ());
		ctr->m_right = new TXKDTree(vmin, vmax);
	}
	else if(splitx==1)
	{
		float py;
		if(numl != numr)
			py= points[numl].y;
		else
			py = (points[numl-1].y+points[numl].y)*0.5f;

		vmin.Set(ctr->m_min.GetX(),ctr->m_min.GetY(),ctr->m_min.GetZ());
		vmax.Set(ctr->m_max.GetX(),py,ctr->m_max.GetZ());
		ctr->m_left = new TXKDTree(vmin, vmax);
		vmin.Set(ctr->m_min.GetX(),py,ctr->m_min.GetZ());
		vmax.Set(ctr->m_min.GetX(),ctr->m_max.GetY(),ctr->m_max.GetZ());
		ctr->m_right = new TXKDTree(vmin, vmax);
	}
	else
	{
		float pz;
		if(numl != numr)
			pz= points[numl].z;
		else
			pz = (points[numl-1].z+points[numl].z)*0.5f;

		vmin.Set(ctr->m_min.GetX(),ctr->m_min.GetY(),ctr->m_min.GetZ());
		vmax.Set(ctr->m_max.GetX(),ctr->m_max.GetY(),pz);
		ctr->m_left = new TXKDTree(vmin,vmax);
		vmin.Set(ctr->m_min.GetX(),ctr->m_min.GetY(),pz);
		vmax.Set(ctr->m_min.GetX(),ctr->m_max.GetY(),ctr->m_max.GetZ());
		ctr->m_right = new TXKDTree(vmin,vmax);
	}

	//build sub-trees
	Build(points,numl,ctr->m_left,depth,max,cdepth+1);
	Build(points+numl,numr,ctr->m_right,depth,max,cdepth+1);
}
Application::Application(SDL_Window* w) {
    Application(w, new BaseLog());
}
示例#4
0
void
NotificationView::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case B_GET_PROPERTY:
		{
			BMessage specifier;
			const char* property;
			BMessage reply(B_REPLY);
			bool msgOkay = true;

			if (msg->FindMessage("specifiers", 0, &specifier) != B_OK)
				msgOkay = false;
			if (specifier.FindString("property", &property) != B_OK)
				msgOkay = false;

			if (msgOkay) {
				if (strcmp(property, "type") == 0)
					reply.AddInt32("result", fType);

				if (strcmp(property, "app") == 0)
					reply.AddString("result", fApp);

				if (strcmp(property, "title") == 0)
					reply.AddString("result", fTitle);

				if (strcmp(property, "content") == 0)
					reply.AddString("result", fText);

				if (strcmp(property, "progress") == 0)
					reply.AddFloat("result", fProgress);

				if ((strcmp(property, "icon") == 0) && fBitmap) {
					BMessage archive;
					if (fBitmap->Archive(&archive) == B_OK)
						reply.AddMessage("result", &archive);
				}

				reply.AddInt32("error", B_OK);
			} else {
				reply.what = B_MESSAGE_NOT_UNDERSTOOD;
				reply.AddInt32("error", B_ERROR);
			}

			msg->SendReply(&reply);
			break;
		}
		case B_SET_PROPERTY:
		{
			BMessage specifier;
			const char* property;
			BMessage reply(B_REPLY);
			bool msgOkay = true;

			if (msg->FindMessage("specifiers", 0, &specifier) != B_OK)
				msgOkay = false;
			if (specifier.FindString("property", &property) != B_OK)
				msgOkay = false;

			if (msgOkay) {
				if (strcmp(property, "app") == 0)
					msg->FindString("data", &fApp);

				if (strcmp(property, "title") == 0)
					msg->FindString("data", &fTitle);

				if (strcmp(property, "content") == 0)
					msg->FindString("data", &fText);

				if (strcmp(property, "icon") == 0) {
					BMessage archive;
					if (msg->FindMessage("data", &archive) == B_OK) {
						delete fBitmap;
						fBitmap = new BBitmap(&archive);
					}
				}

				SetText(Application(), Title(), Text());
				Invalidate();

				reply.AddInt32("error", B_OK);
			} else {
				reply.what = B_MESSAGE_NOT_UNDERSTOOD;
				reply.AddInt32("error", B_ERROR);
			}

			msg->SendReply(&reply);
			break;
		}
		case kRemoveView:
		{
			BMessage remove(kRemoveView);
			remove.AddPointer("view", this);
			BMessenger msgr(Window());
			msgr.SendMessage( &remove );
			break;
		}
		default:
			BView::MessageReceived(msg);
	}
}
示例#5
0
void
NotificationView::FrameResized( float w, float /*h*/)
{
	SetText(Application(), Title(), Text());
}
示例#6
0
static void OnOtherProject(ConstructorAppFnr& fnr)
{
    ConstructorApp& app = Application();
    if( CheckBeforeClosing(app) )
        fnr(app);
}
示例#7
0
bool CManipulatorTool::MouseInput(int iButton, tinker_mouse_state_t iState)
{
	if (!IsActive())
		return false;

	if (!iState)
	{
		if (m_bTransforming)
		{
			m_bTransforming = false;

			m_trsTransform = GetNewTRS();

			m_pListener->ManipulatorUpdated(m_sListenerArguments);

			return true;
		}

		return false;
	}

	int x, y;
	Application()->GetMousePosition(x, y);

	Vector vecPosition = GameServer()->GetRenderer()->WorldPosition(Vector((float)x, (float)y, 1));
	Vector vecCamera = GameServer()->GetRenderer()->GetCameraPosition();

	float flClosest = -1;
	m_iLockedAxis = -1;

	Matrix4x4 mTransform = m_trsTransform.GetMatrix4x4(false, false);

	float flScale = (float)(Vector(GameServer()->GetCameraManager()->GetCameraPosition()) - mTransform.GetTranslation()).Length()/10.0f;
	Vector vecX = (Vector(1, 0, 0)*flScale);
	Vector vecY = (Vector(0, 1, 0)*flScale);
	Vector vecZ = (Vector(0, 0, 1)*flScale);

	if (DistanceToLine(m_trsTransform.m_vecTranslation, vecPosition, vecCamera) < 0.2f*flScale)
	{
		m_flOriginalDistance = (m_trsTransform.m_vecTranslation - vecCamera).Length();
		m_iLockedAxis = 0;
	}

	if (DistanceToLine(mTransform*vecX, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecX - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<1)|(1<<2);
		}
	}

	if (DistanceToLine(mTransform*vecY, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecY - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<0)|(1<<2);
		}
	}

	if (DistanceToLine(mTransform*vecZ, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecZ - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<0)|(1<<1);
		}
	}

	if (m_iLockedAxis >= 0)
	{
		m_flStartX = (float)x;
		m_flStartY = (float)y;
		m_bTransforming = true;

		if (m_pListener && Application()->IsShiftDown())
			m_pListener->DuplicateMove("");

		return true;
	}

	return false;
}
示例#8
0
void ToonixGLDrawer_Term( XSI::CRef in_pSequencerContext, LPVOID *in_pUserData )
{
	_drawer._camera = NULL;
	_drawer._geom = NULL;
	Application().LogMessage(L"ToonixGLDrawer_Term Called");
}
示例#9
0
int main (int size, char** arguments)
{
	//calls the main() method in class Application, which then calls the run() method to run the program (either from the Console class or GraphicalUserInterface class)
	return Application().main(size, arguments);
}
示例#10
0
bool MeshSimBuilder::buildApplication( int argc , char ** argv )
{
	// Initialize common subsystems.
	assert( Frame::initializeFramePool( 10 ) );

	// Initialize interface implementations...
	IAir3TFactory & factory = IAir3TFactory::factory( argc , argv );
	assert( factory.led().initialize() );
	assert( factory.monochromeDisplay().initialize() );
	assert( factory.joystick().initialize() );
	factory.phyTransceiver().initialize();

	// Parse command line arguments and start tests if requested...
	int c;
	optind = 0;
	while ( ( c = getopt( argc , argv , "s:p:n:i:t:" ) ) != -1 )
	{
		switch( c )
		{
			case 't':
				if ( strcmp( optarg , "ledblink" ) == 0 )
				{
					new LEDBlinker( factory.led() );
				}
				else if ( strcmp( optarg , "simplefsm" ) == 0 )
				{
					Trace::out( "Starting Simple FSM..." );
					new CdPlayerHandler();
					return true;
				}
				else if ( strcmp( optarg , "ledblinke" ) == 0 )
				{
					Trace::out( "Starting LED blink test (XF)..." );
					new LEDBlinker( factory.led() );
					return true;
				}
				else if ( strcmp( optarg , "painter" ) == 0 )
				{
					Trace::out( "Starting Painter test..." );
					new PaintTester( factory.joystick() , factory.monochromeDisplay() );
					return true;
				}
				else if ( strcmp( optarg , "local" ) == 0 )
				{
					Trace::out( "Starting Local TicTacToe game..." );
					new LocalTTTController();
					return true;
				}
				else if ( strcmp( optarg , "phy" ) == 0 )
				{
					Trace::out( "Starting PHY test..." );
					new PhyTester( factory.phyTransceiver() , factory.joystick() , factory.monochromeDisplay() );
					return true;
				}
#				ifdef DATALINK_LAYER_TESTER_PRESENT
					else if ( strcmp( optarg , "datalink" ) == 0 )
					{
						Trace::out( "Starting Data link test..." );
						assert( factory.dataLink().initialize( factory.phyTransceiver() , Node::NodeId::fromHexString( __DATALINK_ID ) ) );
						new DataLinkTester( factory.dataLink(), factory.joystick() );
						return true;
					}
#				endif
#				ifdef APPLICATION_LAYER_TESTER_PRESENT
					else if ( strcmp( optarg , "applayer" ) == 0 )
					{
						Trace::out( "Starting Application layer test..." );
						assert( DataLink().initialize( factory.phyTransceiver() , Node::NodeId::fromHexString( __DATALINK_ID ) ) );
						assert( Application().initialize() );
						new ApplicationLayerTester( factory.joystick() , factory.monochromeDisplay() );
						return true;
					}
#				endif
				break;
		}
	}

#ifdef AIR3T_SOLUTION_PRESENT
	// Start the Air3T game if not another test was requested.
	assert( DataLink().initialize( factory.phyTransceiver() , Node::NodeId::fromHexString( __DATALINK_ID ) ) );
	assert( Application().initialize() );
	new Air3T::Controller( __MESH_NAME , factory.monochromeDisplay() , factory.joystick() );
#else
#	warning Air3T Solution is not present. Add here your solution building process or directly inside the main function...
#endif

	return true;
}
void Application::createInstance() {
	assert(mpsInstance == NULL);

	mpsInstance = myNew Application();
}
示例#12
0
文件: ao.cpp 项目: ezhangle/SMAK
void CAOGenerator::GenerateShadowMaps()
{
    double flProcessSceneRead = 0;
    double flProgress = 0;

    size_t iShadowMapSize = 1024;

    // A frame buffer for holding the depth buffer shadow render
    CFrameBuffer oDepthFB = SMAKRenderer()->CreateFrameBuffer(iShadowMapSize, iShadowMapSize, (fb_options_e)(FB_DEPTH_TEXTURE|FB_RENDERBUFFER)); // RB unused

    // A frame buffer for holding the UV layout once it is rendered flat with the shadow
    CFrameBuffer oUVFB = SMAKRenderer()->CreateFrameBuffer(m_iWidth, m_iHeight, (fb_options_e)(FB_TEXTURE|FB_LINEAR|FB_DEPTH)); // Depth unused

    // A frame buffer for holding the completed AO map
    m_oAOFB = SMAKRenderer()->CreateFrameBuffer(m_iWidth, m_iHeight, (fb_options_e)(FB_TEXTURE|FB_TEXTURE_HALF_FLOAT|FB_LINEAR|FB_DEPTH)); // Depth unused

    CRenderingContext c(SMAKRenderer());

    c.UseFrameBuffer(&m_oAOFB);

    c.ClearColor(Color(0, 0, 0, 0));

    c.SetDepthFunction(DF_LEQUAL);
    c.SetDepthTest(true);
    c.SetBackCulling(false);

    Matrix4x4 mBias(
        0.5f, 0.0f, 0.0f, 0.0f,
        0.0f, 0.5f, 0.0f, 0.0f,
        0.0f, 0.0f, 0.5f, 0.0f,
        0.5f, 0.5f, 0.5f, 1.0f); // Bias from [-1, 1] to [0, 1]

    AABB oBox = m_pScene->m_oExtends;
    Vector vecCenter = oBox.Center();
    float flSize = oBox.Size().Length();	// Length of the box's diagonal

    Matrix4x4 mLightProjection = Matrix4x4::ProjectOrthographic(-flSize/2, flSize/2, -flSize/2, flSize/2, 1, flSize*2);

    size_t iSamples = (size_t)sqrt((float)m_iSamples);

    m_pWorkListener->SetAction("Taking exposures", m_iSamples);

    for (size_t x = 0; x <= iSamples; x++)
    {
        float flPitch = -asin(RemapVal((float)x, 0, (float)iSamples, -1, 1)) * 90 / (M_PI/2);

        for (size_t y = 0; y < iSamples; y++)
        {
            if (x == 0 || x == iSamples)
            {
                // Don't do a bunch of samples from the same spot on the poles.
                if (y != 0)
                    continue;
            }

            float flYaw = RemapVal((float)y, 0, (float)iSamples, -180, 180);

            // Randomize the direction a tad to help fight moire
            Vector vecDir = AngleVector(EAngle(flPitch+RandomFloat(-1, 1)/2, flYaw+RandomFloat(-1, 1)/2, 0));
            Vector vecLightPosition = vecDir*flSize + vecCenter;	// Puts us twice as far from the closest vertex

            if (ao_debug.GetInt() > 1)
                SMAKWindow()->AddDebugLine(vecLightPosition, vecLightPosition-vecDir);

            Matrix4x4 mLightView = Matrix4x4::ConstructCameraView(vecLightPosition, (vecCenter-vecLightPosition).Normalized(), Vector(0, 1, 0));

            c.SetProjection(mLightProjection);
            c.SetView(mLightView);

            // If we're looking from below and ground occlusion is on, don't bother with this render.
            if (!(flPitch < -10 && m_bGroundOcclusion))
            {
                c.UseProgram("model");
                c.UseFrameBuffer(&oDepthFB);
                c.SetViewport(Rect(0, 0, iShadowMapSize, iShadowMapSize));
                c.SetBackCulling(false);
                c.ClearDepth();

                c.BeginRenderVertexArray(m_iSceneDepth);
                c.SetPositionBuffer((size_t)0, 8*sizeof(float));
                c.SetNormalsBuffer((size_t)3*sizeof(float), 8*sizeof(float));
                c.SetTexCoordBuffer((size_t)6*sizeof(float), 8*sizeof(float));
                c.EndRenderVertexArray(m_iSceneDepthVerts);

                c.UseFrameBuffer(nullptr);

                if (ao_debug.GetBool())
                {
                    CRenderingContext c(SMAKRenderer());
                    c.SetViewport(Rect(0, 0, iShadowMapSize/2, iShadowMapSize/2));

                    DrawTexture(oDepthFB.m_iDepthTexture, 1, c);
                }
            }

            Matrix4x4 mTextureMatrix = mBias*mLightProjection*mLightView;

            {
                CRenderingContext c(SMAKRenderer(), true);

                c.UseFrameBuffer(&oUVFB);
                c.SetViewport(Rect(0, 0, m_iWidth, m_iHeight));
                c.ClearColor(Color(0, 0, 0, 0));
                c.ClearDepth();

                c.UseProgram("flat_shadow");
                c.SetUniform("mBiasedLightMatrix", mTextureMatrix);
                c.SetUniform("iShadowMap", 0);
                c.SetUniform("vecLightNormal", -vecDir);
                c.SetUniform("bOccludeAll", (flPitch < -10 && m_bGroundOcclusion));
                c.SetUniform("flTime", (float)Application()->GetTime());
                c.BindTexture(oDepthFB.m_iDepthTexture);

                c.BeginRenderVertexArray(m_iScene);
                c.SetPositionBuffer((size_t)0, 8*sizeof(float));
                c.SetNormalsBuffer((size_t)3*sizeof(float), 8*sizeof(float));
                c.SetTexCoordBuffer((size_t)6*sizeof(float), 8*sizeof(float));
                c.EndRenderVertexArray(m_iSceneVerts);
            }

            if (ao_debug.GetBool())
            {
                CRenderingContext c(SMAKRenderer());
                c.SetViewport(Rect(iShadowMapSize/2, 0, m_iWidth, m_iHeight));
                DrawTexture(oUVFB.m_iMap, 1, c);
            }

            double flTimeBefore = SMAKWindow()->GetTime();

            c.SetViewport(Rect(0, 0, m_iWidth, m_iHeight));
            c.UseFrameBuffer(&m_oAOFB);
            AccumulateTexture(oUVFB.m_iMap);
            c.UseFrameBuffer(nullptr);

            if (ao_debug.GetBool())
            {
                CRenderingContext c(SMAKRenderer());
                c.UseProgram("ao");
                c.SetViewport(Rect(iShadowMapSize/2+m_iWidth, 0, m_iWidth, m_iHeight));
                c.SetUniform("iAOMap", 0);
                c.SetBlend(BLEND_ALPHA);
                DrawTexture(m_oAOFB.m_iMap, 1, c);
            }

            flProcessSceneRead += (SMAKWindow()->GetTime() - flTimeBefore);
            flTimeBefore = SMAKWindow()->GetTime();

            m_pWorkListener->WorkProgress(x*iSamples + y);

            flProgress += (SMAKWindow()->GetTime() - flTimeBefore);

            if (m_bStopGenerating)
                break;
        }

        if (m_bStopGenerating)
            break;
    }

    c.UseFrameBuffer(&m_oAOFB);
    c.ReadPixels(0, 0, m_iWidth, m_iHeight, m_pvecPixels);
    c.UseFrameBuffer(nullptr);

    if (!m_bStopGenerating)
    {
        size_t iBufferSize = m_iWidth*m_iHeight;

        m_pWorkListener->SetAction("Reading pixels", iBufferSize);

        for (size_t p = 0; p < iBufferSize; p++)
        {
            Vector4D& vecPixel = m_pvecPixels[p];
            if (vecPixel.w == 0.0f)
                continue;

            m_avecShadowValues[p].x = vecPixel.x;
            m_aiShadowReads[p] = (size_t)vecPixel.w;
            m_bPixelMask[p] = true;

            m_pWorkListener->WorkProgress(p);
        }
    }

    oDepthFB.Destroy();
    oUVFB.Destroy();
    // Don't destroy m_oAOFB yet, we need it in a bit. It gets destroyed later.
}
示例#13
0
文件: ao.cpp 项目: ezhangle/SMAK
void CAOGenerator::Generate()
{
    double flTimeStarted = Application()->GetTime();

    if (!m_eAOMethod)
        return;

    m_pWorkListener->BeginProgress();
    m_pWorkListener->SetAction("Setting up", 0);

    m_bIsGenerating = true;
    m_bStopGenerating = false;
    m_bDoneGenerating = false;
    m_bIsBleeding = false;

    m_flLowestValue = -1;
    m_flHighestValue = 0;

    if (SMAKWindow())
        SMAKWindow()->ClearDebugLines();

    memset(&m_bPixelMask[0], 0, m_iWidth*m_iHeight*sizeof(bool));

    if (m_eAOMethod == AOMETHOD_SHADOWMAP)
    {
        ShadowMapSetupScene();
        GenerateShadowMaps();
    }
    else
    {
        if (m_eAOMethod == AOMETHOD_RENDER)
            RenderSetupScene();
        // In AO debug mode we need this to do the debug rendering, so do it anyways.
        else if (ao_debug.GetBool())
            RenderSetupScene();

        GenerateByTexel();
    }

    size_t i;

    m_pWorkListener->SetAction("Averaging reads", m_iWidth*m_iHeight);

    // Average out all of the reads.
    for (i = 0; i < m_iWidth*m_iHeight; i++)
    {
        // Don't immediately return, just skip this loop. We have cleanup work to do.
        if (m_bStopGenerating)
            break;

        if (m_eAOMethod == AOMETHOD_SHADOWMAP)
            m_avecShadowValues[i] = Vector(m_avecShadowValues[i].x, m_avecShadowValues[i].x, m_avecShadowValues[i].x);

        if (m_aiShadowReads[i])
            m_avecShadowValues[i] /= (float)m_aiShadowReads[i];
        else
            m_avecShadowValues[i] = Vector(0,0,0);

        m_pWorkListener->WorkProgress(i);
    }

    if (m_eAOMethod == AOMETHOD_RENDER || m_eAOMethod == AOMETHOD_SHADOWMAP)
    {
        if (m_eAOMethod == AOMETHOD_SHADOWMAP)
        {
            m_oAOFB.Destroy();
            CRenderer::UnloadVertexDataFromGL(m_iScene);
            CRenderer::UnloadVertexDataFromGL(m_iSceneDepth);
        }
        else
        {
            for (size_t i = 0; i < m_aiSceneMaterials.size(); i++)
                CRenderer::UnloadVertexDataFromGL(m_aiSceneMaterials[i]);

            m_oRenderFB.Destroy();
        }
    }

    // Somebody get this ao some clotters and morphine, STAT!
    m_bIsBleeding = true;
    if (!m_bStopGenerating)
        Bleed();
    m_bIsBleeding = false;

    if (!m_bStopGenerating)
        m_bDoneGenerating = true;
    m_bIsGenerating = false;

    // One last call to let them know we're done.
    m_pWorkListener->EndProgress();

    double flTimeEnded = Application()->GetTime();
    double flTimePassed = flTimeEnded - flTimeStarted;
    TMsg(sprintf("AO generation completed in %f seconds\n", flTimePassed));
}
示例#14
0
bool CShader::Compile()
{
	tstring sShaderHeader = CShaderLibrary::GetShaderHeader();

	if (CShaderLibrary::Get()->m_iSamples)
		sShaderHeader += "#define USE_MULTISAMPLE_TEXTURES 1\n";

	sShaderHeader += CShaderLibrary::GetShaderFunctions();

	FILE* f = tfopen("shaders/" + m_sVertexFile + ".vs", "r");

	TAssert(f);
	if (!f)
		return false;

	tstring sVertexShader = sShaderHeader;
	sVertexShader += "uniform mat4x4 mProjection;\n";
	sVertexShader += "uniform mat4x4 mView;\n";
	sVertexShader += "uniform mat4x4 mGlobal;\n";

	tstring sLine;
	while (fgetts(sLine, f))
		sVertexShader += sLine;

	fclose(f);

	f = tfopen("shaders/" + m_sFragmentFile + ".fs", "r");

	TAssert(f);
	if (!f)
		return false;

	tstring sFragmentShader = sShaderHeader;
	sFragmentShader += "out vec4 vecOutputColor;\n";

	while (fgetts(sLine, f))
		sFragmentShader += sLine;

	fclose(f);

	size_t iVShader = glCreateShader(GL_VERTEX_SHADER);
	const char* pszStr = sVertexShader.c_str();
	glShaderSource((GLuint)iVShader, 1, &pszStr, NULL);
	glCompileShader((GLuint)iVShader);

	int iVertexCompiled;
	glGetShaderiv((GLuint)iVShader, GL_COMPILE_STATUS, &iVertexCompiled);

	if (iVertexCompiled != GL_TRUE || Application()->HasCommandLineSwitch("--debug-gl"))
	{
		int iLogLength = 0;
		char szLog[1024];
		glGetShaderInfoLog((GLuint)iVShader, 1024, &iLogLength, szLog);
		CShaderLibrary::Get()->WriteLog(m_sVertexFile + ".vs", szLog, pszStr);
	}

	size_t iFShader = glCreateShader(GL_FRAGMENT_SHADER);
	pszStr = sFragmentShader.c_str();
	glShaderSource((GLuint)iFShader, 1, &pszStr, NULL);
	glCompileShader((GLuint)iFShader);

	int iFragmentCompiled;
	glGetShaderiv((GLuint)iFShader, GL_COMPILE_STATUS, &iFragmentCompiled);

	if (iFragmentCompiled != GL_TRUE || Application()->HasCommandLineSwitch("--debug-gl"))
	{
		int iLogLength = 0;
		char szLog[1024];
		glGetShaderInfoLog((GLuint)iFShader, 1024, &iLogLength, szLog);
		CShaderLibrary::Get()->WriteLog(m_sFragmentFile + ".fs", szLog, pszStr);
	}

	size_t iProgram = glCreateProgram();

	glBindAttribLocation(iProgram, 0, "vecPosition");		// Force position at location 0. ATI cards won't work without this.

	glAttachShader((GLuint)iProgram, (GLuint)iVShader);
	glAttachShader((GLuint)iProgram, (GLuint)iFShader);
	glLinkProgram((GLuint)iProgram);

	int iProgramLinked;
	glGetProgramiv((GLuint)iProgram, GL_LINK_STATUS, &iProgramLinked);

	if (iProgramLinked != GL_TRUE || Application()->HasCommandLineSwitch("--debug-gl"))
	{
		int iLogLength = 0;
		char szLog[1024];
		glGetProgramInfoLog((GLuint)iProgram, 1024, &iLogLength, szLog);
		CShaderLibrary::Get()->WriteLog("link", szLog, "link");
	}

	if (iVertexCompiled != GL_TRUE || iFragmentCompiled != GL_TRUE || iProgramLinked != GL_TRUE)
	{
		TError("Shader compilation failed for shader " + m_sName + ". Check shaders.txt\n");

		Destroy();

		return false;
	}

	m_iProgram = iProgram;
	m_iVShader = iVShader;
	m_iFShader = iFShader;

	m_iPositionAttribute = glGetAttribLocation(m_iProgram, "vecPosition");
	m_iNormalAttribute = glGetAttribLocation(m_iProgram, "vecNormal");
	m_iTangentAttribute = glGetAttribLocation(m_iProgram, "vecTangent");
	m_iBitangentAttribute = glGetAttribLocation(m_iProgram, "vecBitangent");
	for (size_t i = 0; i < MAX_TEXTURE_CHANNELS; i++)
		m_aiTexCoordAttributes[i] = glGetAttribLocation(m_iProgram, sprintf("vecTexCoord%d", i).c_str());
	m_iColorAttribute = glGetAttribLocation(m_iProgram, "vecVertexColor");

	glBindFragDataLocation(m_iProgram, 0, "vecOutputColor");

	TAssert(m_iPositionAttribute != ~0);

	int iNumUniforms;
	glGetProgramiv(m_iProgram, GL_ACTIVE_UNIFORMS, &iNumUniforms);

	char szUniformName[256];
	GLsizei iLength;
	GLint iSize;
	GLenum iType;
	for (int i = 0; i < iNumUniforms; i++)
	{
		glGetActiveUniform(m_iProgram, i, sizeof(szUniformName), &iLength, &iSize, &iType, szUniformName);

		tstring sUniformName = szUniformName;
		if (sUniformName == "mProjection")
			continue;
		if (sUniformName == "mView")
			continue;
		if (sUniformName == "mGlobal")
			continue;

		CShader::CUniform& oUniform = m_asUniforms[sUniformName];
		oUniform.m_pDefault = nullptr;
		switch (iType)
		{
		case GL_FLOAT: oUniform.m_sUniformType = "float"; break;
		case GL_FLOAT_VEC2: oUniform.m_sUniformType = "vec2"; break;
		case GL_FLOAT_VEC3: oUniform.m_sUniformType = "vec3"; break;
		case GL_FLOAT_VEC4: oUniform.m_sUniformType = "vec4"; break;
		case GL_INT: oUniform.m_sUniformType = "int"; break;
		case GL_BOOL: oUniform.m_sUniformType = "bool"; break;
		case GL_FLOAT_MAT4: oUniform.m_sUniformType = "mat4"; break;
		case GL_SAMPLER_2D: oUniform.m_sUniformType = "sampler2D"; break;
		default: TUnimplemented();
		}
	}

	for (auto it = m_aParameters.begin(); it != m_aParameters.end(); it++)
	{
		for (size_t j = 0; j < it->second.m_aActions.size(); j++)
		{
			auto it2 = m_asUniforms.find(it->second.m_aActions[j].m_sName);
			TAssert(it2 != m_asUniforms.end());
			if (it2 == m_asUniforms.end())
			{
				TError("Shader '" + m_sName + "' specifies a uniform '" + it->second.m_aActions[j].m_sName + "' that is not in the linked program.\n");
				continue;
			}

			CShader::CUniform& oUniform = it2->second;

			// This is almost cheating
			CData d;
			d.SetValue(it->second.m_aActions[j].m_sValue);

			if (oUniform.m_sUniformType == "float")
				it->second.m_aActions[j].m_flValue = d.GetValueFloat();
			else if (oUniform.m_sUniformType == "vec2")
				it->second.m_aActions[j].m_vec2Value = d.GetValueVector2D();
			else if (oUniform.m_sUniformType == "vec3")
				it->second.m_aActions[j].m_vecValue = d.GetValueVector();
			else if (oUniform.m_sUniformType == "vec4")
				it->second.m_aActions[j].m_vec4Value = d.GetValueVector4D();
			else if (oUniform.m_sUniformType == "int")
				it->second.m_aActions[j].m_iValue = d.GetValueInt();
			else if (oUniform.m_sUniformType == "bool")
				it->second.m_aActions[j].m_bValue = d.GetValueBool();
			else if (oUniform.m_sUniformType == "mat4")
			{
				TUnimplemented();
			}
			else if (oUniform.m_sUniformType == "sampler2D")
			{
				// No op.
			}
			else
				TUnimplemented();
		}
	}

	for (auto it = m_aDefaults.begin(); it != m_aDefaults.end(); it++)
	{
		auto it2 = m_asUniforms.find(it->first);
		TAssert(it2 != m_asUniforms.end());
		if (it2 == m_asUniforms.end())
		{
			TError("Shader '" + m_sName + "' specifies a default for uniform '" + it->second.m_sName + "' that is not in the linked program.\n");
			continue;
		}

		CShader::CUniform& oUniform = it2->second;
		oUniform.m_pDefault = &it->second;

		// Again with the cheating.
		CData d;
		d.SetValue(it->second.m_sValue);

		if (oUniform.m_sUniformType == "float")
			it->second.m_flValue = d.GetValueFloat();
		else if (oUniform.m_sUniformType == "vec2")
			it->second.m_vec2Value = d.GetValueVector2D();
		else if (oUniform.m_sUniformType == "vec3")
			it->second.m_vecValue = d.GetValueVector();
		else if (oUniform.m_sUniformType == "vec4")
			it->second.m_vec4Value = d.GetValueVector4D();
		else if (oUniform.m_sUniformType == "int")
			it->second.m_iValue = d.GetValueInt();
		else if (oUniform.m_sUniformType == "bool")
			it->second.m_bValue = d.GetValueBool();
		else if (oUniform.m_sUniformType == "mat4")
		{
			TUnimplemented(); 
		}
		else if (oUniform.m_sUniformType == "sampler2D")
		{
			TUnimplemented(); // Can't set a default texture... yet.
		}
		else
			TUnimplemented();
	}

	return true;
}
示例#15
0
// The Game Loop http://www.youtube.com/watch?v=c4b9lCfSDQM
void CGame::GameLoop()
{
	m_hPlayer = CreateCharacter();

	// Initialize the box's position etc
	m_hPlayer->SetGlobalOrigin(Point(0, 0, 0));
	m_hPlayer->m_vecMovement = Vector(0, 0, 0);
	m_hPlayer->m_vecMovementGoal = Vector(0, 0, 0);
	m_hPlayer->m_vecVelocity = Vector(0, 0, 0);
	m_hPlayer->m_vecGravity = Vector(0, -10, 0);
	m_hPlayer->m_flSpeed = 15;
	m_hPlayer->m_clrRender = Color(0.8f, 0.4f, 0.2f, 1.0f);
	m_hPlayer->m_bHitByTraces = false;
	m_hPlayer->m_aabbSize = AABB(-Vector(0.5f, 0, 0.5f), Vector(0.5f, 2, 0.5f));
	m_hPlayer->m_bTakesDamage = true;

	Vector vecMonsterMin = Vector(-1, 0, -1);
	Vector vecMonsterMax = Vector(1, 2, 1);

	/*CCharacter* pTarget1 = CreateCharacter();
	pTarget1->SetTransform(Vector(2, 2, 2), 0, Vector(0, 1, 0), Vector(6, 0, 6));
	pTarget1->m_aabbSize.vecMin = vecMonsterMin;
	pTarget1->m_aabbSize.vecMax = vecMonsterMax;
	pTarget1->m_iBillboardTexture = m_iMonsterTexture;
	pTarget1->m_bEnemyAI = true;
	pTarget1->m_bTakesDamage = true;

	CCharacter* pTarget2 = CreateCharacter();
	pTarget2->SetTransform(Vector(2, 2, 2), 0, Vector(0, 1, 0), Vector(6, 0, -6));
	pTarget2->m_aabbSize.vecMin = vecMonsterMin;
	pTarget2->m_aabbSize.vecMax = vecMonsterMax;
	pTarget2->m_iBillboardTexture = m_iMonsterTexture;
	pTarget2->m_bEnemyAI = true;
	pTarget2->m_bTakesDamage = true;

	CCharacter* pTarget3 = CreateCharacter();
	pTarget3->SetTransform(Vector(3, 3, 3), 0, Vector(0, 1, 0), Vector(-6, 0, 8));
	pTarget3->m_aabbSize.vecMin = vecMonsterMin;
	pTarget3->m_aabbSize.vecMax = vecMonsterMax;
	pTarget3->m_iBillboardTexture = m_iMonsterTexture;
	pTarget3->m_bEnemyAI = true;
	pTarget3->m_bTakesDamage = true;*/

	Vector vecPropMin = Vector(-.1f, 0, -.1f);
	Vector vecPropMax = Vector(.1f, .2f, .1f);

	mtsrand(0);

	for (int i = 0; i < 800; i++)
	{
		float rand1 = (float)(mtrand()%1000)/1000; // [0, 1]
		float rand2 = (float)(mtrand()%1000)/1000; // [0, 1]

		float theta = rand1 * 2.0f * (float)M_PI;
		float radius = sqrt(rand2);

		Vector position = Vector(radius * cos(theta), 0, radius * sin(theta));
		position = position * 50;

		CCharacter* pProp = CreateCharacter();
		pProp->SetTransform(Vector(1, 1, 1), 0, Vector(0, 1, 0), position);
		pProp->m_aabbSize.vecMin = vecPropMin;
		pProp->m_aabbSize.vecMax = vecPropMax;
		pProp->m_clrRender = Color(0.4f, 0.8f, 0.2f, 1.0f);
		pProp->m_iTexture = m_iCrateTexture;
	}

	CRenderingContext c(GetRenderer());
	c.RenderBox(Vector(-1, 0, -1), Vector(1, 2, 1));
	c.CreateVBO(m_iMeshVB, m_iMeshSize);

	float flPreviousTime = 0;
	float flCurrentTime = Application()->GetTime();

	while (true)
	{
		// flCurrentTime will be lying around from last frame. It's now the previous time.
		flPreviousTime = flCurrentTime;
		flCurrentTime = Application()->GetTime();

		float dt = flCurrentTime - flPreviousTime;

		// Keep dt from growing too large.
		if (dt > 0.15f)
			dt = 0.15f;

		Update(dt);

		Draw();
	}
}
示例#16
0
// -----------------------------------------------------------------------------
// CLocalizationAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CLocalizationAppUi::HandleCommandL( TInt aCommand )
    {
    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

		// Number
        case ELocalizationCommandNumber:
            {
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Amount to show
				TReal myAmount = 1234.567;
				
				// Real number formatter, initialized with system's current locale settings
				TRealFormat myFormat;

				// Format real with current locales decimal separator setting
				myBuf.AppendNum(myAmount, myFormat);
				
				// Show formatted text
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
            }
            break;
		
		// Currency
		case ELocalizationCommandCurrency:
			{
				// locale is initialized with system's current locale settings
				TLocale myLocale;
				
				// buffer for localized text
				TBuf<50> myBuf;

				// amount is integer, but it is treated as last two digits
				// were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ...
				TInt myAmount = 123456789;
				
				// Format currency according to current locale settings
				myLocale.FormatCurrency(myBuf, myAmount);

				// Show formatted text				
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Date
		case ELocalizationCommandDate:
			{
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Object for datetime data
				TTime myDate;
				
				// Set current datetime to object
				myDate.HomeTime();
				
				// Format date according to current locale settings
				// Format string is universal, so that whatever the locale is,
				// date is always formatted correctly
				myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X"));
				
				// Show formatted text				
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Time
		case ELocalizationCommandTime:
			{
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Object for datetime data
				TTime myTime;
				
				// Set current datetime to object
				myTime.HomeTime();

				// Format time to current locale
				// Format string is universal, so that whatever the locale is,
				// time is always formatted correctly
				myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B"));
				
				// Show formatted text			
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Text
		case ELocalizationCommandText:
			{
				// buffer for string parameters that may change order
				CDesCArrayFlat* strings = new CDesCArrayFlat( 2 );
				CleanupStack::PushL( strings );

				// Initialize parameter buffer
				
				// First parameter
				strings->AppendL( _L("Heidi") );
				
				// Second parameter
				strings->AppendL( _L("2") );
				
	            // Load a string from the resource file, and append parameters into it
				HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings );
				CleanupStack::PushL( textResource );
	            
				// Show formatted text			
	            CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( *textResource );
	            
	            // Cleanupstack
				CleanupStack::PopAndDestroy( textResource );
				CleanupStack::PopAndDestroy( strings );
			}
			break;
			
		// Image
		case ELocalizationCommandImage:
			{
			    // find the drive where the app has been installed
			    TParse parse;
			    parse.Set(Application()->AppFullName(),0,0);
			    	            
				// Load bitmap name from the resource file
            	HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive());
            	
				// bitmap pointer
				CFbsBitmap* bitmap;
				
		        // Create and Load the Bitmap
		        bitmap = new( ELeave )CFbsBitmap;
		        CleanupStack::PushL( bitmap );
		        
		        // Load the first bitmap (index 0) from multi-bitmap file
		        User::LeaveIfError(bitmap->Load( *bmpFile, 0 ));
		        
                CleanupStack::Pop( bitmap );		        
		        // Draw bitmap to screen 
		        // ownership of bitmap is transferred to view
		        iAppView->DrawImage( bitmap );

		        // Cleanupstack
            	CleanupStack::PopAndDestroy( bmpFile );
			}
			break;
		
		// Default case
        default:
            break;
        }
    }
示例#17
0
文件: main.cpp 项目: uafshahid/Spade
int main(int argc, char **argv) {
    return Application(argc, argv).run();
}
示例#18
0
static void OnSaveAsProject()
{
    if( SaveProjectAs(Application().win) )
        SaveProject();
}