Ejemplo n.º 1
0
void Game::renderPass(uint64_t frame)
{	
	const Rect cameraRect(mCameraPosition - (mScreenSize / 2), mScreenSize);
	
	Renderables renderables = Renderable::all();
	
	for (Renderables::iterator iter = renderables.begin(); iter != renderables.end(); ++iter)
	{
		Renderable& object = **iter;
		Rect boundingRect = object.boundingRect();
		
		if (!object.hidden() && cameraRect.overlaps(boundingRect))
		{
			// Motion blur
			Color::push();
			int max = 1;
			Color::translate(Color(1.0, 1.0, 1.0, 1.0 / max));
			for (int i = 0; i < max; ++i)
			{
				glMatrixMode(GL_MODELVIEW);
				glPushMatrix();
				object.render(frame - i);
				glMatrixMode(GL_MODELVIEW);
				glPopMatrix();
			}
			Color::pop();
		}
	}
}
Ejemplo n.º 2
0
void Game::update()
{
	Renderables renderables = Renderable::all();
	for (Renderables::iterator iter = renderables.begin(); iter != renderables.end(); ++iter)
	{
		(*iter)->update();
	}
}
Ejemplo n.º 3
0
void Game::render()
{
	glPushMatrix();
	// Camera.
	
	glTranslatef(-(mCameraPosition.x - (mScreenSize.width / 2)), -(mCameraPosition.y - (mScreenSize.height / 2)), 0.0);
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	renderPass(frames);
	
	if (drawBoundingBoxes)
	{
		Renderables rs = Renderable::all();
		for (Renderables::const_iterator iter = rs.begin(); iter != rs.end(); ++iter)
		{
			Rect boundingRect = (*iter)->boundingRect();
			
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			
			glTranslatef(boundingRect.origin.x, boundingRect.origin.y, 0.0);

			glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
			glBegin(GL_LINE_LOOP);
			{
				glLineWidth(1.0);
				Color(1.0, 1.0, 1.0, 0.5).set();
				glVertex2f(0.0, 0.0);
				glVertex2f(boundingRect.size.width, 0.0);
				glVertex2f(boundingRect.size.width, boundingRect.size.height);
				glVertex2f(0.0, boundingRect.size.height);
			}
			glEnd();
			
			glPopMatrix();
		}
	}
	
	glPopMatrix();
	
	// TODO: Draw widgets here instead of compensating for the translation in the widget drawing code.
	// ^ would also ensure that widgets are always on top of content.
	
	SDL_GL_SwapBuffers();
}
Ejemplo n.º 4
0
		const_iterator begin() const { return m_children.begin(); }