Beispiel #1
0
void AdManager::OnRender()
{

#ifdef WIN32
	if (m_bShowingAd)
	{
		//draw a fake rectangle the same size as the real ad will be, this is just for testing, so you get an idea
		//of how big the ad when developing on Windows, and when it will pop up

		CL_Vec2f vRatio = CL_Vec2f(1,1);
		if (GetFakePrimaryScreenSizeX() != 0)
		{
			vRatio.x = (GetScreenSizeXf()/float(GetOriginalScreenSizeX()));
			vRatio.y =(GetScreenSizeYf()/float(GetOriginalScreenSizeY()));
		}
		rtRect r(0,0, (int)(m_vBannerSize.x*vRatio.x),(int)(m_vBannerSize.y*vRatio.y));
		
		//move to bottom
		r.AdjustPosition(0, GetScreenSizeY()-r.GetHeight());

		//center
		r.AdjustPosition( (GetScreenSizeX()-r.GetWidth())/2, 0 );
		
		DrawFilledRect(r, MAKE_RGBA(40,255,40,200));
	}
#endif

}
void RemoveOrthoRenderSize()
{
	//g_globalBatcher.Flush(); //by stone
	
	if (NeedsOrthoSet()) 
		return;
	
	if (g_OrthoRenderSizeActive)
	{
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glPushMatrix();

		glLoadIdentity();
		RotateGLIfNeeded();
		g_renderOrthoRenderSizeX = GetScreenSizeXf();
		g_renderOrthoRenderSizeY = GetScreenSizeYf();
	
		float offset = 0.0f;
		glOrthof( offset,  g_renderOrthoRenderSizeX+offset, g_renderOrthoRenderSizeY+offset, offset,  -1, 1 );		
		glMatrixMode(GL_MODELVIEW);
		CHECK_GL_ERROR();
	}

}
Beispiel #3
0
void BaseApp::OnScreenSizeChange()
{
	
#ifdef _DEBUG
	//LogMsg("Changing screen-size to %d, %d, %d", GetScreenSizeX(), GetScreenSizeY(), GetOrientation());
#endif
	
	GenerateSetPerspectiveFOV(C_APP_FOV, GetScreenSizeXf()/ GetScreenSizeYf(),0.1f,500.0f);
}
void SetupOrtho()
{
	if (!NeedsOrthoSet()) 
		return;

	//g_globalBatcher.Flush(); //by stone

	CHECK_GL_ERROR();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glEnable(GL_TEXTURE_2D);
	glEnableClientState(GL_VERTEX_ARRAY);	
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);	
	glDisableClientState(GL_COLOR_ARRAY);	
	glDisableClientState(GL_NORMAL_ARRAY);

	CHECK_GL_ERROR();
	RotateGLIfNeeded();

	//Note:  We could setup our projection matrix upside down so the upper left would be 0,0, but.. then you have to wind your
	//triangles backwards (or keep switching to front face culling) which I find even more confusing than dealing with the y offsets.


	//When PrepareForGL() is called (removing our 2d ortho stuff), it gets turned back into normal back face culling

#ifdef _IRR_STATIC_LIB_
	glFrontFace( GL_CW );
	glCullFace(GL_BACK);
#else
	//glFrontFace( GL_CCW );
	glCullFace(GL_FRONT);
#endif
	

	g_renderOrthoRenderSizeX = GetScreenSizeXf();
	g_renderOrthoRenderSizeY = GetScreenSizeYf();
	
	float tempX = g_renderOrthoRenderSizeX;
	float tempY = g_renderOrthoRenderSizeY;

    CHECK_GL_ERROR();

	glOrthof( 0,  tempX, tempY, 0,  -1, 1 );		
	
	CHECK_GL_ERROR();

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	//disable depth testing and depth writing
	glDisable(GL_DEPTH_TEST);
	glDepthMask(GL_FALSE);
	SetOrthoModeFlag();
	CHECK_GL_ERROR();
}
bool GLFlashAdaptor_Initialize()
{
	LogMsg("initializing GLFlashAdaptor");
	g_projectionStack.reserve(2);
	g_projectionStack.push_back(CL_Mat4f::identity());

	g_modelStack.reserve(32);
	g_modelStack.push_back(CL_Mat4f::identity());
	g_scissorRect = CL_Rectf(0,0,GetScreenSizeXf(), GetScreenSizeYf());

	return true;
}
void ScrollBarRenderComponent::OnRender(VariantList *pVList)
{
	//NOTE: We don't support drawing a horizontal scroll bar yet!
	CHECK_GL_ERROR();
	//LogMsg("Drawing progress bar: %.2f", progress);
	if (*m_pAlpha <= 0.07)
	{
		return; //not ready
	}

	float contentAreaRatio;
	
	GLboolean bScissorEnabled = false;
	glGetBooleanv(GL_SCISSOR_TEST, &bScissorEnabled);

	if (bScissorEnabled)
	{
		g_globalBatcher.Flush();
		//disable it temporarily
		glDisable(GL_SCISSOR_TEST);
	}
	float barHeight;
	float barWidth;
	CL_Vec2f vFinalPos;
	uint32 color = ColorCombine(*m_pColor, *m_pColorMod, *m_pAlpha);

	if (!m_pSurf) return; //can't do anything without the graphics loaded
	
	contentAreaRatio = (m_pBoundsRect->get_height()+m_pSize2d->y)/m_pSize2d->y;

	if (!m_bUsingScrollComponent && m_pBoundsRect->get_height() < (m_pSize2d->y+1)) //I don't really know why I need that +1..but it works..
	{
		contentAreaRatio = 0; //definitely don't need to scroll here
	}

	if (contentAreaRatio > 1)
	{
		//render vertical scroll bar
		m_pSurf->SetupAnim(1,2);

		barHeight = m_pSize2d->y/contentAreaRatio;
		
		if (barHeight < m_pSurf->GetFrameHeight()*2) barHeight = m_pSurf->GetFrameHeight()*2;
		
		barWidth = m_pSurf->GetFrameWidth();
		//LogMsg("percent scrolled is %.2f, contentAreaRation is %.2f", m_pProgress2d->y, contentAreaRatio);

		vFinalPos = pVList->m_variant[0].GetVector2()+ *m_pPos2d + CL_Vec2f(m_pSize2d->x, 0);

		if (vFinalPos.x >= GetScreenSizeXf())
		{
			//position on the inside, not the outside
			vFinalPos.x -= ( barWidth+(iPadMapX(8) )); //adjust the spacer with the screensize
		}
		//slide it down to the right position:
		vFinalPos.y += (m_pSize2d->y - barHeight)* m_pProgress2d->y;

		//draw the top of the capsule
		m_pSurf->BlitAnim(vFinalPos.x, vFinalPos.y,0,0, color);
		vFinalPos.y += m_pSurf->GetFrameHeight(); 
		barHeight -=  m_pSurf->GetFrameHeight()*2;
		//draw the bottom end cap
		m_pSurf->BlitAnim(vFinalPos.x, vFinalPos.y+barHeight,0,1, color);
		//first draw the first end cap
		CL_Rectf r = CL_Rectf(0, 0, barWidth, barHeight);
		ApplyOffset(&r, vFinalPos);
		DrawFilledRect(r, color);
	}

	contentAreaRatio = (m_pBoundsRect->get_width()+m_pSize2d->x)/m_pSize2d->x;

	if (!m_bUsingScrollComponent && m_pBoundsRect->get_width() < (m_pSize2d->x+1)) //I don't really know why I need that +1..but it works..
	{
		contentAreaRatio = 0; //definitely don't need to scroll here
	}
	
	if (contentAreaRatio > 1)
	{
		//render horizontal scroll bar
		m_pSurf->SetupAnim(2,1); //repurpose the graphics for horizontal...

		barWidth = m_pSize2d->x/contentAreaRatio;

		if (barWidth < m_pSurf->GetFrameWidth()*2) barWidth = m_pSurf->GetFrameWidth()*2;

		barHeight= m_pSurf->GetFrameHeight();
		//LogMsg("percent scrolled is %.2f, contentAreaRation is %.2f", m_pProgress2d->x, contentAreaRatio);

		vFinalPos = pVList->m_variant[0].GetVector2()+ *m_pPos2d + CL_Vec2f(0, m_pSize2d->y);

		if (vFinalPos.y >= GetScreenSizeYf())
		{
			//position on the inside, not the outside
			vFinalPos.y -= ( barHeight+(iPadMapY(6) )); //adjust the spacer with the screensize
		}
		//slide it down to the right position:
		vFinalPos.x += (m_pSize2d->x - barWidth)* m_pProgress2d->x;

		//draw the top of the capsule
		m_pSurf->BlitAnim(vFinalPos.x, vFinalPos.y,0,0, color);
		vFinalPos.x += m_pSurf->GetFrameWidth(); 
		barWidth -=  m_pSurf->GetFrameWidth()*2;
		//draw the bottom end cap
		m_pSurf->BlitAnim(vFinalPos.x+barWidth, vFinalPos.y,1,0, color);
		//first draw the first end cap
		CL_Rectf r = CL_Rectf(0, 0, barWidth, barHeight);
		ApplyOffset(&r, vFinalPos);
		DrawFilledRect(r, color);
		CHECK_GL_ERROR();

	}
	
	
	if (bScissorEnabled)
	{
		g_globalBatcher.Flush();
		glEnable(GL_SCISSOR_TEST);
	}
	CHECK_GL_ERROR();

}