| 23 | } |
| 24 | |
| 25 | void SimulationView::setup(SimulationFacade const& simulationFacade) |
| 26 | { |
| 27 | _simulationFacade = simulationFacade; |
| 28 | |
| 29 | _cellDetailOverlayActive = GlobalSettings::get().getValue("settings.simulation view.overlay", _cellDetailOverlayActive); |
| 30 | _brightness = GlobalSettings::get().getValue("windows.simulation view.brightness", _brightness); |
| 31 | _contrast = GlobalSettings::get().getValue("windows.simulation view.contrast", _contrast); |
| 32 | _motionBlur = GlobalSettings::get().getValue("windows.simulation view.motion blur factor", _motionBlur); |
| 33 | |
| 34 | _shader = std::make_shared<_Shader>(Const::SimulationVertexShader, Const::SimulationFragmentShader); |
| 35 | |
| 36 | _scrollbarX = std::make_shared<_SimulationScrollbar>( |
| 37 | "SimScrollbarX", _SimulationScrollbar ::Orientation::Horizontal, _simulationFacade); |
| 38 | _scrollbarY = std::make_shared<_SimulationScrollbar>( |
| 39 | "SimScrollbarY", _SimulationScrollbar::Orientation::Vertical, _simulationFacade); |
| 40 | |
| 41 | // set up vertex data (and buffer(s)) and configure vertex attributes |
| 42 | // ------------------------------------------------------------------ |
| 43 | float vertices[] = { |
| 44 | // positions // texture coordinates |
| 45 | 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, // top right |
| 46 | 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, // bottom right |
| 47 | -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, // bottom left |
| 48 | -1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left |
| 49 | }; |
| 50 | unsigned int indices[] = { |
| 51 | 0, |
| 52 | 1, |
| 53 | 3, // first triangle |
| 54 | 1, |
| 55 | 2, |
| 56 | 3 // second triangle |
| 57 | }; |
| 58 | glGenVertexArrays(1, &_vao); |
| 59 | glGenBuffers(1, &_vbo); |
| 60 | glGenBuffers(1, &_ebo); |
| 61 | |
| 62 | glBindVertexArray(_vao); |
| 63 | |
| 64 | glBindBuffer(GL_ARRAY_BUFFER, _vbo); |
| 65 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
| 66 | |
| 67 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ebo); |
| 68 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); |
| 69 | |
| 70 | // position attribute |
| 71 | glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0); |
| 72 | glEnableVertexAttribArray(0); |
| 73 | |
| 74 | // texture coordinate attribute |
| 75 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float))); |
| 76 | glEnableVertexAttribArray(1); |
| 77 | |
| 78 | resize(Viewport::get().getViewSize()); |
| 79 | |
| 80 | _shader->use(); |
| 81 | _shader->setInt("texture1", 0); |
| 82 | _shader->setInt("texture2", 1); |
nothing calls this directly
no test coverage detected