Changeset 2930
- Timestamp:
- Apr 2, 2012, 9:14:15 AM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r2929 r2930 191 191 } 192 192 193 /* 194 * ----------------------------------------------------------------------- 193 /** 194 * Creates a heightmap from the given the data. The format of the data 195 * should be as follows: 195 196 * 196 * CreateHeightMap --197 * xMin, xMax, xNum, yMin, yMax, yNum, heights... 197 198 * 198 * Creates a heightmap from the given the data. The format of the data 199 * should be as follows: 200 * 201 * xMin, xMax, xNum, yMin, yMax, yNum, heights... 202 * 203 * xNum and yNum must be integer values, all others are real numbers. 204 * The number of heights must be xNum * yNum; 205 * 206 * ----------------------------------------------------------------------- 199 * xNum and yNum must be integer values, all others are real numbers. 200 * The number of heights must be xNum * yNum; 207 201 */ 208 202 static HeightMap * … … 266 260 } 267 261 268 /*269 * ----------------------------------------------------------------------270 *271 * GetHeightMapFromObj --272 *273 * ----------------------------------------------------------------------274 */275 262 static int 276 263 GetHeightMapFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr) … … 293 280 294 281 295 /* 296 * ---------------------------------------------------------------------- 297 * FUNCTION: GetVolumeFromObj 298 * 282 /** 299 283 * Used internally to decode a series of volume index values and 300 284 * store then in the specified vector. If there are no volume index … … 304 288 * Updates pushes index values into the vector. Returns TCL_OK or 305 289 * TCL_ERROR to indicate an error. 306 * ----------------------------------------------------------------------307 290 */ 308 291 static int … … 325 308 } 326 309 327 /* 328 * ---------------------------------------------------------------------- 329 * FUNCTION: GetVolumes() 330 * 310 /** 331 311 * Used internally to decode a series of volume index values and 332 312 * store then in the specified vector. If there are no volume index … … 336 316 * Updates pushes index values into the vector. Returns TCL_OK or 337 317 * TCL_ERROR to indicate an error. 338 * ----------------------------------------------------------------------339 318 */ 340 319 static int … … 366 345 } 367 346 368 /* 369 * ---------------------------------------------------------------------- 370 * FUNCTION: GetHeightMaps() 371 * 347 /** 372 348 * Used internally to decode a series of volume index values and 373 349 * store then in the specified vector. If there are no volume index … … 377 353 * Updates pushes index values into the vector. Returns TCL_OK or 378 354 * TCL_ERROR to indicate an error. 379 * ----------------------------------------------------------------------380 355 */ 381 356 static int … … 406 381 } 407 382 408 409 /* 410 * ---------------------------------------------------------------------- 411 * FUNCTION: GetAxis() 412 * 383 /** 413 384 * Used internally to decode an axis value from a string ("x", "y", 414 385 * or "z") to its index (0, 1, or 2). Returns TCL_OK if successful, 415 386 * along with a value in valPtr. Otherwise, it returns TCL_ERROR 416 387 * and an error message in the interpreter. 417 * ----------------------------------------------------------------------418 388 */ 419 389 static int … … 441 411 } 442 412 443 /* 444 * ---------------------------------------------------------------------- 445 * FUNCTION: GetAxisFromObj() 446 * 413 /** 447 414 * Used internally to decode an axis value from a string ("x", "y", 448 415 * or "z") to its index (0, 1, or 2). Returns TCL_OK if successful, 449 416 * along with a value in indexPtr. Otherwise, it returns TCL_ERROR 450 417 * and an error message in the interpreter. 451 * ----------------------------------------------------------------------452 418 */ 453 419 int … … 457 423 } 458 424 459 /* 460 * ---------------------------------------------------------------------- 461 * FUNCTION: GetAxisDirFromObj() 462 * 425 /** 463 426 * Used internally to decode an axis value from a string ("x", "y", 464 427 * or "z") to its index (0, 1, or 2). Returns TCL_OK if successful, 465 428 * along with a value in indexPtr. Otherwise, it returns TCL_ERROR 466 429 * and an error message in the interpreter. 467 * ----------------------------------------------------------------------468 430 */ 469 431 static int … … 486 448 } 487 449 488 /* 489 * ---------------------------------------------------------------------- 490 * FUNCTION: GetColor() 491 * 450 /** 492 451 * Used internally to decode a color value from a string ("R G B") 493 452 * as a list of three numbers 0-1. Returns TCL_OK if successful, 494 453 * along with RGB values in rgbPtr. Otherwise, it returns TCL_ERROR 495 454 * and an error message in the interpreter. 496 * ----------------------------------------------------------------------497 455 */ 498 456 static int … … 513 471 514 472 515 /* 516 * ----------------------------------------------------------------------- 517 * 518 * GetDataStream -- 519 * 520 * Read the requested number of bytes from standard input into the given 521 * buffer. The buffer is then decompressed and decoded. 522 * 523 * ----------------------------------------------------------------------- 473 /** 474 * Read the requested number of bytes from standard input into the given 475 * buffer. The buffer is then decompressed and decoded. 524 476 */ 525 477 int … … 576 528 } 577 529 578 579 530 static int 580 531 CameraAimOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 691 642 692 643 w = NanoVis::winWidth, h = NanoVis::winHeight; 644 693 645 NanoVis::resizeOffscreenBuffer(2048, 2048); 694 646 #ifdef notdef … … 696 648 NanoVis::cam->setScreenSize(30, 90, 2048 - 60, 2048 - 120); 697 649 #endif 698 NanoVis:: offscreenBufferCapture(); //enable offscreen render650 NanoVis::bindOffscreenBuffer(); //enable offscreen render 699 651 NanoVis::display(); 700 652 NanoVis::readScreen(); 701 #ifdef notdef 702 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 703 #endif 653 704 654 NanoVis::ppmWrite("nv>image -bytes %d -type print"); 705 655 NanoVis::resizeOffscreenBuffer(w, h); 656 706 657 return TCL_OK; 707 658 } … … 1015 966 } 1016 967 1017 1018 968 static int 1019 969 VolumeAnimationCaptureOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 1037 987 interpolator->update(fraction); 1038 988 1039 NanoVis::offscreenBufferCapture(); //enable offscreen render 989 int fboOrig; 990 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig); 991 992 NanoVis::bindOffscreenBuffer(); //enable offscreen render 1040 993 1041 994 NanoVis::display(); 1042 995 NanoVis::readScreen(); 1043 996 1044 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);997 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig); 1045 998 1046 999 NanoVis::bmpWriteToFile(frame_num, fileName); … … 1117 1070 return (*proc) (clientData, interp, objc, objv); 1118 1071 } 1119 1120 1072 1121 1073 static int … … 2169 2121 #if PLANE_CMD 2170 2122 static int 2171 Plane NewOp(ClientData clientData, Tcl_Interp *interp, int objc,2123 PlaneAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 2172 2124 Tcl_Obj *const *objv) 2173 2125 { … … 2181 2133 } 2182 2134 if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) { 2135 return TCL_ERROR; 2136 } 2137 if (index >= NanoVis::numPlanes) { 2138 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL); 2183 2139 return TCL_ERROR; 2184 2140 } … … 2198 2154 } 2199 2155 bzero(tmp, w*h*4); 2200 int status = read( 0, tmp, w*h*sizeof(float));2156 int status = read(fileno(NanoVis::stdin), tmp, w*h*sizeof(float)); 2201 2157 if (status <= 0) { 2202 exit(0); // Bail out on read error? Should log the 2203 // error and return a non-zero exit status. 2158 delete[] tmp; 2159 Tcl_AppendResult(interp, "Failed to read image data for plane", (char*)NULL); 2160 return TCL_ERROR; 2204 2161 } 2205 2162 NanoVis::plane[index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp); … … 2214 2171 TRACE("link the plane to the 2D renderer command\n"); 2215 2172 2216 int plane_index , tf_index;2173 int plane_index; 2217 2174 2218 2175 if (objc != 3) { 2219 2176 Tcl_AppendResult(interp, "wrong # args: should be \"", 2220 Tcl_GetString(objv[0]), " plane_index t f_index\"", (char*)NULL);2177 Tcl_GetString(objv[0]), " plane_index transfunc_name \"", (char*)NULL); 2221 2178 return TCL_ERROR; 2222 2179 } … … 2224 2181 return TCL_ERROR; 2225 2182 } 2226 if (Tcl_GetIntFromObj(interp, objv[2], &tf_index) != TCL_OK) { 2227 return TCL_ERROR; 2228 } 2229 //NanoVis::plane_renderer->add_plane(NanoVis::plane[plane_index], tf[tf_index]); 2183 if (plane_index >= NanoVis::numPlanes) { 2184 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL); 2185 return TCL_ERROR; 2186 } 2187 NanoVis::planeRenderer->addPlane(NanoVis::plane[plane_index], 2188 NanoVis::getTransfunc(Tcl_GetString(objv[2]))); 2230 2189 return TCL_OK; 2231 2190 } … … 2248 2207 return TCL_ERROR; 2249 2208 } 2250 int mode; 2251 if (Tcl_GetIntFromObj(interp, objv[2], &mode) != TCL_OK) { 2252 return TCL_ERROR; 2253 } 2254 if (mode == 0) { 2209 if (plane_index >= NanoVis::numPlanes) { 2210 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL); 2211 return TCL_ERROR; 2212 } else if (plane_index < 0) { 2255 2213 plane_index = -1; 2256 2214 } 2257 NanoVis::plane_renderer->set_active_plane(plane_index); 2215 2216 NanoVis::planeRenderer->setActivePlane(plane_index); 2258 2217 return TCL_OK; 2259 2218 } 2260 2219 2261 2220 static Rappture::CmdSpec planeOps[] = { 2262 {"enable", 1, PlaneEnableOp, 4, 4, "planeIdx mode",}, 2221 {"active", 1, PlaneEnableOp, 3, 3, "planeIdx",}, 2222 {"add", 1, PlaneAddOp, 5, 5, "planeIdx width height",}, 2263 2223 {"link", 1, PlaneLinkOp, 4, 4, "planeIdx transfuncIdx",}, 2264 {"new", 1, PlaneNewOp, 5, 5, "planeIdx width height",},2265 2224 }; 2266 2225 static int nPlaneOps = NumCmdSpecs(planeOps); -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r2922 r2930 190 190 { 191 191 TRACE("Rendering box %s\n", _name); 192 glColor4d(_sv.color.r, _sv.color.g, _sv.color.b, _sv.color.a); 193 194 glPushMatrix(); 192 193 glPushAttrib(GL_ENABLE_BIT); 195 194 196 195 glEnable(GL_DEPTH_TEST); 197 196 glDisable(GL_TEXTURE_2D); 198 glEnable(GL_BLEND); 199 197 glDisable(GL_BLEND); 198 //glEnable(GL_BLEND); 199 200 glMatrixMode(GL_MODELVIEW); 200 201 glPushMatrix(); 202 201 203 Vector3 origin = volPtr->location(); 202 204 glTranslatef(origin.x, origin.y, origin.z); … … 239 241 TRACE("rendering box %g,%g %g,%g %g,%g\n", x0, x1, y0, y1, z0, z1); 240 242 243 glColor4d(_sv.color.r, _sv.color.g, _sv.color.b, _sv.color.a); 241 244 glLineWidth(_sv.lineWidth); 242 245 glBegin(GL_LINE_LOOP); … … 276 279 277 280 glPopMatrix(); 281 glPopAttrib(); 282 278 283 assert(CheckGL(AT)); 279 glPopMatrix();280 assert(CheckGL(AT));281 282 glDisable(GL_DEPTH_TEST);283 glDisable(GL_BLEND);284 glEnable(GL_TEXTURE_2D);285 284 } 286 285 … … 633 632 float *destPtr = data; 634 633 const float *values = _dataPtr->values(); 635 for (size_t iz =0; iz < _dataPtr->zNum(); iz++) {636 for (size_t iy =0; iy < _dataPtr->yNum(); iy++) {637 for (size_t ix =0; ix < _dataPtr->xNum(); ix++) {634 for (size_t iz = 0; iz < _dataPtr->zNum(); iz++) { 635 for (size_t iy = 0; iy < _dataPtr->yNum(); iy++) { 636 for (size_t ix = 0; ix < _dataPtr->xNum(); ix++) { 638 637 double vx, vy, vz, vm; 639 638 vx = values[0]; … … 641 640 vz = values[2]; 642 641 vm = sqrt(vx*vx + vy*vy + vz*vz); 643 destPtr[0] = vm / NanoVis::magMax; 644 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5; 645 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5; 646 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5; 642 destPtr[0] = vm / NanoVis::magMax; 643 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5; 644 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5; 645 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5; 647 646 values += 3; 648 647 destPtr += 4; … … 1067 1066 licRenderer->setOffset(flowPtr->GetRelativePosition()); 1068 1067 NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition()); 1069 1070 1068 } 1071 1069 AdvectFlows(); … … 1947 1945 } 1948 1946 NanoVis::AdvectFlows(); 1949 NanoVis::offscreenBufferCapture(); 1947 1948 int fboOrig; 1949 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig); 1950 1951 NanoVis::bindOffscreenBuffer(); 1950 1952 NanoVis::display(); 1951 1953 NanoVis::readScreen(); 1952 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1954 1955 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig); 1956 1953 1957 movie.append(context, NanoVis::screenBuffer, pad); 1954 1958 } … … 1967 1971 1968 1972 char command[200]; 1969 sprintf(command,"nv>image - bytes %lu -type movie -token \"%s\"\n",1970 (unsigned long)data.size(), token);1973 sprintf(command,"nv>image -type movie -token \"%s\" -bytes %lu\n", 1974 token, (unsigned long)data.size()); 1971 1975 NanoVis::sendDataToClient(command, data.bytes(), data.size()); 1972 1976 } -
trunk/packages/vizservers/nanovis/PlaneRenderer.cpp
r2870 r2930 19 19 20 20 PlaneRenderer::PlaneRenderer(int width, int height) : 21 _active _plane(-1),22 _n _planes(0),23 _render _width(width),24 _render _height(height),21 _activePlane(-1), 22 _numPlanes(0), 23 _renderWidth(width), 24 _renderHeight(height), 25 25 _shader(new NvColorTableShader()) 26 26 { … … 35 35 36 36 int 37 PlaneRenderer::add _plane(Texture2D *p, TransferFunction *tfPtr)37 PlaneRenderer::addPlane(Texture2D *p, TransferFunction *tfPtr) 38 38 { 39 int ret = _n _planes;39 int ret = _numPlanes; 40 40 41 41 _plane.push_back(p); … … 43 43 44 44 if (ret == 0) 45 _active _plane = ret;45 _activePlane = ret; 46 46 47 _n _planes++;47 _numPlanes++; 48 48 return ret; 49 49 } 50 50 51 51 void 52 PlaneRenderer::remove _plane(int index)52 PlaneRenderer::removePlane(int index) 53 53 { 54 54 std::vector<Texture2D *>::iterator piter = _plane.begin()+index; … … 58 58 _tf.erase(tfiter); 59 59 60 _n _planes--;60 _numPlanes--; 61 61 } 62 62 … … 64 64 PlaneRenderer::render() 65 65 { 66 if (_n _planes == 0)66 if (_numPlanes == 0) 67 67 return; 68 69 glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT); 68 70 69 71 glEnable(GL_TEXTURE_2D); 70 72 glEnable(GL_BLEND); 71 73 72 glViewport(0, 0, _render _width, _render_height);74 glViewport(0, 0, _renderWidth, _renderHeight); 73 75 glMatrixMode(GL_PROJECTION); 76 glPushMatrix(); 74 77 glLoadIdentity(); 75 gluOrtho2D(0, _render _width, 0, _render_height);78 gluOrtho2D(0, _renderWidth, 0, _renderHeight); 76 79 glMatrixMode(GL_MODELVIEW); 80 glPushMatrix(); 77 81 glLoadIdentity(); 78 82 … … 80 84 81 85 //if no active plane 82 if (_active _plane == -1)86 if (_activePlane == -1) 83 87 return; 84 88 85 _shader->bind(_plane[_active _plane], _tf[_active_plane]);89 _shader->bind(_plane[_activePlane], _tf[_activePlane]); 86 90 glBegin(GL_QUADS); 87 91 glTexCoord2f(0, 0); glVertex2f(0, 0); 88 glTexCoord2f(1, 0); glVertex2f(_render _width, 0);89 glTexCoord2f(1, 1); glVertex2f(_render _width, _render_height);90 glTexCoord2f(0, 1); glVertex2f(0, _render _height);92 glTexCoord2f(1, 0); glVertex2f(_renderWidth, 0); 93 glTexCoord2f(1, 1); glVertex2f(_renderWidth, _renderHeight); 94 glTexCoord2f(0, 1); glVertex2f(0, _renderHeight); 91 95 glEnd(); 92 96 _shader->unbind(); 97 98 glMatrixMode(GL_PROJECTION); 99 glPopMatrix(); 100 101 glMatrixMode(GL_MODELVIEW); 102 glPopMatrix(); 103 104 glPopAttrib(); 93 105 } 94 106 95 107 void 96 PlaneRenderer::set _active_plane(int index)108 PlaneRenderer::setActivePlane(int index) 97 109 { 98 _active _plane = index;110 _activePlane = index; 99 111 } 100 112 101 113 void 102 PlaneRenderer::set _screen_size(int w, int h)114 PlaneRenderer::setScreenSize(int w, int h) 103 115 { 104 _render _width = w;105 _render _height = h;116 _renderWidth = w; 117 _renderHeight = h; 106 118 } -
trunk/packages/vizservers/nanovis/PlaneRenderer.h
r2870 r2930 38 38 ~PlaneRenderer(); 39 39 40 int add_plane(Texture2D *p, TransferFunction *tf); 40 /// Add a plane and its transfer function. 41 int addPlane(Texture2D *p, TransferFunction *tf); 41 42 42 // Add a plane and its transfer function. We require a transfer function 43 // when a plane is added. 44 void remove_plane(int index); 43 void removePlane(int index); 45 44 46 void set_active_plane(int index); //set the active plane to be rendered 45 /// Set the active plane to be rendered 46 void setActivePlane(int index); 47 47 48 void set_screen_size(int w, int h); //change the rendering size 48 /// Change the rendering size 49 void setScreenSize(int w, int h); 49 50 50 51 void render(); 51 52 52 53 private: 53 std::vector<Texture2D *> _plane; // Array of volumes54 std::vector<TransferFunction *> _tf; // Array of corresponding transfer functions55 int _active _plane; //The active plane, only one is rendered56 int _n _planes;54 std::vector<Texture2D *> _plane; ///< Array of images 55 std::vector<TransferFunction *> _tf; ///< Array of corresponding transfer functions 56 int _activePlane; ///< The active plane, only one is rendered 57 int _numPlanes; 57 58 58 int _render _width; //render size59 int _render _height;59 int _renderWidth; 60 int _renderHeight; 60 61 61 62 NvColorTableShader *_shader; -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2928 r2930 128 128 #if PLANE_CMD 129 129 // pointers to 2D planes, currently handle up 10 130 int NanoVis::numPlanes = 10; 130 131 Texture2D *NanoVis::plane[10]; 131 132 #endif … … 458 459 { 459 460 Tcl_HashEntry *hPtr; 460 hPtr = Tcl_FindHashEntry(& NanoVis::volumeTable, name);461 hPtr = Tcl_FindHashEntry(&volumeTable, name); 461 462 if (hPtr != NULL) { 462 463 Volume *volPtr; … … 466 467 } 467 468 int isNew; 468 hPtr = Tcl_CreateHashEntry(& NanoVis::volumeTable, name, &isNew);469 hPtr = Tcl_CreateHashEntry(&volumeTable, name, &isNew); 469 470 Volume* volPtr; 470 471 volPtr = new Volume(0.f, 0.f, 0.f, width, height, depth, 1., n_component, 471 data, vmin, vmax, nzero_min);472 data, vmin, vmax, nzero_min); 472 473 Tcl_SetHashValue(hPtr, volPtr); 473 volPtr->name(Tcl_GetHashKey(& NanoVis::volumeTable, hPtr));474 volPtr->name(Tcl_GetHashKey(&volumeTable, hPtr)); 474 475 return volPtr; 475 476 } 476 477 477 478 // Gets a colormap 1D texture by name. 478 TransferFunction *479 TransferFunction * 479 480 NanoVis::getTransfunc(const char *name) 480 481 { … … 485 486 return NULL; 486 487 } 487 return (TransferFunction *)Tcl_GetHashValue(hPtr);488 return (TransferFunction *)Tcl_GetHashValue(hPtr); 488 489 } 489 490 490 491 // Creates of updates a colormap 1D texture by name. 491 TransferFunction *492 TransferFunction * 492 493 NanoVis::defineTransferFunction(const char *name, size_t n, float *data) 493 494 { … … 521 522 int old_height = winHeight; 522 523 523 planeRenderer->set _screen_size(width, height);524 planeRenderer->setScreenSize(width, height); 524 525 resizeOffscreenBuffer(width, height); 525 526 … … 530 531 } 531 532 legendTexture = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 532 int index = planeRenderer->add _plane(legendTexture, tf);533 planeRenderer->set _active_plane(index);534 535 offscreenBufferCapture();533 int index = planeRenderer->addPlane(legendTexture, tf); 534 planeRenderer->setActivePlane(index); 535 536 bindOffscreenBuffer(); 536 537 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 537 538 planeRenderer->render(); … … 551 552 assert(nWritten == 1); 552 553 } 553 planeRenderer->remove _plane(index);554 planeRenderer->removePlane(index); 554 555 resizeOffscreenBuffer(old_width, old_height); 555 556 … … 564 565 { 565 566 TRACE("in initOffscreenBuffer\n"); 567 assert(_finalFbo == 0); 566 568 // Initialize a fbo for final display. 567 569 glGenFramebuffersEXT(1, &_finalFbo); … … 572 574 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 573 575 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 576 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 577 574 578 #if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT) 575 579 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0, … … 582 586 GL_RGB, GL_INT, NULL); 583 587 #endif 588 584 589 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); 585 590 glGenRenderbuffersEXT(1, &_finalDepthRb); … … 598 603 } 599 604 600 // Check framebuffer completeness at the end of initialization.601 //CHECK_FRAMEBUFFER_STATUS();602 603 //assert(glGetError()==0);604 605 TRACE("leaving initOffscreenBuffer\n"); 605 606 } … … 646 647 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 647 648 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 649 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 650 648 651 #if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT) 649 652 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0, … … 656 659 GL_RGB, GL_INT, NULL); 657 660 #endif 658 TRACE("before bindframebuffer\n"); 661 659 662 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); 660 TRACE("after bindframebuffer\n");661 663 glGenRenderbuffersEXT(1, &_finalDepthRb); 662 664 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb); … … 674 676 } 675 677 676 //CHECK_FRAMEBUFFER_STATUS();677 678 TRACE("change camera\n"); 678 679 //change the camera setting 679 680 cam->setScreenSize(0, 0, winWidth, winHeight); 680 planeRenderer->set _screen_size(winWidth, winHeight);681 planeRenderer->setScreenSize(winWidth, winHeight); 681 682 682 683 TRACE("leaving resizeOffscreenBuffer(%d, %d)\n", w, h); … … 726 727 void NanoVis::init(const char* path) 727 728 { 728 // print systeminformation729 // print OpenGL driver information 729 730 TRACE("-----------------------------------------------------------\n"); 730 TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),731 glGetString(GL_VERSION));732 TRACE(" Graphics hardware: %s\n", glGetString(GL_RENDERER));731 TRACE("OpenGL version: %s\n", glGetString(GL_VERSION)); 732 TRACE("OpenGL vendor: %s\n", glGetString(GL_VENDOR)); 733 TRACE("OpenGL renderer: %s\n", glGetString(GL_RENDERER)); 733 734 TRACE("-----------------------------------------------------------\n"); 734 735 … … 744 745 TRACE("Using GLEW %s\n", glewGetString(GLEW_VERSION)); 745 746 747 // OpenGL 2.1 includes VBOs, PBOs, MRT, NPOT textures, point parameters, point sprites, 748 // GLSL 1.2, and occlusion queries. 749 if (!GLEW_VERSION_2_1) { 750 ERROR("OpenGL version 2.1 or greater is required\n"); 751 doExit(1); 752 } 753 754 // Additional extensions not in 2.1 core 755 756 // Framebuffer objects were promoted in 3.0 746 757 if (!GLEW_EXT_framebuffer_object) { 747 ERROR("EXT_framebuffer_oject extension is required to run nanovis\n");758 ERROR("EXT_framebuffer_oject extension is required\n"); 748 759 doExit(1); 749 760 } 750 #ifdef HAVE_NPOT_TEXTURES 751 if (!GLEW_ARB_texture_non_power_of_two) { 752 ERROR("ARB_texture_non_power_of_two extension is required to run nanovis\n"); 761 // Rectangle textures were promoted in 3.1 762 // FIXME: can use NPOT in place of rectangle textures 763 if (!GLEW_ARB_texture_rectangle) { 764 ERROR("ARB_texture_rectangle extension is required\n"); 753 765 doExit(1); 754 766 } 755 #endif756 if (!GLEW_ARB_texture_rectangle) {757 ERROR("ARB_texture_rectangle extension is required to run nanovis\n");758 doExit(1);759 }760 767 #ifdef HAVE_FLOAT_TEXTURES 768 // Float color buffers and textures were promoted in 3.0 761 769 if (!GLEW_ARB_texture_float || 762 770 !GLEW_ARB_color_buffer_float) { 763 ERROR("ARB_texture_float and ARB_color_buffer_float extensions are required to run nanovis\n");771 ERROR("ARB_texture_float and ARB_color_buffer_float extensions are required\n"); 764 772 doExit(1); 765 773 } 766 774 #endif 775 // FIXME: should use ARB programs or (preferably) a GLSL profile for portability 767 776 if (!GLEW_NV_vertex_program3 || 768 777 !GLEW_NV_fragment_program2) { 769 ERROR("NV_vertex_program3 and NV_fragment_program2 extensions are required to run nanovis\n");778 ERROR("NV_vertex_program3 and NV_fragment_program2 extensions are required\n"); 770 779 doExit(1); 771 780 } … … 792 801 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH); 793 802 794 NanoVis::velocityArrowsSlice = new VelocityArrowsSlice;803 velocityArrowsSlice = new VelocityArrowsSlice; 795 804 796 805 licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, … … 805 814 } 806 815 807 /*----------------------------------------------------*/808 816 void 809 NanoVis::initGL( void)817 NanoVis::initGL() 810 818 { 811 819 TRACE("in initGL\n"); … … 827 835 glShadeModel(GL_FLAT); 828 836 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 829 830 glClearColor(0,0,0,1); 831 glClear(GL_COLOR_BUFFER_BIT); 837 glClearColor(0, 0, 0, 1); 838 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 832 839 833 840 //initialize lighting … … 865 872 #if PROTOTYPE 866 873 make_test_2D_data(); 867 planeRenderer->add _plane(plane[0], getTransfunc("default"));874 planeRenderer->addPlane(plane[0], getTransfunc("default")); 868 875 #endif 869 876 … … 1230 1237 { 1231 1238 TRACE("in display_offscreen_buffer\n"); 1239 1232 1240 glEnable(GL_TEXTURE_2D); 1233 1241 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); … … 1250 1258 } 1251 1259 glEnd(); 1260 1252 1261 TRACE("leaving display_offscreen_buffer\n"); 1253 1262 } … … 1337 1346 draw3dAxis() 1338 1347 { 1348 glPushAttrib(GL_ENABLE_BIT); 1349 1339 1350 glDisable(GL_TEXTURE_2D); 1340 1351 glEnable(GL_DEPTH_TEST); 1352 glEnable(GL_COLOR_MATERIAL); 1353 glDisable(GL_BLEND); 1341 1354 1342 1355 //draw axes … … 1344 1357 1345 1358 obj = gluNewQuadric(); 1346 1347 glDepthFunc(GL_LESS);1348 glEnable(GL_COLOR_MATERIAL);1349 glEnable(GL_DEPTH_TEST);1350 glDisable(GL_BLEND);1351 1359 1352 1360 int segments = 50; … … 1416 1424 glPopMatrix(); 1417 1425 1418 glDisable(GL_LIGHTING);1419 glDisable(GL_DEPTH_TEST);1420 1426 gluDeleteQuadric(obj); 1421 1427 1422 glEnable(GL_TEXTURE_2D); 1423 glDisable(GL_DEPTH_TEST); 1428 glPopAttrib(); 1424 1429 } 1425 1430 … … 1590 1595 setVolumeRanges(); 1591 1596 } 1597 1598 //start final rendering 1599 1600 // Need to reset fbo since it may have been changed to default (0) 1601 bindOffscreenBuffer(); 1602 1592 1603 TRACE("in display: glClear\n"); 1593 //start final rendering1594 1604 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 1595 1605 … … 1597 1607 TRACE("in display: volumeMode\n"); 1598 1608 //3D rendering mode 1599 // TBD..1600 //glEnable(GL_TEXTURE_2D);1601 1609 glEnable(GL_DEPTH_TEST); 1610 glEnable(GL_COLOR_MATERIAL); 1602 1611 1603 1612 //camera setting activated … … 1631 1640 } 1632 1641 1633 // TBD : This will be removed after being sure that all the functions work well.1634 //glPushMatrix();1635 1636 1642 //now render things in the scene 1637 1643 if (axisOn) { … … 1844 1850 Tcl_Eval(interp, cmd); 1845 1851 #ifdef notdef 1846 NanoVis::flowVisRenderer->active(true);1847 NanoVis::licRenderer->active(true);1852 flowVisRenderer->active(true); 1853 licRenderer->active(true); 1848 1854 #endif 1849 1855 } … … 1859 1865 Tcl_Eval(interp, cmd); 1860 1866 #ifdef notdef 1861 NanoVis::flowVisRenderer->active(false);1862 NanoVis::licRenderer->active(false);1867 flowVisRenderer->active(false); 1868 licRenderer->active(false); 1863 1869 #endif 1864 1870 } … … 1916 1922 Tcl_Eval(interp, cmd); 1917 1923 #ifdef notdef 1918 NanoVis::flowVisRenderer->deactivatePlane("vf_name1", "plane_name2");1924 flowVisRenderer->deactivatePlane("vf_name1", "plane_name2"); 1919 1925 #endif 1920 1926 } … … 1928 1934 Tcl_Eval(interp, cmd); 1929 1935 #ifdef notdef 1930 NanoVis::flowVisRenderer->removeVectorField("vf_name2");1936 flowVisRenderer->removeVectorField("vf_name2"); 1931 1937 #endif 1932 1938 } … … 1946 1952 shape.max.set(30, 3, 3); 1947 1953 shape.color.set(1, 0, 0, 1); 1948 NanoVis::flowVisRenderer->addDeviceShape("vf_name1", "device1", shape);1954 flowVisRenderer->addDeviceShape("vf_name1", "device1", shape); 1949 1955 shape.min.set(0, -1, -1); 1950 1956 shape.max.set(30, 4, 4); 1951 1957 shape.color.set(0, 1, 0, 1); 1952 NanoVis::flowVisRenderer->addDeviceShape("vf_name1", "device2", shape);1958 flowVisRenderer->addDeviceShape("vf_name1", "device2", shape); 1953 1959 shape.min.set(10, -1.5, -1); 1954 1960 shape.max.set(20, 4.5, 4.5); 1955 1961 shape.color.set(0, 0, 1, 1); 1956 NanoVis::flowVisRenderer->addDeviceShape("vf_name1", "device3", shape);1957 NanoVis::flowVisRenderer->activateDeviceShape("vf_name1");1962 flowVisRenderer->addDeviceShape("vf_name1", "device3", shape); 1963 flowVisRenderer->activateDeviceShape("vf_name1"); 1958 1964 #endif 1959 1965 } … … 1967 1973 Tcl_Eval(interp, cmd); 1968 1974 #ifdef notdef 1969 NanoVis::flowVisRenderer->deactivateDeviceShape("vf_name1");1975 flowVisRenderer->deactivateDeviceShape("vf_name1"); 1970 1976 #endif 1971 1977 } … … 1979 1985 Tcl_Eval(interp, cmd); 1980 1986 #ifdef notdef 1981 NanoVis::flowVisRenderer->activateDeviceShape("vf_name1");1987 flowVisRenderer->activateDeviceShape("vf_name1"); 1982 1988 #endif 1983 1989 } … … 1991 1997 Tcl_Eval(interp, cmd); 1992 1998 #ifdef notdef 1993 NanoVis::flowVisRenderer->activateDeviceShape("vf_name1", "device3");1999 flowVisRenderer->activateDeviceShape("vf_name1", "device3"); 1994 2000 #endif 1995 2001 } … … 2003 2009 Tcl_Eval(interp, cmd); 2004 2010 #ifdef notdef 2005 NanoVis::flowVisRenderer->deactivateDeviceShape("vf_name1", "device3");2011 flowVisRenderer->deactivateDeviceShape("vf_name1", "device3"); 2006 2012 #endif 2007 2013 } … … 2015 2021 Tcl_Eval(interp, cmd); 2016 2022 #ifdef notdef 2017 NanoVis::flowVisRenderer->reset();2018 NanoVis::licRenderer->reset();2023 flowVisRenderer->reset(); 2024 licRenderer->reset(); 2019 2025 #endif 2020 2026 } … … 2066 2072 } 2067 2073 2068 #endif /*XINETD*/2069 2070 2074 void 2071 2075 NanoVis::render() … … 2073 2077 2074 2078 #ifdef notdef 2075 if (( NanoVis::licRenderer != NULL) && (NanoVis::licRenderer->active())) {2076 NanoVis::licRenderer->convolve();2079 if ((licRenderer != NULL) && (licRenderer->active())) { 2080 licRenderer->convolve(); 2077 2081 } 2078 2082 #else 2079 if ( NanoVis::licRenderer != NULL) {2080 NanoVis::licRenderer->convolve();2083 if (licRenderer != NULL) { 2084 licRenderer->convolve(); 2081 2085 } 2082 2086 #endif 2083 2087 2084 2088 #ifdef notdef 2085 if (( NanoVis::flowVisRenderer != NULL) && (NanoVis::flowVisRenderer->active())) {2086 NanoVis::flowVisRenderer->advect();2087 } 2088 #endif 2089 NanoVis::update();2089 if ((flowVisRenderer != NULL) && (flowVisRenderer->active())) { 2090 flowVisRenderer->advect(); 2091 } 2092 #endif 2093 update(); 2090 2094 display(); 2091 2095 glutSwapBuffers(); … … 2098 2102 } 2099 2103 2104 #endif /*XINETD*/ 2105 2100 2106 void 2101 NanoVis::xinetdListen( void)2102 { 2103 NanoVis::flags &= ~REDRAW_PENDING;2107 NanoVis::xinetdListen() 2108 { 2109 flags &= ~REDRAW_PENDING; 2104 2110 2105 2111 TRACE("Enter xinetdListen\n"); … … 2184 2190 } 2185 2191 2186 NanoVis::update(); 2187 2188 NanoVis::offscreenBufferCapture(); //enable offscreen render 2189 2190 NanoVis::display(); 2191 2192 // INSOO 2192 update(); 2193 2194 bindOffscreenBuffer(); //enable offscreen render 2195 2196 display(); 2197 2193 2198 #ifdef XINETD 2194 NanoVis::readScreen(); 2195 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 2199 readScreen(); 2196 2200 #else 2197 NanoVis::displayOffscreenBuffer(); //display the final rendering on screen2198 NanoVis::readScreen();2201 displayOffscreenBuffer(); //display the final rendering on screen 2202 readScreen(); 2199 2203 glutSwapBuffers(); 2200 2204 #endif … … 2211 2215 write(1, rle, rle_size); //unsigned byte 2212 2216 #else 2213 NanoVis::ppmWrite("\nnv>image -type image -bytes");2217 ppmWrite("\nnv>image -type image -bytes"); 2214 2218 #endif 2215 2219 TRACE("Leaving xinetd_listen OK\n"); 2216 2220 } 2217 2221 2218 2219 /*----------------------------------------------------*/2220 2222 int 2221 2223 main(int argc, char **argv) … … 2388 2390 2389 2391 /* 2390 planeRenderer->set _screen_size(width, height);2392 planeRenderer->setScreenSize(width, height); 2391 2393 2392 2394 // generate data for the legend 2393 2395 float data[512]; 2394 2396 for (int i=0; i < 256; i++) { 2395 data[i] = data[i+256] = (float)(i/255.0);2397 data[i] = data[i+256] = (float)(i/255.0); 2396 2398 } 2397 2399 plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 2398 int index = planeRenderer->add _plane(plane[0], tf);2399 planeRenderer->set _active_plane(index);2400 2401 offscreenBufferCapture();2400 int index = planeRenderer->addPlane(plane[0], tf); 2401 planeRenderer->setActivePlane(index); 2402 2403 bindOffscreenBuffer(); 2402 2404 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2403 2405 … … 2419 2421 //ppmWrite(prefix); 2420 2422 //write(1, "\n", 1); 2421 //planeRenderer->remove _plane(index);2423 //planeRenderer->removePlane(index); 2422 2424 2423 2425 // CURRENT 2424 offscreenBufferCapture();2426 bindOffscreenBuffer(); 2425 2427 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2426 2428 //glEnable(GL_TEXTURE_2D); 2427 2429 //glEnable(GL_DEPTH_TEST); 2428 //heightmap->render _topview(renderContext, width, height);2430 //heightmap->renderTopview(renderContext, width, height); 2429 2431 //NanoVis::display(); 2430 2432 if (HeightMap::updatePending) { … … 2436 2438 heightmap->renderTopview(renderContext, width, height); 2437 2439 2438 NanoVis::readScreen(); 2439 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 2440 readScreen(); 2440 2441 2441 2442 // INSOO TEST CODE -
trunk/packages/vizservers/nanovis/nanovis.h
r2877 r2930 72 72 }; 73 73 74 static void xinetdListen(); 74 75 static void init(const char *path); 75 static void xinetdListen();76 76 static void initGL(); 77 77 static void initOffscreenBuffer(); 78 78 static void resizeOffscreenBuffer(int w, int h); 79 static void resize(int w, int h); 80 static void render(); 79 static void displayOffscreenBuffer(); 81 80 static void display(); 82 81 static void idle(); 83 82 static void update(); 84 static void displayOffscreenBuffer(); 83 85 84 static void pan(float dx, float dy); 86 85 static void zoom(float z); … … 120 119 static void updateRot(int delta_x, int delta_y); 121 120 static void updateTrans(int delta_x, int delta_y, int delta_z); 121 static void resize(int w, int h); 122 static void render(); 122 123 #endif 123 124 … … 127 128 screenBuffer); 128 129 } 129 static void offscreenBufferCapture()130 static void bindOffscreenBuffer() 130 131 { 131 132 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); … … 174 175 static PlaneRenderer *planeRenderer; 175 176 #if PLANE_CMD 177 static int numPlanes; 176 178 static Texture2D *plane[]; ///< Pointers to 2D planes 177 179 #endif
Note: See TracChangeset
for help on using the changeset viewer.