Exemplo n.º 1
0
/*
=====================
	destroySystem
=====================
*/
BOOL destroySystem() {
	TCHAR szPath[MAX_PATH] = {0};

	//end all running games
	endAllGames();
	
	botDestroy();
	
	N_CloseTrace();

	//destroy graphics resources
	destroyGraphics( LEFTGAME );
	destroyGraphics( NEUTRAL );

	//winmm
	timeEndPeriod( 1 );
	
	//delete left skin
	if( k_system.hSkinBitmapLeft )
		DeleteObject( k_system.hSkinBitmapLeft );
	
	if( k_system.hSkinBitmapRight )
		DeleteObject( k_system.hSkinBitmapRight );

	if( k_system.pPaths ) {
		N_Free( k_system.pPaths );
	}
	
	if( k_system.pMaps ) {
		N_Free( k_system.pMaps );
	}
	if( k_system.pBots ) {
		N_Free( k_system.pBots );
	}
	
	cfDestroyTable();
	UnbindKeys();
	
#ifdef DEBUG_COMPILE
	N_Sprintf( szPath, MAX_PATH, TEXT( "%s\\leaks.txt" ),
		k_system.szStartDir );
	outputDebugInfo( szPath );
#endif

	return TRUE;
}
Exemplo n.º 2
0
void BasicDemo::renderme()
{
	renderscene(0);
	if(gbDrawBatches)
	{
		((btGpuDemoDynamicsWorld*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab);
	}

//	if (0)
	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		DrawConstraintInfo();
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
Exemplo n.º 3
0
void BasicDemo3D::renderme()
{
	updateCamera();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if(gDrawWire)
	{
		glColor3f(1.f, 1.f, 1.f);
		glDisable(GL_LIGHTING);
		setTexturing(false);
	}
	else
	{
		myinit();
		setTexturing(true);
	}
		
	renderscene(0);

	if(gbDrawBatches)
	{
		((btCudaDemoDynamicsWorld3D*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab);
	}
	glColor3f(0, 0, 0);
	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		DrawConstraintInfo();
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
Exemplo n.º 4
0
cvg_bool OpticalFlow::process(IplImage *frame, cvg_int *prevFrameNumFeatures, CvPoint2D32f **prevFrameFeatures, char **foundFeaturesInCurrentFrame, CvPoint2D32f **currentFrameFeatures) {
	// Convert image to black & white
	cvConvertImage(frame, currentFrame);

	cvg_bool res = !firstRun;
	if (!firstRun) {
		// Find displacements of the features
		CvSize opticalFlowWindow = cvSize(WINDOW_SIZE, WINDOW_SIZE);
		CvTermCriteria terminationCriteria = cvTermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.3);
		cvCalcOpticalFlowPyrLK(	lastFrame, currentFrame, pyramid1, pyramid2,
								lastFrameFeatures, newFeatures, lastFrameFeaturesCount,
								opticalFlowWindow, PYRAMID_LEVELS, foundFeatures, errorFeatures,
								terminationCriteria, 0
								);

		if (prevFrameNumFeatures != NULL) (*prevFrameNumFeatures) = lastFrameFeaturesCount;
		if (prevFrameFeatures != NULL) {
			memcpy(lastFrameFeaturesCopy, lastFrameFeatures, lastFrameFeaturesCount * sizeof(CvPoint2D32f));
			(*prevFrameFeatures) = lastFrameFeaturesCopy;
		}
		if (foundFeaturesInCurrentFrame != NULL) (*foundFeaturesInCurrentFrame) = foundFeatures;
		if (currentFrameFeatures != NULL) (*currentFrameFeatures) = newFeatures;

		if (showDebug) outputDebugInfo(frame, lastFrameFeaturesCount, foundFeatures, lastFrameFeatures, newFeatures);

	} else firstRun = false;

	lastFrameFeaturesCount = maxNumFeatures;
	// Find good features to track in the current frame
	cvGoodFeaturesToTrack(currentFrame, eigImage, tempImage, lastFrameFeatures, &lastFrameFeaturesCount, MIN_FEATURE_QUALITY_TO_ACCEPT, 0.01, NULL);

	// Store current frame for the next iteration
	cvCopy(currentFrame, lastFrame);

	return res;
}
Exemplo n.º 5
0
void ParticlesDemo::renderme()
{

    glColor3f(1.0, 1.0, 1.0);
	glutWireCube(2*WORLD_SIZE);

	glPointSize(5.0f);
	glEnable(GL_POINT_SPRITE_ARB);

	glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
#ifndef __APPLE__
//	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV);
	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif //__APPLE__
	
	glDepthMask(GL_TRUE);
	glEnable(GL_DEPTH_TEST);

	glUseProgram(m_shaderProgram);

	btScalar dist = (m_glutScreenWidth > m_glutScreenHeight) ? m_glutScreenHeight : m_glutScreenWidth;
	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointScale"), dist  );
//	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), 0.5f );
	int numParticles = m_pWorld->getNumParticles();
	int	col_vbo = m_pWorld->m_colVbo;
	int curr_vbo = m_pWorld->m_vbo;
	float sphere_rad = m_pWorld->m_particleRad;

	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), sphere_rad );
	glColor3f(1, 1, 1);

	// render from the vbo
    glBindBuffer(GL_ARRAY_BUFFER, curr_vbo);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);
    if(col_vbo) 
	{
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, col_vbo);
		glColorPointer(4, GL_FLOAT, 0, 0);
		glEnableClientState(GL_COLOR_ARRAY);
	}
	glDrawArrays(GL_POINTS, 0, numParticles);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY); 
	glUseProgram(0);
	glDisable(GL_POINT_SPRITE_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER,0);
	if(m_drawGridMode)
	{
		btVector3& wmin =  m_pWorld->m_worldMin;
		btVector3& wmax =  m_pWorld->m_worldMax;
		glBegin(GL_LINE_LOOP);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glEnd();
		glBegin(GL_LINES);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glEnd();
		if(m_drawGridMode == 2)
		{
			int szx = m_pWorld->m_simParams.m_gridSize[0];
			int szy = m_pWorld->m_simParams.m_gridSize[1];
			glBegin(GL_LINES);
			for(int i = 1; i < (szx-1); i++)
			{
				float wgt = (float)i / (float)(szx-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(vtx[0], wmin[1], wmin[2]);
				glVertex3f(vtx[0], wmax[1], wmin[2]);
			}
			for(int i = 1; i < (szy-1); i++)
			{
				float wgt = (float)i / (float)(szy-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(wmin[0], vtx[1], wmin[2]);
				glVertex3f(wmax[0], vtx[1], wmin[2]);
			}
		glEnd();
		}
	}

	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		showProfileInfo(xOffset, yStart, yIncr);
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}
Exemplo n.º 6
0
void SpheresGridDemo::renderme()
{


	glPointSize(5.0f);
	glEnable(GL_POINT_SPRITE_ARB);
	glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
#ifndef __APPLE__
	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV);
#endif //__APPLE__
	
	glDepthMask(GL_TRUE);
	glEnable(GL_DEPTH_TEST);

	glUseProgram(m_shaderProgram);

	btScalar dist = (m_glutScreenWidth > m_glutScreenHeight) ? m_glutScreenHeight : m_glutScreenWidth;
	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointScale"), dist  );
//	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), 0.5f );
#ifdef SPHERES_DEMO
#ifdef INTEGRATION_DEMO
	int numSpheres = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->getNumSpheres() : m_pWorldS->getNumSpheres();
	int	col_vbo = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_colVbo : m_pWorldS->m_colVbo;
	int curr_vbo = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_vbo : m_pWorldS->m_vbo;
	float sphere_rad = (m_demoType == DEMO_INTEGRATION) ? m_pWorldI->m_sphereRad : m_pWorldS->m_sphereRad;
#else
	int numSpheres = m_pWorldS->getNumSpheres();
	int	col_vbo = m_pWorldS->m_colVbo;
	int curr_vbo =  m_pWorldS->m_vbo;
	float sphere_rad = m_pWorldS->m_sphereRad;
#endif
#else
	int numSpheres = m_pWorldI->getNumSpheres();
	int	col_vbo = m_pWorldI->m_colVbo;
	int curr_vbo =  m_pWorldI->m_vbo;
	float sphere_rad = m_pWorldI->m_sphereRad;
#endif

	

	glUniform1f( glGetUniformLocation(m_shaderProgram, "pointRadius"), sphere_rad );
	glColor3f(1, 1, 1);

	// render from the vbo
    glBindBuffer(GL_ARRAY_BUFFER, curr_vbo);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);
    if(col_vbo) 
	{
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, col_vbo);
		glColorPointer(4, GL_FLOAT, 0, 0);
		glEnableClientState(GL_COLOR_ARRAY);
	}
	glDrawArrays(GL_POINTS, 0, numSpheres);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY); 
	glUseProgram(0);
	glDisable(GL_POINT_SPRITE_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER,0);
#ifdef SPHERES_DEMO
	if((m_demoType != DEMO_INTEGRATION) && m_drawGridMode)
	{
		btVector3& wmin =  m_pWorldS->m_worldMin;
		btVector3& wmax =  m_pWorldS->m_worldMax;
		glBegin(GL_LINE_LOOP);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glEnd();
		glBegin(GL_LINES);
		glVertex3f(wmin[0], wmin[1], wmin[2]);
		glVertex3f(wmax[0], wmin[1], wmin[2]);
		glVertex3f(wmin[0], wmin[1], wmax[2]);
		glVertex3f(wmax[0], wmin[1], wmax[2]);
		glVertex3f(wmin[0], wmax[1], wmin[2]);
		glVertex3f(wmin[0], wmax[1], wmax[2]);
		glVertex3f(wmax[0], wmax[1], wmin[2]);
		glVertex3f(wmax[0], wmax[1], wmax[2]);
		glEnd();
		if(m_drawGridMode == 2)
		{
			int szx = m_pWorldS->m_simParams.m_gridSize[0];
			int szy = m_pWorldS->m_simParams.m_gridSize[1];
			glBegin(GL_LINES);
			for(int i = 1; i < (szx-1); i++)
			{
				float wgt = (float)i / (float)(szx-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(vtx[0], wmin[1], wmin[2]);
				glVertex3f(vtx[0], wmax[1], wmin[2]);
			}
			for(int i = 1; i < (szy-1); i++)
			{
				float wgt = (float)i / (float)(szy-1);
				btVector3 vtx = wmax * wgt + wmin * (1.0f - wgt); 
				glVertex3f(wmin[0], vtx[1], wmin[2]);
				glVertex3f(wmax[0], vtx[1], wmin[2]);
			}
		glEnd();
		}
	}
#endif

	if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		int  xOffset = 10.f;
		int  yStart = 20.f;
		int  yIncr = 20.f;
		if(m_demoType == DEMO_INTEGRATION)
		{
#ifdef INTEGRATION_DEMO
			switch(m_pWorldI->m_usedDevice)
			{
				case 0:
					GLDebugDrawString(xOffset,yStart,"CPU");
					break;
				case 1:
					GLDebugDrawString(xOffset,yStart,"OpenCL");
					break;
				case 2:
					GLDebugDrawString(xOffset,yStart,"CUDA");
					break;
			}
			yStart += 30.f;
#endif

		}
		showProfileInfo(xOffset, yStart, yIncr);
		outputDebugInfo(xOffset, yStart, yIncr);
		resetPerspectiveProjection();
	}
}