本文整理汇总了C++中Input类的典型用法代码示例。如果您正苦于以下问题:C++ Input类的具体用法?C++ Input怎么用?C++ Input使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Input类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDataNum
bool Input::operator!= (const Input & rhs) const
{
return getDataNum() != rhs.getDataNum();
}
示例2: Execute
void Delete::Execute()
{
Input *pIn = pManager->GetInput();
Output *pOut = pManager->GetOutput();
//Get List of selected statements
list<Statement*> SelectedStatements = pManager->GetSelectedStatements();
list<Connector*> SelectedConnectors = pManager->GetSelectedConnectors();
Point TempP;
//list<Connector*>ConnList = pManager->GetConnList();
//Print Message and Wait for any click
pOut->PrintMessage("Delete: Deleting Selected Statements if any, press any key to continue");
pIn->GetPointClicked(TempP);
for (list<Connector*>::iterator it = SelectedConnectors.begin(); it != SelectedConnectors.end(); it++)
{
pManager->DeleteConnector((*it));
}
list<Connector*>ConnList = pManager->GetConnList();
for (list<Statement*>::iterator it = SelectedStatements.begin(); it != SelectedStatements.end(); it++)
{
//Delete Input Connectors
if ((*it)->GetStatementType() != 0 || ((*it)->GetStatementType() == 0 && ((StartEnd*)(*it))->GetMode() == true))
{
list<Connector*> InputConnectors;
for (list<Connector*>::iterator itConn = ConnList.begin(); itConn != ConnList.end(); itConn++)
{
if ((*itConn)->getDstStat() == (*it))
InputConnectors.push_back((*itConn));
}
for (list<Connector*>::iterator itConn = InputConnectors.begin(); itConn != InputConnectors.end(); itConn++)
{
/*
if ((*itConn)->getSrcStat()->GetpConn == (*itConn))
(*itConn)->getSrcStat()->SetpConn(NULL);
else if (((Conditional*)(*itConn)->getSrcStat())->GetpConnL() == (*itConn))
((Conditional*)(*itConn)->getSrcStat())->SetpConnL(NULL);
*/
if ((*itConn)->GetBranchType() == 2)
((Conditional*)(*itConn)->getSrcStat())->SetpConnL(NULL);
else
(*itConn)->getSrcStat()->SetpConn(NULL);
pManager->DeleteConnector((*itConn));
}
}
//Conditional
if ((*it)->GetStatementType() == 3)
{
//Yes
if (((Conditional*)(*it))->GetpConn() != NULL)
pManager->DeleteConnector(((Conditional*)(*it))->GetpConn());
//No
if (((Conditional*)(*it))->GetpConnL() != NULL)
pManager->DeleteConnector(((Conditional*)(*it))->GetpConnL());
}
else //Not Conditional
{
if ((*it)->GetpConn() != NULL)
pManager->DeleteConnector((*it)->GetpConn());
}
pManager->DeleteStatement((*it));
}
pOut->PrintMessage("");
pOut->ClearDrawArea();
pManager->UpdateInterface();
}
示例3: eventLoop
/* Main game event loop.
* Runs at 60 Hz.
* Handles inputs
* Update sprites
* Check collisions
* Draw Screen */
void Game::eventLoop() {
Graphics graphics;
Input input;
SDL_Event event;
player_ = new Player(graphics, 400, 300);
map_ = Map::createMap(graphics);
bool running = true;
while (running) {
const int start_time_ms = SDL_GetTicks();
input.beginNewFrame();
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
input.keyDownEvent(event);
break;
case SDL_KEYUP:
input.keyUpEvent(event);
break;
default:
break;
}
}
/* Exit the game */
if (input.wasKeyPressed(SDLK_ESCAPE)) {
running = false;
}
/* Player Movement */
if (input.isKeyHeld(SDLK_UP) && input.isKeyHeld(SDLK_DOWN)) {
player_->stopMovingVertically();
}
else if (input.isKeyHeld(SDLK_UP)) {
player_->startMovingUp();
}
else if (input.isKeyHeld(SDLK_DOWN)) {
player_->startMovingDown();
}
else {
player_->stopMovingVertically();
}
if (input.isKeyHeld(SDLK_LEFT) && input.isKeyHeld(SDLK_RIGHT)) {
player_->stopMovingHorizontally();
} else if (input.isKeyHeld(SDLK_LEFT)) {
player_->startMovingLeft();
} else if (input.isKeyHeld(SDLK_RIGHT)) {
player_->startMovingRight();
} else {
player_->stopMovingHorizontally();
}
if (input.isKeyHeld(SDLK_RSHIFT)) {
player_->setRunning(true);
}
else {
player_->setRunning(false);
}
/* Update locations */
update(20);
/* Draw to the screen */
draw(graphics);
/* Keep the game running at max 60 fps */
const int delay = 1000 / FPS - (SDL_GetTicks() - start_time_ms);
if (delay > 0) {
SDL_Delay(delay);
}
}
}
示例4: GeoState_readLocalData
bool GeoState_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
// note, StateSet replaced GeoState April 2001.
StateSet& statset = static_cast<StateSet&>(obj);
statset.setRenderingHint(StateSet::OPAQUE_BIN);
StateAttribute::GLModeValue mode;
if (fr[0].matchWord("transparency") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
if (mode&StateAttribute::ON)
{
statset.setRenderingHint(StateSet::TRANSPARENT_BIN);
}
statset.setMode(GL_BLEND,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("antialiasing") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
// what is the OpenGL modes for antialissing, need to look up.
// statset.setMode(GeoState::ANTIALIAS,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("face_culling") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setMode(GL_CULL_FACE,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("lighting") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setMode(GL_LIGHTING,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("texturing") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setTextureMode(0,GL_TEXTURE_2D,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("fogging") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setMode(GL_FOG,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("colortable") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
// what is the OpenGL modes for colortable, need to look up...
// statset.setMode(GeoState::COLORTABLE,mode);
fr+=2;
iteratorAdvanced = true;
}
StateAttribute::GLModeValue texgening = StateAttribute::OFF;
if (fr[0].matchWord("texgening") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
// leave up to a tex gen object to set modes associated with TexGen
// as there are mutiple modes associated with TexGen. See below
// attribute reading code.
texgening = mode;
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("point_smoothing") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setMode(GL_POINT_SMOOTH,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("polygon_offset") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
// no GL mode associated with polygon offset so commenting out.
// statset.setMode(GeoState::POLYGON_OFFSET,mode);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("alpha_test") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
statset.setMode(GL_ALPHA_TEST,mode);
fr+=2;
iteratorAdvanced = true;
}
//.........这里部分代码省略.........
示例5: TEST_CASE
#include "green/GreenData.hpp"
#include "interface/Input.hpp"
#include "solver/SolverData.hpp"
#include "utils/Sphere.hpp"
using pcm::Input;
using pcm::utils::Sphere;
/*! \class Input
* \test \b InputRestartTest_Restart tests input reading on an input file parsed by
* go_pcm.py
*/
TEST_CASE("Input reading using GetKw for an input file for a restart cavity",
"[input][input_restart]") {
std::string filename = "@restart.inp";
Input parsedInput = Input(filename);
std::string units = "AU";
int CODATAyear = 2010;
std::string cavityType = "RESTART";
std::string cavFilename = "cavity.npz";
double area = 0.3;
bool scaling = true;
std::string radiiSet = "BONDI";
double minimalRadius = 100.0;
double diagonalScaling = 1.07;
std::string mode = "IMPLICIT";
std::string solvent = "Water"; // Name in the Solvent object
std::string solverType = "IEFPCM";
double correction = 0.0;
bool hermitivitize = true;
double probeRadius = 1.385 * angstromToBohr(); // The value for water
示例6: apply
static void apply( const Input& in, state1& s )
{
assert( in.size() == 1 );
s.c = in.begin()[ 0 ];
}
示例7: f
//.........这里部分代码省略.........
(*valiter) >> val;
phases.insert(val);
}
// 5. label
node = (*region).FindValue("label");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- region"
<< name << "has no label";
std::string label;
*node >> label;
Region *r = addRegionFromBundle(name, nodeType, dimensions, fullPath, label);
setPhases_(r, phases);
}
const YAML::Node *links = doc.FindValue("Links");
if (links == NULL)
NTA_THROW << "Invalid network structure file -- no links";
if (links->Type() != YAML::NodeType::Sequence)
NTA_THROW << "Invalid network structure file -- links element is not a list";
for (YAML::Iterator link = links->begin(); link != links->end(); link++)
{
// Each link is a map -- extract the 5 values in the map
if ((*link).Type() != YAML::NodeType::Map)
NTA_THROW << "Invalid network structure file -- bad link (not a map)";
if ((*link).size() != 6)
NTA_THROW << "Invalid network structure file -- bad link (wrong size)";
// 1. type
node = (*link).FindValue("type");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have a type";
std::string linkType;
*node >> linkType;
// 2. params
node = (*link).FindValue("params");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have params";
std::string params;
*node >> params;
// 3. srcRegion (name)
node = (*link).FindValue("srcRegion");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have a srcRegion";
std::string srcRegionName;
*node >> srcRegionName;
// 4. srcOutput
node = (*link).FindValue("srcOutput");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have a srcOutput";
std::string srcOutputName;
*node >> srcOutputName;
// 5. destRegion
node = (*link).FindValue("destRegion");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have a destRegion";
std::string destRegionName;
*node >> destRegionName;
// 6. destInput
node = (*link).FindValue("destInput");
if (node == NULL)
NTA_THROW << "Invalid network structure file -- link does not have a destInput";
std::string destInputName;
*node >> destInputName;
if (!regions_.contains(srcRegionName))
NTA_THROW << "Invalid network structure file -- link specifies source region '" << srcRegionName << "' but no such region exists";
Region* srcRegion = regions_.getByName(srcRegionName);
if (!regions_.contains(destRegionName))
NTA_THROW << "Invalid network structure file -- link specifies destination region '" << destRegionName << "' but no such region exists";
Region* destRegion = regions_.getByName(destRegionName);
Output* srcOutput = srcRegion->getOutput(srcOutputName);
if (srcOutput == NULL)
NTA_THROW << "Invalid network structure file -- link specifies source output '" << srcOutputName << "' but no such name exists";
Input* destInput = destRegion->getInput(destInputName);
if (destInput == NULL)
NTA_THROW << "Invalid network structure file -- link specifies destination input '" << destInputName << "' but no such name exists";
// Create the link itself
destInput->addLink(linkType, params, srcOutput);
} // links
}
示例8: Texture_readLocalData
bool Texture_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
Texture& texture = static_cast<Texture&>(obj);
Texture::WrapMode wrap;
if (fr[0].matchWord("wrap_s") && Texture_matchWrapStr(fr[1].getStr(),wrap))
{
texture.setWrap(Texture::WRAP_S,wrap);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("wrap_t") && Texture_matchWrapStr(fr[1].getStr(),wrap))
{
texture.setWrap(Texture::WRAP_T,wrap);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("wrap_r") && Texture_matchWrapStr(fr[1].getStr(),wrap))
{
texture.setWrap(Texture::WRAP_R,wrap);
fr+=2;
iteratorAdvanced = true;
}
Texture::FilterMode filter;
if (fr[0].matchWord("min_filter") && Texture_matchFilterStr(fr[1].getStr(),filter))
{
texture.setFilter(Texture::MIN_FILTER,filter);
fr+=2;
iteratorAdvanced = true;
}
if (fr[0].matchWord("mag_filter") && Texture_matchFilterStr(fr[1].getStr(),filter))
{
texture.setFilter(Texture::MAG_FILTER,filter);
fr+=2;
iteratorAdvanced = true;
}
if (fr.matchSequence("maxAnisotropy %f"))
{
float anis=1.0f;
fr[1].getFloat(anis);
texture.setMaxAnisotropy(anis);
fr +=2 ;
iteratorAdvanced = true;
}
if (fr.matchSequence("borderColor %f %f %f %f"))
{
Vec4 color;
fr[1].getFloat(color[0]);
fr[2].getFloat(color[1]);
fr[3].getFloat(color[2]);
fr[4].getFloat(color[3]);
texture.setBorderColor(color);
fr +=5 ;
iteratorAdvanced = true;
}
if (fr.matchSequence("borderWidth %i"))
{
int width=0;
fr[1].getInt(width);
texture.setBorderWidth(width);
fr +=2 ;
iteratorAdvanced = true;
}
if (fr[0].matchWord("useHardwareMipMapGeneration"))
{
if (fr[1].matchWord("TRUE"))
{
texture.setUseHardwareMipMapGeneration(true);
fr +=2 ;
iteratorAdvanced = true;
}
else if (fr[1].matchWord("FALSE"))
{
texture.setUseHardwareMipMapGeneration(false);
fr +=2 ;
iteratorAdvanced = true;
}
}
if (fr[0].matchWord("unRefImageDataAfterApply"))
{
if (fr[1].matchWord("TRUE"))
{
texture.setUnRefImageDataAfterApply(true);
fr +=2 ;
iteratorAdvanced = true;
}
else if (fr[1].matchWord("FALSE"))
{
texture.setUnRefImageDataAfterApply(false);
//.........这里部分代码省略.........
示例9: OverlayNode_readLocalData
bool OverlayNode_readLocalData(Object &obj, Input &fr)
{
bool iteratorAdvanced = false;
OverlayNode &es = static_cast<OverlayNode&>(obj);
if (fr.matchSequence("technique"))
{
if (fr[1].matchWord("OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY"))
{
es.setOverlayTechnique(OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
iteratorAdvanced = true;
fr += 2;
}
else if (fr[1].matchWord("VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY"))
{
es.setOverlayTechnique(OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
iteratorAdvanced = true;
fr += 2;
}
else if (fr[1].matchWord("VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY"))
{
es.setOverlayTechnique(OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY);
iteratorAdvanced = true;
fr += 2;
}
}
osg::Vec4 vec4(0.0f, 0.0f, 0.0f, 1.0f);
if (fr[0].matchWord("clear_color") &&
fr[1].getFloat(vec4[0]) &&
fr[2].getFloat(vec4[1]) &&
fr[3].getFloat(vec4[2]) &&
fr[4].getFloat(vec4[3]))
{
es.setOverlayClearColor(vec4);
fr += 5;
iteratorAdvanced = true;
}
if (fr[0].matchWord("texture_size_hint"))
{
if (fr[1].isUInt())
{
unsigned int value = 0;
fr[1].getUInt(value);
es.setOverlayTextureSizeHint(value);
iteratorAdvanced = true;
fr += 2;
}
}
if (fr[0].matchWord("texture_unit"))
{
if (fr[1].isUInt())
{
unsigned int value = 0;
fr[1].getUInt(value);
es.setOverlayTextureUnit(value);
iteratorAdvanced = true;
fr += 2;
}
}
if (fr[0].matchWord("subgraph"))
{
fr += 1;
es.setOverlaySubgraph(fr.readNode());
iteratorAdvanced = true;
}
return iteratorAdvanced;
}
示例10: configure
virtual bool configure(ResourceFinder &rf)
{
string slash="/";
string ctrlName;
string robotName;
string partName;
string remoteName;
string localName;
Time::turboBoost();
// get params from the RF
ctrlName=rf.check("local",Value("fakeMobileBaseTest")).asString();
robotName=rf.check("robot",Value("fakeRobot")).asString();
partName = rf.check("part", Value("mobile_base")).asString();
bool holonomic = rf.check("holonomic");
if (holonomic) yInfo() << "Robot is holonomic";
else yInfo() << "Robot is not holonomic";
remoteName=slash+robotName+slash+partName;
localName=slash+ctrlName;
//reads the configuration file
Property ctrl_options;
ConstString configFile=rf.findFile("from");
if (configFile=="") //--from fakeMobileBaseTest.ini
{
yWarning("Cannot find .ini configuration file. By default I'm searching for fakeMobileBaseTest.ini");
// return false;
}
else
{
ctrl_options.fromConfigFile(configFile.c_str());
}
ctrl_options.put("remote", remoteName.c_str());
ctrl_options.put("local", localName.c_str());
int rc_count =0;
int rp_count =0;
int rf_count =0;
double start_time=yarp::os::Time::now();
bool not_yet_connected=true;
//set the thread rate
int period = rf.check("period",Value(20)).asInt();
yInfo("fakeMobileBaseTest thread rate: %d ms.",period);
//GENERAL options
yarp::os::Bottle general_options;
if (ctrl_options.check("GENERAL"))
{
general_options = ctrl_options.findGroup("GENERAL");
}
else
{
yError() << "Missing general_options section";
return false;
}
//initialize ROS
bool useRos = general_options.check("use_ROS", Value(false), "enable ROS communications").asBool();
if(useRos)
{
if (ctrl_options.check("ROS_GENERAL"))
{
string rosNodeName;
yarp::os::Bottle r_group = ctrl_options.findGroup("ROS_GENERAL");
if (r_group.check("node_name") == false)
{
yError() << "Missing node_name parameter"; return false;
}
rosNodeName = r_group.find("node_name").asString();
rosNode = new yarp::os::Node(rosNodeName);
yarp::os::Time::delay(0.1);
}
else
{
yError() << "[ROS_GENERAL] group is missing from configuration file. ROS communication will not be initialized";
}
}
//creates the input
input = new Input();
if (input->open(rf, ctrl_options) ==false)
{
yError() << "Module failed to launch";
return false;
}
//creates the controller
control = new Controller();
if (control->init(holonomic) == false)
{
yError() << "Module failed to launch";
return false;
}
if (ctrl_options.check("ODOMETRY_ERROR"))
//.........这里部分代码省略.........
示例11: SDL_handleEvent
void SDL_handleEvent(SDL_Event &event, bool &done)
{
Input *input = &Input::instance;
#ifndef EMSCRIPTEN
SDL_Window *wnd = SDL_GetWindowFromID(event.window.windowID);
void *data = SDL_GetWindowData(wnd, "_");
spStage stage = (Stage*)data;
#else
spStage stage = getStage();
#endif
if (!stage)
stage = getStage();
Event ev(Input::event_platform);
ev.userData = &event;
Input::instance.dispatchEvent(&ev);
switch (event.type)
{
case SDL_QUIT:
done = true;
break;
case SDL_WINDOWEVENT:
{
/*
if (event.window.event == SDL_WINDOWEVENT_ENTER)
active = false;
if (event.window.event == SDL_WINDOWEVENT_LEAVE)
active = true;
*/
if (event.window.event == SDL_WINDOWEVENT_MINIMIZED)
active = false;
if (event.window.event == SDL_WINDOWEVENT_RESTORED)
active = true;
bool newFocus = focus;
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
newFocus = false;
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
newFocus = true;
if (focus != newFocus)
{
focus = newFocus;
#if HANDLE_FOCUS_LOST
if (focus)
focusAcquired();
log::messageln("focus: %d", (int)focus);
Event ev(focus ? Stage::ACTIVATE : Stage::DEACTIVATE);
if (stage)
stage->dispatchEvent(&ev);
if (!focus)
focusLost();
#endif
}
//log::messageln("SDL_SYSWMEVENT %d", (int)event.window.event);
break;
}
case SDL_MOUSEWHEEL:
input->sendPointerWheelEvent(stage, event.wheel.y, &input->_pointerMouse);
break;
case SDL_KEYDOWN:
{
KeyEvent ev(KeyEvent::KEY_DOWN, &event.key);
stage->dispatchEvent(&ev);
} break;
case SDL_KEYUP:
{
KeyEvent ev(KeyEvent::KEY_UP, &event.key);
stage->dispatchEvent(&ev);
} break;
#if SDL_VIDEO_OPENGL
case SDL_MOUSEMOTION:
input->sendPointerMotionEvent(stage, (float)event.motion.x, (float)event.motion.y, 1.0f, &input->_pointerMouse);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
MouseButton b = MouseButton_Left;
switch (event.button.button)
{
case 1: b = MouseButton_Left; break;
case 2: b = MouseButton_Middle; break;
case 3: b = MouseButton_Right; break;
}
input->sendPointerButtonEvent(stage, b, (float)event.button.x, (float)event.button.y, 1.0f,
event.type == SDL_MOUSEBUTTONDOWN ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP, &input->_pointerMouse);
}
break;
#else
case SDL_FINGERMOTION:
{
//log::messageln("SDL_FINGERMOTION");
//.........这里部分代码省略.........
示例12: _tWinMain
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
Engine::Init();
Input input;
input.Init();
Window window;
window.Init(800, 600, "killerg2d");
ResMgr resmgr;
resmgr.Init();
FrameRate framerate;
framerate.Init(600);
Timer timer;
timer.Init();
SpiritAnimate spirit;
spirit.Init("abc.txt");
int x = 100, y = 100;
int model = 0;
while( !input.IsKeyDown(SDLK_ESCAPE) )
{
timer.Update();
input.Update();
if( input.IsKeyDown(SDLK_LEFT) )
x-=1;
if( input.IsKeyDown(SDLK_RIGHT) )
x+=1;
if( input.IsKeyDown(SDLK_UP) )
y-=1;
if( input.IsKeyDown(SDLK_DOWN) )
y+=1;
if( input.IsKeyDown(SDLK_x) )
spirit.Play();
if( input.IsKeyDown(SDLK_y) )
spirit.Stop();
spirit.Update(timer.GetIntervalF());
window.Clear();
spirit.Draw(&window, x, y);
window.Flush();
framerate.WaitFrame();
}
timer.Destroy();
framerate.Destroy();
resmgr.Destroy();
window.Destroy();
input.Destroy();
Engine::Destroy();
}
示例13: peek
static pair_t peek( Input& in, const std::size_t o = 0 ) noexcept( noexcept( in.Input::peek_char( 0 ) ) )
{
return { in.peek_char( o ), 1 };
}
示例14: mainLoop
void Game::mainLoop() {
Input input;
bool running = true;
SDL_Event event;
units::MS previous_time = SDL_GetTicks();
creation_countdown_ = 1500 + rand() % 250;
while (running) {
{ // Collect input
input.beginFrame();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = false;
}
if (event.type == SDL_KEYDOWN && event.key.repeat == false) {
input.keyDown(event.key);
} else if (event.type == SDL_KEYUP) {
input.keyUp(event.key);
}
}
}
{ // Handle input
if (input.wasKeyPressed(SDL_SCANCODE_ESCAPE)) {
running = false;
}
const float kMoveAmount = 0.2f;
if (input.isKeyHeld(SDL_SCANCODE_W)) {
camera_.translateForward(kMoveAmount);
} else if (input.isKeyHeld(SDL_SCANCODE_S)) {
camera_.translateForward(-kMoveAmount);
}
if (input.isKeyHeld(SDL_SCANCODE_A)) {
camera_.translateStrafe(-kMoveAmount);
} else if (input.isKeyHeld(SDL_SCANCODE_D)) {
camera_.translateStrafe(kMoveAmount);
}
const float kAngle = 5.0f;
if (input.isKeyHeld(SDL_SCANCODE_LEFT)) {
camera_.rotateYaw(kAngle);
} else if (input.isKeyHeld(SDL_SCANCODE_RIGHT)) {
camera_.rotateYaw(-kAngle);
}
if (input.isKeyHeld(SDL_SCANCODE_UP)) {
camera_.rotatePitch(-kAngle);
} else if (input.isKeyHeld(SDL_SCANCODE_DOWN)) {
camera_.rotatePitch(kAngle);
}
if (input.wasKeyPressed(SDL_SCANCODE_P)) {
std::cout << "Objects: " << game_objects_.size() << std::endl;
std::cout << "Captures: " << score_ << std::endl;
std::cout << "FPS: " << fps_ << std::endl;
}
}
{
const units::MS current_time = SDL_GetTicks();
const units::MS dt = current_time - previous_time;
step(dt);
previous_time = current_time;
fps_ = 1000.0f / dt;
}
{
draw();
engine_.swapWindow();
}
SDL_Delay(5);
}
}
示例15: findCandidates
void IdenticalCodeFolding::foldIdenticalCode()
{
// 1. Find folding candidates.
FoldingCandidates candidate_list;
findCandidates(candidate_list);
// 2. Initialize constant section content
for (size_t i = 0; i < candidate_list.size(); ++i) {
candidate_list[i].initConstantContent(m_Backend, m_KeptSections);
}
// 3. Find identical code until convergence
bool converged = false;
size_t iterations = 0;
while (!converged && (iterations < m_Config.options().getICFIterations())) {
converged = matchCandidates(candidate_list);
++iterations;
}
if (m_Config.options().printICFSections()) {
debug(diag::debug_icf_iterations) << iterations;
}
// 4. Fold the identical code
typedef std::set<Input*> FoldedObjects;
FoldedObjects folded_objs;
KeptSections::iterator kept, keptEnd = m_KeptSections.end();
size_t index = 0;
for (kept = m_KeptSections.begin(); kept != keptEnd; ++kept, ++index) {
LDSection* sect = (*kept).first;
Input* obj = (*kept).second.first;
size_t kept_index = (*kept).second.second;
if (index != kept_index) {
sect->setKind(LDFileFormat::Folded);
folded_objs.insert(obj);
if (m_Config.options().printICFSections()) {
KeptSections::iterator it = m_KeptSections.begin() + kept_index;
LDSection* kept_sect = (*it).first;
Input* kept_obj = (*it).second.first;
debug(diag::debug_icf_folded_section) << sect->name()
<< obj->name()
<< kept_sect->name()
<< kept_obj->name();
}
}
}
// Adjust the fragment reference of the folded symbols.
FoldedObjects::iterator fobj, fobjEnd = folded_objs.end();
for (fobj = folded_objs.begin(); fobj != fobjEnd; ++fobj) {
LDContext::sym_iterator sym, symEnd = (*fobj)->context()->symTabEnd();
for (sym = (*fobj)->context()->symTabBegin(); sym != symEnd; ++sym) {
if ((*sym)->hasFragRef() && ((*sym)->type() == ResolveInfo::Function)) {
LDSymbol* out_sym = (*sym)->resolveInfo()->outSymbol();
FragmentRef* frag_ref = out_sym->fragRef();
LDSection* sect = &(frag_ref->frag()->getParent()->getSection());
if (sect->kind() == LDFileFormat::Folded) {
size_t kept_index = m_KeptSections[sect].second;
LDSection* kept_sect =
(*(m_KeptSections.begin() + kept_index)).first;
frag_ref->assign(kept_sect->getSectionData()->front(),
frag_ref->offset());
}
}
} // for each symbol
} // for each folded object
}