Show end.cpp syntax highlighted
/***************************************************************************
end.cpp - End rendering block
-------------------
begin : Tue Apr 1 2003
copyright : (C) 2003 by Reality Rift Studios
email : mattias@realityrift.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoDevOpenGL, end.cpp
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2003
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#include "device.h"
#include "rendertarget.h"
#include "renderqueue.h"
#include <neoengine/renderentity.h>
#include <neoengine/profile.h>
using namespace std;
using namespace NeoEngine;
namespace NeoOGL
{
void Device::End()
{
BEGIN_PROFILE( "Flush" );
m_pkCurTarget->Flush();
END_PROFILE();
BEGIN_PROFILE( "Events" );
BEGIN_PROFILE( "Lights" );
//Call PERLIGHT frame callbacks
vector< FrameCallback* >::iterator ppkCallbackBegin = m_avpkFrameCallbacks[ FrameCallback::PERLIGHT ].begin();
vector< FrameCallback* >::iterator ppkCallbackEnd = m_avpkFrameCallbacks[ FrameCallback::PERLIGHT ].end();
vector< FrameCallback* >::iterator ppkCallback;
unsigned int uiNumLights = m_uiNumLights;
//Frame is finished, reset lights (make sure PERLIGHT objects doesn't get called again if starting new render block)
m_uiNumLights = 0;
Light *pkLight;
for( unsigned int uiLight = 0; uiLight < uiNumLights; ++uiLight )
{
ppkCallback = ppkCallbackBegin;
pkLight = m_ppkLights[ uiLight ];
for( ; ppkCallback != ppkCallbackEnd; ++ppkCallback )
if( (*ppkCallback)->IsActive() )
(*ppkCallback)->FrameEvent( FrameCallback::PERLIGHT, (void*)pkLight );
}
END_PROFILE();
BEGIN_PROFILE( "Frame end" );
//Call FRAMEEND callbacks
ppkCallback = m_avpkFrameCallbacks[ FrameCallback::FRAMEEND ].begin();
ppkCallbackEnd = m_avpkFrameCallbacks[ FrameCallback::FRAMEEND ].end();
for( ; ppkCallback != ppkCallbackEnd; ++ppkCallback )
if( (*ppkCallback)->IsActive() )
(*ppkCallback)->FrameEvent( FrameCallback::FRAMEEND, 0 );
END_PROFILE();
END_PROFILE(); // Events
BEGIN_PROFILE( "glFlush" );
glFlush();
END_PROFILE();
//Increase frame counter
++RenderEntity::s_uiFrameCount;
}
void RenderTarget::Flush()
{
m_pkNormalQueue->CleanOps();
m_pkNoTransQueue->CleanOps();
if( !( m_uiFrameFlags & RenderDevice::NOSORT ) )
m_pkNormalQueue->SortOps();
m_pkNoTransQueue->ExecuteOps();
m_pkNormalQueue->ExecuteOps();
m_pkNormalQueue->m_iNumOps = 0;
m_pkNoTransQueue->m_iNumOps = 0;
}
}; // namespace NeoOGL
See more files for this project here