diff --git a/CMakeLists.txt b/CMakeLists.txt index 032160de..943a3f8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,11 @@ file(GLOB_RECURSE SRCFILES "src/*.cpp") add_executable(Hyprland ${SRCFILES}) +IF(LEGACY_RENDERER MATCHES true) + message(STATUS "Using the legacy GLES2 renderer!") + add_definitions( -DLEGACY_RENDERER ) +ENDIF(LEGACY_RENDERER MATCHES true) + IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) message(STATUS "Configuring Hyprland in Debug with CMake!") ELSE() diff --git a/Makefile b/Makefile index f959427b..8baa9b0e 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,14 @@ idle-protocol.c: idle-protocol.o: idle-protocol.h +legacyrenderer: + mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja + cmake --build ./build --config Release --target all -j 10 + +legacyrendererdebug: + mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja + cmake --build ./build --config Release --target all -j 10 + release: mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -H./ -B./build -G Ninja cmake --build ./build --config Release --target all -j 10 diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index a7563c9d..f02260d0 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -64,8 +64,12 @@ void CHyprError::createQueued() { glBindTexture(GL_TEXTURE_2D, m_tTexture.m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); + + #ifndef GLES2 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); + #endif + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecSize.x, PMONITOR->vecSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); // delete cairo diff --git a/src/includes.hpp b/src/includes.hpp index b82319fd..54893af7 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -84,8 +84,15 @@ extern "C" { #undef static #endif +#ifdef LEGACY_RENDERER +#include +#include +#define GLES2 +#else +#define GLES32 #include #include +#endif #include "helpers/Vector2D.hpp" diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index 3724da37..e27ba486 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -30,15 +30,17 @@ bool CFramebuffer::alloc(int w, int h) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0); + // TODO: Allow this with gles2 + #ifndef GLES2 if (m_pStencilTex) { glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0); glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0); } + #endif auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Framebuffer incomplete, couldn't create! (FB status: %i)", status); @@ -55,7 +57,11 @@ bool CFramebuffer::alloc(int w, int h) { } void CFramebuffer::bind() { + #ifndef GLES2 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb); + #else + glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); + #endif glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y); } diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 8b1b130d..520ea558 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -18,6 +18,10 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() { Debug::log(LOG, "Renderer: %s", glGetString(GL_RENDERER)); Debug::log(LOG, "Supported extensions size: %d", std::count(m_szExtensions.begin(), m_szExtensions.end(), ' ')); + #ifdef GLES2 + Debug::log(WARN, "!RENDERER: Using the legacy GLES2 renderer!"); + #endif + // Init shaders GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC); @@ -509,7 +513,11 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { g_pConfigManager->setInt("decoration:blur", BLURVAL); // restore original fb + #ifndef GLES2 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iCurrentOutputFb); + #else + glBindFramebuffer(GL_FRAMEBUFFER, m_iCurrentOutputFb); + #endif glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y); end(); @@ -575,8 +583,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) { glBindTexture(GL_TEXTURE_2D, PTEX->m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + #ifndef GLES2 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); + #endif glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pMonitor->vecSize.x, pMonitor->vecSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); cairo_surface_destroy(CAIROSURFACE);