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 "ImmediateMode.h"
00018 
00019 using namespace Fluxus;
00020 
00021 ImmediateMode::ImmediateMode()
00022 {
00023 }
00024 
00025 ImmediateMode::~ImmediateMode()
00026 {
00027 }
00028 
00029 void ImmediateMode::Add(Primitive *p, State *s)
00030 {   
00031     IMItem *newitem = new IMItem;
00032     newitem->m_State = *s;
00033     newitem->m_Primitive = p;
00034     m_IMRecord.push_back(newitem);
00035 }
00036 
00037 void ImmediateMode::Render()
00038 {
00039     for(vector<IMItem*>::iterator i=m_IMRecord.begin(); i!=m_IMRecord.end(); ++i)
00040     {
00041         glPushMatrix();
00042         (*i)->m_State.Apply();
00043         // need to set the state to the primitive to update the parts of the state the 
00044         // render call acts on. need to look at this.
00045         (*i)->m_Primitive->SetState(&(*i)->m_State);    
00046         (*i)->m_Primitive->Prerender();
00047         (*i)->m_Primitive->Render();
00048         glPopMatrix();
00049     }
00050 }
00051 
00052 void ImmediateMode::Clear()
00053 {
00054     for(vector<IMItem*>::iterator i=m_IMRecord.begin(); i!=m_IMRecord.end(); ++i)
00055     {
00056         delete *i;
00057     }
00058     
00059     m_IMRecord.clear();
00060 }

Generated on Tue Sep 4 23:22:18 2007 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1