Exemple #1
0
void MainLoop(void)
{
    InputManager* inputMgr = new InputManager();
    GSceneManager* sceneMgr = new GSceneManager(inputMgr);
    
    DAssetsManager* dataMgr = new DAssetsManager(sceneMgr);
    dataMgr->loadAssetGroup(0);
    
    PPhysicsManager* physicsMgr = new PPhysicsManager(sceneMgr);
    GRendering* renderer = new GRendering(sceneMgr);
    
    glfwSwapInterval(0);
    
    do{
        // Erfasse Eingaben
        inputMgr->captureInput();
        
        // Physikberechnungen ausführen
        physicsMgr->performPhysics();
        
        renderer->draw();
        
        // Swap buffers
        glfwSwapBuffers();
        
        countFPS();
        
    } // Check if the ESC key was pressed or the window was closed
    while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
           glfwGetWindowParam( GLFW_OPENED ) );
}
Exemple #2
0
static void idle(void){
	static float last_t = 0.0f;
	float this_t = glutGet(GLUT_ELAPSED_TIME)/1000.0f;
	if(this_t-last_t > 1.0f/61.0f){
		if(renderdiff){
			diffrCalculate();
			redisplay = true;
		}
		if(rotating) redisplay = true;
		idleArcball();
		last_t = this_t;
	}
	

	static uint last_time=0;
	static uint this_time=0;
	
	if(animation&&!pause){
		if(ani_frame >= ani_files)ani_frame = 0;
		else if(ani_frame < 0) ani_frame += ani_files;
		this_time=glutGet(GLUT_ELAPSED_TIME);
		if(this_time-last_time>=ani_speed){
			redisplay=true;
			parseCoords(ani_matrix[ani_frame],"\t");
			ani_frame++;
			last_time=this_time;
		}
	}
	
	if(redisplay){
		redisplay=false;
		countFPS();
		glutPostRedisplay();
	}
}
Exemple #3
0
void Game::tick(float dt) {

    m_level.tick(dt);
    m_elapsed_time += dt;
    countFPS(dt);

    if (m_elapsed_time >= FRAME_TIME) {
        m_fps_counter++;
        m_context.renderer->beginFrame();
        m_level.render();
        m_hud.render();
        doGUI();
        m_context.renderer->renderText(m_fps_text, "arial", 0, 0);
        m_context.renderer->endFrame();
        m_elapsed_time -= FRAME_TIME;
    }

    m_running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
}
Exemple #4
0
void CFastLED::showColor(const struct CRGB & color, uint8_t scale) {
	while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
	lastshow = micros();

	// If we have a function for computing power, use it!
	if(m_pPowerFunc) {
		scale = (*m_pPowerFunc)(scale, m_nPowerData);
	}

	CLEDController *pCur = CLEDController::head();
	while(pCur) {
		uint8_t d = pCur->getDither();
		if(m_nFPS < 100) { pCur->setDither(0); }
		pCur->showColor(color, scale);
		pCur->setDither(d);
		pCur = pCur->next();
	}
	countFPS();
}
void OGLWidget::paintGL()
{
	if (fileLoaded){
		countFPS();
		if (useGPU){			
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			gpuRayCast();
			
		}
		else{			
			volume->rotate(rotationSpeed);
			volume->samplingStepSize = samplingStepSize;
			data = volume->rayCast();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			float* pixel = &data[0];
			glDrawPixels(width, height, GL_LUMINANCE, GL_FLOAT, pixel);
		}		
	}
}
Exemple #6
0
void CFastLED::show(uint8_t scale) {
	// guard against showing too rapidly
	while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
	lastshow = micros();

	// If we have a function for computing power, use it!
	if(m_pPowerFunc) {
		scale = (*m_pPowerFunc)(scale, m_nPowerData);
	}

	CLEDController *pCur = CLEDController::head();
	while(pCur) {
		uint8_t d = pCur->getDither();
		if(m_nFPS < 100) { pCur->setDither(0); }
		pCur->showLeds(scale);
		pCur->setDither(d);
		pCur = pCur->next();
	}
	countFPS();
}