本文整理汇总了C++中sgct::SharedDouble类的典型用法代码示例。如果您正苦于以下问题:C++ SharedDouble类的具体用法?C++ SharedDouble怎么用?C++ SharedDouble使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedDouble类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myPreSyncFun
void myPreSyncFun()
{
if( gEngine->isMaster() && !mPause)
{
curr_time.setVal( curr_time.getVal() + gEngine->getAvgDt());
}
}
示例2: myDrawFun
void myDrawFun()
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
double speed = 25.0;
//create scene transform (animation)
glm::mat4 scene_mat = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -3.0f));
scene_mat = glm::rotate(scene_mat, static_cast<float>(curr_time.getVal() * speed), glm::vec3(0.0f, -1.0f, 0.0f));
scene_mat = glm::rotate(scene_mat, static_cast<float>(curr_time.getVal() * (speed / 2.0)), glm::vec3(1.0f, 0.0f, 0.0f));
glm::mat4 MVP = gEngine->getActiveModelViewProjectionMatrix() * scene_mat;
glm::mat4 MV = gEngine->getActiveModelViewMatrix() * scene_mat;
glm::mat3 NormalMatrix = glm::inverseTranspose(glm::mat3(MV));
glActiveTexture(GL_TEXTURE0);
//glBindTexture( GL_TEXTURE_2D, sgct::TextureManager::instance()->getTextureByName("box") );
glBindTexture(GL_TEXTURE_2D, sgct::TextureManager::instance()->getTextureByHandle(myTextureHandle));
sgct::ShaderManager::instance()->bindShaderProgram("MRT");
glUniformMatrix4fv(m_MVPMatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(m_worldMatrixTransposeID, 1, GL_TRUE, &MV[0][0]); //transpose in transfere
glUniformMatrix3fv(m_normalMatrix, 1, GL_FALSE, &NormalMatrix[0][0]);
glUniform1i(m_textureID, 0);
//draw the box
myBox->draw();
sgct::ShaderManager::instance()->unBindShaderProgram();
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
}
示例3: myPreSyncFun
void myPreSyncFun()
{
if( gEngine->isMaster() )
{
curr_time.setVal( sgct::Engine::getTime() );
}
}
示例4: myDrawFun
void myDrawFun()
{
glEnable( GL_DEPTH_TEST );
glEnable( GL_CULL_FACE );
double speed = 0.44;
//create scene transform (animation)
glm::mat4 scene_mat = glm::translate( glm::mat4(1.0f), glm::vec3( 0.0f, 0.0f, -3.0f) );
scene_mat = glm::rotate( scene_mat, static_cast<float>( curr_time.getVal() * speed ), glm::vec3(0.0f, -1.0f, 0.0f));
scene_mat = glm::rotate( scene_mat, static_cast<float>( curr_time.getVal() * (speed/2.0) ), glm::vec3(1.0f, 0.0f, 0.0f));
glm::mat4 MVP = gEngine->getCurrentModelViewProjectionMatrix() * scene_mat;
glActiveTexture(GL_TEXTURE0);
if(texIndex.getVal() != -1)
glBindTexture(GL_TEXTURE_2D, texIds.getValAt(texIndex.getVal()));
else
glBindTexture(GL_TEXTURE_2D, sgct::TextureManager::instance()->getTextureId("box"));
sgct::ShaderManager::instance()->bindShaderProgram( "xform" );
glUniformMatrix4fv(Matrix_Loc, 1, GL_FALSE, &MVP[0][0]);
//draw the box
myBox->draw();
sgct::ShaderManager::instance()->unBindShaderProgram();
glDisable( GL_CULL_FACE );
glDisable( GL_DEPTH_TEST );
}
示例5: myDrawFun
void myDrawFun()
{
glEnable( GL_DEPTH_TEST );
glEnable( GL_CULL_FACE );
gEngine->setClearColor(clear_color.x, clear_color.y, clear_color.z, 1.0f);
//create scene transform (animation)
glm::mat4 scene_mat = glm::translate( glm::mat4(1.0f), glm::vec3( 0.0f, 0.0f, -3.0f) );
scene_mat = glm::rotate( scene_mat, static_cast<float>( curr_time.getVal() * speed ), glm::vec3(0.0f, -1.0f, 0.0f));
scene_mat = glm::rotate( scene_mat, static_cast<float>( curr_time.getVal() * (speed/2.0) ), glm::vec3(1.0f, 0.0f, 0.0f));
glm::mat4 MVP = gEngine->getCurrentModelViewProjectionMatrix() * scene_mat;
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, (use_texture ? sgct::TextureManager::instance()->getTextureId("box") : NULL));
sgct::ShaderManager::instance()->bindShaderProgram( "xform" );
glUniformMatrix4fv(Matrix_Loc, 1, GL_FALSE, &MVP[0][0]);
//draw the box
myBox->draw();
sgct::ShaderManager::instance()->unBindShaderProgram();
glDisable( GL_CULL_FACE );
glDisable( GL_DEPTH_TEST );
if( gEngine->isMaster() )
{
ImGui_ImplGlfwGL3_NewFrame(gEngine->getCurrentWindowPtr()->getXFramebufferResolution(), gEngine->getCurrentWindowPtr()->getYFramebufferResolution());
// Show a settings window custom made for this application
// Toggle this windows with the 'W' key.
if(show_settings_window)
{
ImGui::SetNextWindowSize(ImVec2(300, 200), ImGuiSetCond_FirstUseEver);
ImGui::Begin("Settings");
ImGui::SliderFloat("Rotation Speed", &(speed), 0.0f, 1.0f);
ImGui::Checkbox("Texture On/Off", &use_texture);
ImGui::ColorEdit3("Clear Color", (float*)&clear_color);
if (ImGui::Button("Toggle Test Window")) show_test_window ^= 1;
ImGui::End();
}
// Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
if (show_test_window)
{
ImGui::SetNextWindowPos(ImVec2(100, 20), ImGuiSetCond_FirstUseEver);
ImGui::ShowTestWindow(&show_test_window);
}
ImGui::Render();
}
}
示例6: myDrawFun
void myDrawFun()
{
float speed = 50.0f;
glm::mat4 scene_mat = glm::rotate( glm::mat4(1.0f), static_cast<float>( curr_time.getVal() ) * speed, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 MVP = gEngine->getActiveModelViewProjectionMatrix() * scene_mat;
sgct::ShaderManager::instance()->bindShaderProgram( "xform" );
glUniformMatrix4fv(matrix_loc, 1, GL_FALSE, &MVP[0][0]);
glUniform1f( time_loc, static_cast<float>( curr_time.getVal() ) );
glBindVertexArray(vertexArray);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 3);
//unbind
glBindVertexArray(0);
sgct::ShaderManager::instance()->unBindShaderProgram();
}
示例7: myDrawFun
void myDrawFun()
{
#ifndef Test
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glTranslatef( 0.0f, -0.15f, 2.5f );
glRotatef( static_cast<float>( curr_time.getVal() ) * 8.0f, 0.0f, 1.0f, 0.0f );
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, sgct::TextureManager::instance()->getTextureId("heightmap"));
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, sgct::TextureManager::instance()->getTextureId("normalmap"));
glEnable(GL_TEXTURE_2D);
//set current shader program
sgct::ShaderManager::instance()->bindShaderProgram("Heightmap");
glUniform1f( curr_timeLoc, static_cast<float>( curr_time.getVal() ) );
glUniform1i( myTextureLocations[0], 0 );
glUniform1i( myTextureLocations[1], 1 );
//glUniform1f(curr_timeLoc, 0.0f);
glLineWidth(2.0); //for wireframe
glCallList(myTerrainDisplayList);
//unset current shader program
sgct::ShaderManager::instance()->unBindShaderProgram();
glActiveTexture(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_TEXTURE_2D);
#else
mySphere->draw();
#endif
}
示例8: myPostSyncPreDrawFun
void myPostSyncPreDrawFun()
{
gEngine->setWireframe(wireframe.getVal());
gEngine->setDisplayInfoVisibility(info.getVal());
gEngine->setStatsGraphVisibility(stats.getVal());
if( takeScreenshot.getVal() )
{
gEngine->takeScreenshot();
takeScreenshot.setVal(false);
}
light.getVal() ? mRootNode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE) :
mRootNode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
mSceneTrans->setMatrix(osg::Matrix::rotate( glm::radians(curr_time.getVal() * 8.0), 0.0, 1.0, 0.0));
mSceneTrans->postMult(osg::Matrix::translate(0.0, -0.1, dist.getVal()));
//transform to scene transformation from configuration file
mSceneTrans->postMult( osg::Matrix( glm::value_ptr( gEngine->getModelMatrix() ) ));
//update the frame stamp in the viewer to sync all
//time based events in osg
mFrameStamp->setFrameNumber( gEngine->getCurrentFrameNumber() );
mFrameStamp->setReferenceTime( curr_time.getVal() );
mFrameStamp->setSimulationTime( curr_time.getVal() );
mViewer->setFrameStamp( mFrameStamp.get() );
mViewer->advance( curr_time.getVal() ); //update
//traverse if there are any tasks to do
if (!mViewer->done())
{
mViewer->eventTraversal();
//update travelsal needed for pagelod object like terrain data etc.
mViewer->updateTraversal();
}
}
示例9: 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;
}
}
}