当前位置: 首页>>代码示例>>C++>>正文


C++ TwWindowSize函数代码示例

本文整理汇总了C++中TwWindowSize函数的典型用法代码示例。如果您正苦于以下问题:C++ TwWindowSize函数的具体用法?C++ TwWindowSize怎么用?C++ TwWindowSize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TwWindowSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TwWindowSize

	void RotationGui::v_init()
	{
		auto sw = WindowInfo::getInstance()->getWidth();
		auto sh = WindowInfo::getInstance()->getHeight();

		TwWindowSize(sw, sh);

		TwInit(TW_OPENGL_CORE, NULL);
		TwWindowSize(sw, sh);
		TwBar *pBar = TwNewBar("RotationBar");
		TwDefine(" RotationBar label='RotationBar' position='1000 16' alpha=0 help='Use this bar to edit the tess.' ");
		TwAddVarRW(pBar, "Quaternion", TW_TYPE_QUAT4F, &m_Orientation, "showval=true open=true ");

	}
开发者ID:byhj,项目名称:byhj-Render,代码行数:14,代码来源:RotationGUI.cpp

示例2: initGUI

void initGUI() {
    // Initialize AntTweakBar GUI
    if (!TwInit(TW_OPENGL, NULL))
    {
        assert(0);
    }

    TwWindowSize(g_WindowWidth, g_WindowHeight);
    TwBar *controlBar = TwNewBar("Controls");
    TwDefine(" Controls position='10 10' size='200 320' refresh=0.1 ");

    TwAddVarCB(controlBar, "use_shaders", TW_TYPE_BOOLCPP, cbSetShaderStatus, cbGetShaderStatus, NULL, " label='shaders' key=s help='Turn programmable pipeline on/off.' ");

    // Shader panel setup
    TwAddVarRW(controlBar, "vs", TW_TYPE_BOOLCPP, &g_UseVertexShader, " group='Shaders' label='vertex' key=v help='Toggle vertex shader.' ");
    TwAddVarRW(controlBar, "gs", TW_TYPE_BOOLCPP, &g_UseGeometryShader, " group='Shaders' label='geometry' key=g help='Toggle geometry shader.' ");
    TwAddVarRW(controlBar, "fs", TW_TYPE_BOOLCPP, &g_UseFragmentShader, " group='Shaders' label='fragment' key=f help='Toggle fragment shader.' ");
    TwAddButton(controlBar, "build", cbCompileShaderProgram, NULL, " group='Shaders' label='build' key=b help='Build shader program.' ");
	//TwDefine( " Controls/Shaders readonly=true "); 

    // Render panel setup
    TwAddVarRW(controlBar, "wiremode", TW_TYPE_BOOLCPP, &g_WireMode, " group='Render' label='wire mode' key=w help='Toggle wire mode.' ");
    TwAddVarRW(controlBar, "face_culling", TW_TYPE_BOOLCPP, &g_FaceCulling, " group=Render label='face culling' key=c help='Toggle face culling.' ");

    // Scene panel setup
    TwEnumVal geometry_type[] = { 
        { ELEPHANT_GEOMETRY    , "Elephant"},
        { CUBE_GEOMETRY        , "Cube"    },
    };
    TwType geom_type = TwDefineEnum("Model", geometry_type, NUM_GEOMETRY_TYPES);
    TwAddVarRW(controlBar, "model", geom_type, &g_GeometryType, " group='Scene' keyIncr=Space help='Change model.' ");
    TwAddVarRW(controlBar, "auto-rotation", TW_TYPE_BOOLCPP, &g_SceneRotEnabled, " group='Scene' label='rotation' key=r help='Toggle scene rotation.' ");
    TwAddVarRW(controlBar, "Translate", TW_TYPE_FLOAT, &g_SceneTraZ, " group='Scene' label='translate' min=1 max=1000 step=0.5 keyIncr=t keyDecr=T help='Scene translation.' ");
    TwAddVarRW(controlBar, "SceneRotation", TW_TYPE_QUAT4F, &g_SceneRot, " group='Scene' label='rotation' open help='Toggle scene orientation.' ");
}
开发者ID:Bublafus,项目名称:NPR-techniques,代码行数:35,代码来源:AntTweakConfiguration.cpp

示例3: TwInit

void SSAO::BuildUI() {
	TwInit(TW_DIRECT3D11, _device);
	TwWindowSize(_screenWidth, _screenHeight);
	_bar = TwNewBar("AmbientOcclusion");
	TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar into a DirectX11 application.' "); // Message added to the help bar.
	int barSize[2] = {300, 375};
	TwSetParam(_bar, NULL, "size", TW_PARAM_INT32, 2, barSize);

	TwAddVarCB(_bar, "Rad", TW_TYPE_FLOAT, SSAO::SetRad, SSAO::GetRad, this, "group=ShaderParams min=0 max=20 step=0.001 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "TotalStr", TW_TYPE_FLOAT, SSAO::SetTotStr, SSAO::GetTotStr, this, "group=ShaderParams min=0 max=50 step=0.1 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Strength", TW_TYPE_FLOAT, SSAO::SetStrength, SSAO::GetStrength, this, "group=ShaderParams min=0.1 max=100 step=0.1 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Offset", TW_TYPE_FLOAT, SSAO::SetOffset, SSAO::GetOffset, this, "group=ShaderParams min=0 max=100 step=0.5 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Falloff", TW_TYPE_FLOAT, SSAO::SetFalloff, SSAO::GetFalloff, this, "group=ShaderParams min=0 max=0.01 step=0.00001 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "BlurSize", TW_TYPE_FLOAT, SSAO::SetBlur, SSAO::GetBlur, this, "group=ShaderParams min=1 max=16 step=1 keyincr=+ keydecr=-");
	TwAddButton(_bar, "Reset", SSAO::ResetButton, this, "");
	TwAddButton(_bar, "ShowDebug", SSAO::ShowDebug, this, "");

	TwEnumVal* a = new TwEnumVal[3];
	a[0].Value = 0; a[0].Label = "buddha";
	a[1].Value = 1; a[1].Label = "hairball";
	a[2].Value = 2; a[2].Label = "sib";
	_index = 0;

	TwType actMesh = TwDefineEnum("mesh", a, 3);

	TwAddVarCB(_bar, "ActiveVol", actMesh, SSAO::SetMesh, SSAO::GetMesh, this, 
		" group='Mesh' keyIncr=Backspace keyDecr=SHIFT+Backspace help='Stop or change the rotation mode.' ");

}
开发者ID:Jake-Baugh,项目名称:screen-space-ambient-occlusion,代码行数:29,代码来源:ssaoEffect.cpp

示例4: ReshapeCallback

static void ReshapeCallback(int width, int height)
{
	glViewport(0, 0, width, height);

	// Send the new window size to AntTweakBar
	TwWindowSize(width, height);
}
开发者ID:Mashewnutz,项目名称:Slo,代码行数:7,代码来源:CDTestFramework.cpp

示例5: reshape_func

// Отработка изменения размеров окна
void reshape_func( int width, int height )
{
   if (width <= 0 || height <= 0)
      return;
   glViewport(0, 0, width, height);
   TwWindowSize(width, height);
}
开发者ID:Icemore,项目名称:homework,代码行数:8,代码来源:main_triangle.cpp

示例6: GET_CONTEXT

void Scene::display()
{
	GET_CONTEXT();
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	TwWindowSize(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));

	GLfloat aspect = static_cast<GLfloat>(glutGet(GLUT_WINDOW_WIDTH))/glutGet(GLUT_WINDOW_HEIGHT);
	glm::mat4 projection = glm::perspective(45.0f, aspect, 0.1f, 500.0f);
	
	glm::mat4 projectionView;

	for (std::size_t i = 0; i < m_objects.size(); ++i)
	{
		if (m_camera)
		{
			m_objects[i]->setCameraView(m_camera->view());
			m_objects[i]->setCameraPos(m_camera->getPos());
		}
		m_objects[i]->setProjection(projection);
		m_objects[i]->render();
	}

	TwDraw();
	glutSwapBuffers();
}
开发者ID:ak239,项目名称:graphics,代码行数:27,代码来源:Scene.cpp

示例7: getWidth

//------------------------------------------------------------------------------
void MyWindow::reshape(int w, int h)
{
    WindowInertiaCamera::reshape(w,h);
    //
    // Let's validate again the base of resource management to make sure things keep consistent
    //
    m_W = getWidth();
    m_H = getHeight();

    glViewport(0, 0, m_W, m_H);
#ifdef USEANTTWEAKBAR
    TwWindowSize(m_W, m_H);
#endif

    float r = (float)m_W / (float)m_H;
    mat4f proj;
    perspective(proj, 30.0f, r, 0.01f, 10.0f);
    mat4f shift(array16_id);

    nvFX::IResourceRepository* pIResRep = nvFX::getResourceRepositorySingleton();
    pIResRep->setParams(0,0, w,h, 1, 0, NULL);
    pIResRep->updateValidated();
    // Not needed: IResourceRepository::updateValidated(); will do it anyways
    //nvFX::IFrameBufferObjectsRepository* pIFBORep = nvFX::getFrameBufferObjectsRepositorySingleton();
    //pIFBORep->setParams(0,0, w,h, 1, 0, NULL);
    //pIFBORep->updateValidated();

    //ui::reshape(w,h);

}
开发者ID:2php,项目名称:nvFX,代码行数:31,代码来源:ShaderToyViewer.cpp

示例8: m_game

Gui::Gui(Scene& scene,
         Game& game,
         Camera& camera,
         Input& input,
         Timer& timer) :
    m_game(game),
    m_camera(camera),
    m_scene(scene),
    m_timer(timer)
{
    TwInit(TW_OPENGL_CORE, nullptr);
    TwWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);

    const std::string barname = "GraphicsTweaker";
    m_tweakbar = TwNewBar(barname.c_str());
    m_tweaker = std::make_unique<Tweaker>(m_tweakbar);
    
    const int border = 10;
    std::ostringstream stream;
    stream << barname << " label='Graphics Tweaker' " 
        << "position='" << border << " " << border << "' "
        << "size='250 " << WINDOW_HEIGHT-border*2 << "' "
        << "alpha=180 text=light valueswidth=80 color='0 0 0' "
        << "refresh=0.05 iconified=false resizable=true "
        << "fontsize=2 fontresizable=false ";
    TwDefine(stream.str().c_str());

    FillTweakBar();

    auto AddKeyCallback = [&input](unsigned int key, unsigned int code)
    {
        input.AddCallback(key, false, [code]()
        { 
            TwKeyPressed(code, 0);
        });
    };

    // Keys required for modifying entries in the tweak bar
    AddKeyCallback(GLFW_KEY_0, '0');
    AddKeyCallback(GLFW_KEY_1, '1');
    AddKeyCallback(GLFW_KEY_2, '2');
    AddKeyCallback(GLFW_KEY_3, '3');
    AddKeyCallback(GLFW_KEY_4, '4');
    AddKeyCallback(GLFW_KEY_5, '5');
    AddKeyCallback(GLFW_KEY_6, '6');
    AddKeyCallback(GLFW_KEY_7, '7');
    AddKeyCallback(GLFW_KEY_8, '8');
    AddKeyCallback(GLFW_KEY_9, '9');
    AddKeyCallback(GLFW_KEY_PERIOD, '.');
    AddKeyCallback(GLFW_KEY_MINUS, '-');
    AddKeyCallback(GLFW_KEY_ENTER, TW_KEY_RETURN);
    AddKeyCallback(GLFW_KEY_LEFT, TW_KEY_LEFT);
    AddKeyCallback(GLFW_KEY_RIGHT, TW_KEY_RIGHT);
    AddKeyCallback(GLFW_KEY_TAB, TW_KEY_TAB);
    AddKeyCallback(GLFW_KEY_END, TW_KEY_END);
    AddKeyCallback(GLFW_KEY_HOME, TW_KEY_HOME);
    AddKeyCallback(GLFW_KEY_BACKSPACE, TW_KEY_BACKSPACE);

    LogInfo("GUI: Tweak bar initialised");
}
开发者ID:karajensen,项目名称:tiny-toon-tanks,代码行数:60,代码来源:Gui.cpp

示例9: glutPassiveMotionFunc

void RotationsViewer::initializeGui()
{
    glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
    TwGLUTModifiersFunc(glutGetModifiers);
    TwInit(TW_OPENGL, NULL);
    TwWindowSize(mWindowWidth, mWindowHeight);

    TwCopyStdStringToClientFunc(onCopyStdStringToClient);

    mDemoBar = TwNewBar("Demo controls");
    TwDefine(" 'Demo controls' size='200 175' position='5 5' iconified=false fontresizable=false alpha=200");

    TwEnumVal modeTypeEV[] = { { DEMO1, "Convert" }, { DEMO2, "Curve" } };
    modeType = TwDefineEnum("ModeType", modeTypeEV, 2);
    TwAddVarRW(mDemoBar, "Demo", modeType, &mMode, NULL);

    TwAddVarRW(mDemoBar, "X Angle", TW_TYPE_DOUBLE, &mXAngle, " group='Convert params' ");
    TwAddVarRW(mDemoBar, "Y Angle", TW_TYPE_DOUBLE, &mYAngle, " group='Convert params' ");
    TwAddVarRW(mDemoBar, "Z Angle", TW_TYPE_DOUBLE, &mZAngle, " group='Convert params' ");
    TwEnumVal rooTypeEV[] = { { XYZ, "XYZ" }, { XZY, "XZY" }, { YXZ, "YXZ" }, { YZX, "YZX" }, { ZXY, "ZXY" }, { ZYX, "ZYX" } };
    rooType = TwDefineEnum("RooType", rooTypeEV, 6);
    TwAddVarRW(mDemoBar, "Rot Order", rooType, &mRotOrder, " group='Convert params' ");

    TwEnumVal splineTypeEV[] = { { ASplineQuat::LINEAR, "Linear" }, { ASplineQuat::CUBIC, "Cubic" } };
    splineType = TwDefineEnum("SplineType", splineTypeEV, 2);
    TwAddVarCB(mDemoBar, "Spline type", splineType, onSetStyleCb, onGetStyleCb, this, " group='Curve params'");
}
开发者ID:codemodo,项目名称:animation_toolkit,代码行数:27,代码来源:RotationsViewer.cpp

示例10: glutCreateMenu

void DemoWindow::initTWBar()
{
	glutCreateMenu(NULL);
	// Initialize AntTweakBar
    TwInit(TW_OPENGL, NULL);

	//// Set GLUT event callbacks
 //   // - Directly redirect GLUT mouse button events to AntTweakBar
 //   glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
 //   // - Directly redirect GLUT mouse motion events to AntTweakBar
 //   glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
 //   // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
 //   glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
 //   // - Directly redirect GLUT key events to AntTweakBar
 //   glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
 //   // - Directly redirect GLUT special key events to AntTweakBar
 //   glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT);
    // - Send 'glutGetModifers' function pointer to AntTweakBar;
    //   required because the GLUT key event functions do not report key modifiers states.
    TwGLUTModifiersFunc(glutGetModifiers);
	bar = TwNewBar("TweakBar");
	TwWindowSize(100, 100);
    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar.
    TwDefine(" TweakBar size='200 400' color='96 216 224' "); // change default tweak bar size and color

}
开发者ID:billhj,项目名称:Etoile,代码行数:26,代码来源:DemoWindow.cpp

示例11: glViewport

void RotationsViewer::onResize(int width, int height)
{
    glViewport(0, 0, (GLsizei)width, (GLsizei)height);
    mWindowWidth = width;
    mWindowHeight = height;
    TwWindowSize(width, height);
}
开发者ID:codemodo,项目名称:animation_toolkit,代码行数:7,代码来源:RotationsViewer.cpp

示例12: glfwSetWindowSize

    void ViewingArea::set_size(GLint width, GLint height, bool calledByUser)
    {
      if(calledByUser)
	{
	  glfwSetWindowSize(glfwWindowPointer_,width,height);
	  TwSetCurrentWindow(size_t(glContext_));
	  TwWindowSize(width,height);
	}
      
      GLfloat hCenterAndRelative=GLfloat(width)/2;
      GLfloat vCenterAndRelative=GLfloat(height)/2;
      GLfloat hChange=hCenterAndRelative-centerAndRelative_[X_INDEX];
      GLfloat vChange=vCenterAndRelative-centerAndRelative_[Y_INDEX];
      insetCenter_[X_INDEX]+=hChange;
      insetCenter_[Y_INDEX]+=vChange;
      insetRelative_[X_INDEX]+=hChange;
      insetRelative_[Y_INDEX]+=vChange;
      centerAndRelative_[X_INDEX]=deviceToScreenMatrix_[X_INDEX*N_ROWS+X_INDEX]=hCenterAndRelative;
      centerAndRelative_[Y_INDEX]=deviceToScreenMatrix_[Y_INDEX*N_ROWS+Y_INDEX]=vCenterAndRelative;
      screenToDeviceMatrix_[X_INDEX*N_ROWS+X_INDEX]=1/deviceToScreenMatrix_[X_INDEX*N_ROWS+X_INDEX];
      screenToDeviceMatrix_[Y_INDEX*N_ROWS+Y_INDEX]=1/deviceToScreenMatrix_[Y_INDEX*N_ROWS+Y_INDEX];
      deviceToScreenMatrix_[N_SPATIAL_DIMENSIONS*N_ROWS+X_INDEX]=hCenterAndRelative;
      deviceToScreenMatrix_[N_SPATIAL_DIMENSIONS*N_ROWS+Y_INDEX]=vCenterAndRelative;
      screenToDeviceMatrix_[N_SPATIAL_DIMENSIONS*N_ROWS+X_INDEX]=-1.0f;
      screenToDeviceMatrix_[N_SPATIAL_DIMENSIONS*N_ROWS+Y_INDEX]=-1.0f;

      update_projection_matrices();
      EventSource<ResizeEvent>::Type::emit(width,height);
      glContext_->update_global_uniform_4x4(GLContext::SCREEN_TO_DEVICE_MATRIX,screenToDeviceMatrix_);
      glContext_->update_global_uniform_4x4(GLContext::DEVICE_TO_SCREEN_MATRIX,deviceToScreenMatrix_);
      glContext_->set_viewport(0,0,width,height);
    }
开发者ID:rhoelzel,项目名称:scigma,代码行数:32,代码来源:viewingarea.cpp

示例13: operator

 virtual void operator()( osg::RenderInfo& renderInfo ) const
 {
     osg::Viewport* viewport = renderInfo.getCurrentCamera()->getViewport();
     if ( viewport ) TwWindowSize( viewport->width(), viewport->height() );
     updateEvents();
     TwDraw();
 }
开发者ID:killlu79,项目名称:osgRecipes,代码行数:7,代码来源:osganttweakbar.cpp

示例14: reshape

void reshape(int width, int height)
{
    reshape_window(width, height);
    //glutReshapeWindow(width, height);
    if (draw_tw)
        TwWindowSize(width, height);
}
开发者ID:happanda,项目名称:Engine,代码行数:7,代码来源:main.cpp

示例15: initGUI

/** Initializes GUI - only AntweakBar menu creation */
void initGUI()
{
    // Initialize AntTweakBar GUI
    if (!TwInit(TW_OPENGL, NULL))
    {
        assert(0);
    }

    TwWindowSize(g_WindowWidth, g_WindowHeight);
    TwBar *controlBar = TwNewBar("Controls");
    TwDefine("Controls position='10 10' size='200 300' refresh=0.1  color='130 140 150'");
	
	TwAddVarCB(controlBar, "gpu", TW_TYPE_BOOLCPP, cbSetGPUUsage, cbGetGPUUsage, NULL, " group='CUDA' label='Compute on:' true='GPU' false='CPU' ");
	//TwAddVarRW(controlBar, "restart", TW_TYPE_BOOLCPP, &g_initData, " group='PROGRAM' label='Restart: ' true='' false='restart' ");
    
    TwAddVarRW(controlBar, "melt", TW_TYPE_BOOLCPP, &g_melt, " group='Render' label='Melt' key=m help='Start melting' ");
	TwAddVarRW(controlBar, "wiremode", TW_TYPE_BOOLCPP, &g_WireMode, " group='Render' label='Wire mode' key=w help='Toggle wire mode.' ");
    TwAddVarRW(controlBar, "march", TW_TYPE_BOOLCPP, &g_useMarchingCubes, " group='Render' label='March. Cubes' help='Toggle marching cubes.' ");
    
    TwAddVarRW(controlBar, "auto-rotation", TW_TYPE_BOOLCPP, &g_SceneRotEnabled, " group='Scene' label='rotation' key=r help='Toggle scene rotation.' ");
    TwAddVarRW(controlBar, "Translate", TW_TYPE_FLOAT, &g_SceneTraZ, " group='Scene' label='translate' min=1 max=1000 step=10 keyIncr=t keyDecr=T help='Scene translation.' ");
    TwAddVarRW(controlBar, "SceneRotation", TW_TYPE_QUAT4F, &g_SceneRot, " group='Scene' label='rotation' open help='Toggle scene orientation.' ");
	
	TwAddVarRO(controlBar, "fps", TW_TYPE_FLOAT, &g_fps, " group='INFO' label='Current fps' ");
	TwAddVarRO(controlBar, "ice", TW_TYPE_FLOAT, &g_iceParticles, " group='INFO' label='Ice particles' ");
	
}
开发者ID:Jaa-c,项目名称:GPU-led,代码行数:28,代码来源:main.cpp


注:本文中的TwWindowSize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。