예제 #1
0
파일: render.cpp 프로젝트: newobj/taz
	void BeginProjectionPerspective()
	{
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();

		if ( m_pCamera )
		{
			const CVec2i& vViewportDims = m_pCamera->GetViewportDims();
			const CVec2i& vViewportPosition = CVec2i(m_vTranslation.x, GetVideo()->GetHeight() - vViewportDims.y + m_vTranslation.y);

			glViewport(vViewportPosition.x, vViewportPosition.y, vViewportDims.x, vViewportDims.y);
			gluPerspective(m_pCamera->GetFOV(), m_pCamera->GetAspectRatio(), m_pCamera->GetNearZ(), m_pCamera->GetFarZ());
		}
		else
		{
			glViewport(0, 0, GetVideo()->GetWidth(), GetVideo()->GetHeight());
			gluPerspective(45.0f, (GLdouble)GetVideo()->GetWidth()/(GLdouble)GetVideo()->GetHeight(), 1.0f, 10000.0f);
		}

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glLoadIdentity();

		if ( m_pCamera )
		{
			CVec3f vLookat = m_pCamera->GetPosition()+m_pCamera->GetDirection();
			gluLookAt(Vec3Expand(m_pCamera->GetPosition()), Vec3Expand(vLookat), Vec3Expand(m_pCamera->GetUp()));
		}
	}
예제 #2
0
void Crowd::UpdateAnimation(int delta)
{
    if (!GetVideo()->IsReady())
    {
        Begin();
    }

    GetVideo()->Update(delta);
}
예제 #3
0
BOOL CGvGVideoMgr::SaveToDB()
{
    if(m_setNotSavedVideoID.empty())
    {
        return TRUE;
    }

    for(VideoIDSet::iterator itr = m_setNotSavedVideoID.begin(); itr != m_setNotSavedVideoID.end(); ++itr)
    {
        VideoID videoID = *itr;

        SGvGVideo *pstVideo = GetVideo(videoID);
        if(NULL == pstVideo)
        {
            continue;
        }

        CBaseDBCMD* poCMD = gsapi::GetDBMgr()->CreateCmd(EDBCT_SAVE_GVG_VIDEO);
        if(NULL == poCMD)
        {
            return FALSE;
        }

        gsapi::GetDBMgr()->AddCommand(poCMD);
        poCMD->SetUserData(pstVideo);
    }

    return TRUE;
}
예제 #4
0
	void Sprite_Impl::paint(){
		IVideo& Vi = GetVideo();
		vector2i_t ss = Vi.getDeviceSize();

		Vi.setBlendColor(m_CMode, color);
		Vi.setBlendMode(m_Mode);
		Vi.selectImageSourceRect(m_SrcRc);
		float w = (float)m_Img.get()->getWidth() * (m_SrcRc.right - m_SrcRc.left), h = (float)m_Img.get()->getHeight() * (m_SrcRc.bottom - m_SrcRc.top);
		Vi.renderImage(*m_Img.get(), rect(-m_CenterH * w, -m_CenterV * h, (1 - m_CenterH) * w, (1 - m_CenterV) * h));
	}
예제 #5
0
BOOL CGvGVideoMgr::LoadPKVideoFromDB()
{
    SGDP::ISDDBSession*	pDBSession = gsapi::GetDBMgr()->GetDBSession();
    if(NULL == pDBSession)
    {
        return FALSE;
    }

    CAutoSqlBuf oAutoBuf;
    CAutoSqlBuf oEscapeBuf;

    CHAR* pszBuff=oAutoBuf.GetSqlBuf();
    CHAR* pszEscapeBuff=oEscapeBuf.GetSqlBuf();

    char buf[256] = {0};
    sprintf(buf, "select * from gvgpkvideo order by VideoID,PKNum asc");

    ISDDBRecordSet *pRecordSet = NULL;
    string strError;
    INT32 nRet = pDBSession->ExecuteSqlRs(buf, &pRecordSet, NULL, &strError);
    if(SDDB_HAS_RECORDSET != nRet && SDDB_NO_RECORDSET != nRet)
    {
        SYS_CRITICAL(_SDT("[%s: %d]: CGvGVideoMgr::LoadPKVideoFromDB execute sql failed! sql = [%s], err = [%s]"), MSG_MARK, buf, strError.c_str());
        return FALSE;
    }

    if(SDDB_HAS_RECORDSET == nRet && pRecordSet)
    {
        VideoID videoID = 0;
        UINT16 wPKNum = 0;

        while(pRecordSet->GetRecord()) // 当有行结果时
        {
            videoID = SDAtou64(pRecordSet->GetFieldValueByName("VideoID"));
            SGvGVideo *pstVideo = GetVideo(videoID);
            if(NULL == pstVideo)
            {
                continue;
            }

            wPKNum = SDAtou(pRecordSet->GetFieldValueByName("PKNum"));
            pstVideo->vecPvPVideo.resize(wPKNum);

            DT_GVG_PK_VIDEO &stPKVideo = pstVideo->vecPvPVideo[wPKNum - 1];
            memset(&stPKVideo, 0, sizeof(stPKVideo));

            DecodeSaveDataFromDB("VideoData", stPKVideo);
        }

        pRecordSet->Release();
    }

    PrintMissingList();
    return TRUE;
}
예제 #6
0
Vector2 Crowd::GetZOrderPoint()
{
    if (anchorPosition >= 0)
    {
        return Vector2(position.GetX() + GetVideo()->GetWidth() / 2, position.GetY() + anchorPosition);
    }
    else
    {
        return Vector2(0, -1);
    }
}
예제 #7
0
파일: game.c 프로젝트: gubagame/gamengine
int gameMainOpen(void)
{

    unsigned int joy;
    tmouse *mo;

    int sound;
    int draw;
    
      

        actualLevel->view.buf=GetVideo();
        
        joy=GetJoystick();
        mo=getMouseInf();
        
        actualLevel->mouse=mo;
        actualLevel->key=joy;
        
   
        draw=getDrawFrame();
    
        switch (runStateGame) 
        {
            case 0:
                if(loadGame(actualLevel,draw)) 
                    runStateGame=1;
            break;
            case 1:
                runGame(actualLevel,draw);
            break;        
            default:
            break;
        }
        
    
        wipeView(&actualLevel->transiction);
              
        if(getRenderAudio())
            sound=SRenderAudio();
        
        if(draw) FlipVideo();
        WaitSyncTimer();  
        
        
        getFPS(&Vfpsg,&Vfps);
		
      
        return draw;
             
   
}
예제 #8
0
파일: appbase.cpp 프로젝트: newobj/taz
void CAppBase::Release()
{
	if ( 0 != --m_cRef ) return;

	GetInput()->Release();
	GetClasses()->Release();
	GetUi()->Release();
	GetRender()->Release();
	GetVideo()->Release();
	GetResources()->Release();
	GetGlue()->RemoveGlued(this);
	GetGlue()->Release();
}
예제 #9
0
파일: render.cpp 프로젝트: newobj/taz
	void BeginRenderPassNormal()
	{
		m_eRenderPass = eRenderPassNormal;

		m_vDimsViewport = CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight());	
		glViewport(0, 0, m_vDimsViewport.x, m_vDimsViewport.y);
/*
		GL::SetTexture2d(false);
		GL::SetColor(CRGBA(64,64,64,192));
		GL::SetLineWidth(1.0f);
		glBegin(GL_LINES);
		for ( float x = 0 ; x < 33 ; x++ )
		{
			for ( float z = 0 ; z < 33 ; z++ )
			{
				glVertex3f(x*10, 0, z*10);
				glVertex3f((x+1)*10, 0, z*10);

				glVertex3f(x*10, 0, z*10);
				glVertex3f(x*10, 0, (z+1)*10);
			}
		}
		glEnd();
*/	}
예제 #10
0
파일: appbase.cpp 프로젝트: newobj/taz
void CAppBase::Acquire()
{
	if ( 1 != ++m_cRef ) return;

	GetGlue()->Acquire();

	GetGlue()->AddGlued(this);
	GetResources()->Acquire();
	GetVideo()->Acquire();
	GetVideo()->SetWidth(800);
	GetVideo()->SetHeight(600);
	GetVideo()->ApplySettings();
	GetRender()->Acquire();
	GetUi()->Acquire();
	GetClasses()->Acquire();
	GetInput()->Acquire();

	// OLD STUFF
	
	CGuid Guid;
	Guid.Create();

	NETWORKINITSTRUCT nis;
	nis.Guid = Guid;
//	if ( !GetNetwork()->Init(nis) )
//	{
//		return -1;
//	}
	
	OBJECTSINITSTRUCT ois;
	ois.bServer = true;
	if ( !GetObjects()->Init(ois) )
	{
		return;
	}
}
예제 #11
0
void CGvGVideoMgr::AddVideo(SGvGVideo &stVideo)
{
    if(0 == stVideo.stGvGInfo.qwVideoID)
    {
        return;
    }

    if(GetVideo(stVideo.stGvGInfo.qwVideoID))
    {
        USR_INFO(_SDT("CGvGVideoMgr::AddVideo[%llu], [%s] vs [%s] %s, round = [%u:%u], PKVideoCnt = %u, found exist video, skip."), 
            stVideo.stGvGInfo.qwVideoID,
            stVideo.stGvGInfo.stG1.aszFactionName,
            stVideo.stGvGInfo.stG2.aszFactionName,
            gvgvideoutil::EchoBattleResult(stVideo.stGvGInfo.byBattleResult).c_str(),
            stVideo.stGvGInfo.stRound.byBigRound, stVideo.stGvGInfo.stRound.bySmallRound,
            stVideo.stGvGInfo.byPKVideoCnt
        );

        return;
    }

    m_mapVideo[stVideo.stGvGInfo.qwVideoID] = stVideo;

    if(stVideo.IsAllPKVideoHere())
    {
        USR_INFO(_SDT("CGvGVideoMgr::AddVideo[%llu], [%s] vs [%s] %s, round = [%u:%u], all pk video is here, PKVideoCnt = %u"), 
            stVideo.stGvGInfo.qwVideoID,
            stVideo.stGvGInfo.stG1.aszFactionName,
            stVideo.stGvGInfo.stG2.aszFactionName,
            gvgvideoutil::EchoBattleResult(stVideo.stGvGInfo.byBattleResult).c_str(),
            stVideo.stGvGInfo.stRound.byBigRound, stVideo.stGvGInfo.stRound.bySmallRound,
            stVideo.stGvGInfo.byPKVideoCnt
        );

        m_setNotSavedVideoID.insert(stVideo.stGvGInfo.qwVideoID);
    }
    else
    {
        USR_INFO(_SDT("CGvGVideoMgr::AddVideo[%llu], [%s] vs [%s] %s, round = [%u:%u], not all pk video is here, PKVideoCnt = %u"), 
            stVideo.stGvGInfo.qwVideoID,
            stVideo.stGvGInfo.stG1.aszFactionName,
            stVideo.stGvGInfo.stG2.aszFactionName,
            gvgvideoutil::EchoBattleResult(stVideo.stGvGInfo.byBattleResult).c_str(),
            stVideo.stGvGInfo.stRound.byBigRound, stVideo.stGvGInfo.stRound.bySmallRound,
            stVideo.stGvGInfo.byPKVideoCnt
        );
    }
}
예제 #12
0
파일: game.c 프로젝트: gubagame/gamengine
gameLevel * setLevel(gameLevel *gl)
{
    
    gl->xview=0;
    gl->yview=0;
    gl->view.buf=GetVideo();
    gl->view.resx=GetVideoWidth();
    gl->view.resy=GetVideoHeight();
    gl->idxLoadActor=0;
    gl->stateGame=0;
    cloneImage(&gl->view,&gl->frame);
    
    runStateGame=0;
	flgRun=1;
    

	return gl;
}
예제 #13
0
파일: render.cpp 프로젝트: newobj/taz
	void RenderFacesImage(IImage* pImage)
	{
		float cx = pImage->GetDims().x/2.0f;
		float cy = pImage->GetDims().y/2.0f;

		float dx = (float)pImage->GetPosition().x+cx;
		float dy = ((float)pImage->GetPosition().y+cy);

		float bx = m_vTranslation.x;
		float by = m_vTranslation.y;

		float u1 = 0.0f;//ShaderStage.eTextureCoords()(0);
		float v1 = 1.0f;//1.0f - ShaderStage.eTextureCoords()(1);
		float u2 = 1.0f;//ShaderStage.eTextureCoords()(2);
		float v2 = 0.0f;//1.0f - ShaderStage.eTextureCoords()(3);

		CRectf rectVertices(dx-cx, dy-cy, dx+cx, dy+cy);
		CRectf rectTexcoords(u1, v1, u2, v2);

		bool bRotate = pImage->GetRotation() != 0.0f;

		if ( bRotate )
		{
			glPushMatrix();
			glTranslatef(+(bx+rectVertices.m_vMin.x+cx), +(by+cy+(GetVideo()->GetHeight() - rectVertices.m_vMax.y)), 0.0f);
			glRotatef(-pImage->GetRotation(), 0, 0, 1);
			glTranslatef(-(bx+rectVertices.m_vMin.x+cx), -(by+cy+(GetVideo()->GetHeight() - rectVertices.m_vMax.y)), 0.0f);
		}

		GL::SetColor(pImage->GetTint());

		glBegin(GL_QUADS);

		glTexCoord2f(rectTexcoords.m_vMin.u, rectTexcoords.m_vMax.v);
		glVertex3f(bx+rectVertices.m_vMin.x, by+(GetVideo()->GetHeight() - rectVertices.m_vMax.y), 1.0f);

		glTexCoord2f(rectTexcoords.m_vMax.u, rectTexcoords.m_vMax.v);
		glVertex3f(bx+rectVertices.m_vMax.x, by+(GetVideo()->GetHeight() - rectVertices.m_vMax.y), 1.0f);

		glTexCoord2f(rectTexcoords.m_vMax.u, rectTexcoords.m_vMin.v);
		glVertex3f(bx+rectVertices.m_vMax.x, by+(GetVideo()->GetHeight() - rectVertices.m_vMin.y), 1.0f);

		glTexCoord2f(rectTexcoords.m_vMin.u, rectTexcoords.m_vMin.v);
		glVertex3f(bx+rectVertices.m_vMin.x, by+(GetVideo()->GetHeight() - rectVertices.m_vMin.y), 1.0f);

		glEnd();

		if ( bRotate )
		{
			glPopMatrix();
		}
	}
예제 #14
0
파일: render.cpp 프로젝트: newobj/taz
	void ClearRectGradient(const CRecti& rect, const CRGBA argba[])
	{
		class CCustomDrawClearRectGradient : public CCustomDraw
		{
			public :

				CCustomDrawClearRectGradient(int nHeight, const CRGBA* argba, const CRecti& rect) 
					: m_nHeight(nHeight), m_argba(argba), m_rect(rect)
				{
				}

				void Render(uint32 iPiece)
				{
					glBegin(GL_QUADS);
					glTexCoord2f(0,0);
					GL::SetColor(m_argba[2]);//glColor4f(m_argba[2].r/255.0f, m_argba[2].g/255.0f, m_argba[2].b/255.0f, m_argba[2].a/255.0f * m_fFade);
					glVertex3f(m_rect.m_vMin.x, (m_nHeight + m_rect.m_vMax.y), 1.0f);
					glTexCoord2f(1,0);
					GL::SetColor(m_argba[3]);//glColor4f(m_argba[3].r/255.0f, m_argba[3].g/255.0f, m_argba[3].b/255.0f, m_argba[3].a/255.0f * m_fFade);
					glVertex3f(m_rect.m_vMax.x, (m_nHeight + m_rect.m_vMax.y), 1.0f);
					glTexCoord2f(1,1);
					GL::SetColor(m_argba[1]);//glColor4f(m_argba[1].r/255.0f, m_argba[1].g/255.0f, m_argba[1].b/255.0f, m_argba[1].a/255.0f * m_fFade);
					glVertex3f(m_rect.m_vMax.x, (m_nHeight + m_rect.m_vMin.y), 1.0f);
					glTexCoord2f(0,1);
					GL::SetColor(m_argba[0]);//glColor4f(m_argba[0].r/255.0f, m_argba[0].g/255.0f, m_argba[0].b/255.0f, m_argba[0].a/255.0f * m_fFade);
					glVertex3f(m_rect.m_vMin.x, (m_nHeight + m_rect.m_vMin.y), 1.0f);
					glEnd();
				}

				int m_nHeight;
				const CRGBA* m_argba;
				const CRecti& m_rect;
		};

		CRecti rectTranslated(rect.m_vMin.x + m_vTranslation.x, -rect.m_vMin.y + m_vTranslation.y, rect.m_vMax.x + m_vTranslation.x, -rect.m_vMax.y + m_vTranslation.y);
		CCustomDrawClearRectGradient CustomDrawClearRectGradient(GetVideo()->GetHeight(), argba, rectTranslated);
		CustomDrawClearRectGradient.AddShader(m_pShaderWhite);

		RenderCustomDraw(&CustomDrawClearRectGradient);
	}
예제 #15
0
파일: render.cpp 프로젝트: newobj/taz
	void ClearRect(const CRecti& rect, const CRGBA& rgba)
	{
		class CCustomDrawClearRect : public CCustomDraw
		{
			public :

				CCustomDrawClearRect(int nHeight, const CRGBA& rgba, const CRecti& rect)
					: m_nHeight(nHeight), m_rgba(rgba), m_rect(rect)
				{
				}

				void Render(uint32 iPiece)
				{
					GL::SetColor(m_rgba);

					glBegin(GL_QUADS);
					glTexCoord2f(0,0);
					glVertex3f(m_rect.m_vMin.x, (m_nHeight + m_rect.m_vMax.y), 1.0f);
					glTexCoord2f(1,0);
					glVertex3f(m_rect.m_vMax.x, (m_nHeight + m_rect.m_vMax.y), 1.0f);
					glTexCoord2f(1,1);
					glVertex3f(m_rect.m_vMax.x, (m_nHeight + m_rect.m_vMin.y), 1.0f);
					glTexCoord2f(0,1);
					glVertex3f(m_rect.m_vMin.x, (m_nHeight + m_rect.m_vMin.y), 1.0f);
					glEnd();
				}

				int m_nHeight;
				const CRGBA& m_rgba;
				const CRecti& m_rect;
		};

		CRecti rectTranslated(rect.m_vMin.x + m_vTranslation.x, -rect.m_vMin.y + m_vTranslation.y, rect.m_vMax.x + m_vTranslation.x, -rect.m_vMax.y + m_vTranslation.y);
		CCustomDrawClearRect CustomDrawClearRect(GetVideo()->GetHeight(), rgba, rectTranslated);
		CustomDrawClearRect.AddShader(m_pShaderWhite);

		RenderCustomDraw(&CustomDrawClearRect);
	}
예제 #16
0
파일: render.cpp 프로젝트: newobj/taz
	void EndRenderPassAccum()
	{
		m_eRenderPass = eRenderPassNormal;

		BeginProjectionOrtho(); 
		{ 
			GL::SetTexture(m_iTextureAccum);
			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, Vec2Expand(m_vDimsAccum), 0);

			GL::SetDepthTest(eDepthTestNone);
			GL::SetBlend(true);

			// Overbright
			{
				GL::SetBlendFunc(eBlendDestColor, eBlendOne);
				GL::SetColor(CRGBA(255,255,255,255/m_nFilterSize));
				for ( uint32 iMultiply = 0 ; iMultiply < m_nAccumMultiply ; ++iMultiply )
				{
					RENDERACCUM(0,0);
				}
				glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, Vec2Expand(m_vDimsAccum), 0);
			}

			// Blur
			{
				GL::SetBlendFunc(eBlendSrcAlpha, eBlendInvSrcAlpha);
				GL::SetColor(CRGBA(255,255,255,255/m_nFilterSize));
				for ( int iFilter = 1 ; iFilter <= m_nFilterSize ; ++iFilter )
				{
					RENDERACCUM(-iFilter*m_fFilterScale,-iFilter*m_fFilterScale);
					RENDERACCUM(iFilter*m_fFilterScale,-iFilter*m_fFilterScale);
					RENDERACCUM(-iFilter*m_fFilterScale,iFilter*m_fFilterScale);
					RENDERACCUM(iFilter*m_fFilterScale,iFilter*m_fFilterScale);
					glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, Vec2Expand(m_vDimsAccum), 0);
				};
			}

			glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
		} 
		EndProjectionOrtho(); 

		m_vDimsViewport = CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight());	
		glViewport(0, 0, m_vDimsViewport.x, m_vDimsViewport.y);

/*		BeginProjectionOrtho();
		{
			RenderShader(IShader::Create("shaders/accumulation.shader"), CRGBA(255,255,255,255), NULL, NULL);
			
			m_iTexture = m_iTextureAccum;
			glBindTexture(GL_TEXTURE_2D, m_iTextureAccum);
			glEnable(GL_TEXTURE_2D);

			float fDiff = 0;//float(GetVideo()->GetWidth() - GetVideo()->GetHeight())/2.0f;

			glBegin(GL_QUADS);
				glTexCoord2f(0,1);
				glVertex3f(0,GetVideo()->GetHeight()+fDiff,0);
				glTexCoord2f(0,0);
				glVertex3f(0,-fDiff,0);
				glTexCoord2f(1,0);
				glVertex3f(GetVideo()->GetWidth(),-fDiff,0);
				glTexCoord2f(1,1);
				glVertex3f(GetVideo()->GetWidth(),GetVideo()->GetHeight()+fDiff,0);
			glEnd();
		}
		EndProjectionOrtho();
*/	}
예제 #17
0
파일: render.cpp 프로젝트: newobj/taz
	CVec2i Project(CCamera* pCamera, const CVec3f& vPos)
	{
		if ( pCamera == NULL )
		{
			pCamera = m_pCamera;
		}

		double afProjectionMatrix[16];
		double afModelMatrix[16];
		int32 anViewport[4];

		glMatrixMode(GL_PROJECTION);
		glPushMatrix();

		glLoadIdentity();
		gluPerspective(pCamera->GetFOV(), pCamera->GetAspectRatio(), pCamera->GetNearZ(), pCamera->GetFarZ());

		// ....

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();

		CVec3f vLookat = pCamera->GetPosition()-pCamera->GetDirection();
		glLoadIdentity();
	//	glScalef(1.0f, 1.0f, -1.0f);
		gluLookAt(Vec3Expand(pCamera->GetPosition()), Vec3Expand(vLookat), Vec3Expand(pCamera->GetUp()));

		// ....

		glGetDoublev(GL_MODELVIEW_MATRIX, afModelMatrix);
		glGetDoublev(GL_PROJECTION_MATRIX, afProjectionMatrix);

		// ....

		const CVec2i& vViewportDims = pCamera->GetViewportDims();

		anViewport[0] = 0;
		anViewport[1] = 0;
		anViewport[2] = vViewportDims.x;
		anViewport[3] = vViewportDims.y;

		// ...

		glMatrixMode(GL_PROJECTION);
		glPopMatrix();

		// ...
		
		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();

		// ...

		double x, y, z;
		gluProject(vPos.x, vPos.y, vPos.z, afModelMatrix, afProjectionMatrix, anViewport, &x, &y, &z);

		// ...

		CVec2i v = CVec2i(x, GetVideo()->GetHeight() - (GetVideo()->GetHeight()-vViewportDims.y+y));

		return v;
	}
예제 #18
0
파일: render.cpp 프로젝트: newobj/taz
	CVec3f Unproject(CCamera* pCamera, const CVec2i& vPos, float fDepth)
	{
		GLdouble  afProjectionMatrix[16];
		GLdouble  afModelMatrix[16];
		GLint  anViewport[4];

		GLint nMatrixMode;
		glGetIntegerv(GL_MATRIX_MODE, &nMatrixMode);

		// ...

		if ( pCamera == NULL )
		{
			pCamera = m_pCamera;
		}

		const CVec2i& vViewportDims = pCamera->GetViewportDims();

		glMatrixMode(GL_PROJECTION);
		glPushMatrix();

		glLoadIdentity();
		gluPerspective(pCamera->GetFOV(), pCamera->GetAspectRatio(), pCamera->GetNearZ(), pCamera->GetFarZ());

		// ....

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();

		CVec3f vLookat = pCamera->GetPosition()+pCamera->GetDirection();
		glLoadIdentity();
	//	glScalef(1.0f, 1.0f, -1.0f);
		gluLookAt(Vec3Expand(pCamera->GetPosition()), Vec3Expand(vLookat), Vec3Expand(pCamera->GetUp()));

		// ....

		glGetDoublev(GL_MODELVIEW_MATRIX, afModelMatrix);
		glGetDoublev(GL_PROJECTION_MATRIX, afProjectionMatrix);
//		glGetIntegerv(GL_VIEWPORT, anViewport);

		anViewport[0] = 0;
		anViewport[1] = 0;
		anViewport[2] = vViewportDims.x;
		anViewport[3] = vViewportDims.y;

		// ...

		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();

		// ...

		glMatrixMode(GL_PROJECTION);
		glPopMatrix();

		// ...

		glMatrixMode(nMatrixMode);

		// ...

		CVec2i v = CVec2i(vPos.x, GetVideo()->GetHeight() - (GetVideo()->GetHeight()-anViewport[3]+vPos.y));

		// ...

		double x, y, z;
		gluUnProject(v.x, v.y, fDepth, afModelMatrix, afProjectionMatrix, anViewport, &x, &y, &z);

		return CVec3f(x,y,z);
	}
예제 #19
0
파일: render.cpp 프로젝트: newobj/taz
	void RenderFacesText(IText* pText)
	{
		// Generate vertex/texcoord data for this text

		const string& sText = pText->GetText();
		const IFont* pFont = pText->GetFont();

		int nTextLength = sText.length();
		int nVideoHeight = GetVideo()->GetHeight();

		float bx = m_vTranslation.x;
		float by = m_vTranslation.y;

		float cx = pText->CalculateExtents().x/2.0f;
		float cy = pText->CalculateExtents().y/2.0f;

		bool bRotate = pText->GetRotation() != 0.0f;

		int cPasses = (pText->GetStyle() & IText::eStyleShadowed)+1;
		for ( int iPass = cPasses-1 ; iPass >= 0 ; --iPass )
		{
			int32 x = 0;
			int32 y = by + nVideoHeight;

			int32 px = pText->GetPosition().x;
			int32 py = pText->GetPosition().y;

			if ( 1 == iPass )
			{
				px += pFont->GetShadowOffset().x;
				py += pFont->GetShadowOffset().y;

				GL::SetColor(pFont->GetShadowColor());
			}
			else
			{
				GL::SetColor(pText->GetTint());
			}

			if ( bRotate )
			{
				glPushMatrix();
				glTranslatef(+(bx+px+cx), +(nVideoHeight - (by+py+cy)), 0.0f);
				glRotatef(-pText->GetRotation(), 0, 0, 1);
				glTranslatef(-(bx+px+cx), -(nVideoHeight - (by+py+cy)), 0.0f);
			}

			for ( int iCharacter = 0 ; iCharacter < nTextLength ; iCharacter++ )
			{
				char chCharacter = sText[iCharacter];

				if ( chCharacter == '\n' )
				{
					x = 0;
					y -= pFont->GetLineSkip();

					continue;
				}

				const CRectf& rect = pFont->GetGlyphTexcoords(chCharacter);
				const CVec2i& vDims = pFont->GetGlyphDims(chCharacter);
				int nAdvance = pFont->GetGlyphAdvance(chCharacter);
				float dx = vDims.x;
				float dy = vDims.y;

				if ( chCharacter == ' ' )
				{
					x += nAdvance;

					continue;
				}

				CRectf rectVertices(px+x, py, px+x+dx, py+dy);
				CRectf rectTexcoords(rect.m_vMin.x, 1.0f-rect.m_vMin.y, rect.m_vMax.x, 1.0f-rect.m_vMax.y);

				glBegin(GL_QUADS);
				{
					glTexCoord2f(rectTexcoords.m_vMin.u, rectTexcoords.m_vMax.v);
					glVertex3f(bx + rectVertices.m_vMin.x, y - rectVertices.m_vMax.y, 1.0f);

					glTexCoord2f(rectTexcoords.m_vMax.u, rectTexcoords.m_vMax.v);
					glVertex3f(bx + rectVertices.m_vMax.x, y - rectVertices.m_vMax.y, 1.0f);

					glTexCoord2f(rectTexcoords.m_vMax.u, rectTexcoords.m_vMin.v);
					glVertex3f(bx + rectVertices.m_vMax.x, y - rectVertices.m_vMin.y, 1.0f);

					glTexCoord2f(rectTexcoords.m_vMin.u, rectTexcoords.m_vMin.v);
					glVertex3f(bx + rectVertices.m_vMin.x, y - rectVertices.m_vMin.y, 1.0f);
				}
				glEnd();

				x += nAdvance;
			}

			if ( bRotate )
			{
				glPopMatrix();
			}
		}
	}
예제 #20
0
void Crowd::Begin()
{
    GetVideo()->Begin();
}
예제 #21
0
파일: appbase.cpp 프로젝트: newobj/taz
void CAppBase::Render()
{
//	SDL_SysWMinfo wmi = { 0 };
//	SDL_GetWMInfo(&wmi);
//	SetWindowPos(wmi.window, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOREPOSITION |SWP_NOSIZE);

	CCamera Camera;
	Camera.SetViewportDims(CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight()));
	GetRender()->SetCamera(&Camera);
	
	CVec3f vDirection;
	vDirection.Point(g_fAzimuth, g_fElevation);
	Camera.SetDirection(-vDirection);
	
	CVec3f vPosition(0,0,0);
	vDirection *= g_fZoom;
	Camera.SetPosition(vPosition+vDirection+CVec3f(160,0,160));
//	Camera.SetFOV(60.0f);
//	Camera.SetAspectRatio(4.0f/3.0f);
	static ITube* s_pTube = NULL;
	if ( !s_pTube )
	{
		s_pTube = ITube::Create();
		s_pTube->SetShader("shaders/tube.shader");
		CVec3f vPoint(0,0,0);
		for ( int i = 0 ; i < 100 ; ++i )
		{
			s_pTube->AddControlPoint(CVec3f(160+20.0f*sin(float(i)/10.0f), i, (160+20.0f*cos(float(i)/10.0f))));
		}
	}

	GetRender()->BeginProjection(eProjectionPerspective);
	{
		GetRender()->BeginRenderPass(eRenderPassAccum);
		{
			GetScene()->Render3d();
			GetRender()->RenderTube(s_pTube);
		}
		GetRender()->EndRenderPass(eRenderPassAccum);

		GetRender()->BeginRenderPass(eRenderPassNormal);
		{
			GetScene()->Render3d();
			GetRender()->RenderTube(s_pTube);

			static bool once = true;
			static CVec3f vSrc;
			static CVec3f vDest;
//				if ( once )
			{
				vSrc = GetRender()->Unproject(NULL, g_vMousePos, 10.0f);
				vDest = GetRender()->Unproject(NULL, g_vMousePos, 10000.0f);
				once=false;
			}

			CVec3f vDir = vDest-vSrc; vDir.Normalize();
			IObject* pObject = NULL;
			if ( pObject = GetScene()->PickObject(vSrc, vDir) )
			{
				Debug("Picked %s", pObject->GetClass()->GetClassDef()->GetName().c_str());
			}

			CPlane3f plane(CVec3f(0,1,0), 0.0f);
			if ( plane.IntersectRay(CRay3f(vSrc, vDir), &g_vCursor3d) )
			{
//				Debug("x,y,z = %f,%f,%f", g_vCursor3d.x, g_vCursor3d.y, g_vCursor3d.z);
			}
			else
			{
//				Debug("...");
			}

//				GetRender()->RenderLine(CVec3f(160,0,160), vDest, CRGBA(255,255,0,255));
//				GetRender()->RenderLine(CVec3f(0,0,0), vDest, CRGBA(0,255,0,255));
//				GetRender()->RenderModelSkinned(&s_ModelSkinned);
		}
		GetRender()->EndRenderPass(eRenderPassNormal);
	}
	GetRender()->EndProjection(eProjectionPerspective);
	GetRender()->BeginProjection(eProjectionOrtho);
	{
		GetUi()->Render();
	}
	GetRender()->EndProjection(eProjectionOrtho);

	GetRender()->SetCamera(NULL);

	GetRender()->Swap();
}
예제 #22
0
void Crowd::Draw(Vector2 offsetVector)
{
    GetVideo()->Draw(GetPosition() - offsetVector);
}
예제 #23
0
void Crowd::Reset()
{
    GetVideo()->Reset();
    SetIsClicked(false);
}