view Renderer/Simple/SimpleEngine.cpp @ 0:df32980116bd

Initial revision
author gongo
date Sat, 02 Feb 2008 19:15:39 +0900
parents
children
line wrap: on
line source

void
SimpleEngine::init(int width, int height, int bpp)
{
    if(SDL_Init( SDL_INIT_VIDEO ) < 0)
    {
	cout << "Couldn't initialize SDL:" << SDL_GetError() << endl;
	exit(1);
    }

    // etc...
}

TaskDepend
SimpleEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait)
{
    SceneGraph *t, *nt;
    t = now;
    nt = next;

    //glPushMatrix();
    int s=0;
    while(t)
    {
	//t->draw(stack);
	t->update(t->data_pack, nt->data_pack);
	if(t->child != NULL)
	{
	    stack[s++] = t->matrix; //push
	    t = t->child;
	}
	else if(t->brother != NULL)
	{
	    stack[--s] = NULL; //pop
	    stack[s++] = t->matrix; //push
	    t = t->brother;
	}
	else
	{
	    while(t)
	    {
		if(t->brother != NULL)
		{
		    stack[--s] = NULL; //pop
		    stack[s++] = t->matrix; //push
		    t = t->brother;
		    break;
		}
		else
		{
		    t = t->parent;
		    if(t)
		    {
			stack[--s] = NULL; //pop
		    }
		}
	    }
	}
    }
    //glPopMatrix();
}

TaskDepend
SimpleEngin::draw_all(SceneGraph* now, TaskDepend wait)
{
    Polygon *t;

    t = this;

    //glPushMatrix();
    int s=0;
    while(t)
    {
	t->draw(stack);
	if(t->child != NULL)
	{
	    stack[s++] = t->matrix; //push
	    t = t->child;
	}
	else if(t->brother != NULL)
	{
	    stack[--s] = NULL; //pop
	    stack[s++] = t->matrix; //push
	    t = t->brother;
	}
	else
	{
	    while(t)
	    {
		if(t->brother != NULL)
		{
		    stack[--s] = NULL; //pop
		    stack[s++] = t->matrix; //push
		    t = t->brother;
		    break;
		}
		else
		{
		    t = t->parent;
		    if(t)
		    {
			stack[--s] = NULL; //pop
		    }
		}
	    }
	}
    }
    //glPopMatrix();
}