| 97 | } |
| 98 | |
| 99 | void SimulationView::resize(IntVector2D const& size) |
| 100 | { |
| 101 | if (_areTexturesInitialized) { |
| 102 | glDeleteFramebuffers(1, &_fbo1); |
| 103 | glDeleteFramebuffers(1, &_fbo2); |
| 104 | glDeleteTextures(1, &_textureSimulationId); |
| 105 | glDeleteTextures(1, &_textureFramebufferId1); |
| 106 | glDeleteTextures(1, &_textureFramebufferId2); |
| 107 | _areTexturesInitialized = true; |
| 108 | } |
| 109 | glGenTextures(1, &_textureSimulationId); |
| 110 | glBindTexture(GL_TEXTURE_2D, _textureSimulationId); |
| 111 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 112 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 113 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 114 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 115 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, size.x, size.y, 0, GL_RGB, GL_UNSIGNED_SHORT, NULL); |
| 116 | _simulationFacade->setImageResource(reinterpret_cast<void*>(uintptr_t(_textureSimulationId))); |
| 117 | |
| 118 | glGenTextures(1, &_textureFramebufferId1); |
| 119 | glBindTexture(GL_TEXTURE_2D, _textureFramebufferId1); |
| 120 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 121 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 122 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 123 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 124 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, size.x, size.y, 0, GL_RGB, GL_UNSIGNED_SHORT, NULL); |
| 125 | |
| 126 | glGenTextures(1, &_textureFramebufferId2); |
| 127 | glBindTexture(GL_TEXTURE_2D, _textureFramebufferId2); |
| 128 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 129 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 130 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 131 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 132 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, size.x, size.y, 0, GL_RGB, GL_UNSIGNED_SHORT, NULL); |
| 133 | |
| 134 | glGenFramebuffers(1, &_fbo1); |
| 135 | glBindFramebuffer(GL_FRAMEBUFFER, _fbo1); |
| 136 | glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _textureFramebufferId1, 0); |
| 137 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 138 | |
| 139 | glGenFramebuffers(1, &_fbo2); |
| 140 | glBindFramebuffer(GL_FRAMEBUFFER, _fbo2); |
| 141 | glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _textureFramebufferId2, 0); |
| 142 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 143 | |
| 144 | Viewport::get().setViewSize(size); |
| 145 | } |
| 146 | |
| 147 | void SimulationView::draw() |
| 148 | { |
no test coverage detected