ImmediateMode.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 
00017 #include <assert.h>
00018 #include "ImmediateMode.h"
00019 
00020 using namespace Fluxus;
00021 
00022 ImmediateMode::ImmediateMode()
00023 {
00024 }
00025 
00026 ImmediateMode::~ImmediateMode()
00027 {
00028 }
00029 
00030 void ImmediateMode::Add(Primitive *p, State *s)
00031 {   
00032     assert(p!=NULL);
00033     assert(s!=NULL);
00034     IMItem *newitem = new IMItem;
00035     newitem->m_State = *s;
00036     newitem->m_Primitive = p;
00037     m_IMRecord.push_back(newitem);
00038 }
00039 
00040 void ImmediateMode::Render(unsigned int CamIndex, ShadowVolumeGen *shadowgen)
00041 {
00043     for(vector<IMItem*>::iterator i=m_IMRecord.begin(); i!=m_IMRecord.end(); ++i)
00044     {
00045         glPushMatrix();
00046         (*i)->m_State.Apply();
00047         // need to set the state to the primitive to update the parts of the state the 
00048         // render call acts on. need to look at this.
00049         assert((*i)->m_Primitive!=NULL);
00050         (*i)->m_Primitive->SetState(&(*i)->m_State);    
00051         (*i)->m_Primitive->Prerender();
00052         (*i)->m_Primitive->Render();
00053         
00054         if (shadowgen && (*i)->m_Primitive->GetState()->Hints & HINT_CAST_SHADOW)
00055         {
00056             shadowgen->Generate((*i)->m_Primitive);
00057         }
00058         glPopMatrix();
00059     }
00060 }
00061 
00062 void ImmediateMode::Clear()
00063 {
00064     for(vector<IMItem*>::iterator i=m_IMRecord.begin(); i!=m_IMRecord.end(); ++i)
00065     {
00066         delete *i;
00067     }
00068     
00069     m_IMRecord.clear();
00070 }

Generated on Wed Sep 17 21:16:30 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1