mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 13:22:23 +08:00
~ brought back path fixing functionality so all paths given in the command line now end with a /
+ added support for texture format definition (TEX0FORMAT) although it might need some more investigation (specially for multi-pass shaders) + added implicit conversion from vec3 to vec2 in shaders Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
154fe905bc
commit
03c4660f5c
35
main.cpp
35
main.cpp
@ -46,17 +46,24 @@ void print_help (const char* route)
|
||||
<< " --fps <maximum-fps>\tLimits the FPS to the given number, useful to keep battery consumption low" << std::endl;
|
||||
}
|
||||
|
||||
std::string stringPathFixes(const std::string& s){
|
||||
std::string str(s);
|
||||
if(str.empty())
|
||||
std::string stringPathFixes(const std::string& s)
|
||||
{
|
||||
if (s.empty () == true)
|
||||
return s;
|
||||
if(str[0] == '\'' && str[str.size() - 1] == '\''){
|
||||
str.erase(str.size() - 1, 1);
|
||||
str.erase(0,1);
|
||||
}
|
||||
if(str[str.size() - 1] != '/')
|
||||
|
||||
std::string str (s);
|
||||
|
||||
// remove single-quotes from the arguments
|
||||
if (str [0] == '\'' && str [str.size() - 1] == '\'')
|
||||
str
|
||||
.erase (str.size() - 1, 1)
|
||||
.erase (0, 1);
|
||||
|
||||
// ensure there's a slash at the end of the path
|
||||
if (str [str.size() - 1] != '/')
|
||||
str += '/';
|
||||
return std::move(str);
|
||||
|
||||
return std::move (str);
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
@ -98,13 +105,13 @@ int main (int argc, char* argv[])
|
||||
case 'p':
|
||||
if (mode == RUN_MODE_UNKNOWN)
|
||||
mode = RUN_MODE_PACKAGE;
|
||||
path = optarg;
|
||||
path = stringPathFixes (optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (mode == RUN_MODE_UNKNOWN)
|
||||
mode = RUN_MODE_DIRECTORY;
|
||||
path = optarg;
|
||||
path = stringPathFixes (optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@ -184,6 +191,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
glfwMakeContextCurrent (window);
|
||||
|
||||
// TODO: FIGURE THESE OUT BASED ON THE SCREEN
|
||||
int windowWidth = 1920;
|
||||
int windowHeight = 1080;
|
||||
|
||||
@ -201,14 +209,13 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
WallpaperEngine::Core::CScene* scene = project->getWallpaper ()->as <WallpaperEngine::Core::CScene> ();
|
||||
wallpaper = new WallpaperEngine::Render::CScene (scene, containers);
|
||||
// TODO: BUILD THE SCENE
|
||||
}
|
||||
else if (project->getType () == "video")
|
||||
{
|
||||
// special steps, running a video needs a root directory change
|
||||
// special steps, running a video needs a root directory change, files are not loaded from the container classes
|
||||
// as they're streamed from disk
|
||||
chdir (path.c_str ());
|
||||
|
||||
// TODO: BUILD THE VIDEO OBJECT
|
||||
WallpaperEngine::Core::CVideo* video = project->getWallpaper ()->as <WallpaperEngine::Core::CVideo> ();
|
||||
wallpaper = new WallpaperEngine::Render::CVideo (video, containers);
|
||||
}
|
||||
|
@ -41,6 +41,12 @@ CTexture::CTexture (void* fileData)
|
||||
case TextureFormat::ARGB8888:
|
||||
internalFormat = GL_RGBA8;
|
||||
break;
|
||||
case TextureFormat::R8:
|
||||
internalFormat = GL_R8;
|
||||
break;
|
||||
case TextureFormat::RG88:
|
||||
internalFormat = GL_RG8;
|
||||
break;
|
||||
default:
|
||||
delete this->m_header;
|
||||
throw std::runtime_error ("Cannot determine the texture format");
|
||||
@ -119,6 +125,13 @@ CTexture::CTexture (void* fileData)
|
||||
height = FreeImage_GetHeight (converted);
|
||||
textureFormat = GL_BGRA;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->m_header->format == TextureFormat::RG88)
|
||||
textureFormat = GL_RG;
|
||||
else if (this->m_header->format == TextureFormat::R8)
|
||||
textureFormat = GL_R;
|
||||
}
|
||||
|
||||
switch (internalFormat)
|
||||
{
|
||||
@ -275,19 +288,6 @@ void CTexture::parseHeader (char* fileData)
|
||||
throw std::runtime_error ("unknown texture format type");
|
||||
}
|
||||
|
||||
if (this->m_header->format == TextureFormat::R8)
|
||||
{
|
||||
delete this->m_header;
|
||||
this->m_header = nullptr;
|
||||
throw std::runtime_error ("R8 format is not supported yet");
|
||||
}
|
||||
else if (this->m_header->format == TextureFormat::RG88)
|
||||
{
|
||||
delete this->m_header;
|
||||
this->m_header = nullptr;
|
||||
throw std::runtime_error ("RG88 format is not supported yet");
|
||||
}
|
||||
|
||||
// read the number of mipmaps available
|
||||
this->m_header->mipmapCount = *pointer ++;
|
||||
|
||||
|
@ -13,14 +13,16 @@ namespace WallpaperEngine::Assets
|
||||
{
|
||||
class CTexture
|
||||
{
|
||||
private:
|
||||
enum ContainerVersion : int
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
TEXB0003 = 3,
|
||||
TEXB0002 = 2,
|
||||
TEXB0001 = 1
|
||||
};
|
||||
struct TextureHeader;
|
||||
|
||||
public:
|
||||
CTexture (void* fileData);
|
||||
~CTexture ();
|
||||
|
||||
const GLuint getTextureID () const;
|
||||
const TextureHeader* getHeader () const;
|
||||
const glm::vec4* getResolution () const;
|
||||
|
||||
|
||||
enum TextureFormat : uint32_t
|
||||
{
|
||||
@ -31,6 +33,14 @@ namespace WallpaperEngine::Assets
|
||||
RG88 = 8,
|
||||
R8 = 9,
|
||||
};
|
||||
private:
|
||||
enum ContainerVersion : int
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
TEXB0003 = 3,
|
||||
TEXB0002 = 2,
|
||||
TEXB0001 = 1
|
||||
};
|
||||
|
||||
class TextureMipmap
|
||||
{
|
||||
@ -96,15 +106,6 @@ namespace WallpaperEngine::Assets
|
||||
/** List of mipmaps */
|
||||
std::vector <TextureMipmap*> mipmaps;
|
||||
};
|
||||
public:
|
||||
CTexture (void* fileData);
|
||||
~CTexture ();
|
||||
|
||||
const GLuint getTextureID () const;
|
||||
const TextureHeader* getHeader () const;
|
||||
const glm::vec4* getResolution () const;
|
||||
|
||||
|
||||
private:
|
||||
void parseHeader (char* fileData);
|
||||
TextureMipmap* parseMipmap (TextureHeader* header, char** fileData);
|
||||
|
@ -24,23 +24,6 @@ CPass::CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass
|
||||
m_material (material),
|
||||
m_pass (pass)
|
||||
{
|
||||
this->m_fragShader = new Render::Shaders::Compiler (
|
||||
this->m_material->getImage ()->getContainer (),
|
||||
pass->getShader (),
|
||||
Shaders::Compiler::Type_Pixel,
|
||||
pass->getCombos (),
|
||||
pass->getConstants ()
|
||||
);
|
||||
this->m_fragShader->precompile ();
|
||||
this->m_vertShader = new Render::Shaders::Compiler (
|
||||
this->m_material->getImage ()->getContainer (),
|
||||
pass->getShader (),
|
||||
Shaders::Compiler::Type_Vertex,
|
||||
this->m_fragShader->getCombos (),
|
||||
pass->getConstants ()
|
||||
);
|
||||
this->m_vertShader->precompile ();
|
||||
|
||||
this->setupTextures ();
|
||||
this->setupShaders ();
|
||||
this->setupShaderVariables ();
|
||||
@ -261,6 +244,37 @@ GLuint CPass::compileShader (Render::Shaders::Compiler* shader, GLuint type)
|
||||
|
||||
void CPass::setupShaders ()
|
||||
{
|
||||
// ensure the constants are defined
|
||||
const CTexture* texture0 = this->m_material->getImage ()->getTexture ();
|
||||
|
||||
// TODO: THE VALUES ARE THE SAME AS THE ENUMERATION, SO MAYBE IT HAS TO BE SPECIFIED FOR THE TEXTURE 0 OF ALL ELEMENTS?
|
||||
if (texture0->getHeader ()->format == CTexture::TextureFormat::RG88)
|
||||
{
|
||||
this->m_pass->insertCombo ("TEX0FORMAT", 8);
|
||||
}
|
||||
else if (texture0->getHeader ()->format == CTexture::TextureFormat::R8)
|
||||
{
|
||||
this->m_pass->insertCombo ("TEX0FORMAT", 9);
|
||||
}
|
||||
|
||||
// prepare the shaders
|
||||
this->m_fragShader = new Render::Shaders::Compiler (
|
||||
this->m_material->getImage ()->getContainer (),
|
||||
this->m_pass->getShader (),
|
||||
Shaders::Compiler::Type_Pixel,
|
||||
this->m_pass->getCombos (),
|
||||
this->m_pass->getConstants ()
|
||||
);
|
||||
this->m_fragShader->precompile ();
|
||||
this->m_vertShader = new Render::Shaders::Compiler (
|
||||
this->m_material->getImage ()->getContainer (),
|
||||
this->m_pass->getShader (),
|
||||
Shaders::Compiler::Type_Vertex,
|
||||
this->m_fragShader->getCombos (),
|
||||
this->m_pass->getConstants ()
|
||||
);
|
||||
this->m_vertShader->precompile ();
|
||||
|
||||
// compile the shaders
|
||||
GLuint vertexShaderID = compileShader (this->m_vertShader, GL_VERTEX_SHADER);
|
||||
GLuint fragmentShaderID = compileShader (this->m_fragShader, GL_FRAGMENT_SHADER);
|
||||
@ -447,8 +461,6 @@ void CPass::setupTextures ()
|
||||
if (index == 0)
|
||||
continue;
|
||||
|
||||
uint32_t textureSize = 0;
|
||||
|
||||
// get the first texture on the first pass (this one represents the image assigned to this object)
|
||||
this->m_textures.emplace_back (
|
||||
this->m_material->getImage ()->getContainer ()->readTexture ((*cur))
|
||||
@ -501,6 +513,13 @@ void CPass::setupShaderVariables ()
|
||||
// create a float value from an integer
|
||||
this->addUniform (var->getName (), static_cast <float> (*(*cur).second->as <CShaderConstantInteger> ()->getValue ()));
|
||||
}
|
||||
else if ((*cur).second->is <CShaderConstantVector3> () == true && var->is <CShaderVariableVector2> () == true)
|
||||
{
|
||||
CShaderConstantVector3* val = (*cur).second->as <CShaderConstantVector3> ();
|
||||
|
||||
// create a new vector2 with the first two values
|
||||
this->addUniform (var->getName (), {val->getValue ()->x, val->getValue ()->y});
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error ("Constant and pixel/vertex variable are not of the same type");
|
||||
|
Loading…
Reference in New Issue
Block a user