예제 #1
0
void fsDrawMgr::renderForEngine()
{
	fsDrawMgr* ins = instance();

	    if (!ins->m_is_render)
	    {
	        return;
	    }

	    fsLowLevelAPI::resetDrawState(); // TODO

	    for (const fsID* id = ins->m_scr_map.getFirstKeyN(); id; id = ins->m_scr_map.getNextKeyN(*id))
	    {
	        fsScr* scr = *ins->m_scr_map.get(*id);

	        if (!scr->isActive())
	        {
	            continue;
	        }

	        fsLowLevelAPI::setViewport( //
	            scr->m_left_in_framebuffer, scr->m_top_in_framebuffer, //
	            scr->m_width_in_framebuffer, scr->m_height_in_framebuffer);

	        fsLowLevelAPI::clearFramebuffer(scr->isClearColor(), scr->isClearDepth(), reinterpret_cast<const u8*>(&scr->m_clear_col));

	        scr->setupProjection();

	        fsDraw* sort_list = NULL;

	        renderScreen(scr, &sort_list, scr->m_view);

	        for (u32 i = 0; i < fsScr::GUEST_SCREEN_NUM; i++)
	        {
	            if (scr->m_guest_id[i] != fsID::ZERO)
	            {
	                renderScreen(*ins->m_scr_map.get(scr->m_guest_id[i]), &sort_list, scr->m_view);
	            }
	        }

	        if (sort_list)
	        {
	            fsDraw* dummy;
	            sortList(&sort_list, &dummy, sort_list);
	        }

	        for (fsDraw* draw = sort_list; draw; draw = draw->m_next_sort)
	        {
	            draw->setupDrawState();
	            draw->render(scr->m_view);
	        }

	        scr->copyScreenTexture();
	    }
}
예제 #2
0
void UiRenderer::render(Renderer &renderer) {
    glDepthMask(GL_FALSE);
    renderHand(renderer);
    int vpWidth, vpHeight;
    renderer.getViewport()->getSize(&vpWidth, &vpHeight);
    Camera camera;
    camera.setOrthographic();
    camera.setBounds(0, vpWidth, 0, vpHeight);
    Matrix4f crosshairMtx;
    crosshairMtx.translate(Vector3f(vpWidth/2, vpHeight/2, -10));
    crosshairMtx.scale(Vector3f(80, 80, 1));
    Matrix4f widget;
    widget.translate(Vector3f(vpWidth/2+12, vpHeight-20, -2));
    widget.scale(Vector3f(380, 80, 1));

    const Mesh &mesh = MeshLoader::getMesh("GUIElement.obj");
    const Material &mat = MaterialLoader::fromTexture("Reticle.png");

    Shader &sh = ShaderLoader::getShader("unshaded.frag");
    renderer.renderMesh(camera, sh, crosshairMtx, mesh, mat);

    // Title
    renderer.setFont("Pacaya", 1.5f);
    renderer.renderText(camera, "GlPortal", Vector3f(25, vpHeight - 75, -20));

    // FPS counter
    renderer.setFont("Pacaya", 0.5f);
    renderer.renderText(camera,
                        std::string("FPS: ") + std::to_string(Game::fps.getFps()),
                        Vector3f(10, vpHeight - 25, -20));
    if (renderer.getScene()->screen->enabled) {
        renderScreen(renderer);
    }
    glDepthMask(GL_TRUE);
}
예제 #3
0
int main(int argc, char* args[]){
    bool quit = false;
    int select = -1;
    int modeMaxButtons[6];
    int keyboardMode = -1;
    isConnected = false;

    for(int i=0; i < MAX_PLAYERS; i++)
        playerReady[i] = 0;

    SDL_Event event;
    SDL_Rect buttonPlacement[MAXBUTTONS];   // Interactable buttons
    SDL_Rect windowPlacement[2];            // Window backgrounds

    initSDL();
    loadMedia();
    initModeMaxButtons(modeMaxButtons);
    setWindows(windowPlacement);
    clearTextStrings(6);
    //SDL_StartTextInput();

    while(!quit){
        while (SDL_PollEvent(&event))
            handleEvent(&event, buttonPlacement, &select, &mode, modeMaxButtons, &keyboardMode, &quit);

        renderScreen(&mode, &select, buttonPlacement, windowPlacement);
        SDL_Delay(10);
    }

    closeRenderer();
    return 0;
}
예제 #4
0
/* ***************************************** */
void b0PopCallback(void *ptr) {
  dbSerialPrintln("b0PopCallback");
  dbSerialPrint("ptr=");
  dbSerialPrintln((uint32_t)ptr);

  renderScreen(SECOND_SCREEN);
}
예제 #5
0
void b2PopCallback(void *ptr) {
  dbSerialPrintln("b2PopCallback");
  dbSerialPrint("ptr=");
  dbSerialPrintln((uint32_t)ptr);

  renderScreen(SETTINGS_SCREEN);
}
예제 #6
0
void GameView::run()
{
	float frameCounter = 0, frameSpeed = 500;
	Clock clock;
	
	bool updateFrame = true;
	while(_screen.isOpen())
	{
		EventManager eventManager;
		sf::Event event;
		while (_screen.pollEvent(event))
		{
			eventManager.processEvent(event);
		}
		updateScreen(eventManager);
		if(updateFrame)
			frameCounter += frameSpeed*clock.restart().asSeconds();
		else
			frameCounter = 0;
		
		frameCounter += frameSpeed*clock.restart().asSeconds();
		
		renderScreen();
	}
}
예제 #7
0
void u0PopCallback(void *ptr)
{
  dbSerialPrintln("u0PopCallback");
  dbSerialPrint("ptr=");
  dbSerialPrintln((uint32_t)ptr);

  renderScreen(HOME_SCREEN);
}
예제 #8
0
void n1PopCallback(void *ptr)
{
  dbSerialPrintln("n1PopCallback");
  dbSerialPrint("ptr=");
  dbSerialPrintln((uint32_t)ptr);

  renderScreen(ABOUT_SCREEN);
}
예제 #9
0
파일: posixino.cpp 프로젝트: ern0/posixino
void LiquidCrystal::print(const char* str) {

    int len = strlen(str);
    for (int n = 0; n < len; n++) writeChar(str[n]);

    if (isChanged()) renderScreen();

} // print()
예제 #10
0
파일: posixino.cpp 프로젝트: ern0/posixino
void LiquidCrystal::clear() {

    memset(screenBuffer,0x20,bufferSize);
    memset(lastScreen,0x20,screenSize);
    x = 0;
    y = 0;

    if (isChanged() || firstClear) renderScreen();
    firstClear = false;

} // clear()
예제 #11
0
파일: posixino.cpp 프로젝트: ern0/posixino
void LiquidCrystal::scrollDisplayRight() {

    for (int n = bufferSize; n > 0; --n) {
        screenBuffer[n] = screenBuffer[n - 1];
    }
    for (int row = 0; row < h; row++) {
        screenBuffer[(row * 3 * w) + (3 * w) - 1] = ' ';
    }

    if (isChanged()) renderScreen();

} // scrollDisplayLeft()
예제 #12
0
파일: posixino.cpp 프로젝트: ern0/posixino
void LiquidCrystal::scrollDisplayLeft() {

    for (int n = 1; n < bufferSize; n++) {
        screenBuffer[n - 1] = screenBuffer[n];
    }
    for (int row = 0; row < h; row++) {
        screenBuffer[row * 3 * w] = ' ';
    }

    if (isChanged()) renderScreen();

} // scrollDisplayLeft()
예제 #13
0
/* Processing weather data which got from forecast.io */
void processWeatherData(const char *name, const char *data) {
  dbSerialPrintln("in processWeather");
  String str = String(data);
  char strBuffer[300] = "";
  str.toCharArray(strBuffer, 300);
  int day = 0;
  String tmpStr;

  dbSerialPrintln("Time now: " + String(Time.hour()) + ":" + String(Time.minute()));
  //dbSerialPrintln("Data: " + str);

  // Parse the API response.
  while(day < 4) {
    if(day == 0)
      weatherData[day].summ = strtok(strBuffer, "~");
    else {
      weatherData[day].summ = strtok(NULL, "~");
      //dbSerialPrintln("Summary: " + );
    }

    weatherData[day].weekday = Time.weekday(Time.now() + day*86400);
    weatherData[day].icon = processIcon(strtok(NULL, "~"), day);

    if(day > 0) {
      weatherData[day].minTemp = (((int)round(atof(strtok(NULL, "~"))))-32)/1.8;
      weatherData[day].maxTemp = (((int)round(atof(strtok(NULL, "~"))))-32)/1.8;
    }

    day++;
  }

  int cnt = 0;
  while(cnt < 4) {
    dbSerialPrint("Day " + String(cnt) + ": ");
    dbSerialPrint("Summary: " + weatherData[cnt].summ + ", ");
    dbSerialPrint("Icon: " + String(weatherData[cnt].icon) + ", ");
    dbSerialPrint("Weekday: " + String(weatherData[cnt].weekday) + ", ");
    dbSerialPrint("Min Temp: " + String(weatherData[cnt].minTemp) + ", ");
    dbSerialPrintln("Max Temp: " + String(weatherData[cnt].maxTemp));
    cnt++;
  }

  weather_state = WEATHER_READY;
  updateweatherhour = Time.hour();

  renderScreen(HOME_SCREEN);
}
예제 #14
0
void DeferredRender::doRender() {
	if(!loaded)
		return;
	
	//std::cout << "geometry" << std::endl;
	geometryPass();
	//backgroundPass();
	//std::cout << "light" << std::endl;
	lightPass();
	//std::cout << "alpha" << std::endl;
	alphaPass();
	// TODO: ajouter pass SSAO, MXAA

	//std::cout << "final" << std::endl;

	renderScreen();
	//throw -1;
}
예제 #15
0
void loop() {
  nexLoop(nex_listen_list);

  /* BUTTON - WILL BE REMOVED LATER */
  // Update button state
  button1.Update();
  // Save click codes in LEDfunction, as click codes are reset at next Update()
  if (button1.clicks != 0)
    function = button1.clicks;

  if(button1.clicks == 1) {
    Serial.println("SINGLE click");
    getWeather();
  }
  /*if(function == 2) Serial.println("DOUBLE click");
  if(function == 3) Serial.println("TRIPLE click");
  if(function == -1) Serial.println("SINGLE LONG click");
  if(function == -2) Serial.println("DOUBLE LONG click");
  if(function == -3) Serial.println("TRIPLE LONG click");*/


  // Change forecast days of week after midnight
  if(currentWeekday < Time.weekday()) {
    currentWeekday = Time.weekday();
    renderScreen(HOME_SCREEN);
  }

  /* Fetching weather data one time in an hour */
  if (Time.hour() != updateweatherhour){
    getWeather();
  }

  /* BUTTON - WILL BE REMOVED LATER */
  function = 0;
  delay(5);
}
예제 #16
0
void Environment::drawScreen()
{
  renderScreen();
  if (mMenuState == State_ChangeMenu) {
    //if (mMenuStatePosition == 25) {
    //   SDL_BlitSurface(mScreen, 0x00, mBuffer, 0x00);
    //} 

    // if we're in a fadeout, use a faded mBuffer and just blit it to
    // the screen
    //if (mMenuStatePosition < 50) {
    SDL_SetAlpha(mBuffer, SDL_SRCALPHA, (255-(mMenuStatePosition*60)));
    SDL_BlitSurface(mBuffer, 0x00, mScreen, 0x00);

    SDL_Flip(mScreen);
    return;
    //} 

  } else {

    SDL_Flip(mScreen);
  }

}
예제 #17
0
파일: GameBase.cpp 프로젝트: carussell/nvvg
bool GameBase::main()
{  
  // This makes sure the device is valid.
  gRenderer.validateDevice();

  // Update Input
  gInput.updateInput();

  // process game logic
  process();
 
  // return if quit flag was set
  if (gWindowsWrapper.isQuiting())
    return true;

  // draw the screen
  gRenderer.beginScene();
  gRenderer.clear(kClearFrameBuffer | kClearDepthBuffer | kClearToFogColor);
  renderScreen();
  gRenderer.endScene();
  gRenderer.flipPages();

  return true;
}
예제 #18
0
void setup() {
  Serial.begin(9600);
  //while(!Serial.available()) Particle.process();

  //nextion.setBrightness(DISPLAY_BRIGHTNESS);

  /* BUTTON - WILL BE REMOVED LATER */
  pinMode(D4, INPUT_PULLUP);
  // Setup button timers (all in milliseconds / ms)
  // (These are default if not set, but changeable for convenience)
  button1.debounceTime   = 20;   // Debounce timer in ms
  button1.multiclickTime = 250;  // Time limit for multi clicks
  button1.longClickTime  = 1000; // time until "held-down clicks" register


  // Subscribing for sensor data
  Particle.subscribe("Outside_Temperature", dataHandler, MY_DEVICES);
  Particle.subscribe("Outside_Humidity", dataHandler, MY_DEVICES);

  // Subscribing for weather data API call
  Particle.subscribe(HOOK_RESP, processWeatherData, MY_DEVICES);

  /* Set the baudrate which is for debug and communicate with Nextion screen. */
  nexInit();

  /* Register the pop event callback functions for the button components. */
  b0.attachPop(b0PopCallback);
  b1.attachPop(b1PopCallback);
  b2.attachPop(b2PopCallback);
  bt0.attachPop(bt0PopCallback, &bt0);
  bt1.attachPop(bt1PopCallback, &bt1);
  n0.attachPop(n0PopCallback);
  n1.attachPop(n1PopCallback);
  bu0.attachPop(bu0PopCallback);
  u0.attachPop(u0PopCallback);

  // See if this EEPROM has saved data
  if(EEPROM.read(0)==117) {
    // Set language
    if(EEPROM.read(1)==1) {
      langCode = 1;
      bt0.setValue((uint32_t)langCode);
    }
    else {
      langCode = 0;
    }
    // Set temperature scale
    if(EEPROM.read(2)==1) {
      tempScale = 1;
      bt1.setValue((uint32_t)tempScale);
    }
    else
      tempScale = 0;
  } else {
        // Initialize
        EEPROM.write(0, 117);
        // Language
        EEPROM.write(1, 0);
        // Temperature scale
        EEPROM.write(2, 0);
    }

  // Set timezone
  Time.zone(TIMEZONE_OFFSET);
  // Set current day of the week
  currentWeekday = Time.weekday();

  renderScreen(HOME_SCREEN);
}
예제 #19
0
파일: posixino.cpp 프로젝트: ern0/posixino
void LiquidCrystal::write(char chr) {
    writeChar(chr);
    if (isChanged()) renderScreen();
} // write()
예제 #20
0
int Environment::askTimedQuestion(char *fTitle, char *fText, int fTimeout, int fDefault)
{
  Element *fQuestionBackground;
  Element *fQuestionText;
  Element *fQuestionTitle;
  Element *fQuestionTimer;

  char buf[255];
  char *fTimerText;

  FontResource *tFont;

  if (fDefault == -1 || fTimeout <= 0) {
    return askQuestion(fTitle, fText);
  }

  fQuestionBackground = mElements->getElementByContent(CONTENT_QUESTIONBACKGROUND, mMenu->getSkinID());
  fQuestionText = mElements->getElementByContent(CONTENT_QUESTIONTEXT, mMenu->getSkinID());
  fQuestionTitle = mElements->getElementByContent(CONTENT_QUESTIONTITLE, mMenu->getSkinID());
  fQuestionTimer = mElements->getElementByContent(CONTENT_QUESTIONTIMER, mMenu->getSkinID());

  fTimerText = mDialog->getValue("TimerText");


  mController->setState(Ctrl_A, Button_Released);
  mController->setState(Ctrl_B, Button_Released);
  mController->setState(Ctrl_Y, Button_Released);

  SDL_Event event;
#ifdef ENABLE_XBOX
  int start = XGetTickCount();
#else
  int start = SDL_GetTicks();
#endif
  int now;

  while (mController->getState(Ctrl_A) == Button_Released &&
      mController->getState(Ctrl_B) == Button_Released &&
      mController->getState(Ctrl_Y) == Button_Released) {
#ifdef WINDOWS
    while (SDL_PollEvent(&event)) {
      mController->update(&event);
    }
#endif

#ifdef ENABLE_XBOX    
    now = XGetTickCount();
#else
    now = SDL_GetTicks();
#endif

    if (now - start > (fTimeout*1000)) {
      return fDefault;
    }

    renderScreen();

    if (fQuestionBackground) {
      fQuestionBackground->drawImage(mScreen);
    }

    if (fQuestionTitle) {
      fQuestionTitle->drawText(fTitle, mScreen);
    }

    if (fQuestionText) {
      fQuestionText->drawText(fText, mScreen);
    }

    if (fQuestionTimer && fTimerText) {
      sprintf(buf, fTimerText, fTimeout - ((int) (now - start) / 1000));
      fQuestionTimer->drawText(buf, mScreen);
    }

    SDL_Flip(mScreen);

#ifdef ENABLE_XBOX
    XSleep(30);
#else       
    SDL_Delay(30);
#endif
  }
  if (mController->getState(Ctrl_A) == Button_Pressed) {
    return 1;
  } else {
    return 0;
  }

}
예제 #21
0
파일: new 1.c 프로젝트: ndelanou/PCWorms
int mainFenetre()
{
	unsigned int frame_max = SDL_GetTicks() + FRAME_RATE, temps = 0;
	Input * pInput = NULL; //structure contenant les informations relatives aux inputs clavier
	SDL_Texture * pTextureDisplay = NULL;	//Texture globale
	SDL_Rect camera = initRect(0, 0, 0, 0); // rect(x,y,w,h)
	Worms** wormsTab = NULL;
	char mapName[100];
	Jeu* jeu = NULL;

	//init SDL + fenetre + renderer
	if (initSWR())
	{
		//Initialisation des inputs
		pInput = initInput();
		if (pInput == NULL)
		{
			fprintf(logFile, "mainFenetre : FAILURE, initInput.\n");
			cleanUp(&pInput, &pTextureDisplay);
			return -1;
		}

		//InitSounds 
		if (!initSDLMixer()){
			fprintf(logFile, "initSDLMixer : FAILURE, init.\n");
			cleanUp(&pInput, &pTextureDisplay);
			return -1;
			
		}

		strcpy(mapName, cMAP);
		/*Initialisation SDL_TTF*/
		if (TTF_Init() == -1)
		{
			fprintf(logFile, "mainFenetre : FAILURE, initialisation de TTF_Init : %s.\n\n", TTF_GetError());
			cleanUp(&pInput, &pTextureDisplay);
			return -1;
		}

		if (mainMenu(pInput, mapName) < 0)
		{
			fprintf(logFile, "mainFenetre : FAILURE, mainMenu .\n\n");
			cleanUp(&pInput, &pTextureDisplay);
			return -1;
		}
		if (!pInput->quit)
		{
			if (mainInit() < 0)	//set le nombre d'équipe et le nombre de worms par équipe
			{
				fprintf(logFile, "mainInit : FAILURE.\n");
				cleanUp(&pInput, &pTextureDisplay);
				return -1;
			}

			/*Init game*/
			jeu = nouveauJeu(mapName);
			if (jeu == NULL)
			{
				fprintf(logFile, "nouveauJeu : FAILURE.\n");
				cleanUp(&pInput, &pTextureDisplay);
				return -1;
			}

			/*Init map*/
			if (initialisionTerrain(&jeu->pMapTerrain, "../assets/pictures/FondMap1.png", jeu->nomMap) < 0)
			{
				fprintf(logFile, "mainFenetre : FAILURE, initialisationTerrain.\n");
				cleanUp(&pInput, &pTextureDisplay);
				return -1;
			}

			/*Init global texture*/
			pTextureDisplay = my_createTextureFromSurface(jeu->pMapTerrain->globalMapSurface);
			if (pTextureDisplay == NULL)
			{
				fprintf(logFile, "mainFenetre : FAILURE, createGlobalTexture.\n");
				destroyMap(&jeu->pMapTerrain);
				cleanUp(&pInput, &pTextureDisplay);
				return -1;
			}

			/*Init sounds*/
			if (loadSounds(BipExplo, 0) < 0)
			{
				fprintf(logFile, "mainFenetre : FAILURE, loadSounds.\n");
				cleanUp(&pInput, &pTextureDisplay);
				return -1;
			}

			/*Init camera*/
			initCameras(jeu->pMapTerrain, &camera, NULL);

			/*Initialisation du tableau global de worms*/
			wormsTab = initWormsTab(jeu->equipes);
			if (wormsTab == NULL)
			{
				destroyMap(&jeu->pMapTerrain);
				cleanUp(&pInput, &pTextureDisplay);
				fprintf(logFile, "mainFenetre : FAILURE, allocating memory to the global array of worms pointer.\n\n");
				return -1;
			}

			/*Init Display*/
			initDisplay(jeu->pMapTerrain, pTextureDisplay);

			/*Initialisation des worms*/
			while (!KaamInitGame(wormsTab, jeu->pMapTerrain->collisionMapSurface))
				renderScreen(2, 0, jeu->pMapTerrain, 1, pTextureDisplay, &camera, NULL);
		}
		while (!(pInput->quit))
		{
			//Récupération des inputs
			getInput(pInput);

			//Gestion des inputs
			if (!gestInput(pInput, jeu->pMapTerrain, pTextureDisplay, &camera, wormsTab))
			{
				fprintf(logFile, "mainFenetre : FAILURE, gestInput.\n");
			}

			//Update de l'écran
			if (pInput->raffraichissement)
			{
				renderScreen(2, 0, jeu->pMapTerrain, 1, pTextureDisplay, &camera, NULL);
				pInput->raffraichissement = 0;
			}

			updateTeamLife(jeu->equipes);
			isGameEnd(jeu->equipes);

			//Gestion du frame Rate
			frameRate(frame_max);
			frame_max = SDL_GetTicks() + FRAME_RATE;
			if ((SDL_GetTicks() - temps) >= 1000)
			{
				temps = SDL_GetTicks();
				jeu->temps -= 1;
			}
		}


		endDisplay();
		cleanSounds();
		Mix_CloseAudio();
		fprintf(logFile, "||| END OF THE GAME |||\n");
		if (jeu != NULL)
			destroyMap(&jeu->pMapTerrain);
		destroyPolice();
		if (wormsTab != NULL)
			free(wormsTab);
		wormsTab = NULL;
	}
	cleanUp(&pInput, &pTextureDisplay);
	fprintf(logFile, "mainFenetre : SUCCESS.\n");
	if (jeu != NULL)
	{
		saveGame(jeu);
		destroyJeu(&jeu);
	}
	{
		time_t t1 = time(NULL);
		fprintf(logFile, "\n\nEnd of Session : %s", ctime(&t1));
		fclose(logFile);
	};
	return 0;
}