Feature/globals handling (#1352)

* Cleaner handling of global state
* Prevent Lua memory corruption (closes #982)
* Initialize glfw first thing to prevent weird joystick loading bug during startup
This commit is contained in:
Alexander Bock
2020-10-21 22:30:05 +02:00
committed by GitHub
parent 1525a0490d
commit efffc25ce0
164 changed files with 1484 additions and 1390 deletions

View File

@@ -78,7 +78,7 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona
setGuiName("ScreenSpaceFramebuffer " + std::to_string(iIdentifier));
}
glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution();
glm::vec2 resolution = global::windowDelegate->currentDrawBufferResolution();
addProperty(_size);
_size.set(glm::vec4(0, 0, resolution.x,resolution.y));
}
@@ -104,7 +104,7 @@ bool ScreenSpaceFramebuffer::deinitializeGL() {
}
void ScreenSpaceFramebuffer::render() {
const glm::vec2& resolution = global::windowDelegate.currentDrawBufferResolution();
const glm::vec2& resolution = global::windowDelegate->currentDrawBufferResolution();
const glm::vec4& size = _size.value();
const float xratio = resolution.x / (size.z - size.x);
@@ -113,14 +113,14 @@ void ScreenSpaceFramebuffer::render() {
if (!_renderFunctions.empty()) {
GLint viewport[4];
//glGetIntegerv(GL_VIEWPORT, viewport);
global::renderEngine.openglStateCache().viewport(viewport);
global::renderEngine->openglStateCache().viewport(viewport);
glViewport(
static_cast<GLint>(-size.x * xratio),
static_cast<GLint>(-size.y * yratio),
static_cast<GLsizei>(resolution.x * xratio),
static_cast<GLsizei>(resolution.y * yratio)
);
global::renderEngine.openglStateCache().setViewportState(viewport);
global::renderEngine->openglStateCache().setViewportState(viewport);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
@@ -171,7 +171,7 @@ void ScreenSpaceFramebuffer::removeAllRenderFunctions() {
}
void ScreenSpaceFramebuffer::createFramebuffer() {
glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution();
glm::vec2 resolution = global::windowDelegate->currentDrawBufferResolution();
_framebuffer = std::make_unique<ghoul::opengl::FramebufferObject>();
_framebuffer->activate();