diff --git a/tests/regression/user/main.cpp b/tests/regression/main.cpp similarity index 100% rename from tests/regression/user/main.cpp rename to tests/regression/main.cpp diff --git a/tests/regression/user-macos/main.h b/tests/regression/main.h similarity index 100% rename from tests/regression/user-macos/main.h rename to tests/regression/main.h diff --git a/tests/regression/user-macos/rand.cpp b/tests/regression/rand.cpp similarity index 100% rename from tests/regression/user-macos/rand.cpp rename to tests/regression/rand.cpp diff --git a/tests/regression/user-macos/rand.h b/tests/regression/rand.h similarity index 100% rename from tests/regression/user-macos/rand.h rename to tests/regression/rand.h diff --git a/tests/regression/user-macos/CMakeLists.txt b/tests/regression/user-macos/CMakeLists.txt index 77b70c68..3229d5a1 100644 --- a/tests/regression/user-macos/CMakeLists.txt +++ b/tests/regression/user-macos/CMakeLists.txt @@ -9,12 +9,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) include_directories(include) -include_directories(.) +include_directories(../) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) diff --git a/tests/regression/user-macos/main.cpp b/tests/regression/user-macos/main.cpp deleted file mode 100644 index f42db6fd..00000000 --- a/tests/regression/user-macos/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "main.h" - -int main(int argv, char ** argc) -{ - - jGL::DesktopDisplay::Config conf; - - conf.VULKAN = false; - conf.COCOA_RETINA = false; - - jGL::DesktopDisplay display(glm::ivec2(resX, resY), "Shape", conf); - - glewInit(); - - jGLInstance = std::move(std::make_unique(display.getRes())); - - jGL::OrthoCam camera(resX, resY, glm::vec2(0.0,0.0)); - - camera.setPosition(0.0f, 0.0f); - - jLog::Log log; - - high_resolution_clock::time_point tic, tock; - double rdt = 0.0; - - jGLInstance->setTextProjection(glm::ortho(0.0,double(resX),0.0,double(resY))); - jGLInstance->setMSAA(1); - - std::shared_ptr circles = jGLInstance->createShapeRenderer - ( - 32 - ); - - std::vector shapes; - - RNG rng; - - std::vector trans; - std::vector cols; - - trans.reserve(64); - shapes.reserve(64); - cols.reserve(64); - - for (unsigned i = 0; i < 64; i++) - { - trans.push_back(jGL::Transform(rng.nextFloat(), rng.nextFloat(), 0.0, 0.1f)); - cols.push_back(glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0)); - - shapes.push_back - ( - { - &trans[i], - &cols[i] - } - ); - - circles->add(shapes[i], std::to_string(i)); - } - - circles->setProjection(camera.getVP()); - - std::shared_ptr shader = std::make_shared(vertexShader, fragmentShader); - - shader->use(); - - double delta = 0.0; - double dt = 1.0/600.0; - - while (display.isOpen()) - { - tic = high_resolution_clock::now(); - - jGLInstance->beginFrame(); - - jGLInstance->clear(); - - for (unsigned i = 0; i getTransform(std::to_string(i)); - trans[i] = jGL::Transform - ( - tr->x+dt*(rng.nextFloat()-0.5), - tr->y+dt*(rng.nextFloat()-0.5), - tr->theta, - tr->scaleX - ); - } - - circles->draw(shader); - - delta = 0.0; - for (int n = 0; n < 60; n++) - { - delta += deltas[n]; - } - delta /= 60.0; - - std::stringstream debugText; - - double mouseX, mouseY; - display.mousePosition(mouseX,mouseY); - - debugText << "Delta: " << fixedLengthNumber(delta,6) - << " ( FPS: " << fixedLengthNumber(1.0/delta,4) - << ")\n" - << "Render draw time: \n" - << " " << fixedLengthNumber(rdt, 6) << "\n" - << "Mouse (" << fixedLengthNumber(mouseX,4) - << "," - << fixedLengthNumber(mouseY,4) - << ")\n"; - - jGLInstance->text( - debugText.str(), - glm::vec2(64.0f, resY-64.0f), - 0.5f, - glm::vec4(0.0f,0.0f,0.0f,1.0f) - ); - - if (frameId == 30) - { - if (log.size() > 0) - { - std::cout << log << "\n"; - } - } - - jGLInstance->endFrame(); - - display.loop(); - - tock = high_resolution_clock::now(); - - deltas[frameId] = duration_cast>(tock-tic).count(); - frameId = (frameId+1) % 60; - - } - - jGLInstance->finish(); - - return 0; -} \ No newline at end of file diff --git a/tests/regression/user-mingw/CMakeLists.txt b/tests/regression/user-mingw/CMakeLists.txt index d4051f93..cfc229a6 100644 --- a/tests/regression/user-mingw/CMakeLists.txt +++ b/tests/regression/user-mingw/CMakeLists.txt @@ -9,15 +9,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) # launch as windows, not console app - so cmd does not open as well add_link_options(-mwindows) include_directories(include) -include_directories(.) +include_directories(../) find_package(Vulkan REQUIRED) find_package(OpenGL REQUIRED) diff --git a/tests/regression/user-mingw/main.cpp b/tests/regression/user-mingw/main.cpp deleted file mode 100644 index f42db6fd..00000000 --- a/tests/regression/user-mingw/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "main.h" - -int main(int argv, char ** argc) -{ - - jGL::DesktopDisplay::Config conf; - - conf.VULKAN = false; - conf.COCOA_RETINA = false; - - jGL::DesktopDisplay display(glm::ivec2(resX, resY), "Shape", conf); - - glewInit(); - - jGLInstance = std::move(std::make_unique(display.getRes())); - - jGL::OrthoCam camera(resX, resY, glm::vec2(0.0,0.0)); - - camera.setPosition(0.0f, 0.0f); - - jLog::Log log; - - high_resolution_clock::time_point tic, tock; - double rdt = 0.0; - - jGLInstance->setTextProjection(glm::ortho(0.0,double(resX),0.0,double(resY))); - jGLInstance->setMSAA(1); - - std::shared_ptr circles = jGLInstance->createShapeRenderer - ( - 32 - ); - - std::vector shapes; - - RNG rng; - - std::vector trans; - std::vector cols; - - trans.reserve(64); - shapes.reserve(64); - cols.reserve(64); - - for (unsigned i = 0; i < 64; i++) - { - trans.push_back(jGL::Transform(rng.nextFloat(), rng.nextFloat(), 0.0, 0.1f)); - cols.push_back(glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0)); - - shapes.push_back - ( - { - &trans[i], - &cols[i] - } - ); - - circles->add(shapes[i], std::to_string(i)); - } - - circles->setProjection(camera.getVP()); - - std::shared_ptr shader = std::make_shared(vertexShader, fragmentShader); - - shader->use(); - - double delta = 0.0; - double dt = 1.0/600.0; - - while (display.isOpen()) - { - tic = high_resolution_clock::now(); - - jGLInstance->beginFrame(); - - jGLInstance->clear(); - - for (unsigned i = 0; i getTransform(std::to_string(i)); - trans[i] = jGL::Transform - ( - tr->x+dt*(rng.nextFloat()-0.5), - tr->y+dt*(rng.nextFloat()-0.5), - tr->theta, - tr->scaleX - ); - } - - circles->draw(shader); - - delta = 0.0; - for (int n = 0; n < 60; n++) - { - delta += deltas[n]; - } - delta /= 60.0; - - std::stringstream debugText; - - double mouseX, mouseY; - display.mousePosition(mouseX,mouseY); - - debugText << "Delta: " << fixedLengthNumber(delta,6) - << " ( FPS: " << fixedLengthNumber(1.0/delta,4) - << ")\n" - << "Render draw time: \n" - << " " << fixedLengthNumber(rdt, 6) << "\n" - << "Mouse (" << fixedLengthNumber(mouseX,4) - << "," - << fixedLengthNumber(mouseY,4) - << ")\n"; - - jGLInstance->text( - debugText.str(), - glm::vec2(64.0f, resY-64.0f), - 0.5f, - glm::vec4(0.0f,0.0f,0.0f,1.0f) - ); - - if (frameId == 30) - { - if (log.size() > 0) - { - std::cout << log << "\n"; - } - } - - jGLInstance->endFrame(); - - display.loop(); - - tock = high_resolution_clock::now(); - - deltas[frameId] = duration_cast>(tock-tic).count(); - frameId = (frameId+1) % 60; - - } - - jGLInstance->finish(); - - return 0; -} \ No newline at end of file diff --git a/tests/regression/user-mingw/main.h b/tests/regression/user-mingw/main.h deleted file mode 100644 index 7fd73b0d..00000000 --- a/tests/regression/user-mingw/main.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -using namespace std::chrono; - -const int resX = 800; -const int resY = 1000; - -uint8_t frameId = 0; -double deltas[60]; - -std::unique_ptr jGLInstance; - -std::string fixedLengthNumber(double x, unsigned length) -{ - std::string d = std::to_string(x); - std::string dtrunc(length,' '); - for (unsigned c = 0; c < dtrunc.length(); c++/*ayy lmao*/) - { - - if (c >= d.length()) - { - dtrunc[c] = '0'; - } - else - { - dtrunc[c] = d[c]; - } - } - return dtrunc; -} - -const char * vertexShader = - "#version 330\n" - "precision lowp float;\n" - "in vec4 a_position;\n" - "in vec4 a_offset;\n" - "in vec4 a_colour;\n" - "uniform mat4 proj;\n" - "out vec2 texCoord;\n" - "out vec4 colour;\n" - "void main(void){" - "vec2 pos = a_position.xy*a_offset.w;\n" - "float ct = cos(a_offset.z); float st = sin(a_offset.z);\n" - "mat2 rot = mat2(ct, -st, st, ct);\n" - "pos = rot*pos + a_offset.xy;\n" - "gl_Position = proj*vec4(pos,0.0,1.0);\n" - "texCoord = a_position.zw;\n" - "colour = a_colour;\n" - "}"; - -const char * fragmentShader = - "#version 330\n" - "precision lowp float;\n" - "in vec2 texCoord;\n" - "in vec4 colour;\n" - "out vec4 fragment;\n" - "void main(void){\n" - "vec2 c = texCoord-vec2(0.5,0.5);\n" - "if (dot(c,c) > 0.5*0.5) {discard;}\n" - "fragment = colour;\n" - "}"; - -#endif /* MAIN_H */ diff --git a/tests/regression/user-mingw/rand.cpp b/tests/regression/user-mingw/rand.cpp deleted file mode 100644 index 8bd4a7e1..00000000 --- a/tests/regression/user-mingw/rand.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -std::uniform_real_distribution RNG::floatU; -std::random_device RNG::device; -std::mt19937 RNG::engine(device()); diff --git a/tests/regression/user-mingw/rand.h b/tests/regression/user-mingw/rand.h deleted file mode 100644 index d703110c..00000000 --- a/tests/regression/user-mingw/rand.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include - -class RNG -{ - -public: - - float nextFloat(){ return floatU(engine); } - -private: - - static std::uniform_real_distribution floatU; - static std::random_device device; - static std::mt19937 engine; - -}; - -#endif /* RAND_H */ - diff --git a/tests/regression/user/CMakeLists.txt b/tests/regression/user/CMakeLists.txt index 973ecce1..e162cdda 100644 --- a/tests/regression/user/CMakeLists.txt +++ b/tests/regression/user/CMakeLists.txt @@ -8,8 +8,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) @@ -17,7 +17,7 @@ set(SRC add_link_options(-no-pie) include_directories(include) -include_directories(.) +include_directories(../) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) diff --git a/tests/regression/user/main.h b/tests/regression/user/main.h deleted file mode 100644 index 7fd73b0d..00000000 --- a/tests/regression/user/main.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -using namespace std::chrono; - -const int resX = 800; -const int resY = 1000; - -uint8_t frameId = 0; -double deltas[60]; - -std::unique_ptr jGLInstance; - -std::string fixedLengthNumber(double x, unsigned length) -{ - std::string d = std::to_string(x); - std::string dtrunc(length,' '); - for (unsigned c = 0; c < dtrunc.length(); c++/*ayy lmao*/) - { - - if (c >= d.length()) - { - dtrunc[c] = '0'; - } - else - { - dtrunc[c] = d[c]; - } - } - return dtrunc; -} - -const char * vertexShader = - "#version 330\n" - "precision lowp float;\n" - "in vec4 a_position;\n" - "in vec4 a_offset;\n" - "in vec4 a_colour;\n" - "uniform mat4 proj;\n" - "out vec2 texCoord;\n" - "out vec4 colour;\n" - "void main(void){" - "vec2 pos = a_position.xy*a_offset.w;\n" - "float ct = cos(a_offset.z); float st = sin(a_offset.z);\n" - "mat2 rot = mat2(ct, -st, st, ct);\n" - "pos = rot*pos + a_offset.xy;\n" - "gl_Position = proj*vec4(pos,0.0,1.0);\n" - "texCoord = a_position.zw;\n" - "colour = a_colour;\n" - "}"; - -const char * fragmentShader = - "#version 330\n" - "precision lowp float;\n" - "in vec2 texCoord;\n" - "in vec4 colour;\n" - "out vec4 fragment;\n" - "void main(void){\n" - "vec2 c = texCoord-vec2(0.5,0.5);\n" - "if (dot(c,c) > 0.5*0.5) {discard;}\n" - "fragment = colour;\n" - "}"; - -#endif /* MAIN_H */ diff --git a/tests/regression/user/rand.cpp b/tests/regression/user/rand.cpp deleted file mode 100644 index 8bd4a7e1..00000000 --- a/tests/regression/user/rand.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -std::uniform_real_distribution RNG::floatU; -std::random_device RNG::device; -std::mt19937 RNG::engine(device()); diff --git a/tests/regression/user/rand.h b/tests/regression/user/rand.h deleted file mode 100644 index d703110c..00000000 --- a/tests/regression/user/rand.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include - -class RNG -{ - -public: - - float nextFloat(){ return floatU(engine); } - -private: - - static std::uniform_real_distribution floatU; - static std::random_device device; - static std::mt19937 engine; - -}; - -#endif /* RAND_H */ -