Esempio n. 1
0
File: port.c Progetto: jaw0/jlisp
void compflush(Obj p){
	Obj cp = CDR(p);
	int i, l;

	switch (SUBSUBPORT(p)){
	  case COMP_T:
	  case COMP_ECHO:
	  case COMP_2WAY:
		Fflush( CAR(cp));
		Fflush( CDR(cp));
		break;
	  case COMP_CONCAT:
		Fflush( CAR(cp));
		break;
	  case COMP_BCAST:
		l = CLENGTH(cp);
		for(i=0; i<l; i++)
			Fflush( CVECTOR(cp)[i] );
		break;
	  case COMP_SYNO:
		Fflush( getvalue(cp));
		break;
	  case COMP_FUNC:
		funcall_0("#<internal:compflush>", CVECTOR(cp)[2]);
		break;
	  default:
		break;
	}
}	
Esempio n. 2
0
File: port.c Progetto: jaw0/jlisp
/* composite ports */
void compputc(Obj p, int c){
	int i, l;
	Obj cp = CDR(p);
	
	switch (SUBSUBPORT(p)){
	  case COMP_T:
		writechar( CAR( cp ), c);
		writechar( CDR( cp ), c);
		break;
	  case COMP_BCAST:
		l = CLENGTH(cp);
		for(i=0; i<l; i++)
			writechar( CVECTOR(cp)[i], c);
		break;
	  case COMP_ECHO:
	  case COMP_2WAY:
		writechar( CDR(cp), c);
		break;
	  case COMP_SYNO:
		Fputc( MAKCHAR(c), getvalue(cp) );
		break;
	  case COMP_FUNC:
		funcall_1("#<internal:compputc>", CVECTOR(cp)[1], MAKCHAR(c));
		break;
	  default:
		break;
	}
}
Esempio n. 3
0
File: print.c Progetto: jaw0/jlisp
int prnvect(Obj a, Obj stream, int how){
	int i;
	
	writestr(stream, "#(");
	if( CLENGTH(a)) prnobj( CVECTOR(a)[0], stream, how);
	for(i=1; i< CLENGTH(a); i++){
		writestr(stream, " ");
		prnobj( CVECTOR(a)[i], stream, how);
	}
	writestr(stream, ")");
		
	return 1;
}
Esempio n. 4
0
//--------------------------------------------------------------
// Name:			DemoInit - global
// Description:		Initiate the things needed for the demo
// Arguments:		None
// Return Value:	A boolean variable: -true: successful initiation
//										-false: unsuccessful initiation
//--------------------------------------------------------------
bool DemoInit( void )
{
	g_glApp.Init( 10, 10, g_iScreenWidth, g_iScreenHeight, 16, "Demo 8_2: Realistic Water with Terrain", IDI_ICON1, IDR_MENU1 );
	g_glApp.CreateTTFont( "Lucida Console", 16 );

	//set the clear color (background) to black
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glDisable( GL_TEXTURE_2D );								//disable two dimensional texture mapping
	glDisable( GL_LIGHTING );								//disable lighting
	glDisable( GL_BLEND );									//disable blending
	glEnable( GL_DEPTH_TEST );								//enable depth testing

	glShadeModel( GL_SMOOTH );								//enable smooth shading
	glClearDepth( 1.0 );									//depth buffer setup
	glDepthFunc( GL_LEQUAL );								//set the type of depth test
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );	//the nicest perspective look
	
	//initialize the ROAM system
	g_ROAM.MakeTerrainPlasma( 1024, 1.0f );

	//set the terrain's lighting system up
	g_ROAM.SetLightingType( SLOPE_LIGHT );
	g_ROAM.SetLightColor( CVECTOR( 1.0f, 1.0f, 1.0f ) );
	g_ROAM.CustomizeSlopeLighting( 1, 1, 0.2f, 0.9f, 7 );
	g_ROAM.CalculateLighting( );

	//load the various terrain tiles
	g_ROAM.LoadTile( LOWEST_TILE,  "../Data/lowestTile.tga" );
	g_ROAM.LoadTile( LOW_TILE,     "../Data/lowTile.tga" );
	g_ROAM.LoadTile( HIGH_TILE,    "../Data/highTile.tga" );
	g_ROAM.LoadTile( HIGHEST_TILE, "../Data/highestTile.tga" );

	//make the texture map, and then save it
	g_ROAM.GenerateTextureMap( 512 );
	g_ROAM.DoTextureMapping( true );
	g_ROAM.DoMultitexturing( true );

	//initialize the ROAM system
	g_ROAM.Init( g_iLevel, 65536, &g_camera );
	g_ROAM.SetMaxTrisPerFrame( 5000 );

	//initialize the water system
	g_water.Init( 1024.0f );
	g_water.LoadReflectionMap( "../Data/reflection_map.tga" );
	g_water.SetColor( 1.0f, 1.0f, 1.0f, 0.9f );

	//set the camera's position
	g_camera.SetPosition( 128.0f, 512.0f, 256.0f );

	g_camera.m_fYaw  += 150;
	g_camera.m_fPitch-= 40;

	//the initiation was successful
	g_log.Write( LOG_SUCCESS, "INITIATION SUCCESSFUL" );
	return true;
}
Esempio n. 5
0
File: port.c Progetto: jaw0/jlisp
void compseek(Obj p, int s){
	Obj cp = CDR(p);
	
	switch (SUBSUBPORT(p)){
	  case COMP_FUNC:
		funcall_1("#<internal:compseek>", CVECTOR(cp)[3], MAKINT(s));
		break;
	  default:
		break;
	}
}
Esempio n. 6
0
File: port.c Progetto: jaw0/jlisp
Obj comptell(Obj p){
	Obj cp = CDR(p);
	
	switch (SUBSUBPORT(p)){
	  case COMP_FUNC:
		return funcall_0("#<internal:comptell>", CVECTOR(cp)[4]);
	  default:
		break;
	}
	return MAKINT(0);
}
Esempio n. 7
0
//--------------------------------------------------------------
// Name:			DemoInit - global
// Description:		Initiate the things needed for the demo
// Arguments:		None
// Return Value:	A boolean variable: -true: successful initiation
//										-false: unsuccessful initiation
//--------------------------------------------------------------
bool DemoInit( void )
{
	srand( GetCurrentTime( ) );

	g_glApp.Init( 10, 10, g_iScreenWidth, g_iScreenHeight, 16, "Demo 4_3: Slope Lighting", IDI_ICON1, IDR_MENU1 );
	g_glApp.CreateTTFont( "Lucida Console", 16 );

	//set the clear color (background) to black
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glDisable( GL_TEXTURE_2D );								//disable two dimensional texture mapping
	glDisable( GL_LIGHTING );								//disable lighting
	glDisable( GL_BLEND );									//disable blending
	glEnable( GL_DEPTH_TEST );								//enable depth testing

	glShadeModel( GL_SMOOTH );								//enable smooth shading
	glClearDepth( 1.0 );									//depth buffer setup
	glDepthFunc( GL_LEQUAL );								//set the type of depth test
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );	//the nicest perspective look

	//load the height map in
	g_bruteForce.MakeTerrainPlasma( 128, 1.0f );
	g_bruteForce.SetHeightScale( 0.25f );

	//set the terrain's lighting system up
	g_bruteForce.SetLightingType( SLOPE_LIGHT );
	g_bruteForce.SetLightColor( CVECTOR( 1.0f, 1.0f, 1.0f ) );
	g_bruteForce.CustomizeSlopeLighting( 1, 1, 0.2f, 0.9f, 15 );
	g_bruteForce.CalculateLighting( );
	
	//load the various terrain tiles
	g_bruteForce.LoadTile( LOWEST_TILE,  "../Data/lowestTile.tga" );
	g_bruteForce.LoadTile( LOW_TILE,     "../Data/lowTile.tga" );
	g_bruteForce.LoadTile( HIGH_TILE,    "../Data/highTile.tga" );
	g_bruteForce.LoadTile( HIGHEST_TILE, "../Data/highestTile.tga" );

	//load the terrain's detail map
	g_bruteForce.LoadDetailMap( "../Data/detailMap.tga" );
	g_bruteForce.DoDetailMapping( g_bDetail, 8 );

	//make the texture map, and then save it
	g_bruteForce.GenerateTextureMap( 256 );
	g_bruteForce.DoTextureMapping( g_bTexture );
	g_bruteForce.DoMultitexturing( g_glApp.CanMultitexture( ) );

	//set the camera's position
	g_camera.SetPosition( 64.0f, 128.0f, 256.0f );
	g_camera.m_fPitch-= 25;

	//the initiation was successful
	g_log.Write( LOG_SUCCESS, "INITIATION SUCCESSFUL" );
	return true;
}
Esempio n. 8
0
//--------------------------------------------------------------
// Name:			DemoRender - global
// Description:		The rendering procedure (that is passed to GLUT)
// Arguments:		None
// Return Value:	None
//--------------------------------------------------------------
void DemoRender( void )
{
	//clear the color and depth buffers
	g_glApp.BeginRendering( );
	
	//reset the modelview matrix
	glLoadIdentity( );

	//setup the viewing matrix
	g_camera.ComputeViewMatrix( );
	g_camera.SetViewMatrix( );

	//setup the terrain
	g_bruteForce.DoTextureMapping( g_bTexture );
	g_bruteForce.DoDetailMapping( g_bDetail, 8 );

	//render the simple terrain!
	glPushMatrix( );
		glScalef( 2.0f, 2.0f, 2.0f );
		g_bruteForce.Render( );
	glPopMatrix( );

	//render some text to the screen
	glDisable( GL_TEXTURE_2D );
	g_glApp.BeginTextMode( );
		//render the number of frames per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), 
					   "FPS:  %7.0f", g_glApp.GetFPS( ) );

		//render the number of vertices per frame
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-85, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Vertices: %d", g_bruteForce.GetNumVertsPerFrame( ) );

		//render how many million triangles are rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-100, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "MTris/S:  %.3f", ( g_bruteForce.GetNumTrisPerFrame( )*g_glApp.GetFPS( ) )/1000000.0f );

		if( g_bTexture )
			g_glApp.Print( 0, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), "Texturing: Enabled", g_glApp.GetFPS( ) );
		else
			g_glApp.Print( 0, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), "Texturing: Disabled", g_glApp.GetFPS( ) );

		if( g_bDetail )
			g_glApp.Print( 0, g_iScreenHeight-90, CVECTOR( 0.0f, 1.0f, 0.0f), "Detail Mapping: Enabled", g_glApp.GetFPS( ) );
		else
			g_glApp.Print( 0, g_iScreenHeight-90, CVECTOR( 0.0f, 1.0f, 0.0f), "Detail Mapping: Disabled", g_glApp.GetFPS( ) );
	g_glApp.EndTextMode( );

	//force a render finish, and then swap buffers
	g_glApp.EndRendering( );
}
Esempio n. 9
0
File: port.c Progetto: jaw0/jlisp
int compgetc(Obj p){
	int c;
	Obj cp = CDR(p), r;

	switch (SUBSUBPORT(p)){
	  case COMP_T:
	  case COMP_ECHO:
		c = readchar( CAR(cp));
		writechar( CDR(cp), c);
		break;
	  case COMP_2WAY:
		c = readchar( CAR(cp));
		break;
	  case COMP_CONCAT:
		c = readchar( CAR(cp));
		if( c == EOF ){
			/* go to next component */
			CDR(p) = CDR(cp);
			if( NULLP(CDR(p))){
				CAR(p) = IC_NIL;
				c = EOF;
			}else{
				c = compgetc(p);
			}
		}
		break;
	  case COMP_SYNO:
		r = Fgetc( getvalue(cp));
		if( r == IC_EOF )
			return EOF;
		if( !ICHARP(r) )
			return JLERROR("#<internal:compgetc>", r, "synonym-port returned a non-char");
		c = CCHAR(r);
		break;
	  case COMP_FUNC:
		r = funcall_0("#<internal:compgetc>", CVECTOR(cp)[0]);
		if( r == IC_EOF )
			return EOF;
		if( !ICHARP(r) )
			return JLERROR("#<internal:compgetc>", r, "function-port returned a non-char");
		c = CCHAR(r);
		break;
	  default:
		c = EOF;
		break;
	}
	return c;
}
Esempio n. 10
0
//-----------------------------------------------------------------------------
// Name: -()
// Desc: negates the vector
//-----------------------------------------------------------------------------
inline CVECTOR CVECTOR::operator -()
{
	return CVECTOR(-x,-y,-z);
}
Esempio n. 11
0
//-----------------------------------------------------------------------------
// Name:
// Desc: divide a vector by a scaler
//-----------------------------------------------------------------------------
inline CVECTOR operator/(CVECTOR u, float s)
{
	return CVECTOR(u.x/s,u.y/s,u.z/s);
}
Esempio n. 12
0
//-----------------------------------------------------------------------------
// Name:
// Desc: dot product of a vector and a scaler
//-----------------------------------------------------------------------------
inline CVECTOR operator*(CVECTOR u, float s)
{
	return CVECTOR(u.x*s, u.y*s,u.z*s);
}
Esempio n. 13
0
//-----------------------------------------------------------------------------
// Name:
// Desc: dot of a scaler and a vector
//-----------------------------------------------------------------------------
inline CVECTOR operator*(float s, CVECTOR u)
{
	return CVECTOR(u.x*s,u.y*s,u.z*s);
}
Esempio n. 14
0
//-----------------------------------------------------------------------------
// Name:
// Desc: cross product
//-----------------------------------------------------------------------------
inline CVECTOR operator ^(CVECTOR u, CVECTOR v)
{
	return CVECTOR(u.y*v.z - u.z*v.y, -u.x*v.z + u.z*v.x, u.x*v.y - u.y*v.x);
}
Esempio n. 15
0
//-----------------------------------------------------------------------------
// Name:
// Desc: subtract vectors
//-----------------------------------------------------------------------------
inline CVECTOR operator -(CVECTOR u, CVECTOR v)
{
	return CVECTOR(u.x - v.x, u.y - v.y , u.z - v.z);
}
Esempio n. 16
0
//-----------------------------------------------------------------------------
// Name:
// Desc: add vectors
//-----------------------------------------------------------------------------
inline CVECTOR operator+(CVECTOR u, CVECTOR v)
{
	return CVECTOR(u.x + v.x, u.y + v.y , u.z + v.z);
}
Esempio n. 17
0
//--------------------------------------------------------------
// Name:			DemoRender - global
// Description:		The rendering procedure (that is passed to GLUT)
// Arguments:		None
// Return Value:	None
//--------------------------------------------------------------
void DemoRender( void )
{
	//clear the color and depth buffers
	g_glApp.BeginRendering( );
	
	//reset the modelview matrix
	glLoadIdentity( );

	//setup the viewing matrix
	g_camera.ComputeViewMatrix( );
	g_camera.SetViewMatrix( );

	//calculate the viewing frustum
	g_camera.CalculateViewFrustum( );

	glFrontFace( GL_CW );
	glEnable( GL_CULL_FACE );

	//update the ROAM mesh
	g_ROAM.Update( );

	//update the water's vertices and re-calculate polygon normals
	g_water.Update( 0.001f );
	g_water.CalcNormals( );

	//render the terrain mesh
	glPushMatrix( );
		g_ROAM.Render( );
	glPopMatrix( );

	//render the water mesh
	glPushMatrix( );
		glTranslatef( 0.0f, 75.0f, 0.0f );

		glDepthMask( GL_FALSE );
		g_water.Render( true );
		glDepthMask( GL_TRUE );
	glPopMatrix( );
	
	//render some text to the screen
	glDisable( GL_TEXTURE_2D );
	g_glApp.BeginTextMode( );
		//render the number of frames per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), 
					   "FPS:  %7.0f", g_glApp.GetFPS( ) );

		//render the number of vertices per frame
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-85, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Vertices: %d", g_ROAM.GetNumVertsPerFrame( )+g_water.GetNumVertices( ) );

		//render how many triangles are getting rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-100, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Tris/S:   %d", g_ROAM.GetNumTrisPerFrame( )+g_water.GetNumTriangles( ) );

		//render how many million triangles are rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-115, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "MTris/S:  %.3f", ( ( g_ROAM.GetNumTrisPerFrame( )+g_water.GetNumTriangles( ) )*g_glApp.GetFPS( ) )/1000000.0f );
	g_glApp.EndTextMode( );

	//force a render finish, and then swap buffers
	g_glApp.EndRendering( );
}
Esempio n. 18
0
//--------------------------------------------------------------
// Name:			DemoRender - global
// Description:		The rendering procedure (that is passed to GLUT)
// Arguments:		None
// Return Value:	None
//--------------------------------------------------------------
void DemoRender( void )
{
	float fScale;
	float ucHeight;

	//clear the color and depth buffers
	g_glApp.BeginRendering( );
	
	//reset the modelview matrix
	glLoadIdentity( );

	fScale= g_geomipmapping.m_vecScale[0];

	//perform collision detection and response against the terrain mesh
	CLAMP( g_camera.m_vecEyePos[0], 100, ( g_geomipmapping.m_iSize*fScale )-100 );
	CLAMP( g_camera.m_vecEyePos[2], 100, ( g_geomipmapping.m_iSize*fScale )-100 );

	ucHeight= ( float )g_geomipmapping.GetScaledHeightAtPoint( ( int )( g_camera.m_vecEyePos[0]/fScale ),
															   ( int )( g_camera.m_vecEyePos[2]/fScale ) );

	if( g_camera.m_vecEyePos[1]<( ucHeight+8 ) )
		g_camera.m_vecEyePos[1]= ucHeight+8;

	//setup the viewing matrix
	g_camera.ComputeViewMatrix( );
	g_camera.SetViewMatrix( );

	//calculate the viewing frustum
	g_camera.CalculateViewFrustum( );

	//render the skydome
	glDisable( GL_CULL_FACE );
	glDisable( GL_DEPTH_TEST );
	glDepthMask( GL_FALSE );
		g_skydome.Set( g_camera.m_vecEyePos[0], g_camera.m_vecEyePos[1]-200.0f, g_camera.m_vecEyePos[2] );
		g_skydome.Render( 0.009f, true );
	glDepthMask( GL_TRUE );
	glEnable( GL_DEPTH_TEST );

	glCullFace( GL_CCW );
	glEnable( GL_CULL_FACE );

	//update the water's vertices and re-calculate polygon normals
	g_water.Update( 0.001f );
	g_water.CalcNormals( );

	//setup the terrain
	g_geomipmapping.Update( g_camera );

	g_geomipmapping.SetFogDepth( g_fFogDepth );
	glEnable( GL_FOG );

	//render the simple terrain!
	glPushMatrix( );
		g_geomipmapping.Scale( 2.0f, 1.0f, 2.0f );
		g_geomipmapping.Render( );
	glPopMatrix( );

	glDisable( GL_FOG );

	glDisable( GL_CULL_FACE );

	//render the water mesh
	glPushMatrix( );
		glTranslatef( 0.0f, 75.0f, 0.0f );

		glDepthMask( GL_FALSE );
		g_water.Render( true );
		glDepthMask( GL_TRUE );
	glPopMatrix( );

	//render some text to the screen
	glDisable( GL_TEXTURE_2D );
	g_glApp.BeginTextMode( );
		//render the number of frames per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), 
					   "FPS:  %7.0f", g_glApp.GetFPS( ) );

		//render the number of vertices per frame
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-85, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Vertices: %d", g_geomipmapping.GetNumVertsPerFrame( )+g_water.GetNumVertices( )+g_skydome.GetNumVertices( ) );

		//render how many triangles are getting rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-100, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Tris:   %d", g_geomipmapping.GetNumTrisPerFrame( )+g_water.GetNumTriangles( )+g_skydome.GetNumTriangles( ) );

		//render how many million triangles are rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-115, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "MTris/S:  %.3f", ( ( g_geomipmapping.GetNumTrisPerFrame( )+g_water.GetNumTriangles( )+g_skydome.GetNumTriangles( ) )*g_glApp.GetFPS( ) )/1000000.0f );

		//render volumetric fog control text
		g_glApp.Print( 30, g_iScreenHeight-70, CVECTOR( 1.0f, 0.0f, 0.0f ), "+    Increase Fog Depth" );
		g_glApp.Print( 30, g_iScreenHeight-86, CVECTOR( 1.0f, 0.0f, 0.0f ), "-    Decrease Fog Depth" );
	g_glApp.EndTextMode( );

	//force a render finish, and then swap buffers
	g_glApp.EndRendering( );
}
Esempio n. 19
0
//--------------------------------------------------------------
// Name:			DemoInit - global
// Description:		Initiate the things needed for the demo
// Arguments:		None
// Return Value:	A boolean variable: -true: successful initiation
//										-false: unsuccessful initiation
//--------------------------------------------------------------
bool DemoInit( void )
{
	static float fFogColor[4]= {	0.35f, 0.35f, 1.0f, 1.0f	};

	srand( GetCurrentTime( ) );

	g_glApp.Init( 10, 10, g_iScreenWidth, g_iScreenHeight, 16, "Demo 8_8b: Vertex-Based Fog Made Easy", IDI_ICON1, IDR_MENU1 );
	g_glApp.CreateTTFont( "Lucida Console", 16 );

	//set the clear color (background) to black
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glDisable( GL_TEXTURE_2D );								//disable two dimensional texture mapping
	glDisable( GL_LIGHTING );								//disable lighting
	glDisable( GL_BLEND );									//disable blending
	glEnable( GL_DEPTH_TEST );								//enable depth testing

	glShadeModel( GL_SMOOTH );								//enable smooth shading
	glClearDepth( 1.0 );									//depth buffer setup
	glDepthFunc( GL_LEQUAL );								//set the type of depth test
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );	//the nicest perspective look

	//load the height map in
	g_geomipmapping.MakeTerrainFault( 513, 64, 0, 255, 0.15f );

	//set the terrain's lighting system up
	g_geomipmapping.SetLightingType( SLOPE_LIGHT );
	g_geomipmapping.SetLightColor( CVECTOR( 0.2f, 0.4f, 1.0f ) );
	g_geomipmapping.CustomizeSlopeLighting( 1, 1, 0.2f, 0.9f, 15 );
	g_geomipmapping.CalculateLighting( );
	
	//load the various terrain tiles
	g_geomipmapping.LoadTile( LOWEST_TILE,  "../Data/lowestTile.tga" );
	g_geomipmapping.LoadTile( LOW_TILE,     "../Data/lowTile.tga" );
	g_geomipmapping.LoadTile( HIGH_TILE,    "../Data/highTile.tga" );
	g_geomipmapping.LoadTile( HIGHEST_TILE, "../Data/highestTile.tga" );

	//load the terrain's detail map
	g_geomipmapping.LoadDetailMap( "../Data/detailMap.tga" );
	g_geomipmapping.DoDetailMapping( true, 16 );

	//make the texture map, and then save it
	g_geomipmapping.GenerateTextureMap( 256 );
	g_geomipmapping.DoTextureMapping( true );
	g_geomipmapping.DoMultitexturing( g_glApp.CanMultitexture( ) );

	//initiate the geomipmapping system
	g_geomipmapping.Init( 17 );

	glFogi( GL_FOG_MODE, GL_LINEAR );		//set a linear fog mode
	glFogfv( GL_FOG_COLOR, fFogColor );		//set the color of the fog
	glFogf( GL_FOG_START, 0.0f );			//set the starting depth to 0
	glFogf( GL_FOG_END, 150.0f );			//set the fog's depth to 150 world units

	g_geomipmapping.SetFogDepth( g_fFogDepth );

	//turn the volumetric fog extension on
	glFogi( GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT );

	//initialize the water system
	g_water.Init( 1024.0f );
	g_water.LoadReflectionMap( "../Data/reflection_map.tga" );
	g_water.SetColor( 1.0f, 1.0f, 1.0f, 0.9f );

	//initialize the skydome
	g_skydome.Init( 5.0f, 5.0f, 256.0f );
	g_skydome.LoadTexture( "../Data/nightsky.tga" );

	//set the camera's position
	g_camera.SetPosition( 128.0f, g_geomipmapping.GetScaledHeightAtPoint( 128, 256 )+50.0f , 256.0f );

	//the initiation was successful
	g_log.Write( LOG_SUCCESS, "INITIATION SUCCESSFUL" );
	return true;
}
Esempio n. 20
0
//--------------------------------------------------------------
// Name:			DemoRender - global
// Description:		The rendering procedure (that is passed to GLUT)
// Arguments:		None
// Return Value:	None
//--------------------------------------------------------------
void DemoRender( void )
{
	int x, z;

	//clear the color and depth buffers
	g_glApp.BeginRendering( );
	
	//reset the modelview matrix
	glLoadIdentity( );

	//now render the current height map in the corner
	glMatrixMode( GL_PROJECTION );			//select the projection matrix
	glPushMatrix( );						//store the projection matrix
		glLoadIdentity( );
		glOrtho( 0, g_iScreenWidth, 0, g_iScreenHeight, -1, 1 );//set up an ortho screen
		glMatrixMode( GL_MODELVIEW );		//select the modelview matrix

		//render the height map
		glBegin( GL_POINTS );
		for( z=0; z<g_bruteForce.m_iSize; z++ )
		{
			for( x=0; x<g_bruteForce.m_iSize; x++ )
			{
				glColor3ub( g_bruteForce.GetTrueHeightAtPoint( x, z ), 
							g_bruteForce.GetTrueHeightAtPoint( x, z ),
							g_bruteForce.GetTrueHeightAtPoint( x, z ) );
				glVertex2d( x, g_iScreenHeight-z );
				}
			}

		//end rendering, and swap buffers
		glEnd( );

	//go back to perspective mode
		glMatrixMode( GL_PROJECTION );		//select the projection matrix
	glPopMatrix( );							//restore the old projection matrix
	glMatrixMode( GL_MODELVIEW );				//select the modelview matrix

	//setup the viewing matrix
	g_camera.ComputeViewMatrix( );
	g_camera.SetViewMatrix( );

	//render the simple terrain!
	g_bruteForce.Render( );

	g_glApp.BeginTextMode( );
		//render the number of frames per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-70, CVECTOR( 0.0f, 1.0f, 0.0f), 
					   "FPS:  %7.0f", g_glApp.GetFPS( ) );

		//render the number of vertices per frame
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-85, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "Vertices: %d", g_bruteForce.GetNumVertsPerFrame( ) );

		//render how many million triangles are rendered per second
		g_glApp.Print( g_iScreenWidth-175, g_iScreenHeight-100, CVECTOR( 0.0f, 1.0f, 0.0f),
					   "MTris/S:  %.3f", ( g_bruteForce.GetNumTrisPerFrame( )*g_glApp.GetFPS( ) )/1000000.0f );
	g_glApp.EndTextMode( );

	//force a render finish, and then swap buffers
	g_glApp.EndRendering( );
}