mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-15 13:52:23 +08:00
+ added proper value for a_TexCoord when the rendering is not hapening from the main texture
TODO: THIS IS ALL EXPERIMENTAL CODE, THESE VALUES WILL BE SETUP ON STARTUP AND NOT ON RUNTIME Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
06c519ce79
commit
09d53e8dd7
@ -94,6 +94,17 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
|
||||
memcpy (this->m_texCoordList, data2, sizeof (data2));
|
||||
|
||||
GLfloat data3 [] = {
|
||||
0.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f
|
||||
};
|
||||
|
||||
memcpy (this->m_passTexCoordList, data3, sizeof (data3));
|
||||
|
||||
// bind vertex list to the openGL buffers
|
||||
glGenBuffers (1, &this->m_vertexBuffer);
|
||||
glBindBuffer (GL_ARRAY_BUFFER, this->m_vertexBuffer);
|
||||
@ -108,6 +119,10 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
glBindBuffer (GL_ARRAY_BUFFER, this->m_texCoordBuffer);
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof (this->m_texCoordList), this->m_texCoordList, GL_STATIC_DRAW);
|
||||
|
||||
glGenBuffers (1, &this->m_passTexCoordBuffer);
|
||||
glBindBuffer (GL_ARRAY_BUFFER, this->m_passTexCoordBuffer);
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof (this->m_passTexCoordList), this->m_passTexCoordList, GL_STATIC_DRAW);
|
||||
|
||||
// generate the main material used to render the image
|
||||
this->m_material = new Effects::CMaterial (this, this->m_image->getMaterial ());
|
||||
|
||||
@ -130,8 +145,6 @@ void CImage::render ()
|
||||
// get the orthogonal projection
|
||||
auto projection = this->getScene ()->getScene ()->getOrthogonalProjection ();
|
||||
|
||||
std::cout << "Rendering " << this->getImage ()->getName () << "\n";
|
||||
|
||||
// pinpong current buffer
|
||||
this->getScene ()->pinpongFramebuffer (&drawTo, nullptr);
|
||||
// render all the other materials
|
||||
@ -285,4 +298,9 @@ const GLuint* CImage::getTexCoordBuffer () const
|
||||
return &this->m_texCoordBuffer;
|
||||
}
|
||||
|
||||
const GLuint* CImage::getPassTexCoordBuffer () const
|
||||
{
|
||||
return &this->m_passTexCoordBuffer;
|
||||
}
|
||||
|
||||
const std::string CImage::Type = "image";
|
@ -39,6 +39,7 @@ namespace WallpaperEngine::Render::Objects
|
||||
const GLuint* getVertexBuffer () const;
|
||||
const GLuint* getPassVertexBuffer () const;
|
||||
const GLuint* getTexCoordBuffer () const;
|
||||
const GLuint* getPassTexCoordBuffer () const;
|
||||
const CTexture* getTexture () const;
|
||||
|
||||
protected:
|
||||
@ -49,9 +50,11 @@ namespace WallpaperEngine::Render::Objects
|
||||
GLfloat m_vertexList [6 * 3];
|
||||
GLfloat m_passesVertexList [6 * 3];
|
||||
GLfloat m_texCoordList [6 * 2];
|
||||
GLfloat m_passTexCoordList [6 * 2];
|
||||
GLuint m_vertexBuffer;
|
||||
GLuint m_passesVertexBuffer;
|
||||
GLuint m_texCoordBuffer;
|
||||
GLuint m_passTexCoordBuffer;
|
||||
uint16_t m_vertexIndices [6];
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ void CPass::render (GLuint drawTo, GLuint input)
|
||||
// update a_TexCoord and a_Position based on what to draw to
|
||||
// this should not be required once we do some prediction on rendering things
|
||||
// but for now should be enough
|
||||
this->a_TexCoord = *this->m_material->getImage ()->getTexCoordBuffer ();
|
||||
this->a_TexCoord = (input == this->m_material->getImage ()->getTexture ()->getTextureID ()) ? *this->m_material->getImage ()->getTexCoordBuffer () : *this->m_material->getImage ()->getPassTexCoordBuffer ();
|
||||
this->a_Position = (drawTo > 0) ? *this->m_material->getImage ()->getPassVertexBuffer () : *this->m_material->getImage ()->getVertexBuffer ();
|
||||
// use the shader we have registered
|
||||
glUseProgram (this->m_programID);
|
||||
@ -140,7 +140,7 @@ void CPass::render (GLuint drawTo, GLuint input)
|
||||
glVertexAttribPointer ((*cur)->id, (*cur)->elements, (*cur)->type, GL_FALSE, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// start actual rendering now
|
||||
glBindBuffer (GL_ARRAY_BUFFER, (drawTo > 0) ? *this->m_material->getImage ()->getPassVertexBuffer () : *this->m_material->getImage ()->getVertexBuffer ());
|
||||
glDrawArrays (GL_TRIANGLES, 0, 6);
|
||||
|
Loading…
Reference in New Issue
Block a user