Esempio n. 1
0
void SetOrthoRenderSize(float x, float y, int screenOffsetX, int screenOffsetY)
{
	
	SetupOrtho();

	if (g_OrthoRenderSizeActive)
	{
		RemoveOrthoRenderSize();
	}
	
	g_OrthoRenderSizeActive = true;
	glMatrixMode(GL_PROJECTION);
	
	glPopMatrix();
	glPushMatrix();

	glLoadIdentity();
	RotateGLIfNeeded();
	g_renderOrthoRenderSizeX = x;
	g_renderOrthoRenderSizeY = y;
	
	float offset = 0;
	glOrthof( (-screenOffsetX)+offset, (x+offset), y+offset, screenOffsetY+offset,  -1, 1 );		
	//glTranslatef(0.5f, 0.5f, 0); //fixes a gl glitch where pixels don't know which side to be on

	glMatrixMode(GL_MODELVIEW);
	CHECK_GL_ERROR();
}
Esempio n. 2
0
void  DrawLine( GLuint rgba,   float ax, float ay, float bx, float by, float lineWidth )
{
	SetupOrtho();

	glDisable( GL_TEXTURE_2D );

	glEnableClientState(GL_VERTEX_ARRAY);	
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	GLfloat	vertices[] = 
	{
		ax,ay, 0,
		bx, by, 0 
	};
	
		glLineWidth(lineWidth); 
		glEnable (GL_LINE_SMOOTH);
		//glDisable(GL_LINE_SMOOTH);
		glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);

		glVertexPointer(3, GL_FLOAT, 0, vertices);
		//glColor4f(1, 1, 1, 1);
		glEnable( GL_BLEND );
		glColor4x( (rgba >>8 & 0xFF)*256,  (rgba>>16& 0xFF)*256, (rgba>>24& 0xFF)*256, (rgba&0xFF)*256);

		glDrawArrays(GL_LINES, 0, 2);
		glColor4x(1 << 16, 1 << 16, 1 << 16, 1 << 16);

		glDisable( GL_BLEND );
		glEnable( GL_TEXTURE_2D );
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);	
		CHECK_GL_ERROR();
}
void TextRenderComponent::OnRender(VariantList *pVList)
{
	if (*m_pAlpha <= 0 || *m_pVisible == 0) return;

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

	//vFinalPos -= GetAlignmentOffset(*m_pSize2d, eAlignment(*m_pAlignment));
	
	if (vFinalPos.y < -m_pSize2d->y) return;
	if (vFinalPos.y > GetOrthoRenderSizeYf()) return;

	
	if (*m_pRotation != 0)
	{
		g_globalBatcher.Flush();
		SetupOrtho();
		PushRotationMatrix(*m_pRotation, vRotationPt);
		vFinalPos -= vRotationPt;
	}

	float alpha;

	if (*m_pDisabled)
	{
		alpha = rt_min(*m_pAlpha, 0.5f);
	} else
	{
		alpha = *m_pAlpha;
	}

	uint32 color = ColorCombine(*m_pColor, *m_pColorMod, alpha);

	switch(*m_pStyle)
	{
	case STYLE_NORMAL:
		
		if (m_pShadowColor != 0)
		{
			GetBaseApp()->GetFont(eFont(*m_pFontID))->DrawScaledSolidColor(vFinalPos.x+2, vFinalPos.y+2, *m_pText, m_pScale2d->x, ColorCombine(*m_pShadowColor, MAKE_RGBA(255,255,255,255), alpha));
		}
		GetBaseApp()->GetFont(eFont(*m_pFontID))->DrawScaled(vFinalPos.x, vFinalPos.y, *m_pText, m_pScale2d->x, color);
		break;
	
	case STYLE_EFFECT_SIN_WAVE:
		RenderAsWave(vFinalPos, color);
		break;
	}

	if (*m_pRotation != 0)
	{
		g_globalBatcher.Flush(); //force it to render now so our transformation matrix will work with it
		PopRotationMatrix();
	}
#ifdef _DEBUG

	//DrawRect(vFinalPos, *m_pSize2d); //useful for debugging our touch hotspot

#endif
}
void RectRenderComponent::OnRender(VariantList *pVList)
{

	if (*m_pAlpha > 0.01)
	{
		CL_Vec2f vFinalPos = pVList->m_variant[0].GetVector2()+*m_pPos2d;
		uint32 color = ColorCombine(*m_pColor, *m_pColorMod, *m_pAlpha);

		if (GET_ALPHA(color) == 0) return;

		CL_Vec2f vRotationPt = vFinalPos;

		g_globalBatcher.Flush();

		if (*m_pRotation != 0)
		{
			SetupOrtho();
			PushRotationMatrix(*m_pRotation, vRotationPt);
			vFinalPos -= vRotationPt;
		}

			CL_Rectf r = CL_Rectf(vFinalPos.x, vFinalPos.y, vFinalPos.x+ m_pSize2d->x, vFinalPos.y+m_pSize2d->y); 
			if (*m_pVisualStyle != STYLE_BORDER_ONLY)
			{
				DrawFilledRect(r, color);
			}
			
			if (GET_ALPHA(*m_pBorderColor) > 0)
			{
				DrawRect(r, *m_pBorderColor, 1);
			}

			if (*m_pVisualStyle == STYLE_3D)
			{
				int shadedColor = ColorCombineMix(color, MAKE_RGBA(0,0,0,255), 0.4f);
				DrawLine(shadedColor, vFinalPos.x, vFinalPos.y+m_pSize2d->y, vFinalPos.x+m_pSize2d->x,vFinalPos.y+m_pSize2d->y, 1);
				DrawLine(shadedColor, vFinalPos.x+m_pSize2d->x, vFinalPos.y, vFinalPos.x+m_pSize2d->x,vFinalPos.y+m_pSize2d->y, 1);

				shadedColor = ColorCombineMix(color, MAKE_RGBA(255,255,255 ,255), 0.4f);
				DrawLine(shadedColor, vFinalPos.x, vFinalPos.y, vFinalPos.x,vFinalPos.y+m_pSize2d->y, 1);
				DrawLine(shadedColor, vFinalPos.x, vFinalPos.y, vFinalPos.x+m_pSize2d->x,vFinalPos.y, 1);
			}

			if (*m_pRotation != 0)
			{
				PopRotationMatrix();
			}

		
	}

}
Esempio n. 5
0
void  GenerateFillRect( GLuint rgba, float x, float y, float w, float h )
{
	SetupOrtho();

	//disable depth testing and depth writing
	glDisable( GL_TEXTURE_2D );
	
	if (BaseApp::GetBaseApp()->GetDisableSubPixelBlits())
	{
		//fix issue for cracks when scaling when 2d tile blits

		x = ceil(x);
		y = ceil(y);
		w = ceil(w);
		h = ceil(h);
	}


	//3 2
	//0 1
	
	GLfloat	vertices[] = {
		x,			y,			0.0,
		x + w,		y,			0.0,
		x +w,			y+h,		0.0,
		x ,		 y+h,		0.0 };

		glEnableClientState(GL_VERTEX_ARRAY);	
	
		glVertexPointer(3, GL_FLOAT, 0, vertices);
		//glColor4f(1, 1, 1, 1);
		assert((rgba&0xFF)*256 != 0 && "Why send something with zero alpha?");
		glEnable( GL_BLEND );
		glDisable( GL_TEXTURE_2D );
		glEnable(GL_ALPHA_TEST);

		glColor4x( (rgba >>8 & 0xFF)*256,  (rgba>>16& 0xFF)*256, (rgba>>24& 0xFF)*256, (rgba&0xFF)*256);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);	

		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
		glColor4x(1 << 16, 1 << 16, 1 << 16, 1 << 16);

		glDisable( GL_BLEND );
		glEnable( GL_TEXTURE_2D );
		glDisable(GL_ALPHA_TEST);

		glEnableClientState(GL_TEXTURE_COORD_ARRAY);	
	CHECK_GL_ERROR();	
}
Esempio n. 6
0
void DrawEllipse (const int segments, CL_Vec2f vPos, float radianWidth, float radiusHeight, bool vFilled, uint32 color)
{

	SetupOrtho();

	glPushMatrix();
	glTranslatef(vPos.x, vPos.y, 0.0);
	vector<float> vertices;
	vertices.resize(segments*2);
	glEnable (GL_LINE_SMOOTH);
	int count=0;
	for (GLfloat i = 0; i < 360.0f; i+=(360.0f/segments))
	{
		vertices[count++] = (float(cos(DEG2RAD(i)))*radianWidth);
		vertices[count++] = (float(sin(DEG2RAD(i)))*radiusHeight);
	}
	glColor4x( (color >>8 & 0xFF)*256,  (color>>16& 0xFF)*256, (color>>24& 0xFF)*256, (color&0xFF)*256);
	if (GET_ALPHA(color) != 255)
	{
		glEnable(GL_BLEND);
		glEnable(GL_ALPHA_TEST);

	}
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);	
	glDisable(GL_TEXTURE_2D);	
	glVertexPointer (2, GL_FLOAT , 0, &vertices.at(0)); 
	glDrawArrays ((vFilled) ? GL_TRIANGLE_FAN : GL_LINE_LOOP, 0, segments);
	
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);	
	glEnable(GL_TEXTURE_2D);	
	if (GET_ALPHA(color) != 255)
	{
		glDisable(GL_BLEND);
		glDisable(GL_ALPHA_TEST);

	}
	glColor4x(1 << 16, 1 << 16, 1 << 16, 1 << 16);
	glPopMatrix();
}
Esempio n. 7
0
void BaseApp::Draw()
{
#ifdef _DEBUG
//LogMsg("**********FRAME START");
#endif
    VariantList vList(Variant(0,0));
    
	m_sig_render(&vList);

	if (GetFPSVisible())
	{
		char stTemp[256];
		sprintf(stTemp, "fps: %d - M: %.2f, T: %.2f A: %.2f F: %.2f", m_gameTimer.GetFPS(), (float(m_memUsed)/1024)/1024, (float(m_texMemUsed)/1024)/1024,  float(GetAudioManager()->GetMemoryUsed()/1024)/ 1024, float(GetFreeMemory()/1024)/ 1024);
	
#ifdef _IRR_STATIC_LIB_
		int prims = 0;
		if (GetIrrlichtManager()->GetDriver())
		{
			prims = GetIrrlichtManager()->GetDriver()->getPrimitiveCountDrawn();
		}
		char stExtra[256];
		sprintf(stExtra, " Prims: %d", prims);
		strcat(stTemp, stExtra);
#endif		
	
#ifdef PLATFORM_FLASH
		char stExtra[256];
		sprintf(stExtra, " Flash: %.2f", float(GetNativeMemoryUsed())/1024/1024);
		strcat(stTemp, stExtra);

#endif

		if (GetFont(FONT_SMALL)->IsLoaded())
		{
			GetFont(FONT_SMALL)->DrawScaled(3,3, stTemp, 0.7f);
		}
	}

	//draw the console messages?
	if (GetConsoleVisible())
	{
		DrawConsole();
	}

	switch (GetLastError())
	{
	case ERROR_MEM:
		GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW MEM!", 0.7f);
		break;

	case ERROR_SPACE:
		GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW STORAGE SPACE!", 0.7f);
		break;
            
        case ERROR_NONE:
            
        break;
	}

	SetupOrtho();
	g_globalBatcher.Flush();
}
Esempio n. 8
0
void  DrawLine( GLuint rgba,   float ax, float ay, float bx, float by, float lineWidth )
{
	SetupOrtho();
	//g_globalBatcher.Flush();

	glDisable( GL_TEXTURE_2D );

	glEnableClientState(GL_VERTEX_ARRAY);	
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisable(GL_CULL_FACE);

	static GLfloat	vertices[3*4];

	CL_Vec2f start = CL_Vec2f(ax, ay);
	CL_Vec2f end = CL_Vec2f(bx, by);

	float dx = ax - bx;
	float dy = ay - by;

	CL_Vec2f rightSide = CL_Vec2f(dy, -dx);

	if (rightSide.length() > 0) 
	{
		rightSide.normalize();
		rightSide *= lineWidth/2;
	}
	
	CL_Vec2f  leftSide =CL_Vec2f(-dy, dx);
	
	if (leftSide.length() > 0) 
	{
		leftSide.normalize();
		leftSide *= lineWidth/2;
	}

	CL_Vec2f one = leftSide + start;

	CL_Vec2f two = rightSide + start;

	CL_Vec2f three = rightSide + end;

	CL_Vec2f four = leftSide = end;

	vertices[0*3+0] = one.x; vertices[0*3+1] = one.y;
	vertices[1*3+0] = two.x; vertices[1*3+1] = two.y;
	vertices[2*3+0] = three.x; vertices[2*3+1] = three.y;
	vertices[3*3+0] = four.x; vertices[3*3+1] = four.y;

	//set the Z
	vertices[0*3+2] = 0;
	vertices[1*3+2] = 0;
	vertices[2*3+2] = 0;
	vertices[3*3+2] = 0;
	
	glVertexPointer(3, GL_FLOAT, 0, vertices);
	//glColor4f(1, 1, 1, 1);
	glEnable( GL_BLEND );
	glColor4x( (rgba >>8 & 0xFF)*256,  (rgba>>16& 0xFF)*256, (rgba>>24& 0xFF)*256, (rgba&0xFF)*256);

	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	glColor4x(1 << 16, 1 << 16, 1 << 16, 1 << 16);

	glEnable(GL_CULL_FACE);

	glDisable( GL_BLEND );
	glEnable( GL_TEXTURE_2D );
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);	
	CHECK_GL_ERROR();
}