HRESULT OGLTest::Init(HINSTANCE hInstance,
                      LPSTR lpCmdLine,
                      int nCmdShow)
{
    parseCmdLine(lpCmdLine);

    HRESULT hr = initWindow(hInstance, nCmdShow);
    if (SUCCEEDED(hr))
    {
        mpRender = CreateRender(miRenderId);
        if (mpRender)
        {
            hr = initOGL();
            if (SUCCEEDED(hr))
            {
                setCurrentGLCtx(mhGLRC);

                hr = mpRender->InitRender();
                if (FAILED(hr))
                {
                    TestShowError(hr, "InitRender");
                }

                setCurrentGLCtx(NULL);
            }
        }
        else
        {
            hr = E_FAIL;
        }
    }

    return hr;
}
IFXRESULT CIFXRenderContext::GetNumDevices(IFXRenderWindow& rWindow, U32& uNumDevices)
{
	IFXRESULT rc = IFX_OK;

	// This will be in virtual coordinates (screen coordinates among all monitors)
	IFXRect VisibleSpriteRect;
	rWindow.GetWindowSizeVC(VisibleSpriteRect);

	uNumDevices = 0;

	// Only proceed further if some portion of the sprite is visible.
	if(VisibleSpriteRect.m_Width > 0 && VisibleSpriteRect.m_Height > 0)
	{
		m_rcWindowVC = VisibleSpriteRect;

		IFXRect rcWin;

		// Cycle over all monitors to find which of them the render context area
		// appears on.
		U32 i;
		for( i = 0; i < m_uNumMonitors; i++)
		{
			rcWin = VisibleSpriteRect;
			if((m_pMonitors[i].m_rcScreen.GetIntersection(rcWin) && !rWindow.GetDTS())
				|| (i == 0 && rWindow.GetDTS()) )
			{
				// The above if statement will succeed if a portion of the render context
				// area appears on monitor i.
				uNumDevices++;

				if(!m_ppRender[i].IsValid())
				{
					// Create a render object for this monitor if there isn't one yet.
					rc = CreateRender(i, rWindow);
				}

				// Do an addref of the render object that we are using.
				m_ppRender[i].IncRef();
			}

			// DecRef will decrement the reference count of the object
			// only if the pointer is valid.  So, if the render object
			// at i has already been destroyed, this will not break.
			// Also, since we have already addref'ed the objects that
			// we are currently using, only render objects that we are no
			// long using will end up with a lower reference count.
			m_ppRender[i].DecRef();
		}
	}

	IFXASSERTBOXEX(IFXSUCCESS(rc), "Failed GetNumDevices", FALSE, TRUE);

	return rc;
}
示例#3
0
/**
* ALI_DTV_SUB_Region_Render_Context_Create:
* @ SUBHandle:       IN, the context ptr of SUB module
* @ display_set:     IN, the ready display set.
* @ region_id:       IN, the ID of the region you want to render.
* @ hline_callback:     IN, function to draw a horizontal line (may be NULL)
* @ string_callback:    IN, function to draw a string (may be NULL)
* @ set_color_callback: IN, function to map pseudo color to display color
* @ priv:               IN, private data to callback functions
*
* Description: Create a rendering context of a region
*
* Returns:  !NULL, the Context 
*            NULL, err
*/
void* ALI_DTV_SUB_Region_Render_Context_Create(HANDLE SUBHandle,void* display_set,unsigned int region_id,
                                                               DrawHLine_CB hline_callback,DrawString_CB string_callback,
                                                               ColorSet_CB set_color_callback,void *priv)
{
  	pSUBCtxt hr = (pSUBCtxt)SUBHandle;
    tDisplaySet *ds=(tDisplaySet *)display_set;    
	if(IS_HANDLE_VALID(hr)&& IS_HANDLE_VALID(ds)){    
       return CreateRender(ds,region_id,hline_callback,string_callback,set_color_callback,priv);
    }
    return NULL;
}
示例#4
0
SYSTEM::CSmartPtr<IRender>  IRender::CreateRenderFromStream(SYSTEM::IArchive &ar)
{
	int startpos = ar.GetCurrentPos();
	int i;
	ar & i;
	std::string renderName = "";

	IRenderPtr pRender = CreateRender( (RENDER_TYPE)i , renderName);

	ar.GetCurrentPos() = startpos; 

	if (pRender != NULL)
		pRender->serialization( ar );

	return pRender;

}
示例#5
0
void ffplayer::RenderThreadRun()
{
	if (m_hwnd)
	{
		CreateRender();
	}

	int iWidth = 0;
	int iHeight = 0;

	bool bFirst = true;
	while (1)
	{
	//	Sleep(10);
		if (m_bStop)
			break;
		
		/*
		if (bFirst)
		{
			if (m_renderBuf.getCurCount() < 2)//这里会导致音乐.mp3的画面没显示
			{
				continue;
			}
		}*/
		if (m_bStepNext&&m_bStepEnd){
			RefreshRender();
			continue;
		}
		if (m_bPause &&!m_bPausedSeek){		
			RefreshRender();
			continue;
		}
	
		PInfo pYuvInfo = m_renderBuf.getInfoFromList();
		if (!pYuvInfo){
			RefreshRender();
			if (m_bFileEnd&&m_fileEndBak){
				m_fileEndBak(m_nID, m_pUser);
				Sleep(1000);
				continue;//
			}
			Sleep(10);
			continue;
		}else{
			if (bFirst){
				bFirst = false;
			}else{
				
				if (pYuvInfo->frameInfo.serial == m_serial/*&&!m_bSeekState&&m_serial == m_audclk.serial*/)//暂停后再seek后,声音暂停了m_audclk.serial还是原来的,不等于m_serial
				{
					if (pYuvInfo->frameInfo.serial == m_lastserial){

				/*		if (m_seekTime != 0)
						{
							//秒
							double duation = pYuvInfo->frameInfo.iTimestampObsolute* av_q2d(m_pFormatCtx->streams[m_videoStream]->time_base);
							if (m_seekTime < duation)
							{
								UpdateVideoPts(pYuvInfo);
								m_freeRenderBuf.insertList(pYuvInfo);//
								continue;
							}
							else
							{
								m_seekTime = 0;
							}

						}*/
					//	if (m_serial == m_audclk.serial)//有这句会导致无音频的视频不会Async
						if (!m_bFastNoDelay)
						{
							int dif = Async(pYuvInfo->frameInfo.iTimestampObsolute);
						}
						
					/*	if (dif < 0)
						{
							UpdateVideoPts(pYuvInfo);
							m_freeRenderBuf.insertList(pYuvInfo);
							continue;
						}*/
						if (m_bPausedSeek)
							m_bPausedSeek = false;

					 }else{
						
						UpdateVideoPts(pYuvInfo);
						m_freeRenderBuf.insertList(pYuvInfo);//只更新pts和serial,不显示,显示会花屏
						continue;
					}
				}else{
					m_freeRenderBuf.insertList(pYuvInfo);//另一个系列不用显示,忽略
					continue;		
				}
			}		

			if (m_displayBak)
			{
				DISPLAYCALLBCK_INFO pDisplayInfo;
				pDisplayInfo.pBuf = (char*)pYuvInfo->Data;
				pDisplayInfo.nBufLen = pYuvInfo->width*pYuvInfo->height * 3 / 2;
				pDisplayInfo.nWidth = pYuvInfo->width;
				pDisplayInfo.nHeight = pYuvInfo->height;
				pDisplayInfo.nUser = (long)m_pDisplayUser;
				pDisplayInfo.nStamp = GetPlayedTime();
				m_displayBak(&pDisplayInfo);
			}
			if (m_hwnd)
			{
				int w, h;
				RECT rc;
				GetWindowRect(m_hwnd, &rc);
				w = rc.right - rc.left;
				h = rc.bottom - rc.top;
				if (iWidth != w || iHeight != h){
					iWidth = w;
					iHeight = h;
					SDL_SetWindowSize(m_sdlWindow, w, h);
				}

				if (m_pTexture == NULL)
					m_pTexture = SDL_CreateTexture(m_pRender, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STREAMING, pYuvInfo->width, pYuvInfo->height);


				//计算yuv一行数据占的字节数
				int iPitch = pYuvInfo->width*SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_IYUV);

				int i = SDL_UpdateTexture(m_pTexture, NULL, pYuvInfo->Data, iPitch);

				SDL_RenderClear(m_pRender);
				SDL_RenderCopy(m_pRender, m_pTexture, NULL, NULL);
				SDL_RenderPresent(m_pRender);
			}
			if (m_bReadFrameFinish)
				m_curFrameCount++;
			else
				m_tmpFrameCount++;			

			m_picSnopshot = pYuvInfo;

			UpdateVideoPts(pYuvInfo);
			m_freeRenderBuf.insertList(pYuvInfo);
			m_bStepEnd = true;		
		}
	}

	DestoryRender();	
}
示例#6
0
    //
    // Constructor
    //
    CDemo_GL::CDemo_GL( 
                       HINSTANCE Instance, UINT Width, UINT Height, const WCHAR *Caption 
                       ):
        IDemo( Instance, Width, Height, Caption )
    {
        Vec3<float> Eye( 0.0f, 50.0f, 120.0f );
        Vec3<float> At( 0.0f, 0.0f, 0.0f );
        Vec3<float> Up( 0.0f, 1.0f, 0.0f );

        m_View.LookAtRH( Eye, At, Up ); 
        m_Proj.PerspectiveRH( 60.0f, (float)m_Width / (float)m_Height, 1.0f, 1000.0f );
        m_Ortho.Ortho2DRH( 0.0f, m_Width, 0.0f, m_Height );

        try
        {
            CreateRender();
        }
        catch (const Sys::CException& Ex)
        {
            DestroyRender();
            
            throw Ex;
        }

        //
        // Render
        //

        try
        {
            CreateRender();
        }
        catch (const Sys::CException& Ex)
        {
            DestroyRender();
            
            throw Ex;
        }

        //
        // Driver description
        //

        GL::CDriver::GetDesc( &m_DriverDesc );

        //
        // Font
        //

        GLU::CFont::TDesc Desc;

        Desc.Height = 14;
        Desc.Width = 0;
        Desc.Weight = FW_NORMAL;
        Desc.Italic = false;
        Desc.Underline = false;
        Desc.CharSet = DEFAULT_CHARSET;
        Desc.OutputPrecision = OUT_DEFAULT_PRECIS;
        Desc.Quality = ANTIALIASED_QUALITY;//DEFAULT_QUALITY;
        Desc.PitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
        wcscpy( Desc.FaceName, L"Microsoft Sans Serif" );

        m_Font = new GLU::CBitmapFont( Desc );

        m_Stack = new GLU::CMatrixStack();
    }