本文整理汇总了C++中sgct::SharedBool类的典型用法代码示例。如果您正苦于以下问题:C++ SharedBool类的具体用法?C++ SharedBool怎么用?C++ SharedBool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedBool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myPostSyncPreDrawFun
void myPostSyncPreDrawFun()
{
if (takeScreenshot.getVal())
{
gEngine->takeScreenshot();
takeScreenshot.setVal(false);
}
}
示例2: myPreSyncFun
void myPreSyncFun()
{
if( gEngine->isMaster() )
{
curr_time.setVal( sgct::Engine::getTime() );
//if texture is uploaded then iterate the index
if (serverUploadDone.getVal() && clientsUploadDone.getVal())
{
texIndex++;
serverUploadDone = false;
clientsUploadDone = false;
}
}
}
示例3: myPostSyncPreDrawFun
void myPostSyncPreDrawFun()
{
if( reloadShader.getVal() )
{
reloadShader.setVal(false); //reset
sgct::ShaderProgram sp = sgct::ShaderManager::instance()->getShaderProgram( "xform" );
sp.reload();
//reset location variables
sgct::ShaderManager::instance()->bindShaderProgram( "xform" );
time_loc = sgct::ShaderManager::instance()->getShaderProgram( "xform").getUniformLocation( "curr_time" );
matrix_loc = sgct::ShaderManager::instance()->getShaderProgram( "xform").getUniformLocation( "MVP" );
sgct::ShaderManager::instance()->unBindShaderProgram();
}
}
示例4: keyCallback
void keyCallback(int key, int action)
{
if( gEngine->isMaster() )
{
switch( key )
{
case 'S':
if(action == SGCT_PRESS)
stats.toggle();
break;
case 'I':
if(action == SGCT_PRESS)
info.toggle();
break;
case 'L':
if(action == SGCT_PRESS)
light.toggle();
break;
case 'W':
if(action == SGCT_PRESS)
wireframe.toggle();
break;
case 'Q':
if(action == SGCT_PRESS)
gEngine->terminate();
break;
case 'P':
case SGCT_KEY_F10:
if(action == SGCT_PRESS)
takeScreenshot.setVal( true );
break;
case SGCT_KEY_UP:
arrowButtons[FORWARD] = ((action == SGCT_REPEAT || action == SGCT_PRESS) ? true : false);
break;
case SGCT_KEY_DOWN:
arrowButtons[BACKWARD] = ((action == SGCT_REPEAT || action == SGCT_PRESS) ? true : false);
break;
}
}
}
示例5: myEncodeFun
void myEncodeFun()
{
sgct::SharedData::instance()->writeDouble(&curr_time);
sharedSpeed.setVal(speed);
sgct::SharedData::instance()->writeFloat(&sharedSpeed);
sharedTextureOnOff.setVal(use_texture);
sgct::SharedData::instance()->writeBool(&sharedTextureOnOff);
sharedClearColor.setVal(glm::vec3(clear_color.x, clear_color.y, clear_color.z));
sgct::SharedData::instance()->writeObj(&sharedClearColor);
}
示例6: myDecodeFun
void myDecodeFun()
{
sgct::SharedData::instance()->readDouble(&curr_time);
sgct::SharedData::instance()->readFloat(&sharedSpeed);
speed = sharedSpeed.getVal();
sgct::SharedData::instance()->readBool(&sharedTextureOnOff);
use_texture = sharedTextureOnOff.getVal();
sgct::SharedData::instance()->readObj(&sharedClearColor);
clear_color.x = sharedClearColor.getVal().x;
clear_color.y = sharedClearColor.getVal().y;
clear_color.z = sharedClearColor.getVal().z;
}
示例7: keyCallback
void keyCallback(int key, int action)
{
if( gEngine->isMaster() )
{
switch( key )
{
case SGCT_KEY_R:
if(action == SGCT_PRESS)
reloadShader.setVal(true);
break;
}
}
}
示例8: main
int main( int argc, char* argv[] )
{
//sgct::MessageHandler::instance()->setNotifyLevel(sgct::MessageHandler::NOTIFY_ALL);
gEngine = new sgct::Engine( argc, argv );
/*imagePaths.addVal( std::pair<std::string, int>("test_00.jpg", IM_JPEG) );
imagePaths.addVal( std::pair<std::string, int>("test_01.png", IM_PNG) );
imagePaths.addVal( std::pair<std::string, int>("test_02.jpg", IM_JPEG) );*/
gEngine->setInitOGLFunction( myInitOGLFun );
gEngine->setDrawFunction( myDrawFun );
gEngine->setPreSyncFunction( myPreSyncFun );
gEngine->setPostSyncPreDrawFunction(myPostSyncPreDrawFun);
gEngine->setCleanUpFunction( myCleanUpFun );
gEngine->setKeyboardCallbackFunction(keyCallback);
gEngine->setContextCreationCallback( contextCreationCallback );
gEngine->setDropCallbackFunction(myDropCallback);
if( !gEngine->init( sgct::Engine::OpenGL_3_3_Core_Profile ) )
{
delete gEngine;
return EXIT_FAILURE;
}
gEngine->setDataTransferCallback(myDataTransferDecoder);
gEngine->setDataTransferStatusCallback(myDataTransferStatus);
gEngine->setDataAcknowledgeCallback(myDataTransferAcknowledge);
//gEngine->setDataTransferCompression(true, 6);
//sgct::SharedData::instance()->setCompression(true);
sgct::SharedData::instance()->setEncodeFunction(myEncodeFun);
sgct::SharedData::instance()->setDecodeFunction(myDecodeFun);
// Main loop
gEngine->render();
running.setVal(false);
if (loadThread)
{
loadThread->join();
delete loadThread;
}
// Clean up
delete gEngine;
// Exit program
exit( EXIT_SUCCESS );
}
示例9: threadWorker
void threadWorker(void *arg)
{
while (running.getVal())
{
//runs only on master
if (transfer.getVal() && !serverUploadDone.getVal() && !clientsUploadDone.getVal())
{
startDataTransfer();
transfer.setVal(false);
//load texture on master
uploadTexture();
serverUploadDone = true;
if(sgct_core::ClusterManager::instance()->getNumberOfNodes() == 1) //no cluster
{
clientsUploadDone = true;
}
}
sgct::Engine::sleep(0.1); //ten iteration per second
}
}
示例10: keyCallback
void keyCallback(int key, int action)
{
if (gEngine->isMaster())
{
switch (key)
{
case SGCT_KEY_S:
if (action == SGCT_PRESS)
stats.toggle();
break;
case SGCT_KEY_I:
if (action == SGCT_PRESS)
info.toggle();
break;
/*case SGCT_KEY_SPACE:
if (action == SGCT_PRESS)
transfer.setVal(true);
break;*/
}
}
}
示例11: keyCallback
void keyCallback(int key, int action)
{
if (gEngine->isMaster())
{
switch (key)
{
case SGCT_KEY_P:
case SGCT_KEY_F10:
if (action == SGCT_PRESS)
takeScreenshot.setVal(true);
break;
}
}
}
示例12: myDropCallback
void myDropCallback(int count, const char** paths)
{
if (gEngine->isMaster())
{
std::size_t found;
//simpy pick the first path to transmit
std::string tmpStr(paths[0]);
//transform to lowercase
std::transform(tmpStr.begin(), tmpStr.end(), tmpStr.begin(), ::tolower);
found = tmpStr.find(".jpg");
if (found != std::string::npos)
{
imagePaths.addVal(std::pair<std::string, int>(paths[0], IM_JPEG));
transfer.setVal(true);
return;
}
found = tmpStr.find(".jpeg");
if (found != std::string::npos)
{
imagePaths.addVal(std::pair<std::string, int>(paths[0], IM_JPEG));
transfer.setVal(true);
return;
}
found = tmpStr.find(".png");
if (found != std::string::npos)
{
imagePaths.addVal(std::pair<std::string, int>(paths[0], IM_PNG));
transfer.setVal(true);
return;
}
}
}
示例13: myPostSyncPreDrawFun
void myPostSyncPreDrawFun()
{
gEngine->setWireframe(wireframe.getVal());
gEngine->setDisplayInfoVisibility(info.getVal());
gEngine->setStatsGraphVisibility(stats.getVal());
sgct_core::ClusterManager::instance()->getTrackingManagerPtr()->setEnabled(useTracking.getVal());
if( takeScreenshot.getVal() )
{
gEngine->takeScreenshot();
takeScreenshot.setVal(false);
}
if( reloadShaders.getVal() )
{
fx.getShaderProgram()->reload();
reloadShaders.setVal(false);
sgct::ShaderManager::instance()->reloadShaderProgram("Heightmap");
}
}
示例14: OnSmartFoxExtensionResponse
//! When something from a server extension is received this function is called. Could be position updating of gameobject, a private message or just a notification. The ["cmd"] parameter of the event that is received reveals which extension that was spitting out the info. Based on extension this function will do different things.
void NetworkManager::OnSmartFoxExtensionResponse(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent) {
// get pointer to main frame.
NetworkManager* ptrMainFrame = (NetworkManager*)ptrContext;
// Check that we're still alive and running
if (ptrMainFrame == NULL) {
return;
}
// Get the cmd parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueCmd = (*ptrEventParams)["cmd"];
boost::shared_ptr<string> ptrNotifiedCmd = ((boost::static_pointer_cast<string>)(ptrEventParamValueCmd));
// check the type of the command
if (*ptrNotifiedCmd == "PilotEvent") {
boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));
pInputRotX = *(ptrNotifiedISFSObject->GetDouble("sgctRotY"));
pInputRotZ = *(ptrNotifiedISFSObject->GetDouble("sgctRotX"));
bool pInputForward = *(ptrNotifiedISFSObject->GetBool("sgctForward"));
//bool pInputBackward = *(ptrNotifiedISFSObject->GetBool("sgctBackward"));
accRotX += pInputRotX * accRotVal;
accRotZ += pInputRotZ * accRotVal;
if (pInputForward) {
if (enginePowerup.getVal() <= 0.0 && navigationSpeed < accThrustMax * eInputEngine)
navigationSpeed += accThrustVal * eInputEngine;
else if (navigationSpeed < accThrustMax * eInputEngine * 2.0)
navigationSpeed += accThrustVal * eInputEngine * 2.0;
}
//if (pInputBackward && navigationSpeed > -0.1) {
// navigationSpeed -= accThrustVal * eInputEngine;
//}
}
if (*ptrNotifiedCmd == "GunnerEvent") {
boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));
gInputRotX = *(ptrNotifiedISFSObject->GetDouble("sgctRotX")) * 3.0;
gInputRotY = *(ptrNotifiedISFSObject->GetDouble("sgctRotY")) * 3.0;
bool fire = *(ptrNotifiedISFSObject->GetBool("sgctFire"));
if (fire && fireTimer <= 0.0) {
//if (gEngine->isMaster())
soundManager.play("laser", osg::Vec3f(0.0f, 0.0f, 0.0f));
fireSync.setVal(true);
fireTimer = fireRate / eInputTurret;
}
}
if (*ptrNotifiedCmd == "EngineerEvent") {
boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));
eInputEngine = ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctEngine"))) * 3 + 0.5); // 0.5 - 3.5
eInputShield = 1.0 - 0.75 * ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctShield"))));// 1.0 - 0.25 (percent of damage taken)
eInputTurret = ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctTurret"))) + 0.5); // 0.5 - 1.5
}
if (*ptrNotifiedCmd == "BenchMarking") {
boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));
double item = *(ptrNotifiedISFSObject->GetDouble("1"));
double item2 = *(ptrNotifiedISFSObject->GetDouble("2"));
double item3 = *(ptrNotifiedISFSObject->GetDouble("3"));
double item4 = *(ptrNotifiedISFSObject->GetDouble("4"));
end = omp_get_wtime();
std::cout << "Reply from server, " << static_cast<int>((end - start) * 1000) << "ms." << endl;
start = omp_get_wtime();
// send new item
if (itemsSent++ < 35 && benchmarkingStarted) {
boost::shared_ptr<ISFSObject> parameters(new SFSObject());
parameters->PutDouble("1", 0.923);
parameters->PutDouble("2", 0.953);
parameters->PutDouble("3", 0.343);
parameters->PutDouble("4", 0.523);
// find our room to send to.
boost::shared_ptr<Room> lastJoined = ptrMainFrame->m_ptrSmartFox->LastJoinedRoom();
// Perform extensionrequest
boost::shared_ptr<IRequest> extRequest(new ExtensionRequest("BenchMarking", parameters, lastJoined));
ptrMainFrame->m_ptrSmartFox->Send(extRequest);
}
else {
benchmarkingStarted = false;
itemsSent = 0;
//.........这里部分代码省略.........
示例15: myPostSyncPreDrawFun
void myPostSyncPreDrawFun()
{
gEngine->setDisplayInfoVisibility(info.getVal());
gEngine->setStatsGraphVisibility(stats.getVal());
}