>> Я до сих пор не разобрался, как он это сделал...... это в тебе говорить токарь ...... то есть опять же на слабо в узко предметной области ...... это не плохо, но суть - догонять ...
... тогда спрошу как токарь токаря, сколько нужно инструкций процессора чтобы визуализировать одну точку? ...
#include <map>#include <string>#include <algorithm>#include <iostream>#include <fx.h>char buf[16];struct point { int x, y;};#define GRID_LEN 1 // размер зерна в холстеclass PaintWindow : public FXMainWindow {FXDECLARE(PaintWindow) typedef std::map<std::pair<int, int>, point> PointMap;private: FXCanvas *canvas; FXLabel *count_label; FXFont *big_font; int isMouseDown = 0; FXColor drawColor = FXRGB(255, 0, 0); FXColor bgColor = FXRGB(0, 0, 0); PointMap pixels; void setpixel(FXEvent *event);protected: PaintWindow() { }public: enum { ID_CANVAS = FXMainWindow::ID_LAST, }; long onPaint(FXObject *, FXSelector, void *); long onMouseDown(FXObject *, FXSelector, void *); long onMouseUp(FXObject *, FXSelector, void *); long onMouseMove(FXObject *, FXSelector, void *); PaintWindow(FXApp *a); virtual void create(); virtual ~PaintWindow();};FXDEFMAP(PaintWindow) PaintWindowMap[] = { // определяем обработчики событий FXMAPFUNC(SEL_PAINT, PaintWindow::ID_CANVAS, PaintWindow::onPaint), FXMAPFUNC(SEL_LEFTBUTTONPRESS, PaintWindow::ID_CANVAS, PaintWindow::onMouseDown), FXMAPFUNC(SEL_RIGHTBUTTONPRESS, PaintWindow::ID_CANVAS, PaintWindow::onMouseDown), FXMAPFUNC(SEL_LEFTBUTTONRELEASE, PaintWindow::ID_CANVAS, PaintWindow::onMouseUp), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, PaintWindow::ID_CANVAS, PaintWindow::onMouseUp), FXMAPFUNC(SEL_MOTION, PaintWindow::ID_CANVAS, PaintWindow::onMouseMove)};FXIMPLEMENT(PaintWindow, FXMainWindow, PaintWindowMap, ARRAYNUMBER(PaintWindowMap))PaintWindow::PaintWindow(FXApp *a) : FXMainWindow(a, a->getAppName(), NULL, NULL, DECOR_ALL, 0, 0, 800, 600) { FXMenuBar *menubar = new FXMenuBar(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X); menubar->setBackColor(FXRGB(208,203,201)); FXMenuPane *filemenu = new FXMenuPane(menubar); new FXMenuCommand(filemenu,"&New\tCtl-N",NULL,NULL); new FXMenuCommand(filemenu,"&Open\tCtl-O",NULL,NULL); new FXMenuCommand(filemenu,"&Save\tCtl-S",NULL,NULL); new FXMenuCommand(filemenu,"&Save as\t Shift-Ctl-S",NULL,NULL); new FXMenuSeparator(filemenu); new FXMenuCommand(filemenu,"&Quit\tCtl-Q\tQuit the application.",NULL,NULL); new FXMenuTitle(menubar,"&File",NULL,filemenu); FXMenuPane *scenemenu = new FXMenuPane(menubar); new FXMenuCommand(scenemenu,"&Build",NULL,NULL); new FXMenuCheck(scenemenu,"&Build on open",NULL); new FXMenuSeparator(scenemenu); new FXMenuCommand(scenemenu,"&Render",NULL,NULL); new FXMenuCommand(scenemenu,"&IPR",NULL,NULL); new FXMenuCheck(scenemenu,"&Auto Clear Log",NULL); new FXMenuSeparator(scenemenu); new FXMenuCommand(scenemenu,"&Clear Texture Cache",NULL,NULL); new FXMenuCheck(scenemenu,"&Low memory triangles",NULL); new FXMenuTitle(menubar,"&Scene",NULL,scenemenu); FXMenuPane *imagemenu = new FXMenuPane(menubar); new FXMenuCommand(imagemenu,"&Reset Zoom",NULL,NULL); new FXMenuCommand(imagemenu,"&Fit to Window",NULL,NULL); new FXMenuSeparator(imagemenu); new FXMenuCommand(imagemenu,"&Save image",NULL,NULL); new FXMenuTitle(menubar,"&Image",NULL,imagemenu); FXMenuPane *helpmenu = new FXMenuPane(menubar); new FXMenuCommand(helpmenu,"&About Sunflow",NULL,NULL); new FXMenuCommand(helpmenu,"&About FOX-1.7",NULL,NULL); new FXMenuTitle(menubar,"&Help",NULL,helpmenu); FXHorizontalFrame *container=new FXHorizontalFrame(this,LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED); container->setBackColor(FXRGB(226,223,222)); FXHorizontalFrame *chartwell=new FXHorizontalFrame(container,FRAME_SUNKEN|LAYOUT_FILL_X| LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT, 0,0,0,0,10,10,10,10); canvas = new FXCanvas(chartwell, this, ID_CANVAS, LAYOUT_FILL_X|LAYOUT_FILL_Y); //count_label = new FXLabel(chartwell, "...", NULL, LAYOUT_EXPLICIT, 34, 177, 133, 56);}PaintWindow::~PaintWindow() {}void PaintWindow::create() { FXMainWindow::create(); show(PLACEMENT_SCREEN); //показываем окно в центре экрана}void PaintWindow::setpixel(FXEvent *event) { int x = event->win_x; int y = event->win_y; x = (event->win_x + 2) / GRID_LEN; y = (event->win_y + 2) / GRID_LEN; std::pair<int, int> p = std::make_pair(x * GRID_LEN, y * GRID_LEN); // создаём хеш из двух координат FXDCWindow dc(canvas); bool add = event->click_button == 1; // если кнопка левая, то рисуем, правой - удаляем dc.setForeground(add ? drawColor : bgColor); if (add) { point pixel; pixel.x = x * GRID_LEN; pixel.y = y * GRID_LEN; pixels[p] = pixel; } else { pixels.erase(p); } dc.fillRectangle(x * GRID_LEN, y * GRID_LEN, GRID_LEN, GRID_LEN); // рисуем квадратики sprintf(buf, "%lu px", pixels.size()); //count_label->setText(buf); // обновляем надпись}long PaintWindow::onMouseUp(FXObject *, FXSelector, void *ptr) { // при отпускании мыши canvas->ungrab(); // отключаем перетаскивание в холсте if (isMouseDown) { FXDCWindow dc(canvas); dc.setForeground(drawColor); isMouseDown = 0; } return 1;}long PaintWindow::onMouseDown(FXObject *, FXSelector, void *ptr) { // при нажатии мыши canvas->grab(); // включаем перетаскивание в холсте setpixel((FXEvent *) ptr); isMouseDown = 1; return 1;}long PaintWindow::onMouseMove(FXObject *, FXSelector, void *ptr) { if (isMouseDown) { setpixel((FXEvent *) ptr); } return 1;}long PaintWindow::onPaint(FXObject *, FXSelector, void *ptr) { //если окно сворачивается или выходит за пределы видимости, то его нужно перерисовать FXEvent *ev = (FXEvent *) ptr; FXDCWindow dc(canvas, ev); dc.setForeground(bgColor); dc.fillRectangle(ev->rect.x, ev->rect.y, ev->rect.w, ev->rect.h); typedef PointMap::iterator it_type; for (it_type iterator = pixels.begin(); iterator != pixels.end(); iterator++) { // перебираем все пиксели наносим их на холст int x = iterator->second.x; int y = iterator->second.y; dc.setForeground(drawColor); dc.fillRectangle(x, y, GRID_LEN, GRID_LEN); } return 1;}using namespace std;void usage() { cout << endl; cout <<"Usage: sunflow [options] scenefile"<< endl; cout << endl; cout <<"Options:"<< endl; cout << endl; cout <<" -o filename Saves the output as the specified filename (png, hdr, tga)"<< endl; cout <<" -nogui Don't open the frame showing rendering progress"<< endl; cout <<" -ipr Render using progressive algorithm"<< endl; cout <<" -sampler type Render using the specified algorithm"<< endl; cout <<" -threads n Render using n threads"<< endl; cout <<" -lopri Set thread priority to low (default)"<< endl; cout <<" -hipri Set thread priority to high"<< endl; cout <<" -smallmesh Load triangle meshes using triangles optimized for memory use"<< endl; cout <<" -dumpkd Dump KDTree to an obj file for visualization"<< endl; cout <<" -buildonly Do not call render method after loading the scene"<< endl; cout <<" -showaa Display sampling levels per pixel for bucket renderer"<< endl; cout <<" -nogi Disable any global illumination engines in the scene"<< endl; cout <<" -nocaustics Disable any caustic engine in the scene"<< endl; cout <<" -pathgi n Use path tracing with n samples to render global illumination"<< endl; cout <<" -quick_ambocc d Applies ambient occlusion to the scene with specified maximum distance"<< endl; cout <<" -quick_uvs Applies a surface uv visualization shader to the scene"<< endl; cout <<" -quick_normals Applies a surface normal visualization shader to the scene"<< endl; cout <<" -quick_id Renders using a unique color for each instance"<< endl; cout <<" -quick_prims Renders using a unique color for each primitive"<< endl; cout <<" -quick_gray Renders using a plain gray diffuse shader"<< endl; cout <<" -quick_wire Renders using a wireframe shader"<< endl; cout <<" -resolution w h Changes the render resolution to the specified width and height (in pixels)"<< endl; cout <<" -aa min max Overrides the image anti-aliasing depths"<< endl; cout <<" -samples n Overrides the image sample count (affects bucket and multipass samplers)"<< endl; cout <<" -bucket n order Changes the default bucket size to n pixels and the default order"<< endl; cout <<" -bake name Bakes a lightmap for the specified instance"<< endl; cout <<" -bakedir dir Selects the type of lightmap baking: dir=view or ortho"<< endl; cout <<" -filter type Selects the image filter to use"<< endl; cout <<" -bench Run several built-in scenes for benchmark purposes"<< endl; cout <<" -rtbench Run realtime ray-tracing benchmark"<< endl; cout <<" -frame n Set frame number to the specified value"<< endl; cout <<" -anim n1 n2 Render all frames between the two specified values (inclusive)"<< endl; cout <<" -translate file Translate input scene to the specified filename"<< endl; cout <<" -v verbosity Set the verbosity level: 0=none,1=errors,2=warnings,3=info,4=detailed"<< endl; cout <<" -h Prints this message"<< endl;}char* getCmdOption(char ** begin, char ** end, const std::string & option){ char ** itr = std::find(begin, end, option); if (itr != end && ++itr != end) { return *itr; } return 0;}bool cmdOptionExists(char** begin, char** end, const std::string& option){ return std::find(begin, end, option) != end;}int main(int argc, char * argv[]){ if ( (argc <= 1) || (argv[argc-1] == NULL) ) { FXApp application("Sunflow", "Sunflow"); application.init(argc, argv); new PaintWindow(&application); application.create(); return application.run(); } if(cmdOptionExists(argv, argv+argc, "-t")) { cout << "flag = t" << endl; } if(cmdOptionExists(argv, argv+argc, "--help")) { usage(); } char * numthreads = getCmdOption(argv, argv + argc, "-t"); if (numthreads) { cout << "threads = " << numthreads << endl; } char * filename = getCmdOption(argv, argv + argc, "-f"); if (filename) { cout << "filename = " << filename << endl; } return 0;}
Чтобы ездить на автомобиле, вовсе нет необходимости знать устройство двигателя.
ЦитироватьЧтобы ездить на автомобиле, вовсе нет необходимости знать устройство двигателя.Чтобы ездить - да , знаний устройства не нужно... но не чтобы модернизировать старый или создать новый двигатель
Фиг его знает, Ланухумыч... мне в школе на УПК рассказывали про АЛУ, УУ, шину данных, шину адреса и т.п. кибернетику ... было не очень интересно, и думал нахрен это не нужно один хрен, посути архитектура компов осталась та же... теперь понимаю, что это была полезная фундаментальная инфа...
>> Чем идея отличается от знания её осуществления?... мы же и боремся за идею, или точнее за её спасение ...... и для этого есть ключ - постановка задачи, она же описание мечты, но более конкретная, формальная ...... вопрос про визуализацию точки был конкретный, то есть что нужно для этого и сколько ...
В числах это выглядит примерно так: в 50 раз и более быстрее рендера Cycles.