int main() { const int ballsCount = 20; const int rectsCount = 2; const int SLEEP_TIME = 1; /* initialize system objects */ Ball ballsArr[ballsCount]; srand(time(NULL)); Rect rects[rectsCount]; rects[0].X = 10; rects[0].Y = 5; rects[0].Width = 25; rects[0].Height = 10; rects[1].X = 50; rects[1].Y = 5; rects[1].Width = 15; rects[1].Height = 5; initAll(ballsCount, ballsArr, rectsCount, rects); /* infinite loop engine */ while(1) { clearScreen(); drawRects(2, rects); updateBalls(ballsCount, ballsArr, rectsCount, rects); drawBalls(ballsCount, ballsArr); tSleep(SLEEP_TIME); } return EXIT_SUCCESS; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawBalls(); glutSwapBuffers(); }
void Blobs02 :: drawBox2d () { ofSetColor( 255, 255, 255 ); ofFill(); // fill drawBlobs(); ofEnableSmoothing(); // lines smoothed. ofNoFill(); drawBlobs(); ofDisableSmoothing(); for( int i=0; i<blobs.size(); i++ ) { if( bDrawNodes ) { for( int j=0; j<blobs[ i ].nodes.size(); j++) { blobs[ i ].nodes[ j ].draw(); } } if( bDrawJoints ) { for( int j=0; j<blobs[ i ].nodeJoints.size(); j++) { blobs[ i ].nodeJoints[ j ].draw(); } } } ofSetColor( 30, 30, 30 ); ofFill(); // ball fill drawBalls(); ofEnableSmoothing(); // ball lines smoothed. ofNoFill(); drawBalls(); ofDisableSmoothing(); }
int simulateTo(Ball **ball, double now) { if(ball == NULL) return -1; while(sim_time <= now) { sim_time += time_inc; advanceBalls(ball, sim_time); drawBalls(ball); drawGraph(ball); usleep(time_inc * 1000000); } return 0; }
void VideoFrame::paintEvent(QPaintEvent *pe) { // Draw image QLabel::paintEvent(pe); // Draw text QPainter painter(this); drawFrame(); drawHough(&painter); drawBalls(&painter); drawCalibration(&painter); }
int main(void) { const int ballsCount = 20; const int SLEEP_TIME = 1; /* initialize system objects */ Ball ballsArr[ballsCount]; srand(time(NULL)); initBalls(ballsCount, ballsArr); /* infinite loop engine */ while(1) { clearScreen(); updateBalls(ballsCount, ballsArr); drawBalls(ballsCount, ballsArr); tSleep(SLEEP_TIME); } return EXIT_SUCCESS; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) // HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow { config = _CONFIG(1024, 768, {0.0f,1.2f,10.f}, {}, 60.f, 0.01f, 40.f); _WINDOW wnd = _WINDOW(hInstance, "Main Window"); if (wnd.isInitialized()) { //load file Model teapot(getFilenameFromCurrentDirectory("teapot.obj"), {0,3,1}, {}, {.5f, .5f, .5f}); Model ball(getFilenameFromCurrentDirectory("sphere.obj"), {}, {}, {.8f,.8f,.8f}); float rotOfTeapot[3] = {0.0f, 0.0f, 0.0f}; while (true) { while (PeekMessage(&wnd.msg, nullptr, 0, 0, PM_REMOVE) > 0) { TranslateMessage(&wnd.msg); DispatchMessage(&wnd.msg); } //Background DrawWindowElements::ClearZBuffer(); DrawWindowElements::FillRectangle(MyColor::LIGHTBLUE); //DrawWindowElements::DrawGrid(32, MyColor::BLACK); //Setting visual and camera DrawCommon::SetProjection(); DrawCommon::SetViewMatrix(); //Drawing models drawTeapot(teapot, rotOfTeapot); drawBalls(ball); DrawMyWindow(wnd.hwndMain); Controller::OverlayHUD(wnd.hwndMain); Sleep(20); if (wnd.msg.message == WM_QUIT) return EXIT_SUCCESS; } } return EXIT_FAILURE; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(0.3f, 0.3f, 0.15f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f); //glRotatef(3.14, 0.0f, 1.0f, 0.0f); glTranslatef(0,0,2.5); drawCoordi(); drawBalls(); //glLoadIdentity(); glFlush(); //glutSwapBuffers(); glutPostRedisplay(); Sleep(150); angle += 0.5; }