Example #1
0
void CreateWorld()
{
	
	Virtual::Cameras::FirstPersonCameraOptions options;	
	g_camera.reset(new Virtual::Cameras::FirstPersonCamera(options));
	g_camera->SetPositionAndTarget(Math::vec3(0, 5, 5), Math::vec3(0,0,0), Math::vec3(0,1,0));


	Utility::WorldDesc world_desc;
	if (!Utility::Parser::LoadWorld(System::Environment::Instance()->GetModelFolder() + L"shop_interior2.pmd", world_desc))
	{
		out_error() << "Can't load world descriptor from file" << std::endl;
		exit(-1);
	}

	g_world.reset(new Virtual::World(world_desc));
}
Example #2
0
 void configDynOptions(const InitializationMap& events)
 {
     if (events.exist("dyn_denys")) {
         const vle::value::Set& denyvs = events.getSet("dyn_denys");
         vle::value::Set::const_iterator isb = denyvs.begin();
         vle::value::Set::const_iterator ise = denyvs.end();
         for (; isb != ise; isb++) {
             denys.insert((*isb)->toString().value());
         }
     }
     if (events.exist("dyn_type")) {
         std::string dyn_type =  events.getString("dyn_type");
         if (dyn_type == "Var") {
             dyn_type = MONO;
         } else if (dyn_type == "Vect") {
             dyn_type = MULTI;
         } else if (dyn_type == "ValueVle") {
             dyn_type = VALUE_VLE;
         } else {
             dyn_type = MONO;
         }
     } else {
         dyn_type = MONO;
     }
     if (events.exist("dyn_sync")) {
         if (events.get("dyn_sync")->isInteger()) {
             dyn_sync = events.getInt("dyn_sync");
         } else {
             dyn_sync = (unsigned int) events.getBoolean("dyn_sync");
         }
     }
     if (events.exist("dyn_sync_out")) {
         if (events.get("dyn_sync_out")->isBoolean()) {
             dyn_sync_out = events.getBoolean("dyn_sync_out");
         }
     }
     dyn_init_value.reset();
     if (events.exist("dyn_init_value")) {
         dyn_init_value = std::unique_ptr<vle::value::Value>(
                 events.get("dyn_init_value")->clone());
     } else {
         dyn_init_value = std::unique_ptr<vle::value::Value>(
                 new value::Double(0.0));
     }
 }
int main(int argc, char** argv)
{
	g_camera.radius = 1000.0f;
	g_camera.phi = 1.57;
	g_camera.theta = 1.57;

	/*	float init_diagram_width = 200.0f;
	float init_diagram_height = 200.0f;
	SitesPtr sites = generateSites(30, init_diagram_width, init_diagram_height);

	diagram.reset(new VoronoiDiagram(sites, init_diagram_width, init_diagram_height));

	edges = diagram->getEdges();*/

	printf("Reading terrain data\n");
	//readTerrainData("../terrain_data/clevel.xyz", g_terrain_data, 3000);
	//readTerrainData("../terrain_data/test.xyz", g_terrain_data);
	//readTerrainData("../terrain_data/downsampled_clevel.xyz", g_terrain_data);
	readTerrainData("../meshes/gourd.xyz", g_terrain_data);
	printf("Number of sites: %d\n", g_terrain_data.sites->size());
	printf("X Data Range: [%3.3f, %3.3f]\n", g_terrain_data.min_x, g_terrain_data.max_x);
	printf("Y Data Range: [%3.3f, %3.3f]\n", g_terrain_data.min_y, g_terrain_data.max_y);
	printf("Z Data Range: [%3.3f, %3.3f]\n", g_terrain_data.min_z, g_terrain_data.max_z);

	diagram.reset(new VoronoiDiagram(g_terrain_data.sites,
									 (g_terrain_data.max_x - g_terrain_data.min_x),
									 (g_terrain_data.max_y - g_terrain_data.min_y)));
	edges = diagram->getEdges();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(100, 100);
	glutInitWindowSize(WindowWidth, WindowHeight);
	glutCreateWindow("Voronoi and Delaunay");

	glutDisplayFunc(DisplayFunc);
	glutReshapeFunc(ReshapeFunc);
	glutMouseFunc(MouseFunc);
	glutMotionFunc(MotionFunc);
	glutKeyboardFunc(KeyboardFunc);

	glutMainLoop();

	return 0;
}
Example #4
0
IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
{
  s32 return_value = IPC_SUCCESS;
  switch (request.request)
  {
  case IOCTL_STM_IDLE:
  case IOCTL_STM_SHUTDOWN:
    NOTICE_LOG(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down");
    Core::QueueHostJob(&Core::Stop, false);
    break;

  case IOCTL_STM_RELEASE_EH:
    if (!s_event_hook_request)
    {
      return_value = IPC_ENOENT;
      break;
    }
    Memory::Write_U32(0, s_event_hook_request->buffer_out);
    EnqueueReply(*s_event_hook_request, IPC_SUCCESS);
    s_event_hook_request.reset();
    break;

  case IOCTL_STM_HOTRESET:
    INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
    INFO_LOG(IOS_STM, "    IOCTL_STM_HOTRESET");
    break;

  case IOCTL_STM_VIDIMMING:  // (Input: 20 bytes, Output: 20 bytes)
    INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
    INFO_LOG(IOS_STM, "    IOCTL_STM_VIDIMMING");
    // Memory::Write_U32(1, buffer_out);
    // return_value = 1;
    break;

  case IOCTL_STM_LEDMODE:  // (Input: 20 bytes, Output: 20 bytes)
    INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
    INFO_LOG(IOS_STM, "    IOCTL_STM_LEDMODE");
    break;

  default:
    request.DumpUnknown(GetDeviceName(), LogTypes::IOS_STM);
  }

  return GetDefaultReply(return_value);
}
Example #5
0
    void Initialize(ASTContext &Ctx) override {
      if (Context) {
        assert(Context == &Ctx);
        return;
      }
        
      Context = &Ctx;

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.startTimer();

      Gen->Initialize(Ctx);

      TheModule.reset(Gen->GetModule());

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.stopTimer();
    }
Example #6
0
void SVGRenderingContext::clipToImageBuffer(GraphicsContext& context, const AffineTransform& absoluteTransform, const FloatRect& targetRect, std::unique_ptr<ImageBuffer>& imageBuffer, bool safeToClear)
{
    if (!imageBuffer)
        return;

    FloatRect absoluteTargetRect = calculateImageBufferRect(targetRect, absoluteTransform);

    // The mask image has been created in the absolute coordinate space, as the image should not be scaled.
    // So the actual masking process has to be done in the absolute coordinate space as well.
    context.concatCTM(absoluteTransform.inverse().valueOr(AffineTransform()));
    context.clipToImageBuffer(*imageBuffer, absoluteTargetRect);
    context.concatCTM(absoluteTransform);

    // When nesting resources, with objectBoundingBox as content unit types, there's no use in caching the
    // resulting image buffer as the parent resource already caches the result.
    if (safeToClear && !currentContentTransformation().isIdentity())
        imageBuffer.reset();
}
Example #7
0
void BBox::Shutdown()
{
	Invalidate();

	if (s_bbox_buffer)
	{
		D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(s_bbox_buffer);
		s_bbox_buffer = nullptr;
	}

	if (s_bbox_staging_buffer)
	{
		D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(s_bbox_staging_buffer);
		s_bbox_staging_buffer = nullptr;
	}

	s_bbox_stream_buffer.reset();
}
Example #8
0
void OsmAnd::ICU::release()
{
    // Release resources:

    delete g_pIcuAccentsAndDiacriticsConverter;
    g_pIcuAccentsAndDiacriticsConverter = nullptr;
    
    delete g_pIcuAnyToLatinTransliterator;
    g_pIcuAnyToLatinTransliterator = nullptr;

    delete g_pIcuWordBreakIterator;
    g_pIcuWordBreakIterator = nullptr;

    g_IcuData.reset();

    // Release ICU
    u_cleanup();
}
void FinderSyncHost::doShareLink(const QString &path) {
    QString repo_id;
    Account account;
    QString path_in_repo;
    if (!lookUpFileInformation(path, &repo_id, &account, &path_in_repo)) {
        qWarning("[FinderSync] invalid path %s", path.toUtf8().data());
        return;
    }

    get_shared_link_req_.reset(new GetSharedLinkRequest(
        account, repo_id, QString("/").append(path_in_repo),
        QFileInfo(path).isFile()));

    connect(get_shared_link_req_.get(), SIGNAL(success(const QString &)), this,
            SLOT(onShareLinkGenerated(const QString &)));

    get_shared_link_req_->send();
}
Example #10
0
error_code MachOUniversalBinary::ObjectForArch::getAsObjectFile(
    std::unique_ptr<ObjectFile> &Result) const {
  if (Parent) {
    StringRef ParentData = Parent->getData();
    StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
    std::string ObjectName =
        Parent->getFileName().str() + ":" +
        Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
    MemoryBuffer *ObjBuffer = MemoryBuffer::getMemBuffer(
        ObjectData, ObjectName, false);
    ErrorOr<ObjectFile *> Obj = ObjectFile::createMachOObjectFile(ObjBuffer);
    if (error_code EC = Obj.getError())
      return EC;
    Result.reset(Obj.get());
    return object_error::success;
  }
  return object_error::parse_failed;
}
Example #11
0
      void updateCode( std::unique_ptr<llvm::MemoryBuffer> buff ) {
        BufferID = SM.addNewSourceBuffer(std::move(buff));

        Parser.reset(
                     new ParserUnit(SM, BufferID,
                                    CompInv.getLangOptions(),
                                    CompInv.getModuleName())
                     );

        Parser->getDiagnosticEngine().addConsumer(DiagConsumer);
        auto &P = Parser->getParser();

        bool Done = false;
        while (!Done) {
          P.parseTopLevel();
          Done = P.Tok.is(tok::eof);
        }
      }
Example #12
0
/* step 3: declare imgtool_create_cannonical_library() */
imgtoolerr_t imgtool_create_cannonical_library(bool omit_untested, std::unique_ptr<imgtool::library> &library)
{
	size_t i;

	/* list of modules that we drop */
	static const char *const irrelevant_modules[] =
	{
		"coco_os9_rsdos"
	};

	library.reset(new imgtool::library());
	if (!library)
		return IMGTOOLERR_OUTOFMEMORY;

	// create all modules
	for (i = 0; i < ARRAY_LENGTH(modules); i++)
		library->add(modules[i]);

	// remove irrelevant modules
	for (i = 0; i < ARRAY_LENGTH(irrelevant_modules); i++)
	{
		library->unlink(irrelevant_modules[i]);
	}

	// if we are omitting untested, go through and block out the functionality in question
	if (omit_untested)
	{
		for (auto &module : library->modules())
		{
			if (module->writing_untested)
			{
				module->write_sector = nullptr;
			}
			if (module->creation_untested)
			{
				module->create = nullptr;
				module->createimage_optguide = nullptr;
				module->createimage_optspec = nullptr;
			}
		}
	}

	return IMGTOOLERR_SUCCESS;
}
Example #13
0
    void initBlur()
    {
        if (blur) return;

        blur.reset(new BlurState);

        // The blurred version of the view is downsampled.
        blur->size = (self().root().viewSize() / GuiWidget::toDevicePixels(4)).max(Vector2ui(1, 1));

        for (int i = 0; i < 2; ++i)
        {
            // Multisampling is disabled in the blurs for now.
            blur->fb[i].reset(new GLTextureFramebuffer(Image::RGB_888, blur->size, 1));
            blur->fb[i]->glInit();
            blur->fb[i]->colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone);
        }

        // Set up the drawble.
        DefaultVertexBuf *buf = new DefaultVertexBuf;
        blur->drawable.addBuffer(buf);
        buf->setVertices(gl::TriangleStrip,
                         DefaultVertexBuf::Builder().makeQuad(
                             Rectanglef(0, 0, 1, 1),
                             Vector4f(1, 1, 1, 1),
                             Rectanglef(0, 0, 1, 1)),
                         gl::Static);

        blur->uBlurStep = Vector2f(1.f / float(blur->size.x),
                                   1.f / float(blur->size.y));

        self().root().shaders().build(blur->drawable.program(), "fx.blur.horizontal")
                << blur->uMvpMatrix
                << blur->uTex
                << blur->uBlurStep
                << blur->uWindow;

        blur->drawable.addProgram("vert");
        self().root().shaders().build(blur->drawable.program("vert"), "fx.blur.vertical")
                << blur->uMvpMatrix
                << blur->uTex
                << blur->uColor
                << blur->uBlurStep
                << blur->uWindow;
    }
Example #14
0
void InitData()
{

    rand_init();

    // Load obj file
    std::string basepath = g_path;
    basepath += "/";
    std::string filename = basepath + g_modelname;

    g_scene.reset(Scene::LoadFromObj(filename, basepath));

    g_scene->camera_.reset(new PerspectiveCamera(
        g_camera_pos
        , g_camera_at
        , CAMERA_UP
        , CAMERA_ZCAP
        , CAMERA_FOVY
        , (float)g_window_width / g_window_height
        ));

    g_scene->SetEnvironment("../Resources/Textures/studio015.hdr", "", g_envmapmul);

#pragma omp parallel for
	for (int i = 0; i < g_cfgs.size(); ++i)
	{
		g_cfgs[i].renderer->SetNumBounces(g_num_bounces);
		g_cfgs[i].renderer->Preprocess(*g_scene);

		g_outputs[i].output = (FrOutput*)g_cfgs[i].renderer->CreateOutput(g_window_width, g_window_height);
		
		g_cfgs[i].renderer->SetOutput(g_outputs[i].output);

		g_outputs[i].fdata.resize(g_window_width * g_window_height);
		g_outputs[i].udata.resize(g_window_width * g_window_height * 4);

		if (g_cfgs[i].type == ConfigManager::kPrimary)
		{
			g_outputs[i].copybuffer = g_cfgs[i].context.CreateBuffer<float3>(g_window_width * g_window_height, CL_MEM_READ_WRITE);
		}
	}

	g_cfgs[g_primary].renderer->Clear(float3(0, 0, 0), *g_outputs[g_primary].output);
}
Example #15
0
void InitCl()
{
	ConfigManager::CreateConfigs(g_mode, g_interop, g_cfgs);

	std::cout << "Running on devices: \n";

	for (int i = 0; i < g_cfgs.size(); ++i)
	{
		std::cout << i << ": " << g_cfgs[i].context.GetDevice(g_cfgs[i].devidx).GetName() << "\n";
	}

	g_interop = false;

	g_outputs.resize(g_cfgs.size());
	g_ctrl.reset(new ControlData[g_cfgs.size()]);

	for (int i = 0; i < g_cfgs.size(); ++i)
	{
		if (g_cfgs[i].type == ConfigManager::kPrimary)
		{
			g_primary = i;

			if (g_cfgs[i].caninterop)
			{
				g_cl_interop_image = g_cfgs[i].context.CreateImage2DFromGLTexture(g_texture);
				g_interop = true;
			}
		}

		g_ctrl[i].clear.store(1);
		g_ctrl[i].stop.store(0);
		g_ctrl[i].newdata.store(0);
		g_ctrl[i].idx = i;
	}
   
    if (g_interop)
    {
        std::cout << "OpenGL interop mode enabled\n";
    }
    else
    {
        std::cout << "OpenGL interop mode disabled\n";
    }
}
Example #16
0
//JNIEXPORT void* hgs_init(int w, int h, jobject surface)
JNIEXPORT bool hgs_init( jint w, jint h, ANativeWindow* window)
{
    LOGD("window %p", window);
    tmpargs_.reset( new Main::Args() );
    tmpargs_->vWidth = w;
    tmpargs_->vHeight = h;

    if (window) {
        //ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
        tmpargs_->renderer_ok_ = 1;
        tmpargs_->vgl.setWindow(window); // pass Ownership // ANativeWindow_release
    }
    //jobject o = env_->NewObject(CLS_DecoderWrap, MID_DecoderWrap_ctor, w,h, surface);
    //oDecoderWrap = env_->NewGlobalRef(o);
    //env_->DeleteLocalRef(o);
    //LOGD("%d:%s %dx%d %p: %p", __LINE__,__func__, w,h,surface, oDecoderWrap);
    //return (void*)oDecoderWrap;
    return 1;
}
Example #17
0
  bool on_accept()
  {
	  if (!task)
	  {
      cout << "In listener::on_accept()" << endl;
      task.reset(new server_work_thread);
      task->sock = std::move(connect_sock);
      task->start();
      cout << "server thread started." << endl;
	    // shutdown the listener thead.. our work is done here.
	    return false;
	  }
	  else
	  {
	    connect_sock->close();
	    cerr << "Multiple attempts to connect to server" 
		  << endl;
	  };
  };
Example #18
0
		FontEffector(D3DCore* core, const TCHAR* filename)
			: Effector{} // ここでは読み込まない
			, cbColor{ nullptr } {
			// 共通のリソースとしてピクセルシェーダをロードする
			if (!psFont) {
				psFont = Shaders::Load<Shaders::PixelShader>(core, filename);
				if (!psFont) {
					// 読み込めなかった
					LOG_ERR("ファイル %s を読み込めませんでした\n", filename);
					return;
				}
				core->AddResource(PtrToRes(psFont));
			}
			// 親クラスのデストラクタで消されないように、shaderには設定しない
			//this->shader = psFont;

			// こいつは自前で削除する
			cbColor.reset(new D3DConstantBuffer<Color>(core));
		}
Example #19
0
void DoState(PointerWrap& p)
{
  // By waiting for the DVD thread to be done working, we ensure
  // that s_request_queue will be empty and that the DVD thread
  // won't be touching anything while this function runs.
  WaitUntilIdle();

  // Move all results from s_result_queue to s_result_map because
  // PointerWrap::Do supports std::map but not Common::SPSCQueue.
  // This won't affect the behavior of FinishRead.
  ReadResult result;
  while (s_result_queue.Pop(result))
    s_result_map.emplace(result.first.id, std::move(result));

  // Both queues are now empty, so we don't need to savestate them.
  p.Do(s_result_map);
  p.Do(s_next_id);

  // s_disc isn't savestated (because it points to files on the
  // local system). Instead, we check that the status of the disc
  // is the same as when the savestate was made. This won't catch
  // cases of having the wrong disc inserted, though.
  // TODO: Check the game ID, disc number, revision?
  bool had_disc = HasDisc();
  p.Do(had_disc);
  if (had_disc != HasDisc())
  {
    if (had_disc)
      PanicAlertT("An inserted disc was expected but not found.");
    else
      s_disc.reset();
  }

  // TODO: Savestates can be smaller if the buffers of results aren't saved,
  // but instead get re-read from the disc when loading the savestate.

  // TODO: It would be possible to create a savestate faster by stopping
  // the DVD thread regardless of whether there are pending requests.

  // After loading a savestate, the debug log in FinishRead will report
  // screwed up times for requests that were submitted before the savestate
  // was made. Handling that properly may be more effort than it's worth.
}
void
AudioSender::process()
{
    auto& mainBuffer = Manager::instance().getRingBufferPool();
    auto mainBuffFormat = mainBuffer.getInternalAudioFormat();

    // compute nb of byte to get corresponding to 1 audio frame
    const std::size_t samplesToGet = std::chrono::duration_cast<std::chrono::seconds>(mainBuffFormat.sample_rate * secondsPerPacket_).count();

    if (mainBuffer.availableForGet(id_) < samplesToGet) {
        const auto wait_time = std::chrono::duration_cast<std::chrono::milliseconds>(secondsPerPacket_);
        if (not mainBuffer.waitForDataAvailable(id_, samplesToGet, wait_time))
            return;
    }

    // get data
    micData_.setFormat(mainBuffFormat);
    micData_.resize(samplesToGet);
    const auto samples = mainBuffer.getData(micData_, id_);
    if (samples != samplesToGet)
        return;

    // down/upmix as needed
    auto accountAudioCodec = std::static_pointer_cast<AccountAudioCodecInfo>(args_.codec);
    micData_.setChannelNum(accountAudioCodec->audioformat.nb_channels, true);

    if (mainBuffFormat.sample_rate != accountAudioCodec->audioformat.sample_rate) {
        if (not resampler_) {
            RING_DBG("Creating audio resampler");
            resampler_.reset(new Resampler(accountAudioCodec->audioformat));
        }
        resampledData_.setFormat(accountAudioCodec->audioformat);
        resampledData_.resize(samplesToGet);
        resampler_->resample(micData_, resampledData_);
        Smartools::getInstance().setLocalAudioCodec(audioEncoder_->getEncoderName());
        if (audioEncoder_->encode_audio(resampledData_) < 0)
            RING_ERR("encoding failed");
    } else {
        if (audioEncoder_->encode_audio(micData_) < 0)
            RING_ERR("encoding failed");
    }
}
Example #21
0
void init_video () // inizializza grafica a 320x200x256 colori.
{

    init();

    // Set SDL video mode (using surface rendering)
    Uint32 rmask, gmask, bmask, amask;

    /* SDL interprets each pixel as a 32-bit number, so our masks must depend
       on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    rmask = 0xff000000;
    gmask = 0x00ff0000;
    bmask = 0x0000ff00;
    amask = 0x00000000;
#else
    rmask = 0x000000ff;
    gmask = 0x0000ff00;
    bmask = 0x00ff0000;
    amask = 0x00000000;
#endif

    // create software video buffer
    video_buffer.reset(new unsigned char[WIDTH*HEIGHT]);
    memset(&video_buffer[0], 0, WIDTH*HEIGHT);

    p_surface_32 = SDL_CreateRGBSurface(0, WIDTH, HEIGHT, 32, rmask, gmask, bmask, amask);
    if (p_surface_32 == nullptr) throw sdl_exception();

    p_window = SDL_CreateWindow("Crystal Pixels",
            SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
            WIDTH_SCALED, HEIGHT_SCALED, SDL_WINDOW_RESIZABLE);
    if (p_window == nullptr) throw sdl_exception();

    p_renderer = SDL_CreateRenderer(p_window, -1, SDL_RENDERER_TARGETTEXTURE);

    p_texture = SDL_CreateTexture(p_renderer, SDL_PIXELFORMAT_ABGR8888,
                                  SDL_TEXTUREACCESS_STREAMING, WIDTH,HEIGHT);

    //p_surface_scaled = SDL_GetWindowSurface(p_window);
    SDL_SetWindowMinimumSize(p_window, WIDTH, HEIGHT);
}
Example #22
0
static error_code getMemoryBufferForStream(int FD,
                                           StringRef BufferName,
                                           std::unique_ptr<MemoryBuffer> &Result) {
  const ssize_t ChunkSize = 4096*4;
  SmallString<ChunkSize> Buffer;
  ssize_t ReadBytes;
  // Read into Buffer until we hit EOF.
  do {
    Buffer.reserve(Buffer.size() + ChunkSize);
    ReadBytes = read(FD, Buffer.end(), ChunkSize);
    if (ReadBytes == -1) {
      if (errno == EINTR) continue;
      return error_code(errno, posix_category());
    }
    Buffer.set_size(Buffer.size() + ReadBytes);
  } while (ReadBytes != 0);

  Result.reset(MemoryBuffer::getMemBufferCopy(Buffer, BufferName));
  return error_code::success();
}
Example #23
0
bool PassDefinition::Parse( Parser& parser,
                            std::unique_ptr<PassDefinition>& token )
{
    // The definition starts with an open brace
    if( !parser.ExpectTerminal( TerminalType::OPEN_BRACE ) )
        return false;

    // Parse some StateAssignmentStatements or CompileStatementss
    PassStatementVector statements;
    parser.ExpectSequenceOf<PassStatement>( statements );
    // The parser may have advanced the lexer too far
    CHECK_PARSER;

    // The definiton ends with a close brace
    if( !parser.ExpectTerminal( TerminalType::CLOSE_BRACE ) )
        return false;

    token.reset( new PassDefinition( std::move(statements) ) );
    return true;
}
Example #24
0
	void AutonomousInit()
	{
		CommandBase::pArm->SetEnabled(true);
		/* std::string autoSelected = SmartDashboard::GetString("Auto Selector", "Default");
		if(autoSelected == "My Auto") {
			autonomousCommand.reset(new MyAutoCommand());
		} else {
			autonomousCommand.reset(new ExampleCommand());
		} */

		autonomousCommand.reset((Command *)chooser->GetSelected());

		if (autonomousCommand)
			std::cout << "Autonomous valid\n";
		else
			std::cout << "Autonomous invalid\n";

		if (autonomousCommand)
			autonomousCommand->Start();
	}
Example #25
0
Node::Node(std::unique_ptr<GameBoard> state, Node* const parent,
		std::unique_ptr<Move> action, uint8_t depth,
		Heuristic alpha, Heuristic beta, bool maximizer)
	: state{std::move(state)},
	  parent{parent},
	  action{std::move(action)},
	  depth{depth},
	  alpha{alpha},
	  beta{beta},
	  maximizer{maximizer},
	  nextNodeMove{0, 0},
	  bestMove{nullptr}
{
	// If they called it with a null GameBoard,
	// they probably want a blank game state
	if (state == nullptr)
	{
		state.reset(new GameBoard);
	}
}
void            PS::loop(std::unique_ptr<IState> &ptr, ftui::ACanvas &can)
{
	(void)ptr;
	this->_b->tiles.render();
	this->_b->act.render(can);
	if (this->_launchSolvingState)
	{
		ft::f(std::cout, "Algo % Heu % Cost % Grid %:\n%\n"
			  , _main.algorithmId
			  , _main.heuristicId
			  , _main.cost
			  , _b->selectedId
			  , _main.grid
			);
		can.clear();
		ptr.reset(new SolvingState(_main, _ocaml));
		// throw std::runtime_error("OK");
	}
	return ;
}
//--------------------------------------------------------------------------------------
// Clean up the objects we've created
//--------------------------------------------------------------------------------------
void CleanupDevice()
{
    if( g_pImmediateContext ) g_pImmediateContext->ClearState();

    if ( g_pBatchInputLayout ) g_pBatchInputLayout->Release();

    if( g_pTextureRV1 ) g_pTextureRV1->Release();
    if( g_pTextureRV2 ) g_pTextureRV2->Release();

    if( g_pDepthStencilView ) g_pDepthStencilView->Release();
    if( g_pDepthStencil ) g_pDepthStencil->Release();
    if( g_pRenderTargetView ) g_pRenderTargetView->Release();
    if( g_pSwapChain ) g_pSwapChain->Release();
    if( g_pImmediateContext ) g_pImmediateContext->Release();
    if( g_pd3dDevice ) g_pd3dDevice->Release();

#ifdef DXTK_AUDIO
    g_audEngine.reset();
#endif
}
    void init()
    {
        ClientApp::shaders().build(program, "model.skeletal.normal_specular_emission")
                << uMvpMatrix
                << uTex
                << uEyePos
                << uAmbientLight
                << uLightDirs
                << uLightIntensities;

        atlas.reset(AtlasTexture::newWithKdTreeAllocator(
                    Atlas::DefaultFlags,
                    GLTexture::maximumSize().min(GLTexture::Size(4096, 4096))));
        atlas->setBorderSize(1);
        atlas->setMarginSize(0);

        // Fallback normal map for models who don't provide one.
        QImage img(QSize(1, 1), QImage::Format_ARGB32);
        img.fill(qRgba(127, 127, 255, 255)); // z+
        defaultNormals = atlas->alloc(img);

        // Fallback emission map for models who don't have one.
        img.fill(qRgba(0, 0, 0, 0));
        defaultEmission = atlas->alloc(img);

        // Fallback specular map (no specular reflections).
        img.fill(qRgba(0, 0, 0, 0));
        defaultSpecular = atlas->alloc(img);

        uTex = *atlas;

        /*
        // All loaded items should use this atlas.
        bank.iterate([this] (DotPath const &path)
        {
            if(bank.isLoaded(path))
            {
                setupModel(bank.model(path));
            }
        });*/
    }
Example #29
0
    void testSubs ()
    {
        setup ("subs");
        {
            auto& root = makeRoot();

            {
                // Add an array with three entries.
                auto array = root.setArray ("ar");
                array.append (23);
                array.append (false);
                array.append (23.5);
            }

            {
                // Add an object with one entry.
                auto obj = root.setObject ("obj");
                obj["hello"] = "world";
            }

            {
                // Add another object with two entries.
                Json::Value value;
                value["h"] = "w";
                value["f"] = false;
                root["obj2"] = value;
            }
        }

        // Json::Value has an unstable order...
        auto case1 = "{\"ar\":[23,false,23.5],"
                "\"obj\":{\"hello\":\"world\"},"
                "\"obj2\":{\"h\":\"w\",\"f\":false}}";
        auto case2 = "{\"ar\":[23,false,23.5],"
                "\"obj\":{\"hello\":\"world\"},"
                "\"obj2\":{\"f\":false,\"h\":\"w\"}}";
        writerObject_.reset();
        expect (output_ == case1 || output_ == case2,
                "Got wrong object:\n  " + output_ + "\nShould be either\n  " +
                case1 + "\nor\n  " + case2);
    }
Example #30
0
PDB_ErrorCode DIASession::createFromExe(StringRef Path,
                                        std::unique_ptr<IPDBSession> &Session) {
  CComPtr<IDiaDataSource> DiaDataSource;
  CComPtr<IDiaSession> DiaSession;

  // We assume that CoInitializeEx has already been called by the executable.
  if (!LoadDIA(DiaDataSource))
    return PDB_ErrorCode::NoPdbImpl;

  llvm::SmallVector<UTF16, 128> Path16;
  if (!llvm::convertUTF8ToUTF16String(Path, Path16))
    return PDB_ErrorCode::InvalidPath;

  const wchar_t *Path16Str = reinterpret_cast<const wchar_t *>(Path16.data());
  HRESULT Result;
  if (FAILED(Result =
                 DiaDataSource->loadDataForExe(Path16Str, nullptr, nullptr))) {
    if (Result == E_PDB_NOT_FOUND)
      return PDB_ErrorCode::InvalidPath;
    else if (Result == E_PDB_FORMAT)
      return PDB_ErrorCode::InvalidFileFormat;
    else if (Result == E_PDB_INVALID_SIG || Result == E_PDB_INVALID_AGE)
      return PDB_ErrorCode::DebugInfoMismatch;
    else if (Result == E_INVALIDARG)
      return PDB_ErrorCode::InvalidParameter;
    else if (Result == E_UNEXPECTED)
      return PDB_ErrorCode::AlreadyLoaded;
    else
      return PDB_ErrorCode::UnknownError;
  }

  if (FAILED(Result = DiaDataSource->openSession(&DiaSession))) {
    if (Result == E_OUTOFMEMORY)
      return PDB_ErrorCode::NoMemory;
    else
      return PDB_ErrorCode::UnknownError;
  }

  Session.reset(new DIASession(DiaSession));
  return PDB_ErrorCode::Success;
}