diff options
-rw-r--r-- | tests/resources/simplegame.frag | 0 | ||||
-rw-r--r-- | tests/resources/simplegame.vert | 0 | ||||
-rw-r--r-- | tests/simplegame.cpp | 4 | ||||
-rw-r--r-- | tests/vector3test.cpp | 28 | ||||
-rw-r--r-- | yage/base/CMakeLists.txt | 15 | ||||
-rw-r--r-- | yage/core/CMakeLists.txt | 15 | ||||
-rw-r--r-- | yage/core/camera2d.cpp (renamed from yage/base/camera2d.cpp) | 0 | ||||
-rw-r--r-- | yage/core/camera2d.h (renamed from yage/base/camera2d.h) | 0 | ||||
-rw-r--r-- | yage/core/glslprogram.cpp (renamed from yage/base/glslprogram.cpp) | 0 | ||||
-rw-r--r-- | yage/core/glslprogram.h (renamed from yage/base/glslprogram.h) | 0 | ||||
-rw-r--r-- | yage/core/imageloader.cpp (renamed from yage/base/imageloader.cpp) | 0 | ||||
-rw-r--r-- | yage/core/imageloader.h (renamed from yage/base/imageloader.h) | 0 | ||||
-rw-r--r-- | yage/core/inputmanager.cpp (renamed from yage/base/inputmanager.cpp) | 0 | ||||
-rw-r--r-- | yage/core/inputmanager.h (renamed from yage/base/inputmanager.h) | 0 | ||||
-rw-r--r-- | yage/core/iomanager.cpp (renamed from yage/base/iomanager.cpp) | 0 | ||||
-rw-r--r-- | yage/core/iomanager.h (renamed from yage/base/iomanager.h) | 0 | ||||
-rw-r--r-- | yage/core/logger.h | 6 | ||||
-rw-r--r-- | yage/core/picopng.cpp (renamed from yage/base/picopng.cpp) | 0 | ||||
-rw-r--r-- | yage/core/picopng.h (renamed from yage/base/picopng.h) | 0 | ||||
-rw-r--r-- | yage/core/resourcemanager.cpp (renamed from yage/base/resourcemanager.cpp) | 0 | ||||
-rw-r--r-- | yage/core/resourcemanager.h (renamed from yage/base/resourcemanager.h) | 0 | ||||
-rw-r--r-- | yage/core/sprite.cpp (renamed from yage/base/sprite.cpp) | 0 | ||||
-rw-r--r-- | yage/core/sprite.h (renamed from yage/base/sprite.h) | 0 | ||||
-rw-r--r-- | yage/core/spritebatch.cpp (renamed from yage/base/spritebatch.cpp) | 0 | ||||
-rw-r--r-- | yage/core/spritebatch.h (renamed from yage/base/spritebatch.h) | 0 | ||||
-rw-r--r-- | yage/core/spritesheet.cpp (renamed from yage/base/spritesheet.cpp) | 0 | ||||
-rw-r--r-- | yage/core/spritesheet.h (renamed from yage/base/spritesheet.h) | 0 | ||||
-rw-r--r-- | yage/core/texture.h (renamed from yage/base/texture.h) | 0 | ||||
-rw-r--r-- | yage/core/texturecache.cpp (renamed from yage/base/texturecache.cpp) | 0 | ||||
-rw-r--r-- | yage/core/texturecache.h (renamed from yage/base/texturecache.h) | 0 | ||||
-rw-r--r-- | yage/core/vertex.h (renamed from yage/base/vertex.h) | 0 | ||||
-rw-r--r-- | yage/core/window.cpp (renamed from yage/base/window.cpp) | 14 | ||||
-rw-r--r-- | yage/core/window.h (renamed from yage/base/window.h) | 0 | ||||
-rw-r--r-- | yage/yage.cpp | 3 |
34 files changed, 67 insertions, 18 deletions
diff --git a/tests/resources/simplegame.frag b/tests/resources/simplegame.frag new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/resources/simplegame.frag diff --git a/tests/resources/simplegame.vert b/tests/resources/simplegame.vert new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/resources/simplegame.vert diff --git a/tests/simplegame.cpp b/tests/simplegame.cpp index f6565fc9..0692574a 100644 --- a/tests/simplegame.cpp +++ b/tests/simplegame.cpp @@ -9,8 +9,12 @@ int main() window.create("Simple Game", 800, 640); while(!window.shouldClose()) { + window.clearBuffer(); + SpriteBatch sp; sp.begin(); + window.pollEvents(); + window.swapBuffer(); } } diff --git a/tests/vector3test.cpp b/tests/vector3test.cpp index b618f2fc..0e10458a 100644 --- a/tests/vector3test.cpp +++ b/tests/vector3test.cpp @@ -14,7 +14,7 @@ using namespace yage; -TEST(Vector4, Initialize) +TEST(Vector3, Initialize) { Vector3i vec{{rand(), rand(), rand()}}; ASSERT_EQ(vec.x, vec[0]); @@ -22,7 +22,7 @@ TEST(Vector4, Initialize) ASSERT_EQ(vec.z, vec[2]); } -TEST(Vector3, Assigning) +TEST(Vector3, Assigning_x) { Vector3i vec{{rand(), rand(), rand()}}; ASSERT_EQ(vec.x, vec[0]); @@ -32,6 +32,30 @@ TEST(Vector3, Assigning) ASSERT_EQ(vec.x, vec[0]); } +TEST(Vector3, Assigning_y) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.y, vec[1]); + vec.x = rand(); + ASSERT_EQ(vec.y, vec[1]); + vec[1] = rand(); + ASSERT_EQ(vec.y, vec[1]); +} + +TEST(Vector3, Assigning_z) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.z, vec[2]); + vec.z = rand(); + ASSERT_EQ(vec.z, vec[2]); + vec[2] = rand(); + ASSERT_EQ(vec.z, vec[2]); +} + +TEST(Vector3, Addition) +{ +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); diff --git a/yage/base/CMakeLists.txt b/yage/base/CMakeLists.txt deleted file mode 100644 index f36d806d..00000000 --- a/yage/base/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -set(YAGE_BASE_SOURCES - base/imageloader.cpp - base/window.cpp - base/texturecache.cpp - base/glslprogram.cpp - base/sprite.cpp - base/spritebatch.cpp - base/spritesheet.cpp - base/resourcemanager.cpp - base/sprite.cpp - base/inputmanager.cpp - base/picopng.cpp - base/camera2d.cpp - base/iomanager.cpp - ) diff --git a/yage/core/CMakeLists.txt b/yage/core/CMakeLists.txt new file mode 100644 index 00000000..810706ab --- /dev/null +++ b/yage/core/CMakeLists.txt @@ -0,0 +1,15 @@ +set(YAGE_CORE_SOURCES + core/imageloader.cpp + core/window.cpp + core/texturecache.cpp + core/glslprogram.cpp + core/sprite.cpp + core/spritebatch.cpp + core/spritesheet.cpp + core/resourcemanager.cpp + core/sprite.cpp + core/inputmanager.cpp + core/picopng.cpp + core/camera2d.cpp + core/iomanager.cpp + ) diff --git a/yage/base/camera2d.cpp b/yage/core/camera2d.cpp index 9eda38ee..9eda38ee 100644 --- a/yage/base/camera2d.cpp +++ b/yage/core/camera2d.cpp diff --git a/yage/base/camera2d.h b/yage/core/camera2d.h index a60893ac..a60893ac 100644 --- a/yage/base/camera2d.h +++ b/yage/core/camera2d.h diff --git a/yage/base/glslprogram.cpp b/yage/core/glslprogram.cpp index cff84e40..cff84e40 100644 --- a/yage/base/glslprogram.cpp +++ b/yage/core/glslprogram.cpp diff --git a/yage/base/glslprogram.h b/yage/core/glslprogram.h index 545dbe54..545dbe54 100644 --- a/yage/base/glslprogram.h +++ b/yage/core/glslprogram.h diff --git a/yage/base/imageloader.cpp b/yage/core/imageloader.cpp index e1d54dc1..e1d54dc1 100644 --- a/yage/base/imageloader.cpp +++ b/yage/core/imageloader.cpp diff --git a/yage/base/imageloader.h b/yage/core/imageloader.h index 8d5c5cd1..8d5c5cd1 100644 --- a/yage/base/imageloader.h +++ b/yage/core/imageloader.h diff --git a/yage/base/inputmanager.cpp b/yage/core/inputmanager.cpp index 15ff374b..15ff374b 100644 --- a/yage/base/inputmanager.cpp +++ b/yage/core/inputmanager.cpp diff --git a/yage/base/inputmanager.h b/yage/core/inputmanager.h index 84728fff..84728fff 100644 --- a/yage/base/inputmanager.h +++ b/yage/core/inputmanager.h diff --git a/yage/base/iomanager.cpp b/yage/core/iomanager.cpp index d5b950d6..d5b950d6 100644 --- a/yage/base/iomanager.cpp +++ b/yage/core/iomanager.cpp diff --git a/yage/base/iomanager.h b/yage/core/iomanager.h index 95abd652..95abd652 100644 --- a/yage/base/iomanager.h +++ b/yage/core/iomanager.h diff --git a/yage/core/logger.h b/yage/core/logger.h new file mode 100644 index 00000000..90a958d5 --- /dev/null +++ b/yage/core/logger.h @@ -0,0 +1,6 @@ +#ifndef YAGE_LOGGER_H +#define YAGE_LOGGER_H + + + +#endif diff --git a/yage/base/picopng.cpp b/yage/core/picopng.cpp index dcc4b367..dcc4b367 100644 --- a/yage/base/picopng.cpp +++ b/yage/core/picopng.cpp diff --git a/yage/base/picopng.h b/yage/core/picopng.h index 095bf68a..095bf68a 100644 --- a/yage/base/picopng.h +++ b/yage/core/picopng.h diff --git a/yage/base/resourcemanager.cpp b/yage/core/resourcemanager.cpp index f3f9aa20..f3f9aa20 100644 --- a/yage/base/resourcemanager.cpp +++ b/yage/core/resourcemanager.cpp diff --git a/yage/base/resourcemanager.h b/yage/core/resourcemanager.h index 52d98e12..52d98e12 100644 --- a/yage/base/resourcemanager.h +++ b/yage/core/resourcemanager.h diff --git a/yage/base/sprite.cpp b/yage/core/sprite.cpp index 9ac4dc55..9ac4dc55 100644 --- a/yage/base/sprite.cpp +++ b/yage/core/sprite.cpp diff --git a/yage/base/sprite.h b/yage/core/sprite.h index 725d2160..725d2160 100644 --- a/yage/base/sprite.h +++ b/yage/core/sprite.h diff --git a/yage/base/spritebatch.cpp b/yage/core/spritebatch.cpp index aaeec32f..aaeec32f 100644 --- a/yage/base/spritebatch.cpp +++ b/yage/core/spritebatch.cpp diff --git a/yage/base/spritebatch.h b/yage/core/spritebatch.h index 953055f6..953055f6 100644 --- a/yage/base/spritebatch.h +++ b/yage/core/spritebatch.h diff --git a/yage/base/spritesheet.cpp b/yage/core/spritesheet.cpp index 5c3499cc..5c3499cc 100644 --- a/yage/base/spritesheet.cpp +++ b/yage/core/spritesheet.cpp diff --git a/yage/base/spritesheet.h b/yage/core/spritesheet.h index 2ead0ba1..2ead0ba1 100644 --- a/yage/base/spritesheet.h +++ b/yage/core/spritesheet.h diff --git a/yage/base/texture.h b/yage/core/texture.h index 82b7dde3..82b7dde3 100644 --- a/yage/base/texture.h +++ b/yage/core/texture.h diff --git a/yage/base/texturecache.cpp b/yage/core/texturecache.cpp index 628f3604..628f3604 100644 --- a/yage/base/texturecache.cpp +++ b/yage/core/texturecache.cpp diff --git a/yage/base/texturecache.h b/yage/core/texturecache.h index b28349ec..b28349ec 100644 --- a/yage/base/texturecache.h +++ b/yage/core/texturecache.h diff --git a/yage/base/vertex.h b/yage/core/vertex.h index 586e8190..586e8190 100644 --- a/yage/base/vertex.h +++ b/yage/core/vertex.h diff --git a/yage/base/window.cpp b/yage/core/window.cpp index 5ac2d8dc..9774bf9e 100644 --- a/yage/base/window.cpp +++ b/yage/core/window.cpp @@ -10,9 +10,20 @@ #include <stdexcept> + + namespace yage { +void key_callback(GLFWwindow *window, int key, int scanCode, int action, int mods) +{ + if(key == GLFW_KEY_E && action == GLFW_PRESS) { + glClearColor(0.5f, 0.f, 0.f, 1.f); + } else { + glClearColor(0.f, 0.5f, 0.f, 1.f); + } +} + Window::Window() = default; Window::~Window() @@ -42,6 +53,9 @@ void Window::create(std::string window_name, int width, int height) // initialize glad gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); + // set key callback + glfwSetKeyCallback(window_, key_callback); + // set vsync on glfwSwapInterval(1); diff --git a/yage/base/window.h b/yage/core/window.h index 84ba8303..84ba8303 100644 --- a/yage/base/window.h +++ b/yage/core/window.h diff --git a/yage/yage.cpp b/yage/yage.cpp index a141d9aa..68acac5a 100644 --- a/yage/yage.cpp +++ b/yage/yage.cpp @@ -10,6 +10,7 @@ #include <GLFW/glfw3.h> +#include <iostream> #include <stdexcept> namespace yage @@ -17,7 +18,7 @@ namespace yage void glfwErrorCallback(int, const char *description) { - fprintf(stderr, "ERROR: %s\n", description); + std::cerr << "ERROR: %s\n" << description; } void init() |