FuncScopeVariableEnvironment::
FuncScopeVariableEnvironment(const FunctionStatement *func)
  : m_func(func), m_staticEnv(NULL), m_argc(0),
    m_argStart(RequestEvalState::argStack().pos()) {

  const Block::VariableIndices &vi = func->varIndices();
  const vector<string> &vars = func->variables();
  m_byIdx.resize(vi.size());
  Globals *g = NULL;
  for (int i = vars.size() - 1; i >= 0; i--) {
    const string &name = vars[i];
    Block::VariableIndices::const_iterator it = vi.find(name);
    ASSERT(it != vi.end());
    if (it == vi.end()) continue;

    const VariableIndex &v = it->second;
    String sname(name.c_str(), name.size(), AttachLiteral);
    if (v.superGlobal() != VariableIndex::Normal &&
        v.superGlobal() != VariableIndex::Globals) {
      if (!g) g = get_globals();
      // This is safe because superglobals are real members of the globals
      // and do not live in an array
      m_byIdx[v.idx()] = &g->get(sname);
    } else {
      Variant &val = m_alist.prepend(sname);
      m_byIdx[v.idx()] = &val;
      if (v.superGlobal() == VariableIndex::Globals) {
        val = get_global_array_wrapper();
      }
    }
  }
}
示例#2
0
  Shake::Shake(SimInfo* info) : info_(info), maxConsIteration_(10), 
                                consTolerance_(1.0e-6), doShake_(false),
                                currConstraintTime_(0.0)  {
    
    if (info_->getNGlobalConstraints() > 0)
      doShake_ = true;
    
    if (!doShake_) return;

    Globals* simParams = info_->getSimParams();

    currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
    if (simParams->haveConstraintTime()){
      constraintTime_ = simParams->getConstraintTime();
    } else {
      constraintTime_ = simParams->getStatusTime();
    }

    constraintOutputFile_ = getPrefix(info_->getFinalConfigFileName()) + 
      ".constraintForces";

    // create ConstraintWriter  
    constraintWriter_ = new ConstraintWriter(info_, 
                                             constraintOutputFile_.c_str());   

    if (!constraintWriter_){
      sprintf(painCave.errMsg, "Failed to create ConstraintWriter\n");
      painCave.isFatal = 1;
      simError();
    }
  }
FuncScopeVariableEnvironment::
FuncScopeVariableEnvironment(const FunctionStatement *func, int argc)
  : m_func(func), m_staticEnv(NULL), m_argc(argc),
    m_argStart(RequestEvalState::argStack().pos()) {

  const Block::VariableIndices &vi = func->varIndices();
  m_byIdx.resize(vi.size());
  Globals *g = NULL;
  for (Block::VariableIndices::const_iterator it = vi.begin();
       it != vi.end(); ++it) {
    const VariableIndex &v = it->second;
    if (v.superGlobal() != VariableIndex::Normal &&
        v.superGlobal() != VariableIndex::Globals) {
      if (!g) g = get_globals();
      // This is safe because superglobals are real members of the globals
      // and do not live in an array
      m_byIdx[v.idx()] = &g->get(String(it->first.c_str(), it->first.size(),
            AttachLiteral), v.hash());
    } else {
      Variant &val = m_alist.prepend(String(it->first.c_str(),
            it->first.size(),
            AttachLiteral));
      m_byIdx[v.idx()] = &val;
      if (v.superGlobal() == VariableIndex::Globals) {
        val = get_global_array_wrapper();
      }
    }
  }
}
示例#4
0
void FittingAnalyzer::Analyze(Trace &trace, const std::string &detType,
                              const std::string &detSubtype,
                              const std::map<std::string, int> & tagMap) {
    TraceAnalyzer::Analyze(trace, detType, detSubtype, tagMap);

    if(trace.HasValue("saturation") || trace.empty() ||
       trace.GetWaveform().size() == 0) {
        EndAnalyze();
        return;
    }

    Globals *globals = Globals::get();

    const double sigmaBaseline = trace.GetValue("sigmaBaseline");
    const double maxVal = trace.GetValue("maxval");
    const double qdc = trace.GetValue("qdc");
    const double maxPos = trace.GetValue("maxpos");
    const vector<double> waveform = trace.GetWaveform();
    bool isDblBeta = detType == "beta" && detSubtype == "double";
    bool isDblBetaT = isDblBeta && tagMap.find("timing") != tagMap.end();

    trace.plot(D_SIGMA, sigmaBaseline*100);

    if(!isDblBetaT) {
        if(sigmaBaseline > globals->sigmaBaselineThresh()) {
            EndAnalyze();
            return;
        }
    } else {
        if(sigmaBaseline > globals->siPmtSigmaBaselineThresh()) {
            EndAnalyze();
            return;
        }
    }

    pair<double,double> pars =  globals->fitPars(detType+":"+detSubtype);
    if(isDblBetaT)
        pars = globals->fitPars(detType+":"+detSubtype+":timing");

    FitDriver *driver;
    switch(fitterType_) {
        case FitDriver::GSL:
            driver = new GslFitter(isDblBetaT);
            break;
        case FitDriver::UNKNOWN:
        default:
            EndAnalyze();
            return;
    }

    driver->PerformFit(waveform, pars, sigmaBaseline, qdc);
    trace.InsertValue("phase", driver->GetPhase()+maxPos);

    trace.plot(DD_AMP, driver->GetAmplitude(), maxVal);
    trace.plot(D_PHASE, driver->GetPhase()*1000+100);
    trace.plot(D_CHISQPERDOF, driver->GetChiSqPerDof());

    delete(driver);
    EndAnalyze();
}
 void initAL(AssocList &al) const {
   Globals *g = get_globals();
   for (int i = 0; i < s_num-1; i++) {
     al.prepend(s_names[i]) = ref(g->get(s_names[i], s_hashes[i]));
   }
   al.prepend("GLOBALS") = get_global_array_wrapper();
 }
示例#6
0
bool SceneLoader::loadScene()
{ 
	TiXmlElement *globalElement = root->FirstChildElement("globals");
	TiXmlElement *viewElement = root->FirstChildElement("view");
	TiXmlElement *illumElement = root->FirstChildElement("illumination");
	if(globalElement == NULL){
		cout << "> Error: Globals tag not found!\n" << endl;
		return false;
	}
	if(viewElement == NULL){
		cout << "> Error: View tag not found!\n" << endl;
		return false;
	}
	if(illumElement == NULL){
		cout << "> Error: Illumination tag not found!\n" << endl;
		return false;
	}
	
	sceneManager = new SceneManager();

	cout << "> loading Globals..." << endl;
	Globals* globals = loadGlobals(globalElement);
	if(!(sceneManager->setGlobals(globals))){
		return false;
	}
	cout << "> Globals successfully loaded" << endl << endl; 
	maxLights = globals->getMaxLights();
	maxMaterials = globals->getMaxMaterials();
	maxTextures = globals->getMaxTextures();
	maxObjects = globals->getMaxObjects();

	cout << "> loading View..." << endl;
	if(!(sceneManager->setView(loadView(viewElement))))
		return false;
	cout << "> View successfully loaded" << endl << endl;

	cout << "> loading Illumination..." << endl;
	if(!(sceneManager->setIllumination(loadIllumination(illumElement))))
		return false;
	cout << "> Illumination successfully loaded" << endl << endl;

	cout << "> loading Materials..." << endl;
	if(!loadMaterials())
		return false;
	cout << "> Materials successfully loaded" << endl << endl;

	cout << "> loading Textures..." << endl;
	if(!loadTextures())
		return false;
	cout << "> Textures successfully loaded" << endl << endl;

	cout << "> loading Objects..." << endl;
	if(!loadObjects())
		return false;
	cout << "> Objects successfully loaded!" << endl << endl;

	return true; 
}
示例#7
0
文件: NPT.cpp 项目: xielm12/OpenMD
  NPT::NPT(SimInfo* info) :
    VelocityVerletIntegrator(info), etaTolerance(1e-6), chiTolerance(1e-6), 
    maxIterNum_(4) {

      Globals* simParams = info_->getSimParams();
    
      if (!simParams->getUseIntialExtendedSystemState()) {
        Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
        currSnapshot->setThermostat(make_pair(0.0, 0.0));
        currSnapshot->setBarostat(Mat3x3d(0.0));
      }
    
      if (!simParams->haveTargetTemp()) {
        sprintf(painCave.errMsg, "You can't use the NVT integrator without a targetTemp!\n");
        painCave.isFatal = 1;
        painCave.severity = OPENMD_ERROR;
        simError();
      } else {
        targetTemp = simParams->getTargetTemp();
      }

      // We must set tauThermostat
      if (!simParams->haveTauThermostat()) {
        sprintf(painCave.errMsg, "If you use the constant temperature\n"
		"\tintegrator, you must set tauThermostat.\n");

        painCave.severity = OPENMD_ERROR;
        painCave.isFatal = 1;
        simError();
      } else {
        tauThermostat = simParams->getTauThermostat();
      }

      if (!simParams->haveTargetPressure()) {
        sprintf(painCave.errMsg, "NPT error: You can't use the NPT integrator\n"
		"   without a targetPressure!\n");

        painCave.isFatal = 1;
        simError();
      } else {
        targetPressure = simParams->getTargetPressure();
      }
    
      if (!simParams->haveTauBarostat()) {
        sprintf(painCave.errMsg,
                "If you use the NPT integrator, you must set tauBarostat.\n");
        painCave.severity = OPENMD_ERROR;
        painCave.isFatal = 1;
        simError();
      } else {
        tauBarostat = simParams->getTauBarostat();
      }
    
      tt2 = tauThermostat * tauThermostat;
      tb2 = tauBarostat * tauBarostat;

      updateSizes();
    }
示例#8
0
void CLOutputMgr::OutputEntryFunction(Globals& globals) {
  // Would ideally use the ExtensionMgr, but there is no way to set it to our
  // own custom made one (without modifying the code).
  std::ostream& out = get_main_out();
  out << "__kernel void entry(__global ulong *result";
  if (CLOptions::atomics()) {
    out << ", __global volatile uint *g_atomic_input";
    out << ", __global volatile uint *g_special_values";
  }
  if (CLOptions::atomic_reductions()) {
    out << ", __global volatile int *g_atomic_reduction";
  }
  if (CLOptions::emi())
    out << ", __global int *emi_input";
  if (CLOptions::fake_divergence())
    out << ", __global int *sequence_input";
  if (CLOptions::inter_thread_comm())
    out << ", __global long *g_comm_values";
  out << ") {" << std::endl;
  globals.OutputArrayControlVars(out);
  globals.OutputBufferInits(out);
  globals.OutputStructInit(out);

  // Block all threads before entering to ensure the local buffers have been
  // initialised.
  output_tab(out, 1);
  StatementBarrier::OutputBarrier(out);
  out << std::endl;

  output_tab(out, 1);
  out << "func_1(";
  globals.GetGlobalStructVar().Output(out);
  out << ");" << std::endl;

  // If using message passing, check and update constraints to prevent deadlock.
  if (CLOptions::message_passing())
    MessagePassing::OutputMessageEndChecks(out);

  // Block all threads after, to prevent hashing stale values.
  output_tab(out, 1);
  StatementBarrier::OutputBarrier(out);
  out << std::endl;

  // Handle hashing and outputting.
  output_tab(out, 1);
  out << "uint64_t crc64_context = 0xFFFFFFFFFFFFFFFFUL;" << std::endl;
  output_tab(out, 1);
  out << "int print_hash_value = 0;" << std::endl;
  HashGlobalVariables(out);
  if (CLOptions::atomics())
    ExpressionAtomic::OutputHashing(out);
  if (CLOptions::inter_thread_comm()) StatementComm::HashCommValues(out);
  output_tab(out, 1);
  out << "result[get_linear_global_id()] = crc64_context ^ 0xFFFFFFFFFFFFFFFFUL;"
      << std::endl;
  out << "}" << std::endl;
}
示例#9
0
void CfdAnalyzer::Analyze(Trace &trace, const std::string &detType,
                          const std::string &detSubtype,
                          const std::map<std::string, int> & tagMap) {
    TraceAnalyzer::Analyze(trace, detType, detSubtype, tagMap);
    Globals *globals = Globals::get();
    unsigned int saturation = (unsigned int)trace.GetValue("saturation");
    if(saturation > 0) {
            EndAnalyze();
            return;
    }
    double aveBaseline = trace.GetValue("baseline");
    unsigned int maxPos = (unsigned int)trace.GetValue("maxpos");
    pair<unsigned int, unsigned int> range = globals->waveformRange("default");
    unsigned int waveformLow  = range.first;
    unsigned int waveformHigh = range.second;
    unsigned int delay = 2;
    double fraction = 0.25;
    vector<double> cfd;
    Trace::iterator cfdStart = trace.begin();
    advance(cfdStart, (int)(maxPos - waveformLow - 2));
    Trace::iterator cfdStop  = trace.begin();
    advance(cfdStop, (int)(maxPos + waveformHigh));
    for(Trace::iterator it = cfdStart;  it != cfdStop; it++) {
            Trace::iterator it0 = it;
            advance(it0, delay);
            double origVal = *it;
            double transVal = *it0;
            cfd.insert(cfd.end(), fraction *
                       (origVal - transVal - aveBaseline));
    }
    vector<double>::iterator cfdMax =
        max_element(cfd.begin(), cfd.end());
    vector<double> fitY;
    fitY.insert(fitY.end(), cfd.begin(), cfdMax);
    fitY.insert(fitY.end(), *cfdMax);
    vector<double>fitX;
    for(unsigned int i = 0; i < fitY.size(); i++)
        fitX.insert(fitX.end(), i);
    double num = fitY.size();
    double sumXSq = 0, sumX = 0, sumXY = 0, sumY = 0;
    for(unsigned int i = 0; i < num; i++) {
            sumXSq += fitX.at(i)*fitX.at(i);
            sumX += fitX.at(i);
            sumY += fitY.at(i);
            sumXY += fitX.at(i)*fitY.at(i);
    }
    double deltaPrime = num*sumXSq - sumX*sumX;
    double intercept =
        (1/deltaPrime)*(sumXSq*sumY - sumX*sumXY);
    double slope =
        (1/deltaPrime)*(num*sumXY - sumX*sumY);
    trace.InsertValue("phase", (-intercept/slope)+maxPos);
    EndAnalyze();
}
void
ConfigureKeys::on_exit()
{
#ifndef DISABLE_LIBSIGC
    Globals g;

    g.render().DeleteTexture(m_bg);
    SDL_EnableKeyRepeat(0, 0); // 0,0 disables key-repeat

    m_con_active.clear();
    m_con_passive.clear();
#endif // DISABLE_LIBSIGC
}
示例#11
0
  NgammaT::NgammaT(SimInfo* info) : NPT(info) {
    Globals* simParams = info_->getSimParams();
    if (!simParams->haveSurfaceTension()) {
      sprintf(painCave.errMsg,
              "If you use the NgammaT integrator, you must set a surface tension.\n");
      painCave.severity = OPENMD_ERROR;
      painCave.isFatal = 1;
      simError();
    } else {
      surfaceTension= simParams->getSurfaceTension()* PhysicalConstants::surfaceTensionConvert * PhysicalConstants::energyConvert;
    }

  }
	void setup(){
		globals.setAverages(0);
		for (int f=0; f<MAX_FEATURES_MFB; ++f) {
			for (int i = 0; i < num_movies; ++i){
				if(TRAIN_SIMU_MFB) movie_features[i][f] = (rand()%14000 + 2000) * 0.000001235f;
				else movie_features[f][i] = (rand()%14000 + 2000) * 0.000001235f;
			}
			for (int i=0; i<num_users; i++){
				if(TRAIN_SIMU_MFB){
					user_features[i][f] = (rand()%14000 + 2000) * 0.000001235f;
				}
				else{
					user_features[f][i] = (rand()%14000 + 2000) * 0.000001235f;
				}
			}
		}
		for(int u=0; u<num_users; u++){
			b_u[u] = 0;
		}
		for (int i = 0; i < num_movies; ++i){
			b_i[i] = 0;
		}
		for(int i=0; i<db->totalVotes(); i++){
			trained_cache[i] = 0.0;
		}
		fprintf(stderr, "Done initializing.\n");
	}
Particle::Particle(PVector _pos, PVector _vel) {
    pos.equals(_pos);
    vel.equals(_vel);
    lifeTime = glob.getLifetime();
    age = 0;
    isDead = false;
    noiseVec.reset();
}
示例#14
0
void CloseFunc()
{
	window.window_handle = -1;
	globals.TakeDown();
	scene.skybox.TakeDown();
	scene.world.TakeDown();
	scene.editor.TakeDown();
}
示例#15
0
void CLOutputMgr::Output() {
  std::ostream &out = get_main_out();
  OutputStructUnionDeclarations(out);

  // Type of message_t, for message passing.
  if (CLOptions::message_passing())
    MessagePassing::OutputMessageType(out);

  Globals *globals = Globals::GetGlobals();
  globals->OutputStructDefinition(out);
  globals->ModifyGlobalVariableReferences();
  globals->AddGlobalStructToAllFunctions();

  OutputForwardDeclarations(out);
  OutputFunctions(out);
  OutputEntryFunction(*globals);
}
示例#16
0
Item* Globals::createSpecialItemVertical(std::string name, unsigned int value)
{
  // 8 est la taille de "Vertical"
  std::string basic_name(name.substr(0, name.size() - 8));
  Item* item(new SpecialItemVertical(basic_name, value));
  item->setTexture(*globals.getTextureManager().getResource(name));
  return item;
}
示例#17
0
    void
    Outro::on_draw()
    {
        if (m_snd_game_exit != NULL)
        {
            if (timer_elapsed() > static_cast<unsigned int>(m_snd_game_exit->length_in_ms) + 100)
            {
                next_state();
            }
        }

        Globals g;

        g.render().DrawTile(0,0, g.values().res_w(), g.values().res_h(), m_img_mainmenu);

        string text1 = g.snd2txt().text();
        string text2 = "";

        if (text1.length() >= 25)
        {
            text2 = text1;
            text1.erase(25, string::npos);
            text2.erase(0, 25);
        }
        g.render().DrawText(500, 400, 1.0, 1.0, 1.0, text1);
        g.render().DrawText(500, 450, 1.0, 1.0, 1.0, text2);
    }
示例#18
0
/**
 * \class na::ViewDragger
 */
ViewDragger::ViewDragger(Globals& g, ds::ui::Sprite& parent)
		: mParent(parent)
		, mMomentum(parent.getEngine())
		, mIsTouchy(false)
		, mReturnTime(g.getSettingsLayout().getFloat("media_viewer:check_bounds:return_time", 0, 0.6f)) {
	mParent.enable(true);
	mParent.enableMultiTouch(ds::ui::MULTITOUCH_INFO_ONLY);
	mParent.setProcessTouchCallback([this](ds::ui::Sprite* bs, const ds::ui::TouchInfo& ti){ onTouched(ti);});

	mMomentum.setMomentumParent(&mParent);
	mMomentum.setMass(8.0f);
	mMomentum.setFriction(0.5f);
}
void Particle::draw() {
    if (!isDead) {
        ofPushStyle();
        ofColor aux;
        aux.r=0;
        aux.g=0;
        aux.b=0;
        aux.a=glob.getPartAlpha();
        ofSetColor(aux);
        ofCircle(pos.x, pos.y, 1-(age/lifeTime));
        ofPopStyle();
    }
}
示例#20
0
    void
    Outro::on_enter()
    {
        Globals g;

        string snd = g.soundlist().get_random_sound(SND_GAME_EXIT);
        m_snd_game_exit = g.sound().load(snd);
        m_img_mainmenu = g.render().LoadTexture(g.images().mainmenu());
        timer_reset();
        timer_start();

        g.sound().play(m_snd_game_exit);
        g.snd2txt().lookup(snd);

        g.render().SetTextSizes(32, 32);
    }
void
ConfigureKeys::draw_grab_key()
{
    Globals g;
    int width  = g.values().res_w();
    int height = g.values().res_h();
    int quarter= width / 4;

    SDL_Rect r = {quarter - 220, 680, width - 2*(quarter-220), 70};

    g.render().FillRect(r, .0, .0, .0, .5f);

    string str = "Press a key for ";

    switch (m_which_player)
    {
        case 0: str += "Player 1!"; break;
        case 1: str += "Player 2!"; break;
    }

    g.render().SetTextSizes(24, 24);
    g.render().DrawText(r, 255, 255, 255, str);
}
void Particle::update() {

    // Use either ofNoise() in case you want to use oF internal Perlin Noise
    // or per.noise() in case you want to use Chris Little's implementation
    //Comment or Uncomment depending on your needs
    // Option 1a, Chris direct ::::
    //Perlin per;
    //noiseFloat = per.noise(pos.x * 0.0025, pos.y * 0.0025, glob.getElapsedFrames() * 0.001);
    // Option 1b, Chris via Globals.h ::::
    noiseFloat = glob.getPerlinNoise(pos.x * 0.0025, pos.y * 0.0025, glob.getElapsedFrames() * 0.001);
    // Option 2, openFrameworks internal ::::
    //noiseFloat = ofNoise(pos.x * 0.0025, pos.y * 0.0025, glob.getElapsedFrames() * 0.001);

    noiseVec.modX((float)(cos(((noiseFloat - 0.3) * (M_PI*2)) * 10)));
    noiseVec.modY((float)(sin(((noiseFloat - 0.3) * (M_PI*2)) * 10)));

    vel.add(noiseVec);
    vel.div(glob.getParSpeedRedFactor());
    pos.add(vel);

    if(1.0-(age/lifeTime) == 0) {
        isDead = true;
    }

    //if we have the lines, respect the space for them
    if (glob.getLinesMode()) {
        if(pos.x < glob.getV0_x() || pos.x > glob.getWid() - glob.getV0_x() || pos.y < 0 || pos.y > glob.getHei()) {
            isDead = true;
            age = lifeTime;
        }
    } else { //else grab the whole screen as limit to kill the particles
        if(pos.x < 0 || pos.x > glob.getWid() || pos.y < 0 || pos.y > glob.getHei()) {
            isDead = true;
            age = lifeTime;
        }
    }

    if(1.0-(age/lifeTime) != 0) {
        age++;
    }
}
示例#23
0
//----------------------------------------------------------------------
void glutInitialize(int tex_size)
{
    //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    //glutInitWindowSize(tex_size, tex_size);
    glutInitWindowSize(1024, 1024);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Quadrics");
    glutKeyboardFunc(keyboard);
	glViewport(0,0, tex_size, tex_size);
    glutIdleFunc(idle);
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);

	g.setWinSize(tex_size, tex_size);
}
示例#24
0
int main(int argc, char * argv[])
{
	globals = Globals();
	srand(int(time(NULL)));

	glutInit(&argc, argv);
	glutInitWindowSize(1024, 512);
	glutInitWindowPosition(0, 0);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH);

	window.window_handle = glutCreateWindow("Mitchell Lutzke and Joe Klonowski - CS559 - UW-Madison");
	glutReshapeFunc(ReshapeFunc);
	glutCloseFunc(CloseFunc);
	glutDisplayFunc(DisplayFunc);
	glutKeyboardFunc(KeyboardFunc);
	glutSpecialFunc(SpecialFunc);
	glutTimerFunc(window.interval, TimerFunc, 16);
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);

	if (glewInit() != GLEW_OK)
	{
		cerr << "GLEW failed to initialize." << endl;
		return 0;
	}

	ilInit();
	iluInit();
	ilutInit();
	ilutRenderer(ILUT_OPENGL);

	globals.Initialize();

	window.controller = new Controller();

	if(! scene.skybox.Initialize())
		return -1;

	if(! scene.editor.Initialize(window.size))
		return -1;

	if(! scene.world.Initialize(ivec2(1024, 512)))
		return -1;
	
	glutMainLoop();

	return 0;
}
示例#25
0
文件: hook.cpp 项目: byplayer/yamy
static LRESULT CALLBACK lowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    if (!g.m_isInitialized)
        initialize(false);

    if (!g_hookData || nCode < 0)
        goto through;

    if (g.m_mouseDetour && g.m_engine) {
        unsigned int result;
        result = g.m_mouseDetour(g.m_engine, wParam, lParam);
        if (result) {
            return 1;
        }
    }

through:
    return CallNextHookEx(g.m_hHookMouseProc,
                          nCode, wParam, lParam);
}
示例#26
0
文件: hook.cpp 项目: byplayer/yamy
static LRESULT CALLBACK lowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    KBDLLHOOKSTRUCT *pKbll = (KBDLLHOOKSTRUCT*)lParam;

    if (!g.m_isInitialized)
        initialize(false);

    if (!g_hookData || nCode < 0)
        goto through;

    if (g.m_keyboardDetour && g.m_engine) {
        unsigned int result;
        result = g.m_keyboardDetour(g.m_engine, wParam, lParam);
        if (result) {
            return 1;
        }
    }
through:
    return CallNextHookEx(g.m_hHookKeyboardProc,
                          nCode, wParam, lParam);
}
示例#27
0
//----------------------------------------------------------------------
int main(int argc, char** argv)
{
	//int tex_size = 4096;
	int tex_size = 2048;
	//int tex_size = 1024;

    glutInit(&argc, argv);
    glutInitialize(tex_size);
	//initializeEnvironment();
	glDisable(GL_BLEND);

  	glewInit();
	setupObjects(tex_size);
	init_shaders();
	g.disableShaders();  // disable shaders


    glutMainLoop();

    return 0;
}
void
ConfigureKeys::on_draw()
{
#ifndef DISABLE_LIBSIGC
    Globals g;

    // background image
    g.render().DrawTile(0, 0, g.values().res_w(), g.values().res_h(), m_bg);

    int width  = g.values().res_w();
    int half   = width / 2;
    int quarter= width / 4;

    SDL_Rect top = {quarter - 220, 80, width - 2*(quarter-220), 80};
    SDL_Rect rl  = {quarter - 220, 170, half - 50, 500};
    SDL_Rect rr  = {half + (half -(quarter - 220 + (half - 50))), 170, half - 50, 500};

    g.render().FillRect(top,.0, .0, .0, 0.5f);
    g.render().FillRect(rl ,.0, .0, .0, 0.5f);
    g.render().FillRect(rr ,.0, .0, .0, 0.5f);

    m_con_active.draw_all();
    m_con_passive.draw_all();

    draw_player_keys();

    m_anim_bomb.Update();

    if (mb_grab_key)
    {
        draw_grab_key();
        m_anim_bomb.Draw(quarter - 185, 740, 50, 50);
        m_anim_bomb.Draw(quarter - 220 + (width - 2*(quarter-220)) - 45, 740, 50, 50);
    }
    else
    {
        int index = m_con_active.current_focused();
        m_anim_bomb.Draw(quarter-145 + 512*(index>5?1:0), 142 + 75*((index>5?(index-6):index)+1), 50, 50);
    }
#endif // DISABLE_LIBSIGC
}
void
ConfigureKeys::on_enter()
{
#ifndef DISABLE_LIBSIGC
    Globals g;

    SDL_EnableKeyRepeat(g.values().get(VAL_MENU_KEYREPEAT_DELAY), g.values().get(VAL_MENU_KEYREPEAT_INTERVAL));

    create_key_map();
    create_gui();

    mb_grab_key = false;
    m_which_player = 0;

    m_bg = g.render().LoadTexture(g.images().background_random());

    m_anim_bomb.SetAnimation(ANI_BOMB);
    m_anim_bomb.Start();

    mp_keyconfig    = &g.keycfg();

    g.render().SetTextSizes(16, 16);
#endif // DISABLE_LIBSIGC
}
示例#30
0
Globals* SceneLoader:: loadGlobals(TiXmlElement *globalElement){
	Globals* globals = new Globals();
	return globals->loadAttributes(globalElement);
}