fractal_t::fractal_t() : pos_(0.5, 0), scale_factor_(1) { #ifdef USE_CORE_OPENGL TwInit(TW_OPENGL_CORE, NULL); #else TwInit(TW_OPENGL, NULL); #endif // Определение "контролов" GUI TwBar *bar = TwNewBar("Parameters"); TwDefine(" Parameters size='300 50' color='70 100 120' valueswidth=220 iconpos=topleft"); TwAddButton(bar, "Fullscreen toggle", toggle_fullscreen_callback, NULL, " label='Toggle fullscreen mode' key=f"); // Создание шейдеров vs_ = create_shader(GL_VERTEX_SHADER , "shaders//fractal.glslvs"); fs_ = create_shader(GL_FRAGMENT_SHADER, "shaders//fractal.glslfs"); // Создание программы путём линковки шейдерова program_ = create_program(vs_, fs_); // Создание буфера с вершинными данными init_buffer(); // Создание VAO init_vertex_array(); }
void AntTweakBarWrapper::Init() { TwInit(TW_OPENGL, NULL); m_control_panel_bar = TwNewBar("Control Panel"); //TwDefine(" 'Control Panel' size='200 210' position='114 10' color='255 255 255' text=dark "); char control_bar_pos_string [255]; sprintf(control_bar_pos_string, "'Control Panel' position='%d 10' color='255 255 0' ", DEFAULT_SCREEN_WIDTH-210); TwDefine(control_bar_pos_string); TwAddVarRW(m_control_panel_bar, "Start Simulation", TwType(sizeof(bool)), &(g_start_simulation), " label='Start Simulation' key=s group='Debug Information' help='Toggle simulation mode.'"); TwAddVarRW(m_control_panel_bar, "Render FP", TwType(sizeof(bool)), &(g_show_render), " label='Render FP' key=w group='Debug Information' help='Toggle render display mode.'"); TwAddVarRW(m_control_panel_bar, "Wireframe", TwType(sizeof(bool)), &(g_show_wireframe), " label='Wireframe mode' key=w group='Debug Information' help='Toggle wireframe display mode.'"); TwAddVarRW(m_control_panel_bar, "Edge List", TwType(sizeof(bool)), &(g_show_edgelist), " label='Edgelist mode' group='Debug Information' help='Toggle edgelist display mode.'"); TwAddVarRW(m_control_panel_bar, "Line Width", TW_TYPE_FLOAT, &(g_linewidth),"label='Line Width' min=0 max=100 step=0.05 help='line width' group='Debug Information'"); TwAddVarRW(m_control_panel_bar, "Fixed Vertex", TwType(sizeof(bool)), &(g_show_fixedvertex), " label='Fixed Vertex' key=w group='Debug Information' help='Toggle fixed vertex mode.'"); TwAddVarRW(m_control_panel_bar, "Point Size", TW_TYPE_FLOAT, &(g_pointsize),"label='Point Size' min=0 max=100 step=0.05 help='Point Size' group='Debug Information'"); TwAddVarRW(m_control_panel_bar, "Zoom", TW_TYPE_FLOAT, &(cameraDistance),"label='Zoom Mode' min=-30 max=30 step=0.1 keyIncr=z keyDecr=Z help='zoom camera' group='Camera'"); m_sim_bar = TwNewBar("Simulation Control"); TwDefine("'Simulation Control' position='0 0' color='255 0 0'"); TwEnumVal shapeEV[NUM_SIMULATION] = { {PositionBasedDynamic, "Position Based Dynamic"}, {MassSpring, "Mass Spring"}, {FiniteElement, "Finite Element"}, {FastMassSpring, "Fast Mass Spring"}, {ProjectiveDynamic, "Projective Dynamic"} }; TwType simmethod = TwDefineEnum("simmethod", shapeEV, NUM_SIMULATION); TwAddVarRW(m_sim_bar, "Simulation Method", simmethod, &g_CurrentMethod, " keyIncr='<' keyDecr='>' help='Change Simulation Method.' "); }
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.' "); }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(windowWidth, windowHeight); glutCreateWindow("Versuch1"); GLenum err = glewInit(); if (GLEW_OK != err) { // Veralteter Treiber etc. std::cerr << "Error: " << glewGetErrorString(err) << "\n"; return 1; } glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT); glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); // same as MouseMotion glutKeyboardFunc(Keyboard); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); TwInit(TW_OPENGL, NULL); SetupRC(); glutMainLoop(); ShutDownRC(); return 0; }
bool ATB::Init() { bool ret = false; if (TwInit(TW_OPENGL_CORE, NULL) == 1) { TwStructMember Vector3fMembers[] = { { "x", TW_TYPE_FLOAT, offsetof(Vector3f, x), "" }, { "y", TW_TYPE_FLOAT, offsetof(Vector3f, y), "" }, { "z", TW_TYPE_FLOAT, offsetof(Vector3f, z), "" } }; TW_TYPE_OGLDEV_VECTOR3F = TwDefineStruct("Vector3f", Vector3fMembers, 3, sizeof(Vector3f), NULL, NULL); TwStructMember AttenuationMembers[] = { { "Const", TW_TYPE_FLOAT, offsetof(LightAttenuation, Constant), "" }, { "Linear", TW_TYPE_FLOAT, offsetof(LightAttenuation, Linear), "" }, { "Exp", TW_TYPE_FLOAT, offsetof(LightAttenuation, Exp), "" } }; TW_TYPE_OGLDEV_ATTENUATION = TwDefineStruct("Attenuation", AttenuationMembers, 3, sizeof(LightAttenuation), NULL, NULL); ret = true; } return ret; }
//---------------CPU Functions---------------// void initTweakMenu() { if(!TwInit(TW_OPENGL, NULL)) { fprintf(stderr, "AntTwekBar fails to initialize! Info: %s\n", TwGetLastError()); exit(0); } bar = TwNewBar("Scene Parameters"); //Camera attributes TwAddVarRW(bar, "View Direction", TW_TYPE_DIR3F, &viewdir, "group = 'Camera Attribute'"); TwAddVarRW(bar, "Move Speed", TW_TYPE_UINT8, &movespeed, " min = 0 max = 25 step = 1 group = 'Camera Attribute' "); TwAddVarRW(bar, "Position x", TW_TYPE_FLOAT, &camera.getPosition().x, " min = -100 max = 100 step = 0.01 group = 'Camera Attribute' "); TwAddVarRW(bar, "Position y", TW_TYPE_FLOAT, &camera.getPosition().y, " min = -100 max = 100 step = 0.01 group = 'Camera Attribute' "); TwAddVarRW(bar, "Position z", TW_TYPE_FLOAT, &camera.getPosition().z, " min = -100 max = 100 step = 0.01 group = 'Camera Attribute' "); TwAddVarRW(bar, "Aperture", TW_TYPE_FLOAT, &aperture, " min = 0.001 max = 10 step = 0.001 group = 'Camera Attribute' "); TwAddVarRW(bar, "Focal", TW_TYPE_FLOAT, &focal, " min = 0.0001 max = 0.9999 step = 0.0001 group = 'Camera Attribute' "); /*//Light attributes TwAddVarRW(bar, "position x", TW_TYPE_FLOAT, &light.getPosition().x, " min = -100 max = 100 step = 0.01 group = 'Light Attribute' "); TwAddVarRW(bar, "position y", TW_TYPE_FLOAT, &light.getPosition().y, " min = -100 max = 100 step = 0.01 group = 'Light Attribute' "); TwAddVarRW(bar, "position z", TW_TYPE_FLOAT, &light.getPosition().z, " min = -100 max = 100 step = 0.01 group = 'Light Attribute' "); //Light color TwAddVarRW(bar, "Color", TW_TYPE_COLOR3F, &light.getColor(), "group = 'Light Attribute'");//*/ }
bool Game::Initialize() { DX11Application::Initialize(); ShaderManager::GetInstance()->Initialize(mDevice, mDeviceContext); Camera::GetInstance()->Init(AglVector3(0, 0.0f, -2.25f), AglVector3(0, 0.0f, 0), AglVector3(0, 1, 0), mScreenWidth, mScreenHeight); TextureManager::GetInstance()->Init(mDevice, mDeviceContext); RasterManager::getInstance()->initialize(mDevice, mDeviceContext); ParticleStates::Init(mDevice, mDeviceContext); AGLLoader::GetInstance()->Init(mDevice, mDeviceContext); // Initialize AntTweakBar if (!TwInit(TW_DIRECT3D11, mDevice)) { MessageBoxA(mWindowHandle, TwGetLastError(), "AntTweakBar initialization failed", MB_OK|MB_ICONERROR); Cleanup(); return 0; } SceneDialog::GetInstance(); m_cameraController = new CameraController(mWindowHandle); SPHEREMESH = new SphereMesh(mDevice, mDeviceContext); BOXMESH = new BoxMesh(mDevice, mDeviceContext); return true; }
// Main int main(int argc, char *argv[]) { int mainWinID; // Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(960, 480); mainWinID = glutCreateWindow("AntTweakBar multi-window example"); glutCreateMenu(NULL); glutDisplayFunc(DisplayMainWindow); glutReshapeFunc(ReshapeMainWindow); // Initialize AntTweakBar TwInit(TW_OPENGL, NULL); // Create two sub-windows g_SubWindowData[0].WinID = glutCreateSubWindow(mainWinID, 8, 8, 480, 464); SetupSubWindow(0); g_SubWindowData[1].WinID = glutCreateSubWindow(mainWinID, 488, 8, 464, 464); SetupSubWindow(1); atexit(Terminate); // Called after glutMainLoop ends // Call the GLUT main loop glutMainLoop(); return 0; }
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'"); }
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 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 }
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.' "); }
int main(int args, char **argv) { glutInit(&args, argv); glutInitWindowSize(800, 600); glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("simple vertex shader"); TwInit(TW_OPENGL, NULL); TwBar *bar = TwNewBar("myBar"); TwDefine("myBar size='200 400' color = '96 216 224'"); TwAddVarRW(bar, "ObjectRotate", TW_TYPE_QUAT4F, &g_Rotate, "label='Object Rotation' opened=true"); TwAddVarRW(bar, "LightDir", TW_TYPE_DIR3F, &g_lightPos, "label='light Pos' opened=true"); glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT); glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT); TwGLUTModifiersFunc(glutGetModifiers); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); SetupRC(); glutMainLoop(); Terminate(); return 0; }
void init(void) { // Define técnica de shading: GL_FLAT, GL_SMOOTH glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT, GL_FILL); // GL_LINE, GL_POINT, GL_FILL // Activa o teste de profundidade glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); TwInit(TW_OPENGL, NULL); mainBar = TwNewBar("Parameters"); TwAddVarRW(mainBar, "Time Scale", TW_TYPE_FLOAT, &TimeScale, " group='Simulation' keyincr=U keydecr=I help='Simulation's time scale'"); TwAddVarRW(mainBar, "Speed", TW_TYPE_FLOAT, &camSpeed, " group='Camera' keyincr=S keydecr=X help='Camera movement speed' "); TwAddVarRW(mainBar, "Manual", TW_TYPE_BOOL16, &manualCam, " group='Camera' keyincr=C help='Toogle camera mode' "); TwAddVarRW(mainBar, "Show Orbits", TW_TYPE_BOOL16, &orbits, " group='Orbits' keyincr=O help='Toogle orbits' "); // Compila o modelo createFloorToDL(); }
/** 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' "); }
void CGUI::Initialize() { TwInit(TW_DIRECT3D9, g_Device); m_pGUI = TwNewBar("SA::Render"); TwAddButton(m_pGUI, "ReloadShaders", ReloadShaders, NULL, "group=Global"); }
// GLWindow event handlers void GXBaseContext::OnCreate(void) { Setup2D(); //Setup TweakBar TwInit(TW_OPENGL, NULL); TwWindowSize(Width(), Height()); }
bool initUserInterface(){ if (!TwInit(TW_OPENGL, NULL)) return false; gpUserInterface = new CUserInterface(); return true; }
void ofxTweakbars::init() { visible = true; is_initialized = true; if (!TwInit(TW_OPENGL, NULL)) { throw TwGetLastError(); } TwWindowSize(ofGetWidth(), ofGetHeight()); setEventHandlers(); }
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",); }
/*! * \brief Initialize the interface to an Intersil PCF8563 hardware clock. * * \return 0 on success or -1 in case of an error. * */ int PcfRtcInit(NUTRTC *rtc) { int rc; uint32_t tmp; if ((rc = TwInit(0)) == 0) { rc = PcfRtcGetStatus(rtc, &tmp); } return rc; }
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(); }
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(); }
/*! * \brief Initialize the interface to an Intersil X12xx hardware clock. * * \deprecated New applications must use NutRegisterRtc(). * * \return 0 on success or -1 in case of an error. * */ int X12Init(void) { int rc; u_long tmp; if ((rc = TwInit(0)) == 0) { rc = X12RtcGetStatus(&tmp); } return (rc); }
gl_context::gl_context(std::string const& name, int width, int height) { init_glfw(); create_glfw_window(name, width, height); glfwMakeContextCurrent(_main_window); TwInit(TW_OPENGL_CORE, nullptr); TwWindowSize(width, height); _tweak_bar = TwNewBar("MainBar"); init_glew(); glGenVertexArrays(1, &_vertex_array_id); glBindVertexArray(_vertex_array_id); }
void outPut::init_Tw() { ///Initialisation AntTweakBar TwInit(TW_OPENGL, NULL); TwWindowSize(_reg.WIDTH, _reg.HEIGHT); // redirection des callbacks GFLW sur AntTweakBar glfwSetMouseButtonCallback((GLFWmousebuttonfun)TwEventMouseButtonGLFW); glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW); glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW); glfwSetKeyCallback((GLFWkeyfun)TwEventKeyGLFW); glfwSetCharCallback((GLFWcharfun)TwEventCharGLFW); }
void initI2C(void) { static uint8_t runOnce = 0; if (!runOnce) { runOnce = 1; u_long baud = 100000; TwInit(0); TwIOCtl(TWI_SETSPEED, &baud); DDRD &= ~( _BV(PD0) | _BV(PD1)); PORTD |= _BV(PD0) | _BV(PD1); } }
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 "); }
/*! * \brief Transmit and/or receive data as a master. * * The two-wire serial interface must have been initialized by calling * TwInit() before this function can be used. * * \param sla Slave address of the destination. This slave address * must be specified as a 7-bit address. For example, the * PCF8574A may be configured to slave addresses from 0x38 * to 0x3F. * \param txdata Points to the data to transmit. Ignored, if the number * of data bytes to transmit is zero. * \param txlen Number of data bytes to transmit. If zero, then the * interface will not send any data to the slave device * and will directly enter the master receive mode. * \param rxdata Points to a buffer, where the received data will be * stored. Ignored, if the maximum number of bytes to * receive is zero. * \param rxsiz Maximum number of bytes to receive. Set to zero, if * no bytes are expected from the slave device. * \param tmo Timeout in milliseconds. To disable timeout, set this * parameter to NUT_WAIT_INFINITE. * * \return The number of bytes received, -1 in case of an error or timeout. * * \note Timeout is not used in the bit banging version. */ int NutTwiMasterTranceive(NUTTWIBUS *bus, uint8_t sla, const void *txdata, uint16_t txlen, void *rxdata, uint16_t rxsiz, uint32_t tmo) { int rc = 0; uint8_t *cp; NUTTWIICB *icb = bus->bus_icb; if (!twibb_initialized) { TwInit(0); } /* This routine is marked reentrant, so lock the interface. */ if (NutEventWait(&bus->bus_mutex, tmo)) { icb->tw_mm_error = TWERR_IF_LOCKED; return -1; } TwStart(); /* Send SLA+W and check for ACK. */ if ((rc = TwPut(sla << 1)) == 0) { for (cp = (uint8_t *)txdata; txlen--; cp++) { if ((rc = TwPut(*cp)) != 0) { break; } } } if (rc == 0 && rxsiz) { TwStart(); /* Send SLA+R and check for ACK. */ if ((rc = TwPut((sla << 1) | 1)) == 0) { for (cp = rxdata;; cp++) { *cp = TwGet(); if (++rc >= rxsiz) { break; } TwAck(); } } } TwStop(); if (rc == -1) { icb->tw_mm_error = TWERR_SLA_NACK; } /* Release the interface. */ NutEventPost(&bus->bus_mutex); return rc; }
void GUI::init(GLFWwindow* window, const std::string& name){ int width, height; glfwGetWindowSize(window, &width, &height); TwInit(TW_OPENGL, NULL); TwWindowSize(width, height); m_bar = TwNewBar(name.c_str()); // directly redirect GLFW events to AntTweakBar glfwSetMouseButtonCallback(window, (GLFWmousebuttonfun)TwEventMouseButtonGLFW3); glfwSetCursorPosCallback(window, (GLFWcursorposfun)TwEventMousePosGLFW3); glfwSetScrollCallback(window, (GLFWscrollfun)TwEventMouseWheelGLFW3); glfwSetKeyCallback(window, (GLFWkeyfun)TwEventKeyGLFW3); glfwSetCharCallback(window, (GLFWcharfun)TwEventCharGLFW3); }