Exemple #1
0
void Renderer::render() {
  Clock::startSection("render");

  startRender();

  renderMap();

  for (auto &it : entities_) {
    renderEntity(it.second);
  }
  // render overlay second for z ordering issues
  if (entityOverlayRenderer_) {
    for (auto &it : entities_) {
      renderEntityOverlay(it.second);
    }
  }
  effectManager_->render(getRenderTime());

  endRender();
}
Exemple #2
0
void Font::write(float x, float y, float z, const char *text, int count, Alignment alignment) {
	if (count <= 0)
		count = getTextLength(text);

	// Get first line
	int pos = 0;
	int len = findTextChar(text, pos, count, '\n');
	if (len == -1) len = count;
	beginRender();
	while (pos < count) {
		float cx = x;
		if (alignment == Alignment::CENTER) {
			float w = getTextWidth(&text[pos], len);
			cx -= w / 2;
		} else if (alignment == Alignment::RIGHT) {
			float w = getTextWidth(&text[pos], len);
			cx -= w;
		}

		writeInternal(cx, y, z, &text[pos], len);

		y -= getLineHeight();

		// Get next line
		pos += len;
		int ch = getTextChar(text, pos, &pos);
		if (ch == '\n') {
			len = findTextChar(text, pos, count, '\n');
			if (len == -1)
				len = count - pos;
			else
				len = len - pos;
		}
	}
	endRender();
}
Exemple #3
0
void App::_render() {
    beginRender();
    render();
    endRender();
}
Exemple #4
0
void Render::render(RenderCamera* camera, RenderTarget *target, bool depthOnly)
{
	RENDERER_PERFZONE(Render_render);
	const uint32 numLights = (uint32)m_visibleLights.Size();
	if(target)
	{
		target->bind();
	}

	// TODO: ²ÄÖÊ·Ö×é
	if(beginRender())
	{
		if(depthOnly)
		{
			RENDERER_PERFZONE(Render_render_depthOnly);
			bindAmbientState(Colour(0,0,0,1));
			bindViewProj(camera);
			renderMeshes(m_visibleLitMeshes,   RenderMaterial::PASS_DEPTH);
			renderMeshes(m_visibleUnlitMeshes, RenderMaterial::PASS_DEPTH);
		}
		else if(numLights > RENDERER_DEFERRED_THRESHOLD)
		{
			RENDERER_PERFZONE(Render_render_deferred);
			bindDeferredState();
			bindViewProj(camera);
			renderMeshes(m_visibleLitMeshes,   RenderMaterial::PASS_UNLIT);
			renderMeshes(m_visibleUnlitMeshes, RenderMaterial::PASS_UNLIT);
			renderDeferredLights();
		}
		else if(numLights > 0)
		{
			RENDERER_PERFZONE(Render_render_lit);
			bindAmbientState(m_ambientColor);
			bindViewProj(camera);
			RenderLight &light0 = *m_visibleLights[0];
			light0.bind();
			renderMeshes(m_visibleLitMeshes, light0.getPass());
			light0.m_renderer = 0;
			
			//bindAmbientState(Colour(0,0,0,1));
			beginMultiPass();
			for(uint32 i=1; i<numLights; i++)
			{
				RenderLight &light = *m_visibleLights[i];
				light.bind();
				renderMeshes(m_visibleLitMeshes, light.getPass());
				light.m_renderer = 0;
			}
			endMultiPass();
			renderMeshes(m_visibleUnlitMeshes, RenderMaterial::PASS_UNLIT);
		}
		else
		{
			RENDERER_PERFZONE(Render_render_unlit);
			bindAmbientState(Colour(0,0,0,1));
			bindViewProj(camera);
			renderMeshes(m_visibleLitMeshes,   RenderMaterial::PASS_UNLIT);
			renderMeshes(m_visibleUnlitMeshes, RenderMaterial::PASS_UNLIT);
		}
		endRender();
	}
	if(target) 
	{
		target->unbind();
	}
	m_visibleLitMeshes.Reset();
	m_visibleUnlitMeshes.Reset();
	m_visibleLights.Reset();
}
Exemple #5
0
void Font::writeBox(float x, float y, float z, float width, const char *text, int count, Alignment alignment) {
	if (count <= 0)
		count = getTextLength(text);

	float currWidth = 0, wordWidth;
	int lineS = 0, lineE = 0, wordS = 0, wordE = 0;
	int wordCount = 0;

	const char *s = " ";
	float spaceWidth = getTextWidth(s, 1);
	bool softBreak = false;

	beginRender();
	for (; lineS < count;) {
		// Determine the extent of the line
		for (;;) {
			// Determine the number of characters in the word
			while (wordE < count &&
				getTextChar(text, wordE) != ' ' &&
				getTextChar(text, wordE) != '\n')
				// Advance the cursor to the next character
				getTextChar(text, wordE, &wordE);

			// Determine the width of the word
			if (wordE > wordS) {
				wordCount++;
				wordWidth = getTextWidth(&text[wordS], wordE - wordS);
			} else
				wordWidth = 0;

			// Does the word fit on the line? The first word is always accepted.
			if (wordCount == 1 || currWidth + (wordCount > 1 ? spaceWidth : 0) + wordWidth <= width) {
				// Increase the line extent to the end of the word
				lineE = wordE;
				currWidth += (wordCount > 1 ? spaceWidth : 0) + wordWidth;

				// Did we reach the end of the line?
				if (wordE == count || getTextChar(text, wordE) == '\n') {
					softBreak = false;

					// Skip the newline character
					if (wordE < count)
						// Advance the cursor to the next character
						getTextChar(text, wordE, &wordE);

					break;
				}

				// Skip the trailing space
				if (wordE < count && getTextChar(text, wordE) == ' ')
					// Advance the cursor to the next character
					getTextChar(text, wordE, &wordE);

				// Move to next word
				wordS = wordE;
			} else {
				softBreak = true;

				// Skip the trailing space
				if (wordE < count && getTextChar(text, wordE) == ' ')
					// Advance the cursor to the next character
					getTextChar(text, wordE, &wordE);

				break;
			}
		}

		// Write the line
		if (alignment == Alignment::JUSTIFY) {
			float spacing = 0;
			if (softBreak) {
				if (wordCount > 2)
					spacing = (width - currWidth) / (wordCount - 2);
				else
					spacing = (width - currWidth);
			}

			writeInternal(x, y, z, &text[lineS], lineE - lineS, spacing);
		} else {
			float cx = x;
			if (alignment == Alignment::RIGHT)
				cx = x + width - currWidth;
			else if (alignment == Alignment::CENTER)
				cx = x + 0.5f*(width - currWidth);

			writeInternal(cx, y, z, &text[lineS], lineE - lineS);
		}

		if (softBreak) {
			// Skip the trailing space
			if (lineE < count && getTextChar(text, lineE) == ' ')
				// Advance the cursor to the next character
				getTextChar(text, lineE, &lineE);

			// We've already counted the first word on the next line
			currWidth = wordWidth;
			wordCount = 1;
		} else {
			// Skip the line break
			if (lineE < count && getTextChar(text, lineE) == '\n')
				// Advance the cursor to the next character
				getTextChar(text, lineE, &lineE);

			currWidth = 0;
			wordCount = 0;
		}

		// Move to next line
		lineS = lineE;
		wordS = wordE;
		y -= getLineHeight();
	}
	endRender();
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
void ofxOculusRift::endRenderSceneRightEye()
{
	endRender( &eyeFboRight );
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
void ofxOculusRift::endRenderSceneLeftEye()
{
	endRender( &eyeFboLeft );
}
Exemple #8
0
void wyRenderTexture::clear(float r, float g, float b, float a) {
	beginRender(r, g, b, a);
	endRender();
}