Initial Commit

This commit is contained in:
2025-04-14 23:07:35 -04:00
commit d5c5059140
4 changed files with 194 additions and 0 deletions

48
CMakeLists.txt Normal file
View File

@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.30)
project(ReShader
VERSION 1.0
LANGUAGES CXX)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed!")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cmake/CPM.cmake)
CPMAddPackage(NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip)
CPMAddPackage(NAME mcolor
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-6.2.zip)
CPMAddPackage(NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-12.zip)
CPMAddPackage(NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/3.4.5.zip)
CPMAddPackage(NAME ReWindow
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-32.zip)
CPMAddPackage(NAME JGL
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-52.zip)
CPMAddPackage(NAME JUI
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-5.16.zip)
add_executable(ReShader main.cpp)
target_include_directories(ReShader PUBLIC ${Event_SOURCE_DIR}/include)
target_include_directories(ReShader PUBLIC ${J3ML_SOURCE_DIR}/include)
target_include_directories(ReShader PUBLIC ${jlog_SOURCE_DIR}/include)
target_include_directories(ReShader PUBLIC ${JGL_SOURCE_DIR}/include)
target_include_directories(ReShader PUBLIC ${ReWindow_SOURCE_DIR}/include)
target_include_directories(ReShader PUBLIC ${JUI_SOURCE_DIR}/include)
target_link_libraries(ReShader PUBLIC Event J3ML jlog ReWindow JGL JUI)

8
README.md Normal file
View File

@@ -0,0 +1,8 @@
# ReShader
A program and codebase for rapid iteration of GLSL programs.
## Features
* Hot Reload
* This Dick
* Public Domain

24
cmake/CPM.cmake Normal file
View File

@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
set(CPM_DOWNLOAD_VERSION 0.38.7)
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)
include(${CPM_DOWNLOAD_LOCATION})

114
main.cpp Normal file
View File

@@ -0,0 +1,114 @@
#include <iostream>
#include <ReWindow/types/Window.h>
#include <JUI/Widgets/Scene.hpp>
#include <JUI/Widgets/Window.hpp>
class ReShaderProgram : public ReWindow::OpenGLWindow {
public:
JUI::Scene* scene;
ReShaderProgram() : ReWindow::OpenGLWindow("ReShader", 1080, 720, 2, 1) {
}
void CreateMenu() {
using namespace JUI::UDimLiterals;
auto* wind = new JUI::Window(scene);
wind->SetTitle("ReShader");
wind->MinSize({100, 100});
wind->Size({200_px, 200_px});
}
bool Open() override
{
if (!OpenGLWindow::Open())
return false;
auto size = GetSize();
auto vec_size = Vector2i(size.x, size.y);
bool result = JGL::Init(vec_size, 0.f, 0.f);
JGL::Update(vec_size);
glClearColor(0.f, 0.f, 0.f, 0.f);
// TODO: Delete when we update to the next release of JGL
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // NOTE: This MUST be called for text rendering to work properly!!!
scene = new JUI::Scene();
CreateMenu();
return true;
}
void PropagateWindowSize() {
auto size = GetSize();
Vector2i vSize = Vector2i(size.x, size.y);
JGL::Update(vSize);
scene->SetViewportSize(Vector2(vSize));
}
void Update(float elapsed) {
scene->Update(elapsed);
}
void Draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
scene->Draw();
}
void OnRefresh(float elapsed) override {
Update(elapsed);
PropagateWindowSize();
Draw();
this->SwapBuffers();
}
void OnMouseButtonDown(const ReWindow::MouseButtonDownEvent &e) override {
if (e.Button == MouseButtons::Left)
scene->ObserveMouseInput(JUI::MouseButton::Left, true);
if (e.Button == MouseButtons::Middle)
scene->ObserveMouseInput(JUI::MouseButton::Middle, true);
if (e.Button == MouseButtons::Right)
scene->ObserveMouseInput(JUI::MouseButton::Right, true);
}
void OnMouseButtonUp(const ReWindow::MouseButtonUpEvent &e) override {
if (e.Button == MouseButtons::Left)
scene->ObserveMouseInput(JUI::MouseButton::Left, false);
if (e.Button == MouseButtons::Middle)
scene->ObserveMouseInput(JUI::MouseButton::Middle, false);
if (e.Button == MouseButtons::Right)
scene->ObserveMouseInput(JUI::MouseButton::Right, false);
}
void OnMouseMove(const ReWindow::MouseMoveEvent &e) override {
Vector2 nmp = Vector2(e.Position.x, e.Position.y);
scene->ObserveMouseMovement(nmp);
}
void OnKeyDown(const ReWindow::KeyDownEvent &e) override {
scene->ObserveKeyInput(e.key, true);
}
void OnKeyUp(const ReWindow::KeyUpEvent &e) override {
scene->ObserveKeyInput(e.key, false);
}
protected:
private:
};
int main(int argc, char** argv) {
auto* program = new ReShaderProgram();
program->Open();
program->SetFullscreen(false);
program->SetVsyncEnabled(false);
program->SetResizable(true);
while (program->IsAlive())
program->ManagedRefresh();
return 0;
}