3D Game Builder SDK

SDK Functions

gameCloseTGA( char * name )

Description

Close an image file that was opened using the gameOpenTGA( char * name ) function.

Specification

int gameCloseTGA( int id )

int id

= the id number of the image

return value

= 1 (succeeded) or 0 (failed)

Notes

Use this function to close a TGA image file that was opened using the gameOpenTGA( char * name ) function.

For Example

#include "3dgamebuilder.h"

int		player = 0;
int		f22 = 0;

// draw the ship
void drawShip( float x, float y, float z, float angle, float width, float height )
{ 
	float	w2, h2;

	w2 = width  * 0.5f;
	h2 = height * 0.5f;

	glPushMatrix();
		glTranslatef( x, y, z );
		glRotatef( angle, 0.0f, 0.0f, 1.0f );

		gameBindTexture( f22 );
		glBegin( GL_TRIANGLE_STRIP );
			glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
			glTexCoord2f( 0.0f, 0.0f );
			glVertex2f( -w2, -h2 );
			glTexCoord2f( 1.0f, 0.0f );
			glVertex2f( -w2,  h2 );
			glTexCoord2f( 0.0f, 1.0f );
			glVertex2f(  w2, -h2 );
			glTexCoord2f( 1.0f, 1.0f );
			glVertex2f(  w2,  h2 );
		glEnd();
		gameBindTexture( 0 );
	glPopMatrix();
}

// exported game function
DLL_EXPORT int gameLoop(void)
{
	float	posx  = 0.0f;
	float	posy  = 0.0f;
	float	stepx = 0.0005f;
	float	stepy = 0.001f;
	float	angle = 0.0f;
	float	x,y,r,a;
	float	gravity = 0.00025f;

	float	ratio = (272.0f/470.0f);
	float	width = 1.0f/ratio;
	int		thrust;
	int		sound;
	int		shoot;

	// validate
	if (!gameValidateTGA( "f22a.tga" ))
		return 1;
	
	// init
	f22 = gameOpenTGA( "f22a.tga" );
	f22 = gameSetInvisibleColorTGA( f22, 1.0f, 1.0f, 0.0f );

	// game loop
	while(1)
	{
		thrust = 0;

		gamePadRead();
		gameStartRender();
	
			glMatrixMode( GL_PROJECTION );
			glLoadIdentity();
			glScalef( ratio, 1.0f, 1.0f );
			
			glMatrixMode( GL_MODELVIEW );
			glLoadIdentity();

			drawShip( posx, posy, 0.0f, angle, 0.3f, 0.4f );

		gameEndRender();
	}

	// clean up
	gameCloseTGA(f22);

	return 0;
}

See Also

  gameValidateTGA( char * name )
  gameOpenTGA( char * name )
  gameCloseTGA( int id )
  gameSetAdditiveBlendTGA( int id, int set )
  gameSetSmoothTGA( int id, int set )
  gameSetInvisibleColorTGA( int id, float r, float g, float b )
  gameSetTransparencyTGA( int id_base, int id_alpha )
  gameBindTexture( int id )

Go Back

SDK Functions