예제 #1
0
	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 ");

	}
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.' ");
}
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.' ");

}
예제 #4
0
static void ReshapeCallback(int width, int height)
{
	glViewport(0, 0, width, height);

	// Send the new window size to AntTweakBar
	TwWindowSize(width, height);
}
예제 #5
0
// Отработка изменения размеров окна
void reshape_func( int width, int height )
{
   if (width <= 0 || height <= 0)
      return;
   glViewport(0, 0, width, height);
   TwWindowSize(width, height);
}
예제 #6
0
파일: Scene.cpp 프로젝트: ak239/graphics
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();
}
예제 #7
0
//------------------------------------------------------------------------------
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);

}
예제 #8
0
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");
}
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'");
}
예제 #10
0
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

}
예제 #11
0
void RotationsViewer::onResize(int width, int height)
{
    glViewport(0, 0, (GLsizei)width, (GLsizei)height);
    mWindowWidth = width;
    mWindowHeight = height;
    TwWindowSize(width, height);
}
예제 #12
0
    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);
    }
예제 #13
0
 virtual void operator()( osg::RenderInfo& renderInfo ) const
 {
     osg::Viewport* viewport = renderInfo.getCurrentCamera()->getViewport();
     if ( viewport ) TwWindowSize( viewport->width(), viewport->height() );
     updateEvents();
     TwDraw();
 }
예제 #14
0
파일: main.cpp 프로젝트: happanda/Engine
void reshape(int width, int height)
{
    reshape_window(width, height);
    //glutReshapeWindow(width, height);
    if (draw_tw)
        TwWindowSize(width, height);
}
예제 #15
0
파일: main.cpp 프로젝트: Jaa-c/GPU-led
/** 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' ");
	
}
// GLWindow event handlers
void GXBaseContext::OnCreate(void) 
{
	Setup2D();

	//Setup TweakBar
	TwInit(TW_OPENGL, NULL);
	TwWindowSize(Width(), Height());
}
예제 #17
0
 void GLFW_App::setWindowSize(const glm::vec2 &size)
 {
     App::setWindowSize(size);
     TwWindowSize(size.x, size.y);
     if(!m_windows.empty())
         glfwSetWindowSize(m_windows.back()->handle(), (int)size[0], (int)size[1]);
     
 }
예제 #18
0
// Callback function called by GLFW when window size changes
void GLFWCALL WindowSizeCB(int width, int height)
{
    // Set OpenGL viewport and default camera
    glViewport(0, 0, width, height);

    // Send the new window size to AntTweakBar
    TwWindowSize(width, height);
}
static void onFramebufferSizeChanged(GLFWwindow* window, int width, int height){
	glViewport(0, 0, width, height);
	s_proj = glm::perspective(FOV, float(width) / float(height),
		NEAR_PLANE, FAR_PLANE);

	// AntTweakBar
	TwWindowSize(width, height);
}
// Callback function called by GLUT when window size changes
void OnReshape(int width, int height)
{
    // Set OpenGL viewport
    glViewport(0, 0, width, height);

    // Send the new window size to AntTweakBar
    TwWindowSize(width, height);
}
void resize(GLFWwindow* pWin, int w, int h)
{
    if (pWin == g_pWindow)
    {
        g_app.resize(w,h);
        TwWindowSize(w,h);
    }
}
예제 #22
0
int main( int argc, char** argv )
{
	// Initialize GLFW
	glfwInit();
	if( !setupWindow( appWidth, appHeight, fullScreen ) ) return -1;
	
	// Initalize application and engine
	app = new Application( generatePath( argv[0], "../Content" ) );
	if ( !app->init() )
	{
		// Fake message box
		glfwCloseWindow();
		glfwOpenWindow( 800, 16, 8, 8, 8, 8, 24, 8, GLFW_WINDOW );
		glfwSetWindowTitle( "Unable to initalize engine - Make sure you have an OpenGL 2.0 compatible graphics card" );
		glfwSleep( 5 );
		
		std::cout << "Unable to initalize engine" << std::endl;
		std::cout << "Make sure you have an OpenGL 2.0 compatible graphics card";
		glfwTerminate();
		return -1;
	}
	app->resize( appWidth, appHeight );
	TwWindowSize( appWidth, appHeight );
	//glfwDisable( GLFW_MOUSE_CURSOR );

	int frames = 0;
	float fps = 30.0f;
	t0 = glfwGetTime();
	running = true;

	// Game loop
	while( running )
	{
		// Calc FPS
		++frames;
		if( frames >= 3 )
		{
			double t = glfwGetTime();
			fps = frames / (float)(t - t0);
			frames = 0;
			t0 = t;
		}

		// Render
		app->mainLoop( fps );
		TwDraw();
		glfwSwapBuffers();
	}

	glfwEnable( GLFW_MOUSE_CURSOR );

	// Quit
	app->release();
	delete app;
	glfwTerminate();

	return 0;
}
예제 #23
0
	void Reshape(int w, int h) {
		if (h == 0) h = 1;
		glViewport(0, 0, w, h);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(60, ((float)w) / ((float)h), 0.5f, 2*Camera::maxDistance);

		TwWindowSize(w, h);
	}
예제 #24
0
파일: part2.cpp 프로젝트: isqb/graphics
void reshape(int width, int height)
{
    globals.width = width;
    globals.height = height;
    globals.trackball.setRadius(double(std::min(width, height)) / 2.0);
    globals.trackball.setCenter(glm::vec2(width, height) / 2.0f);
    glViewport(0, 0, width, height);
	TwWindowSize(width,height);
}
예제 #25
0
	void Reshape(int w, int h) {
		if (h == 0) h = 1;
		glViewport(0, 0, w, h);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(60, ((float)w) / ((float)h), 1, 2000);
		glMatrixMode(GL_MODELVIEW);
		TwWindowSize(w, h);
	}
void GXBaseContext::OnResize(int w, int h)
{
	GLWindow::OnResize(w, h);

	Setup2D();

	//REsize tweakbar
	TwWindowSize(w, h);
}
예제 #27
0
	void CubeGui::v_init(int sw, int sh)
	{
	    TwInit(TW_OPENGL_CORE, NULL);
		TwWindowSize(sw, sh);

		m_pBar = TwNewBar("CubeGui");
		TwDefine(" CubeGui label='CubeGui' position='1300 10' alpha=30 help='Use this bar to edit the tess.' ");
		//TwAddVarRW(m_pBar, "speed",);
	
	}
예제 #28
0
void ofxTweakbars::init() {
	visible = true;
	is_initialized = true;
	if (!TwInit(TW_OPENGL, NULL)) {
		throw TwGetLastError();
	}
	TwWindowSize(ofGetWidth(), ofGetHeight());
	setEventHandlers();

}
예제 #29
0
void Game::Initialise(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
{
	//Initialise Input
	m_Input = new Input;
	m_Input->Initialise(hinstance,hwnd,screenWidth,screenHeight);

	//Initialise Graphics
	m_Graphics = new GameRenderer;
	m_Graphics->Initialise(screenWidth, screenHeight, hwnd);


	//Initialise AntTweakBar
	TwInit(TW_DIRECT3D11, m_Graphics->GetDevice());
	TwWindowSize(screenWidth, screenHeight);

	//Create the camera
	m_Camera = new Camera;
	m_Camera->SetPosition(0, 25, -75);

	m_Camera->SetRotation(10, 0, 0);

	//Create the skybox
	m_sky = new Skybox;
	m_sky->Initialise(m_Graphics->GetDevice(), hwnd);
	m_sky->SetPosition(XMFLOAT3(0, 0, 0));

	//Create the ant tweak bar
	m_gameTweakBar = TwNewBar("Water Wave Simulation");
	int barSize[2] = { 200, 680 };
	TwSetParam(m_gameTweakBar, NULL, "size", TW_PARAM_INT32, 2, barSize);

	//Toggle wireframe on/off
	TwAddButton(m_gameTweakBar, "comment1", Callback, m_Graphics, " label='Toggle Wireframe' ");


	//Create the wave manager
	m_waveManager = new WaveManager;
	TwAddButton(m_gameTweakBar, "comment2", NextPreset, m_waveManager, " label='Next Preset' ");
	m_waveManager->Initialise(m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), m_gameTweakBar);
	
	m_waveManager->CreateWater(XMFLOAT3(-480, 0, -480), m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), hwnd);

	m_hwnd = hwnd;

	//Create terrain 
	Mesh* terrainMesh = new Mesh;
	terrainMesh->Initialise(m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), "terrain.txt", "../WaveSim/Data/Textures/sand.tga");
	//Use same mesh for multiple instances
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(1500, -10, 2000));
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(10, -10, 1000));
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(-1000, -10, 0));
	Console::Log("Terrain Initalised...");
	//Create directional light
	CreateLight();
}
예제 #30
0
 void GLFW_App::init()
 {
     // Initialize GLFW
     if( !glfwInit() )
     {
         throw Exception("GLFW failed to initialize");
     }
     
     int num_color_bits = 8;
     
     //TODO: find out why this is necessary for smooth gradients
     glfwWindowHint(GLFW_RED_BITS, num_color_bits);
     glfwWindowHint(GLFW_GREEN_BITS, num_color_bits);
     glfwWindowHint(GLFW_BLUE_BITS, num_color_bits);
     
     // request an OpenGl 4.1 Context
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
     glfwWindowHint(GLFW_SAMPLES, 4);
     
     // create the window
     addWindow(GLFW_Window::create(getWidth(), getHeight(), getName(), fullSceen()));
     gl::setWindowDimension(windowSize());
     
     // set graphical log stream
     Logger::get()->add_outstream(&m_outstream_gl);
     
     // version
     LOG_INFO<<"OpenGL: " << glGetString(GL_VERSION);
     LOG_INFO<<"GLSL: " << glGetString(GL_SHADING_LANGUAGE_VERSION);
     
     glfwSwapInterval(1);
     glClearColor(0, 0, 0, 1);
     
     // file search paths
     kinski::addSearchPath(".", true);
     kinski::addSearchPath("./res", true);
     kinski::addSearchPath("../Resources", true);
     
     //---------------------------------
     #ifdef KINSKI_MAC
     kinski::addSearchPath("/Library/Fonts");
     kinski::addSearchPath("~/Library/Fonts");
     #endif
     //---------------------------------
     
     // AntTweakbar
     TwInit(TW_OPENGL_CORE, NULL);
     TwWindowSize(getWidth(), getHeight());
     
     // call user defined setup callback
     setup();
 }