bool CRenderPipeline::BatchRender(void)
{
	if ( 0 == m_sRenderVal || m_ActiveRenderOp == NULL )
		return false;
	m_sVertexCount += m_ActiveRenderOp->vertexData->vertexCount;
	return _Render(m_ActiveRenderOp);
}
Beispiel #2
0
void Engine::Run(void)
{
    uint32 ms;
    uint32 diff;
    float diff_scaled;
    while(!s_quit)
    {
        if(IsReset())
            _Reset();

        ms = GetTicks();
        diff = ms - s_lastFrameTimeReal;
        if(diff > 127) // 127 ms max. allowed diff time
            diff = 127;
        diff_scaled = diff * s_speed;
        s_fracTime = diff_scaled / 1000.0f;

        s_accuTime += diff_scaled;
        s_diffTime = uint32(s_accuTime);
        s_accuTime -= s_diffTime; // s_accuTime stores the remaining sub-milliseconds
        s_diffTimeReal = diff; // limiting this to 127 max is intentional (its not the real REAL diff then, but oh well)
        
        _ProcessEvents();
        if(!_paused)
        {
            s_curFrameTime += s_diffTime;
            _Process();
            if(_screen)
                _Render();
        }

        _CalcFPS();
        s_lastFrameTimeReal = ms;
    }
}
/*
 * For every spatial in scene, if it is LJNode,
 * call _Render recursively. Else, if it is
 * LJGeometry, caches it in a geometry cacher
 * having the same material id.
 */
HRESULT LJOGLRenderManager::_Render(LJSpatial& scene)
{
	LJGeometry *g = dynamic_cast<LJGeometry*>(&scene);
	if(g)
	{
		// empth cache
		LJOGLVCache *emptyCache = NULL;
		// find a proper cache
		VCACHES::iterator it = m_pVCaches->begin();
		while(it != m_pVCaches->end())
		{
			// found a cache with the same material
			if((*it)->GetMaterial() == g->GetMaterial())
			{
				 if(LJFailed((*it)->Add(g)))
				 {
					 return LJ_FAIL;
				 }
				 return LJ_OK;
			}
			if((*it)->IsEmpty())
			{
				emptyCache = *it;
			}
			++it;
		}
		if(emptyCache)
		{
			emptyCache->SetMaterial(g->GetMaterial());
			emptyCache->Add(g);
			return LJ_OK;
		}
		//create new cache to store the geometry
		LJOGLVCache *newCache = new LJOGLVCache(m_pLJOGL, m_pLog);
		newCache->Add(g);
		newCache->SetMaterial(g->GetMaterial());
		m_pVCaches->push_back(newCache);
		return LJ_OK;
	}
	else
	{
		LJNode *n = dynamic_cast<LJNode*>(&scene);
		if(n)
		{
			LJNode::CHILDLIST childList = n->GetChildList();
			LJNode::CHILDLIST::iterator it = childList.begin();
			while(it != childList.end())
			{
				if( LJFailed( _Render(*(*it)) ) )
					return LJ_FAIL;
				++it;
			}
			return LJ_OK;
		}
	}
	return LJ_FAIL;
}
/// 화면에 지형을 출력한다.
HRESULT	ZTerrain::Draw( ZFrustum* pFrustum )
{
	LPDWORD		pI;

    if( FAILED( m_pIB->Lock( 0, (m_cxDIB-1)*(m_czDIB-1)*2 * sizeof(TRIINDEX), (void**)&pI, 0 ) ) )
        return E_FAIL;
	m_nTriangles = m_pQuadTree->GenerateIndex( pI, m_pvHeightMap, pFrustum );
    m_pIB->Unlock();
//	g_pLog->Log( "Triangles=%d", m_nTriangles );
	_Render();

	return S_OK;
}
Beispiel #5
0
int vxl::Stoat() {
	int result = _CreateWindow();
	if (result != 0) return result;
	_Init();
	while (!glfwWindowShouldClose(m_window)) {
		// clear both depth and color each frame
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		_Update();
		_Render();
		glfwSwapBuffers(m_window);
		glfwPollEvents();
	}
	return 0;
}
bool CRenderPipeline::RenderEx(CRenderOperation* op)
{
	if ( 0 == op->vertexData->vertexCount )
		return true;
	if ( op->useIndexes &&  0 == op->indexData->indexCount )
		return true;

	if (op->useIndexes)
		m_sRenderVal = op->indexData->indexCount;
	else
		m_sRenderVal = op->vertexData->vertexCount;

	switch (op->operationType)
	{
	case PT_TRIANGLELIST:
		m_sRenderVal /= 3;
		m_sFaceCount += m_sRenderVal;
		break;
	case PT_TRIANGLESTRIP :
	case PT_TRIANGLEFAN:
		m_sRenderVal -= 2;
		m_sFaceCount += m_sRenderVal - 2;
		break;
	case PT_LINELIST :
		m_sRenderVal /= 2;
		break;
	case PT_LINESTRIP:
		m_sRenderVal -= 1;
		break;
	case PT_POINTLIST:
		break;
	}

	if ( 0 == m_sRenderVal )
		return true;

	m_sVertexCount += op->vertexData->vertexCount;
	m_pCurGpuPro = NULL;

	_setVertexDeclaration(op->vertexData->vertexDeclaration);
	_setVertexBufferBinding(op->vertexData->vertexBufferBinding);

	++m_sDrawPrimitiveCount;
	return _Render(op);
}
/*
 * add a geometry to the render list
 */
HRESULT LJOGLRenderManager::Render(LJSpatial& scene)
{
	HRESULT hr = LJ_OK;
	hr = _Render(scene);
	return hr;
}