Skip to content

Commit

Permalink
Solved ordering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Mar 27, 2009
1 parent bf4f5b6 commit 5ea2ab0
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion actions.cpp
Expand Up @@ -16,7 +16,7 @@ DoActionTag::DoActionTag(RECORDHEADER h, std::istream& in):DisplayListTag(h,in)
}
}

UI16 DoActionTag::getDepth()
UI16 DoActionTag::getDepth() const
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion actions.h
Expand Up @@ -16,7 +16,7 @@ class DoActionTag: public DisplayListTag
public:
DoActionTag(RECORDHEADER h, std::istream& in);
void Render( );
UI16 getDepth();
UI16 getDepth() const;
void printInfo(int t=0);
};

Expand Down
2 changes: 1 addition & 1 deletion frame.cpp
Expand Up @@ -6,7 +6,7 @@

using namespace std;

void Frame::Render()
void Frame::Render(int baseLayer)
{
cout << "Start Frame" << endl << endl;
list < DisplayListTag* >::iterator i=displayList.begin();
Expand Down
3 changes: 1 addition & 2 deletions frame.h
Expand Up @@ -10,12 +10,11 @@ class Frame
{
private:
STRING Label;
int baseLayer;
public:
std::list<DisplayListTag*> displayList;

Frame(const std::list<DisplayListTag*>& d):displayList(d),hack(0){ }
void Render();
void Render(int baseLayer);
void setLabel(STRING l);

int hack;
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Expand Up @@ -82,9 +82,9 @@ int main()

//if(sys.clip.state.FP>=43)
// sys.clip.frames[sys.clip.state.FP].hack=1;
sys.clip.frames[sys.clip.state.FP].Render();
sys.clip.frames[sys.clip.state.FP].Render(0);

if(1)
if(0)
{

glReadPixels(0,240,640,240,GL_DEPTH_COMPONENT,GL_FLOAT,buffer);
Expand Down
13 changes: 12 additions & 1 deletion swf.cpp
Expand Up @@ -40,6 +40,11 @@ SystemState::SystemState():currentDisplayList(&clip.displayList),currentState(&c
sem_init(&sem_run,0,0);
}

bool list_orderer(const DisplayListTag* a, int d)
{
return a->getDepth()<d;
}

void* ParseThread::worker(void* in_ptr)
{
ifstream& f=*(ifstream*)in_ptr;
Expand Down Expand Up @@ -67,7 +72,13 @@ void* ParseThread::worker(void* in_ptr)
break;
case DISPLAY_LIST_TAG:
if(dynamic_cast<DisplayListTag*>(tag)->add_to_list)
sys.clip.displayList.push_back(dynamic_cast<DisplayListTag*>(tag));
{
list<DisplayListTag*>::iterator it=lower_bound(sys.clip.displayList.begin(),
sys.clip.displayList.end(),
dynamic_cast<DisplayListTag*>(tag)->getDepth(),
list_orderer);
sys.clip.displayList.insert(it,dynamic_cast<DisplayListTag*>(tag));
}
break;
case SHOW_TAG:
{
Expand Down
4 changes: 2 additions & 2 deletions swftypes.h
Expand Up @@ -24,8 +24,8 @@ class UI16
public:
UI16():val(0){}
UI16(uint16_t v):val(v){}
operator uint16_t(){ return val; }
operator UI32(){ return val; }
operator uint16_t() const { return val; }
operator UI32() const { return val; }
};

class UI8
Expand Down
17 changes: 13 additions & 4 deletions tags.cpp
Expand Up @@ -96,6 +96,8 @@ SetBackgroundColorTag::SetBackgroundColorTag(RECORDHEADER h, std::istream& in):C
// std::cout << BackgroundColor << std::endl;
}

bool list_orderer(const DisplayListTag* a, int d);

DefineSpriteTag::DefineSpriteTag(RECORDHEADER h, std::istream& in):RenderTag(h,in)
{
list < DisplayListTag* >* bak=sys.currentDisplayList;
Expand All @@ -115,7 +117,13 @@ DefineSpriteTag::DefineSpriteTag(RECORDHEADER h, std::istream& in):RenderTag(h,i
throw "Sprite Render";
case DISPLAY_LIST_TAG:
if(dynamic_cast<DisplayListTag*>(tag)->add_to_list)
clip.displayList.push_back(dynamic_cast<DisplayListTag*>(tag));
{
list<DisplayListTag*>::iterator it=lower_bound(clip.displayList.begin(),
clip.displayList.end(),
dynamic_cast<DisplayListTag*>(tag)->getDepth(),
list_orderer);
clip.displayList.insert(it,dynamic_cast<DisplayListTag*>(tag));
}
break;
case SHOW_TAG:
{
Expand Down Expand Up @@ -196,17 +204,18 @@ void DefineSpriteTag::Render(int layer)
sys.currentState=&clip.state;
std::cout << "==> Render Sprite" << std::endl;
clip.state.next_FP=min(clip.state.FP+1,clip.frames.size()-1);
clip.state.next_FP=min(clip.state.next_FP,4);
// clip.state.next_FP=min(clip.state.next_FP,4);

list<DisplayListTag*>::iterator it=clip.frames[clip.state.FP].displayList.begin();
cerr << "Inizio DEBUG frame " << clip.state.FP << endl;
cerr << "Inizio DEBUG frame " << clip.state.FP << " layer " << layer << endl;
for(it;it!=clip.frames[clip.state.FP].displayList.end();it++)
{
(*it)->printInfo(1);
cerr << "Depth " << (*it)->getDepth() << endl;
}
cerr << "Fine DEBUG" << endl;

clip.frames[clip.state.FP].Render();
clip.frames[clip.state.FP].Render(layer);
// clip.frames.back().hack=layer;
// clip.frames.back().Render();

Expand Down
6 changes: 3 additions & 3 deletions tags.h
Expand Up @@ -44,7 +44,7 @@ class DisplayListTag: public Tag
bool add_to_list;
DisplayListTag(RECORDHEADER h, std::istream& s):Tag(h,s),add_to_list(true){}
virtual TAGTYPE getType(){ return DISPLAY_LIST_TAG; }
virtual UI16 getDepth()=0;
virtual UI16 getDepth() const=0;
virtual void Render()=0;
};

Expand Down Expand Up @@ -178,7 +178,7 @@ class PlaceObject2Tag: public DisplayListTag
public:
PlaceObject2Tag(RECORDHEADER h, std::istream& in);
void Render( );
UI16 getDepth()
UI16 getDepth() const
{
return Depth;
}
Expand All @@ -193,7 +193,7 @@ class FrameLabelTag: public DisplayListTag
public:
FrameLabelTag(RECORDHEADER h, std::istream& in);
void Render( );
UI16 getDepth()
UI16 getDepth() const
{
return 0;
}
Expand Down

0 comments on commit 5ea2ab0

Please sign in to comment.