static void drawScene(void) { int width = image_width; int height = image_height; setupScreen(width, height); int numOfVertices = 6; g_resources.attributes.position = glGetAttribLocation(program, "position"); glEnableVertexAttribArray(g_resources.attributes.position); glBindBuffer(GL_ARRAY_BUFFER, g_resources.vertex_buffer); glVertexAttribPointer( g_resources.attributes.position, /* attribute */ 3, /* size */ GL_FLOAT, /* type */ GL_FALSE, /* normalized? */ 0,//sizeof(GLfloat)*3, /* stride */ (void*)0 /* array buffer offset */ ); glDrawArrays(GL_TRIANGLES, 0, numOfVertices); glutSwapBuffers(); }
int main(int argc, char** argv){ setupVideoWriting(); int width = image_width; int height = image_height; setupBoard(width, height, argc, argv); setupScreen(width, height); initShaders(); loadTexture(); setupTexture(); setupBuffers(); glutDisplayFunc(&drawScene); glutIdleFunc(&replay); glutMainLoop(); cvReleaseVideoWriter(&writer); return 0; }
// This was a test for Win32, didn't work... void rebuild_video_context(int w, int h) { printf("rebuilding context in %d x %d\n", w, h); if (SDL_WasInit(SDL_INIT_VIDEO)) SDL_QuitSubSystem(SDL_INIT_VIDEO); if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { crrc_exit(CRRC_EXIT_FAILURE, SDL_GetError()); } printf("Setting up new surface...\n"); setupScreen(w, h, cfgfile->getInt("video.fullscreen.fUse", 0)); delete scenery; // delete SkySphere; printf("Setting up new Sky...\n"); SkySphere = new CSkySphere(8000.0, cfgfile->getInt("video.textures.fUse_textures", 1)); printf("Setting up new scenery...\n"); scenery = new BuiltinScenery(cfg->location()); if (read_airplane_file(cfgfile->getString("airplane.file", "models/allegro.xml").c_str())) { // Failed to load airplane file. // Using some fallback. cfgfile->setAttributeOverwrite("airplane.file", FileSysTools::getDataPath("models/allegro.xml")); if (read_airplane_file(cfgfile->getString("airplane.file").c_str())) { // The fallback failed, too. Abort. fprintf(stderr, "Unable to load airplane file %s\n", cfgfile->getString("airplane.file").c_str())); crrc_exit(CRRC_EXIT_FAILURE, "Unable to load airplane file"); }
void WindowSizeFunc(GLFWwindow * win, int width, int height) { if (width<640) width = 640; if (height<360) height = 360; windowwidth = width; windowheight = height > 0 ? height : 1; glfwSetWindowSize(win, width, height); setupScreen(); }
ArduRCT_TouScruinoV1::ArduRCT_TouScruinoV1(ArduRCT_RealTimeClock *rtc, ArduRCT_Switch *up, ArduRCT_Switch *down, ArduRCT_Switch *left, ArduRCT_Switch *right, ArduRCT_Switch *center) { setupScreen(TOUSCRUINO_V1_CD_PIN, TOUSCRUINO_V1_CS_PIN, TOUSCRUINO_V1_RESET_PIN); setupBacklight(TOUSCRUINO_V1_BACKLIGHT_PIN); registerSwitch(up); registerSwitch(down); registerSwitch(right); registerSwitch(left); registerSwitch(center); registerRTC(rtc); }
void Client::handleHello(const Event&, void*) { SInt16 major, minor; if (!ProtocolUtil::readf(m_stream, kMsgHello, &major, &minor)) { sendConnectionFailedEvent("Protocol error from server, check encryption settings"); cleanupTimer(); cleanupConnection(); return; } // check versions LOG((CLOG_DEBUG1 "got hello version %d.%d", major, minor)); if (major < kProtocolMajorVersion || (major == kProtocolMajorVersion && minor < kProtocolMinorVersion)) { sendConnectionFailedEvent(XIncompatibleClient(major, minor).what()); cleanupTimer(); cleanupConnection(); return; } // say hello back LOG((CLOG_DEBUG1 "say hello version %d.%d", kProtocolMajorVersion, kProtocolMinorVersion)); ProtocolUtil::writef(m_stream, kMsgHelloBack, kProtocolMajorVersion, kProtocolMinorVersion, &m_name); // now connected but waiting to complete handshake setupScreen(); cleanupTimer(); // make sure we process any remaining messages later. we won't // receive another event for already pending messages so we fake // one. if (m_stream->isReady()) { m_events->addEvent(Event(m_events->forIStream().inputReady(), m_stream->getEventTarget())); } }
// ResidualVM specific method void OSystem_Android::launcherInitSize(uint w, uint h) { setupScreen(w, h, true, true, false); }
void triangleApp::draw(){ setupScreen(); IT->renderTexture(0, 0, VI.getWidth(dev), VI.getHeight(dev)); IT2->renderTexture(VI.getWidth(dev), 0, VI.getWidth(dev+1), VI.getHeight(dev+1)); }
void SurfaceSdlGraphicsManager::launcherInitSize(uint w, uint h) { closeOverlay(); setupScreen(w, h, false, false); }
void setupScriptApi(QScriptEngine *engine) { setupAddressCluster(engine); setupAlarms(engine); setupCLineEdit(engine); setupCRMAcctLineEdit(engine); setupComments(engine); setupContactWidget(engine); setupCurrDisplay(engine); setupDocuments(engine); setupGLCluster(engine); setupInclude(engine); setupItemLineEdit(engine); setupMetaSQLHighlighterProto(engine); setupOrderLineEdit(engine); setupOrReportProto(engine); setupParameterEditProto(engine); setupParameterGroup(engine); setupParameterList(engine); setupPeriodListViewItem(engine); setupPoLineEdit(engine); setupProjectLineEdit(engine); setupQActionProto(engine); setupQBoxLayoutProto(engine); setupQByteArrayProto(engine); setupQDialog(engine); setupQDomAttrProto(engine); setupQDomCDATASectionProto(engine); setupQDomCharacterDataProto(engine); setupQDomCommentProto(engine); setupQDomDocumentFragmentProto(engine); setupQDomDocumentProto(engine); setupQDomDocumentTypeProto(engine); setupQDomElementProto(engine); setupQDomEntityProto(engine); setupQDomEntityReferenceProto(engine); setupQDomImplementationProto(engine); setupQDomNamedNodeMapProto(engine); setupQDomNodeListProto(engine); setupQDomNodeProto(engine); setupQDomNotationProto(engine); setupQDomProcessingInstructionProto(engine); setupQDomTextProto(engine); setupQDoubleValidatorProto(engine); setupQEventProto(engine); setupQFontProto(engine); setupQGridLayoutProto(engine); setupQIconProto(engine); setupQItemDelegateProto(engine); setupQLayoutItemProto(engine); setupQLayoutProto(engine); setupQMenuProto(engine); setupQMessageBox(engine); setupQNetworkAccessManagerProto(engine); setupQNetworkReplyProto(engine); setupQNetworkRequestProto(engine); setupQPrinterProto(engine); setupQSizePolicy(engine); setupQSpacerItem(engine); setupQSqlDatabaseProto(engine); setupQSqlErrorProto(engine); setupQSqlRecordProto(engine); setupQStackedWidgetProto(engine); setupQTabWidgetProto(engine); setupQTextDocumentProto(engine); setupQTextEditProto(engine); setupQTimerProto(engine); setupQToolBarProto(engine); setupQTreeWidgetItemProto(engine); setupQt(engine); setupQUrlProto(engine); setupQValidatorProto(engine); setupQWidgetProto(engine); setupRaLineEdit(engine); setupRevisionLineEdit(engine); setupScreen(engine); setupShipmentClusterLineEdit(engine); setupSoLineEdit(engine); setupToLineEdit(engine); setupUsernameCluster(engine); setupUsernameLineEdit(engine); setupVendorGroup(engine); setupWComboBox(engine); setupWoCluster(engine); setupWomatlCluster(engine); setupXCheckBox(engine); setupXComboBox(engine); setupXDataWidgetMapperProto(engine); setupXDateEdit(engine); setupXSqlTableModelProto(engine); setupXSqlQueryProto(engine); setupXTreeWidget(engine); setupXTreeWidgetItem(engine); }
int main(int argc, char * argv[]) { int ch, opt; int errflag; char *optargTrainingSet=NULL, optargSep=','; std::vector<char> trainingSet; while ((opt = getopt(argc, argv, ":hc:s:")) != -1) { switch (opt) { case 'h': errflag++; break; case 'c': optargTrainingSet = optarg; break; case 's': sscanf(optarg, "%c", &optargSep); break; case ':': std::cerr << "option -" << optopt << "requires an operand" << std::endl; errflag++; break; case '?': std::cerr << "unrecognized option:-" << optopt << std::endl; errflag++; break; } } if (errflag || (optargTrainingSet == NULL)) { printCLHelp(argv[0]); return EXIT_FAILURE; } if (splitStringToChar(optargTrainingSet, trainingSet, optargSep) != 0) { return EXIT_FAILURE; } // Initialize app initTT(); //char a[] = {'a', 's', 'd', 'f', ' '}; charsRefer = generateString(trainingSet.data(), (int)trainingSet.size(), buffersize); charsTyped.resize(buffersize); charsTyped.clear(); setupScreen(); updateReferLine(charsRefer); updateActionLine(charsTyped, charsRefer); updateInfoLine(); updateCursorPosition(charsTyped); ch = getch(); while (ch != ASCII_CTRL_C) { if (!isPrintableKey(ch) && !isSpecialKey(ch)) { ch = getch(); continue; } switch (ch) { case ASCII_BACKSPACE: case ASCII_DELETE: std::cout << (char) ASCII_CTRL_G; // sound the bell refresh(); break; case ASCII_CTRL_R: resetStatistics(); case ASCII_NEWLINE: case ASCII_CRETURN: if (isEOL(charsTyped) || (ch == ASCII_CTRL_R)) { charsRefer = generateString(trainingSet.data(), (int)trainingSet.size(), buffersize); updateReferLine(charsRefer); clearActionLine(); clearBuffer(charsTyped); } break; default: if (addChar(charsTyped, ch)) { updateActionLine(charsTyped, charsRefer); } updateInfoLine(); updateCursorPosition(charsTyped); } ch = getch(); } refresh(); endwin(); /* std::cout << "buffersize= " << buffersize << std::endl; std::cout << "reference = " << charsRefer.size() << std::endl; std::cout << "capacity = " << charsTyped.capacity() << std::endl; std::cout << "typed_in = " << charsTyped.size() << std::endl; */ printf("Goodbye!\n"); return 0; }
void setupScriptApi(QScriptEngine *engine) { setupAddressCluster(engine); setupAlarms(engine); setupCLineEdit(engine); setupCRMAcctLineEdit(engine); setupComments(engine); setupContactCluster(engine); setupCurrDisplay(engine); setupDocuments(engine); setupGLCluster(engine); setupItemLineEdit(engine); setupMetaSQLHighlighterProto(engine); setupOrderLineEdit(engine); setupParameterGroup(engine); setupPoLineEdit(engine); setupProjectLineEdit(engine); setupQActionProto(engine); setupQDomAttrProto(engine); setupQDomCDATASectionProto(engine); setupQDomCharacterDataProto(engine); setupQDomCommentProto(engine); setupQDomDocumentFragmentProto(engine); setupQDomDocumentProto(engine); setupQDomDocumentTypeProto(engine); setupQDomElementProto(engine); setupQDomEntityProto(engine); setupQDomEntityReferenceProto(engine); setupQDomImplementationProto(engine); setupQDomNamedNodeMapProto(engine); setupQDomNodeListProto(engine); setupQDomNodeProto(engine); setupQDomNotationProto(engine); setupQDomProcessingInstructionProto(engine); setupQDomTextProto(engine); setupQMenuProto(engine); setupQMessageBox(engine); setupQNetworkAccessManagerProto(engine); setupQNetworkReplyProto(engine); setupQNetworkRequestProto(engine); setupQSqlDatabaseProto(engine); setupQSqlRecordProto(engine); setupQStackedWidgetProto(engine); setupQTabWidgetProto(engine); setupQTextDocumentProto(engine); setupQTextEditProto(engine); setupQTreeWidgetItemProto(engine); setupQUrlProto(engine); setupRaLineEdit(engine); setupRevisionLineEdit(engine); setupScreen(engine); setupShipmentClusterLineEdit(engine); setupSoLineEdit(engine); setupToLineEdit(engine); setupUsernameLineEdit(engine); setupVendorGroup(engine); setupWComboBox(engine); setupWoLineEdit(engine); setupWomatlCluster(engine); setupXComboBox(engine); setupXDataWidgetMapperProto(engine); setupXDateEdit(engine); setupXSqlTableModelProto(engine); setupXTreeWidgetItemProto(engine); }
static portTASK_FUNCTION( vLcdTask, pvParameters ) { unsigned int pressure; unsigned int xPos; unsigned int yPos; //portTickType xLastWakeTime; int step_width = 320/sequence_steps; int step_height = 240/numNotes; int left, bottom = 0; int right = step_width; int top = step_height; int i, n, x; int waiting = 0; int newlySelectedSequence = 0; int prevMode = 0; int prevSeq = 0; /* Just to stop compiler warnings. */ ( void ) pvParameters; /* Initialise LCD display */ /* NOTE: We needed to delay calling lcd_init() until here because it uses * xTaskDelay to implement a delay and, as a result, can only be called from * a task */ lcd_init(); lcd_fillScreen(LIGHT_GRAY); /* Initial LCD display */ setupScreen(step_width,left, bottom,right,top); /* Infinite loop blocks waiting for a touch screen interrupt event from * the queue. */ while(1) { /* Clear TS interrupts (EINT3) */ /* Reset and (re-)enable TS interrupts on EINT3 */ EXTINT = 8; /* Reset EINT3 */ /* Enable TS interrupt vector (VIC) (vector 17) */ VICIntEnable = 1 << 17; /* Enable interrupts on vector 17 */ /* Block on a queue waiting for an event from the TS interrupt handler */ xSemaphoreTake(xLcdSemphr, portMAX_DELAY); /* Disable TS interrupt vector (VIC) (vector 17) */ VICIntEnClr = 1 << 17; /* Measure next sleep interval from this point */ //xLastWakeTime = xTaskGetTickCount(); // When switching sequences in edit mode. if(mode == 2){ setupScreen(step_width,0, 0,step_width,step_height); mode = 0; } // Switching from playback mode to edit mode, screen must be setup. if((prevMode == 1) && (mode == 0)){ setupScreen(step_width,0, 0,step_width,step_height); } // Switching from edit mode to playback mode. else if((prevMode == 0) && (mode == 1)) { setupPlaybackMode(); } prevMode = mode; /*** EDIT MODE ***/ /*****************/ if(mode != 1) { /* Start polling the touchscreen pressure and position ( getTouch(...) ) */ /* Keep polling until pressure == 0 */ getTouch(&xPos, &yPos, &pressure); while (pressure > 0) { // Button debounce on screen touch. waiting = 0; while(waiting<100000) { waiting++; } // Iterating through each row. for(i=0; i<numNotes; i++) { if((xPos < top) && (xPos > bottom)) { // If touch within bounds of row i, check for the corresponding column. for(n=0; n<sequence_steps; n++) { if((yPos < right) && (yPos > left)){ // Render column cells to clear previously selected cell and set up newly selected or change previously selected note time. for(x=0; x<numNotes;x++){ lcd_fillRect((x*step_height), (n*step_width), (x*step_height)+step_height, ((n*step_width)+step_width), LIGHT_GRAY); lcd_drawRect((x*step_height), (n*step_width), (x*step_height)+step_height, ((n*step_width)+step_width), DARK_GRAY); if(x != i){ // Majority of cells will have no note. timing[x][n] = 0; } } if(timing[i][n]==0 || timing[i][n]==1){ timing[i][n]++; } else { timing[i][n] = timing[i][n] + 2; } if (timing[i][n] > 4){ timing[i][n] = 0; } final_timing[n] = timing[i][n]; if(timing[i][n] == 1){ // Full note. lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, MAROON); } else if(timing[i][n] == 2){ // Half note. lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, OLIVE); } else if(timing[i][n] == 4){ // Quarter note. lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, PURPLE); } sequence[n] = i; } left = left + step_width; right = right + step_width; } } left = 0; right = step_width; top = top + step_height; bottom = bottom + step_height; } step_width = 320/sequence_steps; bottom = 0; left = 0; right = step_width; top = step_height; getTouch(&xPos, &yPos, &pressure); } } /*** PLAYBACK MODE ***/ /*********************/ else { /* Start polling the touchscreen pressure and position ( getTouch(...) ) */ /* Keep polling until pressure == 0 */ getTouch(&xPos, &yPos, &pressure); while (pressure > 0) { // Bound touch area for more efficiency. if((xPos < 235) && (xPos > 185)){ // Select current sequence. for(i=0; i<9; i++) { if(((xPos < 235) && (xPos > 185)) && ((yPos < (35*i) + 35) && (yPos > (35*i) + 5))){ // If a new sequence selected, must save the one that's currently in use to the listOfSequences[][] and listOfTimingSequences[][] // and then reinitialise the current sequence[] to the relative one in listOfSequences[][] and listOfTimingSequences[][]. newlySelectedSequence = i; if(newlySelectedSequence != currentlySelectedSequence) { lcd_fillRect(185, (35*currentlySelectedSequence) + 5, 235, (35*currentlySelectedSequence) + 35, LIGHT_GRAY); lcd_fillRect(185, (35*newlySelectedSequence) + 5, 235, (35*newlySelectedSequence) + 35, MAGENTA); for(n=0;n<sequence_steps;n++){ listOfSequences[currentlySelectedSequence][n] = sequence[n]; listOfTimingSequences[currentlySelectedSequence][n] = final_timing[n]; } currentlySelectedSequence = newlySelectedSequence; for(n=0;n<sequence_steps;n++){ sequence[n] = listOfSequences[currentlySelectedSequence][n]; final_timing[n] = listOfTimingSequences[currentlySelectedSequence][n]; } } } } } getTouch(&xPos, &yPos, &pressure); } // Prevent flicker. if(prevSeq != currentlySelectedSequence){ // Only fill part of screen to reduce flicker. lcd_fillRect(0, 0, 175, 320, LIGHT_GRAY); // Setup note bars for current sequence[] and final_timing[]. for(i=0; i<sequence_steps; i++) { if(sequence[i] != numNotes) { if(final_timing[i]==1){ lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, MAROON); } else if(final_timing[i]==2){ lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, OLIVE); } else if(final_timing[i]==4){ lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, PURPLE); } } } // Setup BPM visual display. updateBPMVisuals(); // Setup octave visual display. updateOctaveVisuals(); } prevSeq = currentlySelectedSequence; } } }