Exemplo n.º 1
0
void drawShadowText( long colorTop, long colorShadow, HGOSFONT3D font, 
					long left, long top, long right, long bottom, bool proportional, const char* text, bool bold, float scale,
					long xOffset, long yOffset)
{
	gos_TextSetAttributes( font, colorShadow, scale, true, proportional, bold, false, 2 );
	gos_TextSetRegion( left + xOffset, top + yOffset, right + xOffset, bottom + yOffset);
	gos_TextSetPosition( left + xOffset, top + yOffset );
	gos_TextDraw( text );
	gos_TextSetAttributes( font, colorTop, scale, true, proportional, bold, false, 2 );
	gos_TextSetRegion( left, top, right, bottom );
	gos_TextSetPosition( left, top );
	gos_TextDraw( text );
}
Exemplo n.º 2
0
void aButton::render()
{
	if ( state != HIDDEN )
	{
		if ( textureHandle )
		{
			unsigned long gosID = mcTextureManager->get_gosTextureHandle( textureHandle );
			gos_SetRenderState( gos_State_Texture, gosID ); 
		}
		else
			gos_SetRenderState( gos_State_Texture, 0 ); 

			gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
			gos_SetRenderState( gos_State_Filter, gos_FilterNone);
			gos_SetRenderState( gos_State_AlphaTest, true);
			gos_SetRenderState( gos_State_TextureAddress, gos_TextureClamp );
			gos_SetRenderState( gos_State_TextureMapBlend,gos_BlendModulateAlpha );

			gos_DrawQuads( location, 4 );


		if ( data.textID && data.textFont )
		{
			char buffer[256];
			cLoadString( data.textID, buffer, 256 );
			DWORD width, height;
			gos_TextSetAttributes(data.textFont, data.textColors[state], data.textSize, true, true, false, false, data.textAlign);			
			gos_TextSetRegion( data.textRect.left, data.textRect.top, data.textRect.right, data.textRect.bottom );
			gos_TextStringLength( &width, &height, buffer );
			gos_TextSetPosition( data.textRect.left, (data.textRect.top + data.textRect.bottom)/2 - height/2 + 1 );
			gos_TextDraw( buffer );

			if ( data.outlineText )
			{
				drawEmptyRect( data.textRect, data.textColors[state], data.textColors[state] );
			}
		}
		if ( data.outline )
		{
			GUI_RECT tmp;
			tmp.left = location[0].x;
			tmp.top = location[0].y;
			tmp.right = location[2].x;
			tmp.bottom = location[2].y;

			drawEmptyRect( tmp, location[0].argb, location[0].argb );
		}

		for ( int i = 0; i < numberOfChildren(); i++ )
		{
			pChildren[i]->render();
		}
	}
}
Exemplo n.º 3
0
void drawShadowText( long colorTop, long colorShadow, HGOSFONT3D font, 
					long left, long top, bool proportional, const char* text, bool bold, float scale,
					long xOffset, long yOffset)
{
	gos_TextSetAttributes( font, colorShadow, scale, false, proportional, bold, false, 0 );
	gos_TextSetRegion( 0, 0, Environment.screenWidth, Environment.screenHeight );
	gos_TextSetPosition( left + xOffset, top + yOffset );
	gos_TextDraw( text );
	gos_TextSetAttributes( font, colorTop, scale, false, proportional, bold, false, 0 );
	gos_TextSetPosition( left, top );
	gos_TextDraw( text );

}
Exemplo n.º 4
0
void GameDebugWindow::render(void)
{
    if(!display)
        return;
    int32_t i;
    gos_TextSetAttributes(font, 0xffffffff, 1.0, true, true, false, false);
    gos_TextSetRegion(0, 0, Environment.screenWidth, Environment.screenHeight);
    int32_t curY = pos[1] + 5;
    for(i = linePos; i < MAX_DEBUG_WINDOW_LINES; i++)
    {
        gos_TextSetPosition(pos[0] + 5, curY);
        curY += fontHeight;
        gos_TextDraw(textBuffer[i]);
    }
    for(i = 0; i < linePos; i++)
    {
        gos_TextSetPosition(pos[0] + 5, curY);
        curY += fontHeight;
        gos_TextDraw(textBuffer[i]);
    }
}
Exemplo n.º 5
0
void aFont::render( const char* text, int xPos, int yPos, int areaWidth, int areaHeight, 
				   unsigned long color, bool bBold, int alignment )
{
	gos_TextSetAttributes( gosFont, color, size, true, true, bBold, false, alignment );
	
	if ( areaWidth < 1 )
	{
		if ( alignment == 1 )
		{
			unsigned long width, height;
			gos_TextStringLength( &width, &height, text );
			xPos -= width;
			areaWidth = width + 1;
		}
		else
			areaWidth = Environment.screenWidth;
	}

	if ( areaHeight < 1 )
	{
		if ( alignment == 3  ) // bottom
		{
			unsigned long width, height;
			gos_TextStringLength( &width, &height, text );
			yPos -= height;
			areaHeight = height + 1;
		}
		
		else
			areaHeight = Environment.screenHeight;
	}

	gos_TextSetRegion( xPos, yPos, xPos + areaWidth, yPos + areaHeight );
	
	gos_TextSetPosition( xPos, yPos );
	gos_TextDraw( text );	

}
Exemplo n.º 6
0
//---------------------------------------------------------------------------
void GameCamera::render(void)
{
	//------------------------------------------------------
	// At present, these actually draw.  Later they will
	// add elements to the draw list and sort and draw.
	// The later time has arrived.  We begin sorting immediately.
	// NO LONGER NEED TO SORT!
	// ZBuffer time has arrived.  Share and Enjoy!
	// Everything SIMPLY draws at the execution point into the zBuffer
	// at the correct depth.  Miracles occur at that point!
	// Big code change but it removes a WHOLE bunch of code and memory!
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	gos_GetViewport(&viewMulX, &viewMulY, &viewAddX, &viewAddY);
	MidLevelRenderer::MLRState default_state;
	default_state.SetBackFaceOn();
	default_state.SetDitherOn();
	default_state.SetTextureCorrectionOn();
	default_state.SetZBufferCompareOn();
	default_state.SetZBufferWriteOn();
	default_state.SetFilterMode(MidLevelRenderer::MLRState::BiLinearFilterMode);
	float z = 1.0f;
	Stuff::RGBAColor fColor;
	fColor.red   = ((fogColor >> 16) & 0xff);
	fColor.green = ((fogColor >> 8) & 0xff);
	fColor.blue  = ((fogColor)&0xff);
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	screenResolution.x = viewMulX;
	screenResolution.y = viewMulY;
	calculateProjectionConstants();
	TG_Shape::SetViewport(viewMulX, viewMulY, viewAddX, viewAddY);
	userInput->setViewport(viewMulX, viewMulY, viewAddX, viewAddY);
	gos_TextSetRegion(viewAddX, viewAddY, viewMulX, viewMulY);
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	screenResolution.x = viewMulX;
	screenResolution.y = viewMulY;
	calculateProjectionConstants();
	globalScaleFactor = getScaleFactor();
	globalScaleFactor *= viewMulX / 640.0; // Scale Mechs to ScreenRES
	//-----------------------------------------------
	// Set Ambient for this pass of rendering
	uint32_t lightRGB = (ambientRed << 16) + (ambientGreen << 8) + ambientBlue;
	eye->setLightColor(1, lightRGB);
	eye->setLightIntensity(1, 1.0);
	MidLevelRenderer::PerspectiveMode = usePerspective;
	theClipper->StartDraw(cameraOrigin, cameraToClip, fColor, &fColor, default_state, &z);
	MidLevelRenderer::GOSVertex::farClipReciprocal =
		(1.0f - cameraToClip(2, 2)) / cameraToClip(3, 2);
	if (active && turn > 1)
	{
		//----------------------------------------------------------
		// Turn stuff on line by line until perspective is working.
		if (Environment.Renderer != 3)
			theSky->render(1);
		land->render(); // render the Terrain
		if (Environment.Renderer != 3)
			craterManager->render();			 // render the craters and footprints
		ObjectManager->render(true, true, true); // render all other objects
		land->renderWater();					 // Draw Water Last!
		if (useShadows && Environment.Renderer != 3)
			ObjectManager->renderShadows(true, true, true);
		if (mission && mission->missionInterface)
			mission->missionInterface->drawVTOL();
		if (!drawOldWay && !inMovieMode)
		{
			if (compass && (turn > 3) && drawCompass)
				compass->render(-1); // Force this to zBuffer in front of everything
		}
		if (!drawOldWay)
			mcTextureManager->renderLists(); // This sends triangles down to the
											 // card.  All "rendering" to this
											 // point has been setting up tri
											 // lists
		if (drawOldWay)
		{
			// Last thing drawn were shadows which are not Gouraud Shaded!!!
			// MLR to be "efficient" doesn't set this state by default at
			// startup!
			gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		}
		theClipper->RenderNow(); // Draw the FX
		if (useNonWeaponEffects)
			weather->render(); // Draw the weather
	}
	if (drawOldWay && !inMovieMode)
	{
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Perspective, 1);
		if (compass && (turn > 3) && drawCompass)
			compass->render();
	}
	//---------------------------------------------------------
	// Check if we are inMovieMode and should be letterboxed.
	// draw letterboxes here.
	if (inMovieMode && (letterBoxPos != 0.0f))
	{
		// Figure out the two faces we need to draw based on letterBox Pos and
		// Alpha
		float barTopX = screenResolution.y * letterBoxPos;
		float barBotX = screenResolution.y - barTopX;
		gos_SetRenderState(gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		gos_SetRenderState(gos_State_MonoEnable, 0);
		gos_SetRenderState(gos_State_Perspective, 0);
		gos_SetRenderState(gos_State_Clipping, 1);
		gos_SetRenderState(gos_State_AlphaTest, 1);
		gos_SetRenderState(gos_State_Specular, 0);
		gos_SetRenderState(gos_State_Dither, 1);
		gos_SetRenderState(gos_State_TextureMapBlend, gos_BlendModulate);
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState(gos_State_TextureAddress, gos_TextureClamp);
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Texture, 0);
		//------------------------------------
		gos_VERTEX gVertex[4];
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= 0.0f;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (letterBoxAlpha << 24);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= 0.0f;
		gVertex[1].y	= barTopX;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (letterBoxAlpha << 24);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= barTopX;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (letterBoxAlpha << 24);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= screenResolution.x;
		gVertex[3].y	= 0.0f;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (letterBoxAlpha << 24);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= barBotX;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (letterBoxAlpha << 24);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= screenResolution.x;
		gVertex[1].y	= barBotX;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (letterBoxAlpha << 24);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= screenResolution.y;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (letterBoxAlpha << 24);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= 0.0f;
		gVertex[3].y	= screenResolution.y;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (letterBoxAlpha << 24);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
	}
	if (inMovieMode && (fadeAlpha != 0x0))
	{
		// We are fading to something other then clear screen.
		gos_SetRenderState(gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		gos_SetRenderState(gos_State_MonoEnable, 0);
		gos_SetRenderState(gos_State_Perspective, 0);
		gos_SetRenderState(gos_State_Clipping, 1);
		gos_SetRenderState(gos_State_AlphaTest, 1);
		gos_SetRenderState(gos_State_Specular, 0);
		gos_SetRenderState(gos_State_Dither, 1);
		gos_SetRenderState(gos_State_TextureMapBlend, gos_BlendModulate);
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState(gos_State_TextureAddress, gos_TextureClamp);
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Texture, 0);
		//------------------------------------
		gos_VERTEX gVertex[4];
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= 0.0f;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= 0.0f;
		gVertex[1].y	= screenResolution.y;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= screenResolution.y;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= screenResolution.x;
		gVertex[3].y	= 0.0f;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
	}
	//-----------------------------------------------------
}
Exemplo n.º 7
0
unsigned long aFont::height( const char* st, int areaWidth ) const
{
	unsigned long width, height;
	gos_TextSetAttributes (gosFont, 0, size, false, true, false, false);
	gos_TextSetRegion( 0, 0, areaWidth, Environment.screenHeight );
	gos_TextStringLength(&width,&height,st);

	unsigned long lineCount = 1;

	if ( width > areaWidth - 1 )
	{
		unsigned long curLineWidth = 0;

		gosASSERT( strlen( st) < 2048 );

		
		char pLine[2048]; // should be more than adequate

		char* pLastWord = (char*)st;
		char* pTmp = (char*)st;
		char* pTmpLine = (char*)pLine;

		int numberOfWordsPerLine = 0;


		bool bHasSpaces = true;
		if (  !strstr( st, " " ) )
		{
			if ( !strstr( st, "\n" ) )
				bHasSpaces = false;
		}

		while( *pTmp != NULL )
		{
			if ( *pTmp == '\n' )
			{
				lineCount++;
				numberOfWordsPerLine = 0;
				curLineWidth = 0;	
				pTmpLine = pLine;
				pLastWord = pTmp+1;
			}
			else if ( !bHasSpaces )
			{
				if ( pTmp > st )
				{
					char tmp = *(pTmp-1);
					if ( !isleadbyte( tmp ) )
					{
						*(pTmpLine) = NULL;
						gos_TextStringLength( &curLineWidth, &height, pLine );
						if ( curLineWidth > areaWidth )
						{
							lineCount++;
							pTmp--;
							pTmpLine = pLine;
							curLineWidth = 0;
							numberOfWordsPerLine = 0;

						}

					}
					
				
				}
			}

			else if ( isspace( *pTmp ) )
			{
				*(pTmpLine) = NULL;
				gos_TextStringLength( &curLineWidth, &height, pLine );
				if ( curLineWidth > areaWidth )
				{
					gos_TextStringLength( &curLineWidth, &height, pLastWord );
					if ( numberOfWordsPerLine == 0 || curLineWidth > areaWidth )
					{
						static bool firstTime = true;
						if (firstTime)
						{
							Assert( true, 0, "this list box item contains a word of greater "
									" area than the list box, giving up" );
							firstTime = false;
						}
						/*There are times when you just can't guarantee that this won't occur,
						so we have to just continue and deal with it.*/
						//return height;

						pLastWord = pTmp;
					}
					lineCount++;
					pTmpLine = pLine;
					pTmp = pLastWord - 1;
					curLineWidth = 0;
					numberOfWordsPerLine = 0;

				}
		
				pLastWord = pTmp;
				numberOfWordsPerLine++;
			}


			*pTmpLine = *pTmp;
			if ( isleadbyte( *pTmpLine ) )
			{
				*(pTmpLine+1) = *(pTmp+1);
			}

			pTmpLine = (char*)_mbsinc( (unsigned char*)pTmpLine );
			pTmp = (char*)_mbsinc( (unsigned char*)pTmp );
		}

		// one last check
		*pTmpLine = NULL;
		gos_TextStringLength( &curLineWidth, &height, pLine );
		if ( curLineWidth > areaWidth )
		{
			lineCount++;
		}

		if ( *pTmp == NULL )
			lineCount++;	
	}

	gos_TextStringLength( &width, &height, "A" );

	return (height) * lineCount ;
}