diff --git a/main.cpp b/main.cpp index db0ab96..3180819 100644 --- a/main.cpp +++ b/main.cpp @@ -131,8 +131,9 @@ void initGLFW () // set some window hints (opengl version to be used) glfwWindowHint (GLFW_SAMPLES, 4); - glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if (DEBUG) glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); diff --git a/src/WallpaperEngine/Render/CCamera.cpp b/src/WallpaperEngine/Render/CCamera.cpp index 2008a78..0483b73 100644 --- a/src/WallpaperEngine/Render/CCamera.cpp +++ b/src/WallpaperEngine/Render/CCamera.cpp @@ -56,7 +56,7 @@ void CCamera::setOrthogonalProjection (float width, float height) { // TODO: GET THE ZNEAR AND ZFAR FROM THE BACKGROUND (IF AVAILABLE) // get the orthogonal projection (the float is there to ensure the values are casted to float, so maths do work) - this->m_projection = glm::ortho (-width / 2, width / 2, -height / 2, height / 2, 0, 1000); + this->m_projection = glm::ortho (-width / 2.0, width / 2.0, -height / 2.0, height / 2.0, 0, 1000); this->m_projection = glm::translate (this->m_projection, this->getEye ()); // update the orthogonal flag this->m_isOrthogonal = true; diff --git a/src/WallpaperEngine/Render/CWallpaper.cpp b/src/WallpaperEngine/Render/CWallpaper.cpp index ddee0b8..1612f6a 100644 --- a/src/WallpaperEngine/Render/CWallpaper.cpp +++ b/src/WallpaperEngine/Render/CWallpaper.cpp @@ -14,6 +14,10 @@ CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CCont m_context (context), m_destFramebuffer (GL_NONE) { + // generate the VAO to stop opengl from complaining + glGenVertexArrays (1, &this->m_vaoBuffer); + glBindVertexArray (this->m_vaoBuffer); + this->setupShaders (); GLfloat texCoords [] = { diff --git a/src/WallpaperEngine/Render/CWallpaper.h b/src/WallpaperEngine/Render/CWallpaper.h index e3bc744..dfa7471 100644 --- a/src/WallpaperEngine/Render/CWallpaper.h +++ b/src/WallpaperEngine/Render/CWallpaper.h @@ -128,6 +128,7 @@ namespace WallpaperEngine::Render GLint g_Texture0; GLint a_Position; GLint a_TexCoord; + GLuint m_vaoBuffer; /** * The framebuffer to draw the background to */ diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index 5fb3b1d..61ce853 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -19,14 +19,13 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : glm::vec3 origin = this->getImage ()->getOrigin (); glm::vec2 size = this->getSize (); glm::vec3 scale = this->getImage ()->getScale (); - glm::vec2 scaledSize = size * glm::vec2 (scale); // calculate the center and shift from there - this->m_pos.x = (-scene_width / 2) + (origin.x - (scaledSize.x / 2)); - this->m_pos.z = (-scene_width / 2) + (origin.x + (scaledSize.x / 2)); - this->m_pos.y = (-scene_height / 2) + origin.y + (scaledSize.y / 2); - this->m_pos.w = (-scene_height / 2) + (origin.y - (scaledSize.y / 2)); + this->m_pos.x = origin.x - (scaledSize.x / 2); + this->m_pos.w = origin.y + (scaledSize.y / 2); + this->m_pos.z = origin.x + (scaledSize.x / 2); + this->m_pos.y = origin.y - (scaledSize.y / 2); if (this->getImage ()->getAlignment ().find ("top") != std::string::npos) { @@ -50,6 +49,12 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : this->m_pos.z -= scaledSize.x / 2; } + // wallpaper engine + this->m_pos.x -= scene_width / 2; + this->m_pos.y = scene_height / 2 - this->m_pos.y; + this->m_pos.z -= scene_width / 2; + this->m_pos.w = scene_height / 2 - this->m_pos.w; + // detect texture (if any) auto textures = (*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures (); @@ -105,35 +110,35 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : this->m_texture->getRealWidth (), this->m_texture->getRealHeight () ); - GLfloat realWidth = this->m_texture->getRealWidth () / 2.0f; - GLfloat realHeight = this->m_texture->getRealHeight () / 2.0f; + GLfloat realWidth = this->m_texture->getRealWidth (); + GLfloat realHeight = this->m_texture->getRealHeight (); // build a list of vertices, these might need some change later (or maybe invert the camera) GLfloat sceneSpacePosition [] = { + this->m_pos.x, this->m_pos.y, 0.0f, this->m_pos.x, this->m_pos.w, 0.0f, - this->m_pos.z, this->m_pos.w, 0.0f, - this->m_pos.x, this->m_pos.y, 0.0f, - this->m_pos.x, this->m_pos.y, 0.0f, - this->m_pos.z, this->m_pos.w, 0.0f, - this->m_pos.z, this->m_pos.y, 0.0f + this->m_pos.z, this->m_pos.y, 0.0f, + this->m_pos.z, this->m_pos.y, 0.0f, + this->m_pos.x, this->m_pos.w, 0.0f, + this->m_pos.z, this->m_pos.w, 0.0f }; GLfloat copySpacePosition [] = { - -realWidth, -realHeight, 0.0f, - realWidth, -realHeight, 0.0f, - -realWidth, realHeight, 0.0f, - -realWidth, realHeight, 0.0f, - realWidth, -realHeight, 0.0f, - realWidth, realHeight, 0.0f + 0.0, realHeight, 0.0f, + 0.0, 0.0, 0.0f, + realWidth, realHeight, 0.0f, + realWidth, realHeight, 0.0f, + 0.0, 0.0, 0.0f, + realWidth, 0.0, 0.0f }; GLfloat passSpacePosition [] = { - -1.0f, -1.0f, 0.0f, - 1.0f, -1.0f, 0.0f, - -1.0f, 1.0f, 0.0f, - -1.0f, 1.0f, 0.0f, - 1.0f, -1.0f, 0.0f, - 1.0f, 1.0f, 0.0f + -1.0, 1.0, 0.0f, + -1.0, -1.0, 0.0f, + 1.0, 1.0, 0.0f, + 1.0, 1.0, 0.0f, + -1.0, -1.0, 0.0f, + 1.0, -1.0, 0.0f }; float width = 1.0f; @@ -174,21 +179,21 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : } GLfloat texcoordCopy [] = { + x, height, x, y, - width, y, - x, height, - x, height, - width, y, - width, height + width, height, + width, height, + x, y, + width, y }; GLfloat texcoordPass [] = { + 0.0f, 1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, - 0.0f, 1.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f + 1.0f, 1.0f, + 1.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f }; // bind vertex list to the openGL buffers @@ -217,8 +222,7 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : this->getScene ()->getCamera ()->getProjection () * this->getScene ()->getCamera ()->getLookAt (); - this->m_modelViewProjectionPass = - glm::ortho (-size.x / 2, size.x / 2, -size.y / 2, size.y / 2, 0, 10000); + this->m_modelViewProjectionPass = glm::ortho (0.0, size.x, 0.0, size.y); } void CImage::setup ()