//----------------------------------------------------------------------------- void* HardwarePixelBuffer::lock(size_t offset, size_t length, LockOptions options) { assert(!isLocked() && "Cannot lock this buffer, it is already locked!"); assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer"); Image::Box myBox(0, 0, 0, mWidth, mHeight, mDepth); const PixelBox &rv = lock(myBox, options); return rv.data; }
GL_Window::GL_Window(int x, int y, int w, int h, const char *label): Fl_Gl_Window(x, y, w, h, label) { _gw = new osgViewer::GraphicsWindowEmbedded(x,y,w,h); root = new osg::Group; geode = new osg::Geode; osg::ref_ptr<osg::Capsule> myCapsule (new osg::Capsule(osg::Vec3f(),1,2)); osg::ref_ptr<osg::Box> myBox (new osg::Box(osg::Vec3f(),2,2,2)); osg::ref_ptr<osg::Cylinder> myCylinder (new osg::Cylinder(osg::Vec3f(),.75,2.5)); osg::ref_ptr<osg::Sphere> mySphere (new osg::Sphere(osg::Vec3f(),1.5)); osg::ref_ptr<osg::Cone> myCone (new osg::Cone(osg::Vec3f(),1,2)); shape_vec.push_back(new osg::ShapeDrawable(myBox.get())); shape_vec.push_back(new osg::ShapeDrawable(myCapsule.get())); shape_vec.push_back(new osg::ShapeDrawable(myCone.get())); shape_vec.push_back(new osg::ShapeDrawable(myCylinder.get())); shape_vec.push_back(new osg::ShapeDrawable(mySphere.get())); geode->addDrawable(shape_vec[1].get()); // default shape to pick from root->addChild(geode.get()); stateset = geode->getOrCreateStateSet(); // initial material properties diffuse_color.set(1, 1, 1, 1.0); specular_color.set(1,1,1,1); ambient_color.set(1,1,1,1); shininess = 10; alpha = 1; // apply the properties to the material material = new osg::Material; material->setDiffuse(osg::Material::FRONT, diffuse_color); material->setSpecular(osg::Material::FRONT, specular_color); material->setShininess(osg::Material::FRONT, shininess); material->setAmbient(osg::Material::FRONT, ambient_color); stateset->setAttribute(material.get()); //stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); texture = new osg::Texture2D; getCamera()->setViewport(new osg::Viewport(0,0,w,h)); getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(w)/static_cast<double>(h), 1.0f, 10000.0f); getCamera()->setGraphicsContext(_gw.get()); setSceneData(root.get()); setCameraManipulator(new osgGA::TrackballManipulator); addEventHandler(new osgViewer::StatsHandler); setThreadingModel(osgViewer::Viewer::SingleThreaded); }
/* Draws the engine pole and the pivot pole for the cylinder head. */ void draw_engine_pole(void) { glPushMatrix(); glColor4f(0.9, 0.9, 0.9, 1.0); myBox(0.5, 3.0, 0.5); glColor3f(0.5, 0.1, 0.5); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.9, -0.4); myCylinder(obj, 0.1, 0.0, 2); glPopMatrix(); }
int main() { string name = "", color = "", cont = ""; bool keepGoing = true; unsigned int prizeNum = 0, value = 0, choice = 0, number = 0; cout << "Setting up prize boxes are we?" << endl; // cout << "How many baxes are you making?" << endl; // cin >> amount; // for (int i = 1; i < amount; i++) // j = i; // Box j; //clears screen not 100% sure it works for all systems "borrowed" from one of luke's old labs #ifdef _WIN32 std::system("cls"); #else // Assume POSIX std::system("clear"); #endif cout << "What is the box number?\n"; cin >> number; cout << "What color would you like the box to be?" << endl; cin >> color; cout << "How many prizes do you want to cram in the box?" << endl; cin >> prizeNum; Box myBox(number, color , prizeNum); cout << "Heres the box" << endl; cout << "Box number: " << myBox.getBoxNumber() << " Box color: " << myBox.getBoxColor() << " Box prize capacity " << myBox.getPrizeCapacity() << endl; cout << "Enter any key to continue\n"; cin >> cont; do { //clears screen not 100% sure it works for all systems "borrowed" from one of luke's old labs #ifdef _WIN32 std::system("cls"); #else // Assume POSIX std::system("clear"); #endif cout << "What would you like to do with the box?\n" << "1. View box attributes\n" << "2. Change box attributes\n" << "3. View the contents of the box\n" << "4. Change the contents of the box\n" << "5. Quit\n" << endl; cin >> choice; switch (choice) { case 1: cout << "Box number: " << myBox.getBoxNumber() << " Box color: " << myBox.getBoxColor() << " Box prize capacity " << myBox.getPrizeCapacity() << endl; cout << "Enter any key to continue\n"; cin >> cont; break; case 2: cout << "What would you like to change?\n" << "1. Box number\n" << "2. Box color\n"; cin >> choice; switch (choice) { case 1: cout << "what number would you like to change it to?\n"; cin >> number; myBox.setBoxNumber(number); cout << "The new Box number is " << myBox.getBoxNumber() << endl; break; case 2: cout << "What color would you like to change it to?\n"; cin >> color; myBox.setBoxColor(color); cout << "The new box color is " << color << endl; break; } break; case 3: for (unsigned int i = 0; i < myBox.getPrizeCapacity(); i++) { cout << "Prize " << i + 1 << " " << myBox.getPrize(i).getPrizeName() << " Value $" << myBox.getPrize(i).getPrizeValue() << endl; } cout << "Enter any key to continue\n"; cin >> cont; break; case 4: cout << "what would you like to do?\n" << "1. Add a prize\n" << "2. Remove a prize\n"; cin >> choice; switch (choice) { case 1: cout << "What is the name of the prize?\n"; cin >> name; cout << " How much is it worth?\n"; cin >> value; if (!myBox.addPrize(Prize(name,value))) { cout << "Sorry the box is already full\n"; cout << "Enter any key to continue\n"; cin >> cont; } // else // myBox.addPrize(Prize(name, value)); break; case 2: cout << "which prize would you like to remove?\n"; for (unsigned int i = 0; i < myBox.getPrizeCapacity(); i++) { cout << "Prize " << i + 1 << " " << myBox.getPrize(i).getPrizeName() << " Value $" << myBox.getPrize(i).getPrizeValue() << endl; } cout << "Enter a prize number\n"; cin >> number; if (myBox.getPrize(number - 1).getPrizeValue() == 0 ) { cout << "There isn't a prize at that location\n"; cout << "Enter any key to continue\n"; cin >> cont; } else myBox.removePrize(number - 1); break; }