mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-15 22:02:29 +08:00
Bumped up to OpenGL 3.3
Added base VAO Fixed scene image align issues and things being flipped vertically under specific situations Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
0843f69edf
commit
672ea47d23
5
main.cpp
5
main.cpp
@ -131,8 +131,9 @@ void initGLFW ()
|
|||||||
|
|
||||||
// set some window hints (opengl version to be used)
|
// set some window hints (opengl version to be used)
|
||||||
glfwWindowHint (GLFW_SAMPLES, 4);
|
glfwWindowHint (GLFW_SAMPLES, 4);
|
||||||
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2);
|
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1);
|
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
|
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||||
|
@ -56,7 +56,7 @@ void CCamera::setOrthogonalProjection (float width, float height)
|
|||||||
{
|
{
|
||||||
// TODO: GET THE ZNEAR AND ZFAR FROM THE BACKGROUND (IF AVAILABLE)
|
// 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)
|
// 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 <float> (-width / 2, width / 2, -height / 2, height / 2, 0, 1000);
|
this->m_projection = glm::ortho <float> (-width / 2.0, width / 2.0, -height / 2.0, height / 2.0, 0, 1000);
|
||||||
this->m_projection = glm::translate (this->m_projection, this->getEye ());
|
this->m_projection = glm::translate (this->m_projection, this->getEye ());
|
||||||
// update the orthogonal flag
|
// update the orthogonal flag
|
||||||
this->m_isOrthogonal = true;
|
this->m_isOrthogonal = true;
|
||||||
|
@ -14,6 +14,10 @@ CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CCont
|
|||||||
m_context (context),
|
m_context (context),
|
||||||
m_destFramebuffer (GL_NONE)
|
m_destFramebuffer (GL_NONE)
|
||||||
{
|
{
|
||||||
|
// generate the VAO to stop opengl from complaining
|
||||||
|
glGenVertexArrays (1, &this->m_vaoBuffer);
|
||||||
|
glBindVertexArray (this->m_vaoBuffer);
|
||||||
|
|
||||||
this->setupShaders ();
|
this->setupShaders ();
|
||||||
|
|
||||||
GLfloat texCoords [] = {
|
GLfloat texCoords [] = {
|
||||||
|
@ -128,6 +128,7 @@ namespace WallpaperEngine::Render
|
|||||||
GLint g_Texture0;
|
GLint g_Texture0;
|
||||||
GLint a_Position;
|
GLint a_Position;
|
||||||
GLint a_TexCoord;
|
GLint a_TexCoord;
|
||||||
|
GLuint m_vaoBuffer;
|
||||||
/**
|
/**
|
||||||
* The framebuffer to draw the background to
|
* The framebuffer to draw the background to
|
||||||
*/
|
*/
|
||||||
|
@ -19,14 +19,13 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
|||||||
glm::vec3 origin = this->getImage ()->getOrigin ();
|
glm::vec3 origin = this->getImage ()->getOrigin ();
|
||||||
glm::vec2 size = this->getSize ();
|
glm::vec2 size = this->getSize ();
|
||||||
glm::vec3 scale = this->getImage ()->getScale ();
|
glm::vec3 scale = this->getImage ()->getScale ();
|
||||||
|
|
||||||
glm::vec2 scaledSize = size * glm::vec2 (scale);
|
glm::vec2 scaledSize = size * glm::vec2 (scale);
|
||||||
|
|
||||||
// calculate the center and shift from there
|
// calculate the center and shift from there
|
||||||
this->m_pos.x = (-scene_width / 2) + (origin.x - (scaledSize.x / 2));
|
this->m_pos.x = origin.x - (scaledSize.x / 2);
|
||||||
this->m_pos.z = (-scene_width / 2) + (origin.x + (scaledSize.x / 2));
|
this->m_pos.w = origin.y + (scaledSize.y / 2);
|
||||||
this->m_pos.y = (-scene_height / 2) + origin.y + (scaledSize.y / 2);
|
this->m_pos.z = origin.x + (scaledSize.x / 2);
|
||||||
this->m_pos.w = (-scene_height / 2) + (origin.y - (scaledSize.y / 2));
|
this->m_pos.y = origin.y - (scaledSize.y / 2);
|
||||||
|
|
||||||
if (this->getImage ()->getAlignment ().find ("top") != std::string::npos)
|
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;
|
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)
|
// detect texture (if any)
|
||||||
auto textures = (*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures ();
|
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 ()
|
this->m_texture->getRealWidth (), this->m_texture->getRealHeight ()
|
||||||
);
|
);
|
||||||
|
|
||||||
GLfloat realWidth = this->m_texture->getRealWidth () / 2.0f;
|
GLfloat realWidth = this->m_texture->getRealWidth ();
|
||||||
GLfloat realHeight = this->m_texture->getRealHeight () / 2.0f;
|
GLfloat realHeight = this->m_texture->getRealHeight ();
|
||||||
|
|
||||||
// build a list of vertices, these might need some change later (or maybe invert the camera)
|
// build a list of vertices, these might need some change later (or maybe invert the camera)
|
||||||
GLfloat sceneSpacePosition [] = {
|
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.x, this->m_pos.w, 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.x, this->m_pos.y, 0.0f,
|
this->m_pos.z, this->m_pos.y, 0.0f,
|
||||||
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.z, this->m_pos.w, 0.0f
|
||||||
this->m_pos.z, this->m_pos.y, 0.0f
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GLfloat copySpacePosition [] = {
|
GLfloat copySpacePosition [] = {
|
||||||
-realWidth, -realHeight, 0.0f,
|
0.0, realHeight, 0.0f,
|
||||||
realWidth, -realHeight, 0.0f,
|
0.0, 0.0, 0.0f,
|
||||||
-realWidth, realHeight, 0.0f,
|
realWidth, realHeight, 0.0f,
|
||||||
-realWidth, realHeight, 0.0f,
|
realWidth, realHeight, 0.0f,
|
||||||
realWidth, -realHeight, 0.0f,
|
0.0, 0.0, 0.0f,
|
||||||
realWidth, realHeight, 0.0f
|
realWidth, 0.0, 0.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
GLfloat passSpacePosition [] = {
|
GLfloat passSpacePosition [] = {
|
||||||
-1.0f, -1.0f, 0.0f,
|
-1.0, 1.0, 0.0f,
|
||||||
1.0f, -1.0f, 0.0f,
|
-1.0, -1.0, 0.0f,
|
||||||
-1.0f, 1.0f, 0.0f,
|
1.0, 1.0, 0.0f,
|
||||||
-1.0f, 1.0f, 0.0f,
|
1.0, 1.0, 0.0f,
|
||||||
1.0f, -1.0f, 0.0f,
|
-1.0, -1.0, 0.0f,
|
||||||
1.0f, 1.0f, 0.0f
|
1.0, -1.0, 0.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
float width = 1.0f;
|
float width = 1.0f;
|
||||||
@ -174,21 +179,21 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLfloat texcoordCopy [] = {
|
GLfloat texcoordCopy [] = {
|
||||||
|
x, height,
|
||||||
x, y,
|
x, y,
|
||||||
width, y,
|
width, height,
|
||||||
x, height,
|
width, height,
|
||||||
x, height,
|
x, y,
|
||||||
width, y,
|
width, y
|
||||||
width, height
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GLfloat texcoordPass [] = {
|
GLfloat texcoordPass [] = {
|
||||||
|
0.0f, 1.0f,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 1.0f,
|
||||||
0.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
0.0f, 1.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f
|
||||||
1.0f, 1.0f
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// bind vertex list to the openGL buffers
|
// 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 ()->getProjection () *
|
||||||
this->getScene ()->getCamera ()->getLookAt ();
|
this->getScene ()->getCamera ()->getLookAt ();
|
||||||
|
|
||||||
this->m_modelViewProjectionPass =
|
this->m_modelViewProjectionPass = glm::ortho <float> (0.0, size.x, 0.0, size.y);
|
||||||
glm::ortho<float> (-size.x / 2, size.x / 2, -size.y / 2, size.y / 2, 0, 10000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CImage::setup ()
|
void CImage::setup ()
|
||||||
|
Loading…
Reference in New Issue
Block a user