int TestLauncher::testFps2() { timeval start; timeval end; Wallpaper::loadWallpapers(); Wallpaper::getWallpaper(800, 600); Image *img[1]; img[0] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png"); mainGraphics->drawImage(img[0], 0, 0); const int cnt = 500; gettimeofday(&start, nullptr); for (int k = 0; k < cnt; k ++) { for (int f = 0; f < 300; f ++) mainGraphics->testDraw(); mainGraphics->updateScreen(); } gettimeofday(&end, nullptr); const int tFps = calcFps(start, end, cnt); file << mTest << std::endl; file << tFps << std::endl; printf("fps: %d\n", tFps / 10); sleep(1); return 0; }
/* Update the rendered image and handle events * Return: true if everything went fine, false if user requested to quit. */ bool stepGraphics() { SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { printf("\nRequested Quit.\n\n"); return false; } else if (event.type == SDL_KEYDOWN) { switch (event.key.keysym.sym) { case SDLK_ESCAPE: printf("\nRequested Quit.\n\n"); return false; break; case SDLK_LEFT: angle--; break; case SDLK_RIGHT: angle++; break; case SDLK_UP: config.timeStep *= 1.2; printf("Time step: %f\n", config.timeStep); break; case SDLK_DOWN: config.timeStep /= 1.2; printf("Time step: %f\n", config.timeStep); break; case SDLK_SPACE: config.thermostatTemp *= 1.2; printf("Temperature: %f\n", config.thermostatTemp); break; case SDLK_BACKSPACE: config.thermostatTemp /= 1.2; printf("Temperature: %f\n", config.thermostatTemp); break; case SDLK_RETURN: SDL_WM_ToggleFullScreen(surface); break; default: break; } } } render(); calcFps(); return true; }
int TestLauncher::testInternal() { timeval start; timeval end; Wallpaper::loadWallpapers(); Wallpaper::getWallpaper(800, 600); Image *img[4]; img[0] = Theme::getImageFromTheme( "graphics/sprites/manaplus_emotions.png"); img[1] = Theme::getImageFromTheme( "graphics/sprites/manaplus_emotions.png"); img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png"); img[3] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png"); int idx = 0; const int mem = mainGraphics->getMemoryUsage(); // int cnt = 5; const int cnt = 5000; gettimeofday(&start, nullptr); for (int k = 0; k < cnt; k ++) { for (int x = 0; x < 800; x += 20) { for (int y = 0; y < 600; y += 25) { mainGraphics->drawImage(img[idx], x, y); mainGraphics->drawImage(img[idx], x + 1, y); mainGraphics->drawImage(img[idx], x, y + 5); idx ++; if (idx > 3) idx = 0; } } mainGraphics->updateScreen(); } gettimeofday(&end, nullptr); const int tFps = calcFps(start, end, cnt); file << mTest << std::endl; file << tFps << std::endl; file << mem << std::endl; sleep(1); return 0; }
int TestLauncher::testFps() { timeval start; timeval end; Wallpaper::loadWallpapers(); Wallpaper::getWallpaper(800, 600); Image *img[5]; const int sz = 4; img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png"); img[1] = Theme::getImageFromTheme( "graphics/gui/target-cursor-normal-l.png"); img[2] = Theme::getImageFromTheme("themes/wood/window.png"); img[3] = Theme::getImageFromTheme("themes/pink/window.png"); img[4] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png"); int idx = 0; const int cnt = 50; gettimeofday(&start, nullptr); for (int k = 0; k < cnt; k ++) { for (int x = 0; x < 800; x += 30) { for (int y = 0; y < 600; y += 50) { mainGraphics->drawImage(img[idx], x, y); idx ++; if (idx > sz) idx = 0; mainGraphics->drawImage(img[idx], x, y); idx ++; if (idx > sz) idx = 0; } } mainGraphics->updateScreen(); } gettimeofday(&end, nullptr); const int tFps = calcFps(start, end, cnt); file << mTest << std::endl; file << tFps << std::endl; printf("fps: %d\n", tFps / 10); sleep(1); return 0; }
int TestLauncher::testFps3() { timeval start; timeval end; Wallpaper::loadWallpapers(); Wallpaper::getWallpaper(800, 600); Image *img[2]; img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png"); img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png"); ImageVertexes *const vert1 = new ImageVertexes; vert1->image = img[0]; ImageVertexes *const vert2 = new ImageVertexes; vert2->image = img[1]; for (int f = 0; f < 50; f ++) { for (int d = 0; d < 50; d ++) { mainGraphics->calcTileVertexes(vert1, img[0], f * 16, d * 12); mainGraphics->calcTileVertexes(vert1, img[1], f * 16 + 5, d * 12); } } mainGraphics->finalize(vert1); mainGraphics->finalize(vert2); const int cnt = 2000; gettimeofday(&start, nullptr); for (int k = 0; k < cnt; k ++) { mainGraphics->drawTileVertexes(vert1); mainGraphics->drawTileVertexes(vert2); mainGraphics->updateScreen(); } gettimeofday(&end, nullptr); const int tFps = calcFps(start, end, cnt); file << mTest << std::endl; file << tFps << std::endl; printf("fps: %d\n", tFps / 10); sleep(1); return 0; }
/********************************************* Main render method **********************************************/ void App::renderMain(){ calcFps(); utilBeginRender(); camLook(); if(isConnected()){ mFlowMgr->render(); calculateMousePoint(); } mParticleSystem->render(); if(isConnected()) mFlowMgr->renderSelection(); utilEndRender(); }
ffmpegWidget::ffmpegWidget (QWidget* parent) : QWidget (parent) { // xv stuff this->xv_port = -1; this->xv_format = -1; this->xv_image = NULL; this->dpy = NULL; this->maxW = 0; this->maxH = 0; this->setMinimumSize(64,48); /* Now setup QImage or xv whichever we have */ this->ff_fmt = PIX_FMT_RGB24; if (fallback == 0) this->xvSetup(); /* setup some defaults, we'll overwrite them with sensible numbers later */ /* Private variables, read/write */ _x = 0; // x offset in image pixels _y = 0; // y offset in image pixels _zoom = 30; // zoom level _gx = 0; // grid x in image pixels _gy = 0; // grid y in image pixels _gs = 0; // grid spacing in image pixels _grid = false; // grid on or off _gcol = Qt::white; // grid colour _fcol = 0; // false colour _url = QString(""); // ffmpeg url this->disableUpdates = false; /* Private variables: read only */ _maxX = 0; // Max x offset in image pixels _maxY = 0; // Max y offset in image pixels _maxGx = 0; // Max grid x offset in image pixels _maxGy = 0; // Max grid y offset in image pixels _imW = 0; // Image width in image pixels _imH = 0; // Image height in image pixels _visW = 0; // Image width currently visible in image pixels _visH = 0; // Image height currently visible in image pixels _scImW = 0; // Image width in viewport scaled pixels _scImH = 0; // Image height in viewport scaled pixels _scVisW = 0; // Image width visible in viewport scaled pixels _scVisH = 0; // Image height visible in viewport scaled pixels _fps = 0.0; // Frames per second displayed // other this->sfx = 1.0; this->sfy = 1.0; this->rawbuf = NULL; this->fullbuf = NULL; this->lastFrameTime = new QTime(); this->ff = NULL; this->widgetW = 0; this->widgetH = 0; this->ctx = NULL; // fps calculation this->tickindex = 0; this->ticksum = 0; for (int i=0; i<MAXTICKS; i++) { this->ticklist[i] = 0; } this->timer = new QTimer(this); connect(this->timer, SIGNAL(timeout()), this, SLOT(calcFps())); this->timer->start(100); }
/* Renders the frame and calls calcFps() */ static void render(RenderConf *rc) { double ws = world.worldSize; RenderMat3 m3; double m4[16]; calcFps(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* 3D */ renderSet3D(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); mat3_from_quat(m3, quat_conjugate(cam_orientation)); mat4_from_mat3(m4, m3); glMultMatrixd(m4); glTranslatef(-cam_position.x, -cam_position.y, -cam_position.z); if (autorotate) camOrbit(5, 0); if (renderSPGridBoxes) renderBoxes(rc->numBoxes); if (renderWorldLoops) { /* Line loops for world box */ glColor3f(0.0, 1.0, 0.0); glBegin(GL_LINE_LOOP); glVertex3f(-ws/2, -ws/2, -ws/2); glVertex3f(-ws/2, -ws/2, +ws/2); glVertex3f(-ws/2, +ws/2, +ws/2); glVertex3f(-ws/2, +ws/2, -ws/2); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(+ws/2, -ws/2, -ws/2); glVertex3f(+ws/2, -ws/2, +ws/2); glVertex3f(+ws/2, +ws/2, +ws/2); glVertex3f(+ws/2, +ws/2, -ws/2); glEnd(); } /* Strands */ for (int s = 0; s < world.numStrands; s++) renderStrand(&world.strands[s], rc); /* Text */ renderSet2D(); const int n = 64; char string[n]; snprintf(string, n, "T = %lf K", getKineticTemperature()); renderString(string, 10, 40); snprintf(string, n, "t = %lf µs (dt = %lf fs)", getTime() / MICROSECONDS, getIntegratorTimeStep() / FEMTOSECONDS); renderString(string, 10, 25); int ips; double tps; getProgressPerSecond(&ips, &tps); snprintf(string, n, "ips = %d (time/min = %lf ns)", ips, tps / NANOSECONDS * 60); renderString(string, 10, 10); glLoadIdentity(); renderString(fps_string, 10, SCREEN_H - 10); StringList *node = strings; while (node != NULL) { renderString(node->rsc.string, node->rsc.x, node->rsc.y); node = node->next; } SDL_GL_SwapBuffers(); }
//---------- // 表示関数 //---------- void display( void ) { glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); glDisable( GL_CULL_FACE ); glDisable( GL_ALPHA_TEST ); glDisable( GL_BLEND ); g_clARTK.display(); glEnable( GL_CULL_FACE ); glEnable( GL_ALPHA_TEST ); glEnable( GL_BLEND ); if( g_clARTK.isMarkerFound() ) { double dMat[16]; glMatrixMode( GL_PROJECTION ); g_clARTK.getProjectionMat( dMat ); glLoadMatrixd( dMat ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glPushMatrix(); g_clARTK.getModelViewMat( dMat ); glLoadMatrixd( dMat ); glScalef( 1.0f, 1.0f, -1.0f ); // 左手系 → 右手系 g_clPMDModel.render(); // ステンシルバッファに影の形を描画 glDisable( GL_CULL_FACE ); glDisable( GL_TEXTURE_2D ); glDisable( GL_LIGHTING ); glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, ~0 ); glStencilOp( GL_REPLACE, GL_KEEP, GL_REPLACE ); glColorMask( 0, 0, 0, 0 ); glDepthMask( 0 ); glMultMatrixf( (const float *)g_matPlanarProjection ); g_clPMDModel.renderForShadow(); // 影用の描画 glColorMask( 1, 1, 1, 1 ); // ステンシルバッファの影の形を塗りつぶす float fWndW = glutGet( GLUT_WINDOW_WIDTH ), fWndH = glutGet( GLUT_WINDOW_HEIGHT ); glStencilFunc( GL_EQUAL, 1, ~0); glStencilOp( GL_KEEP, GL_KEEP ,GL_KEEP ); glDisable( GL_DEPTH_TEST ); glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); gluOrtho2D( 0.0f, fWndW, 0.0f, fWndH ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); glColor4f( 0.2f, 0.2f, 0.2f, 0.5f ); glBegin( GL_TRIANGLE_FAN ); glVertex2f( 0.0f, fWndH ); glVertex2f( fWndW, fWndH ); glVertex2f( fWndW, 0.0f ); glVertex2f( 0.0f, 0.0f ); glEnd(); glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); glPopMatrix(); glDepthMask( 1 ); glEnable( GL_LIGHTING ); glEnable( GL_DEPTH_TEST ); glDisable( GL_STENCIL_TEST ); glPopMatrix(); } calcFps(); glutSwapBuffers(); }