// EPX3 scaled down to 2X void RenderEPXC(unsigned char *src, unsigned int srcpitch, unsigned char *dst, unsigned int dstpitch, int nWidth, int nHeight, int vidDepth) { // E D H // A X C // F B G #define DrawPix(on00,on01,on10,on11) /* on00 on01 */ \ { /* on10 on11 */ \ if ((((on00||on10)?colorA:colorX) != ((on01||on11)?colorC:colorX)) \ && (((on10||on11)?colorB:colorX) != ((on00||on01)?colorD:colorX))) \ { \ const bool XnE = colorX != colorE; \ const bool XnF = colorX != colorF; \ const bool XnG = colorX != colorG; \ const bool XnH = colorX != colorH; \ const bool DA = on00 && colorD == colorA && (XnE || XnG || colorD != colorH || colorA != colorF); \ const bool AB = on10 && colorA == colorB && (XnF || XnH || colorA != colorE || colorB != colorG); \ const bool BC = on11 && colorB == colorC && (XnG || XnE || colorB != colorF || colorC != colorH); \ const bool CD = on01 && colorC == colorD && (XnH || XnF || colorC != colorG || colorD != colorE); \ if (!on00||!on01||!on10||!on11 || ((colorA != colorC) && (colorB != colorD) && \ ((colorX == colorA) || (colorX==colorB) || (colorX==colorC) || (colorX==colorD) || (colorX==colorE) || (colorX==colorF) || (colorX==colorG) || (colorX==colorH)))) \ { \ const uint16 colorAA = on00&&on10 && ((DA && XnF) || (AB && XnE)) ? colorA : colorX; \ const uint16 colorBB = on10&&on11 && ((AB && XnG) || (BC && XnF)) ? colorB : colorX; \ const uint16 colorCC = on01&&on11 && ((BC && XnH) || (CD && XnG)) ? colorC : colorX; \ const uint16 colorDD = on00&&on01 && ((CD && XnE) || (DA && XnH)) ? colorD : colorX; \ *dP1++ = _TWO_PIX(Interp44(on00 && DA ? colorA : colorX, colorDD, colorAA, colorX), Interp44(on01 && CD ? colorC : colorX, colorBB, colorCC, colorX)); \ *dP2++ = _TWO_PIX(Interp44(on10 && AB ? colorA : colorX, colorAA, colorBB, colorX), Interp44(on11 && BC ? colorC : colorX, colorCC, colorDD, colorX)); \ } else { \ *dP1++ = _TWO_PIX(Interp01(colorX, on00 && DA && (colorX!=colorB&&colorX!=colorC) ? colorA : colorX), Interp01(colorX, on01 && CD && (colorX!=colorA&&colorX!=colorB) ? colorC : colorX)); \ *dP2++ = _TWO_PIX(Interp01(colorX, on10 && AB && (colorX!=colorC&&colorX!=colorD) ? colorA : colorX), Interp01(colorX, on11 && BC && (colorX!=colorD&&colorX!=colorA) ? colorC : colorX)); \ } \ } else { \ *dP1++ = _TWO_PIX(colorX, colorX); \ *dP2++ = _TWO_PIX(colorX, colorX); \ } \ } if(vidDepth == 32) { #define _TWO_PIX TWO_PIX_32 DrawInit(2,uint64); DrawRows(2,1); // 2x scale, and diags is on since we do use all 8 surrounding pixels #undef _TWO_PIX } else { #define _TWO_PIX TWO_PIX DrawInit(2,uint32); DrawRows(2,1); // 2x scale, and diags is on since we do use all 8 surrounding pixels #undef _TWO_PIX } #undef DrawPix }
int main (int argc, char **argv) { if( Import3DS(myModel, argv[1]) == false ){ // printf("Error: import 3ds file failed"); // exit(0); inputModel = false; } glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(600, 600); glutInitWindowPosition(100, 70); glutCreateWindow("Model Viewer (Lighting & texture mapping) Bo CHEN"); DrawInit(); init(); cameraMove(); glutDisplayFunc(DisplayFunc); glutIdleFunc(IdleFunc); glutKeyboardFunc(keyboard); /* set keyboard handler */ glutSpecialFunc(ProcessArrowKey); glutMouseFunc(ProcessMouse); glutMotionFunc(ProcessMouseMotion); glutMainLoop(); return 0; }
MainScreen::MainScreen() : LcdScreen(), m_HasMail( false ) { m_Font = new Font7x5(); m_TimeFont = new Font7x5Time(); #define make_text_c(lbl,dt) m_Texts->insert( make_pair( lbl, dt ) ) #define make_text(lbl,x,y,w) make_text_c( lbl, new DrawableText( x, y, w, m_Font ) ) #define make_text_time(lbl,x,y,w) make_text_c( lbl, new DrawableText( x, y, w, m_TimeFont ) ) make_text( TXT_ARTIST, 0, 0, m_Surface->GetWidth() ); make_text_time( TXT_PL_DISP, m_Surface->GetWidth(), 0, -53 ); make_text( TXT_TITLE, 0, 8, m_Surface->GetWidth() ); make_text( TXT_ALBUM, 0, 16, m_Surface->GetWidth() ); make_text( TXT_STATUS, 0, 23, 80 ); make_text( TXT_EMAIL, m_Surface->GetWidth(), 23, -70 ); #define TIME_YPOS (m_Surface->GetHeight() - 1 - 5 - 7) make_text_time( TXT_TIME_POS, 0, TIME_YPOS, 25 ); make_text_time( TXT_CLOCK, (m_Surface->GetWidth() / 2) - (39 / 2), TIME_YPOS, 39 ); make_text_time( TXT_TIME_LENGTH, m_Surface->GetWidth(), TIME_YPOS, -25 ); #undef make_text #undef make_text_time #undef make_text_c DrawInit(); }
int main (int argc, char **argv) { // Glut Init glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(200, 0); glutInitWindowSize(640, 480); glutCreateWindow("Rotatable Koch snowflake. <Click mouse to form Tri>"); // Set Callbacks glutDisplayFunc(DisplayFunc); glutKeyboardFunc(KeyboardFunc); glutMouseFunc(MouseClickFunc); glutSpecialFunc(ProcessArrowKey); glutIdleFunc(IdleFunc); // Program Inits DrawInit(); CameraInit(); // Go! glutSwapBuffers(); glutMainLoop(); return 0; }
int SFInitDraw(lua_State* l) { int driver = lua_tonumber(Scripts.vm, 1); int filtering = lua_tonumber(Scripts.vm, 2); DrawInit(driver, filtering); return 0; }
int DrawMain(int argc, char *argv[]) { DrawInit(argc, argv); glutMainLoop(); return 0; }
SQInteger SFInitDraw(HSQUIRRELVM v) { int driver; int filtering; sq_getinteger(Scripts.vm, 2, &driver); sq_getinteger(Scripts.vm, 3, &filtering); DrawInit(driver, filtering); return 0; }
// code for improved 2X EPX, which tends to do better with diagonal edges than regular EPX void RenderEPXB(unsigned char *src, unsigned int srcpitch, unsigned char *dst, unsigned int dstpitch, int nWidth, int nHeight, int vidDepth) { // E D H // A X C // F B G #define DrawPix(on00,on01,on10,on11) /* on00 on01 */ \ { /* on10 on11 */ \ if ((((on00||on10)?colorA:colorX) != ((on01||on11)?colorC:colorX)) \ && (((on10||on11)?colorB:colorX) != ((on00||on01)?colorD:colorX)) \ && ((!on00||!on01||!on10|!on11) || \ ((colorX == colorA) || (colorX == colorB) || (colorX == colorC) || (colorX == colorD) || /* diagonal */ \ (((colorE != colorG) || (colorX == colorF) || (colorX == colorH)) && /* edge */ \ ((colorF != colorH) || (colorX == colorE) || (colorX == colorG)))))) /* smoothing */ \ { \ *dP1++ = _TWO_PIX((on00 && colorD == colorA && (colorX != colorE || colorX != colorG || colorD != colorH || colorA != colorF)) ? colorD : colorX, \ (on01 && colorC == colorD && (colorX != colorH || colorX != colorF || colorC != colorG || colorD != colorE)) ? colorC : colorX); \ *dP2++ = _TWO_PIX((on10 && colorA == colorB && (colorX != colorF || colorX != colorH || colorA != colorE || colorB != colorG)) ? colorA : colorX, \ (on11 && colorB == colorC && (colorX != colorG || colorX != colorE || colorB != colorF || colorC != colorH)) ? colorB : colorX); \ } else { \ *dP1++ = _TWO_PIX(colorX, colorX); \ *dP2++ = _TWO_PIX(colorX, colorX); \ } \ } // again, this supports 32-bit or 16-bit rendering if(vidDepth == 32) { #define _TWO_PIX TWO_PIX_32 DrawInit(2,uint64); DrawRows(2,1); // 2x scale, and diags is on since we do use all 8 surrounding pixels #undef _TWO_PIX } else { #define _TWO_PIX TWO_PIX DrawInit(2,uint32); DrawRows(2,1); // 2x scale, and diags is on since we do use all 8 surrounding pixels #undef _TWO_PIX } #undef DrawPix }
/* * MAIN TASK */ int main(void) { //GPIO_InitTypeDef GPIO_InitStructure; SystemInit(); /*Initializes Erika related stuffs*/ EE_system_init(); SWatch_state.errorStatus = errorSig; SWatch_state.ModelData.prevZCSigState = &ZCSig; SWatch_state.ModelData.dwork = &DWork; /* init state machine */ SWatch_initialize(&SWatch_state, &Bplus, &Bminus, &Btime, &Btimer, &Balarm, &Bswatch, &Bstart, &Bstop, &hours, &minutes, &seconds, &tenths, &mode, &alarm_signal, &timer_exp); /*Initialize systick */ EE_systick_set_period(MILLISECONDS_TO_TICKS(1, SystemCoreClock)); EE_systick_enable_int(); EE_systick_start(); /* Initializes LCD and touchscreen */ IOE_Config(); /* Initialize the LCD */ STM32f4_Discovery_LCD_Init(); // LCD_Clear(White); /* Set the LCD Text size */ // LCD_SetFont(&Font8x12); // Lcd_Touch_Calibration(); InitTouch(-0.102, 0.0656, -335, 10); /* Draw the background */ DrawInit(MyWatchScr); LCD_SetTextColor(Black); LCD_SetBackColor(Black); LCD_DrawFullRect(10, 80, 240, 56); WPrint(&MyWatchScr[SEP1STR], ":"); WPrint(&MyWatchScr[SEP2STR], ":"); /* Program cyclic alarms which will fire after an initial offset, * and after that periodically * */ SetRelAlarm(AlarmTaskLCD, 10, 50); SetRelAlarm(AlarmTaskClock, 10, 100); /* Forever loop: background activities (if any) should go here */ for (;;) { } }
int main(int argc, char *argv[]) { if (CALL_FAILED(DrawInit())) return -1; else { Surface surface; GraphicsSetTitle(APP_TITLE); shInit(); if (!(argc == 2 && shOpenFile(argv[1]))) shOpenFileDialog(&surface, DefaultFont); while (shProcess() > 0); shDestroy(); DrawDestroy(); } return 0; }
/* ./show_file [-s Size] [-f freetype_font_file] [-h HZK] <text_file> */ int main(int argc, char **argv) { int iError; unsigned int dwFontSize = 16; char acHzkFile[128]; char acFreetypeFile[128]; char acTextFile[128]; char acDisplay[128]; char cOpr; int bList = 0; acHzkFile[0] = '\0'; acFreetypeFile[0] = '\0'; acTextFile[0] = '\0'; strcpy(acDisplay, "fb"); while ((iError = getopt(argc, argv, "ls:f:h:d:")) != -1) { /* СЎПо : ./show_file -l */ switch(iError) { case 'l': { bList = 1; break; } case 's': { dwFontSize = strtoul(optarg, NULL, 0); break; } case 'f': { strncpy(acFreetypeFile, optarg, 128); acFreetypeFile[127] = '\0'; break; } case 'h': { strncpy(acHzkFile, optarg, 128); acHzkFile[127] = '\0'; break; } case 'd': { strncpy(acDisplay, optarg, 128); acDisplay[127] = '\0'; break; } default: { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; break; } } } if (!bList && (optind >= argc)) { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; } iError = DrawInit(); if (iError) { printf("DrawInit error!\n"); return -1; } if (bList) { printf("supported display:\n"); ShowDispOpr(); printf("supported font:\n"); ShowFontOpr(); printf("supported encoding:\n"); ShowEncodingOpr(); return 0; } strncpy(acTextFile, argv[optind], 128); acTextFile[127] = '\0'; iError = OpenTextFile(acTextFile); if (iError) { printf("OpenTextFile error!\n"); return -1; } iError = SetFontsDetail(acHzkFile, acFreetypeFile, dwFontSize); if (iError) { printf("SetFontsDetail error!\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = SelectAndInitDisplay(acDisplay); if (iError) { printf("SelectAndInitDisplay error!\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = ShowNextPage(); DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); if (iError) { printf("Error to show first page\n"); return -1; } while (1) { printf("Enter 'n' to show next page, 'u' to show previous page, 'q' to exit: "); do { cOpr = getchar(); } while ((cOpr != 'n') && (cOpr != 'u') && (cOpr != 'q')); if (cOpr == 'n') { ShowNextPage(); } else if (cOpr == 'u') { ShowPrePage(); } else { ExitDisplay(); return 0; } } return 0; }
int main(int argc, char *argv[]) { int nproc; // mpi groupsize // init MPI_Init(&argc, &argv); #ifdef MPE MPE_Log_get_state_eventIDs(&compute_begin, &compute_end); MPE_Describe_state(compute_begin, compute_end, "Compute", "red"); #endif GetArgs(argc, argv); // deleted TP 10/12/12 // #ifdef USE_BIL // BIL_Init(MPI_COMM_WORLD); // #endif MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nproc); Init(); // run MPI_Barrier(MPI_COMM_WORLD); TotTime = MPI_Wtime(); Run(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); TotTime = MPI_Wtime() - TotTime; // print the performance stats //parflow->PrintPerf(TotTime, TotInTime, TotOutTime, // TotCompCommTime, TotParticles, size); //#ifdef GRAPHICS #if 0 if (rank == 0) { VECTOR3 min, max; min = VECTOR3(0.0f, 0.0f, 0.0f); max = VECTOR3((float)(size[0] - 1), (float)(size[1] - 1), (float)(size[2] - 1)); DrawInit(pt, npt, tot_ntrace, argc, argv, min, max, 0); } #endif // Gather traces { // synchronize prior to gathering MPI_Barrier(MPI_COMM_WORLD); int *ntrace = NULL; // number of traces for each proc int n; // total number of my points // gather number of points in each trace at the root => ntrace int all_gather = 0; // 0: only root collects the data n = parflow->GatherNumPts(ntrace, all_gather, nblocks); // gather the actual points in each trace at the root parflow->GatherPts(ntrace, n, nblocks); MPI_Barrier(MPI_COMM_WORLD); if (ntrace) delete[] ntrace; } #if 1 if (rank==0) { PathlineLoader trace("field_lines.out"); trace.connectTraces(); trace.dump(); } #else // The direct printout does not have fixed order if (rank==0) { printf("Traces=%d\n", tot_ntrace); int i,j, c=0; for (i=0; i<tot_ntrace; i++) { for (j=0; j<npt[i]; j++) { VECTOR4 &v = pt[c++]; printf("%f %f %f %f, ", v[0], v[1], v[2], v[3]); } printf("\n"); } } #endif //printf("cleaning up\n"); Cleanup(); MPI_Barrier(MPI_COMM_WORLD); // edited TP 10/12/12 // #ifdef USE_BIL // BIL_Finalize(); // #endif //printf("DIY_Finalize\n"); DIY_Finalize(); // end TP MPI_Finalize(); }
/* Initialise Video, PAD, DVD, Font */ void Initialise (void) { VIDEO_Init (); PAD_Init (); DVD_Init(); *(volatile unsigned long*)0xcc00643c = 0x00000000; //allow 32mhz exi bus // Disable IPL modchips to allow access to IPL ROM fonts ipl_set_config(6); usleep(1000); //wait for modchip to disable (overkill) __SYS_ReadROM(IPLInfo,256,0); // Read IPL tag // By default, let libOGC figure out the video mode GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); //Last mode used if(is_gamecube()) { // Gamecube, determine based on IPL int retPAD = 0, retCnt = 10000; while(retPAD <= 0 && retCnt >= 0) { retPAD = PAD_ScanPads(); usleep(100); retCnt--; } // L Trigger held down ignores the fact that there's a component cable plugged in. if(VIDEO_HaveComponentCable() && !(PAD_ButtonsDown(0) & PAD_TRIGGER_L)) { if(strstr(IPLInfo,"MPAL")!=NULL) { swissSettings.sramVideo = 2; vmode = &TVMpal480Prog; //Progressive 480p } else if((strstr(IPLInfo,"PAL")!=NULL)) { swissSettings.sramVideo = 1; vmode = &TVPal576ProgScale; //Progressive 576p } else { swissSettings.sramVideo = 0; vmode = &TVNtsc480Prog; //Progressive 480p } } else { //try to use the IPL region if(strstr(IPLInfo,"MPAL")!=NULL) { swissSettings.sramVideo = 2; vmode = &TVMpal480IntDf; //PAL-M } else if(strstr(IPLInfo,"PAL")!=NULL) { swissSettings.sramVideo = 1; vmode = &TVPal576IntDfScale; //PAL } else { swissSettings.sramVideo = 0; vmode = &TVNtsc480IntDf; //NTSC } } } setVideoMode(vmode); init_font(); DrawInit(); drive_version(&driveVersion[0]); swissSettings.hasDVDDrive = *(u32*)&driveVersion[0] ? 1 : 0; if(!driveVersion[0]) { // Reset DVD if there was a IPL replacement that hasn't done that for us yet uiDrawObj_t *progBox = DrawPublish(DrawProgressBar(true, 0, "Initialise DVD .. (HOLD B if NO DVD Drive)")); dvd_reset(); // low-level, basic dvd_read_id(); if(!(PAD_ButtonsHeld(0) & PAD_BUTTON_B)) { dvd_set_streaming(*(char*)0x80000008); } drive_version(&driveVersion[0]); swissSettings.hasDVDDrive = *(u32*)&driveVersion[0] ? 2 : 0; if(!swissSettings.hasDVDDrive) { DrawDispose(progBox); progBox = DrawPublish(DrawMessageBox(D_INFO, "No DVD Drive Detected !!")); sleep(2); } DrawDispose(progBox); } }