Skip to content

Commit

Permalink
move to using GlVixen
Browse files Browse the repository at this point in the history
  • Loading branch information
WinteryFox committed Nov 10, 2023
1 parent c89503a commit fc154a5
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 10 deletions.
26 changes: 26 additions & 0 deletions .idea/QtSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/sonarlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/engine/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ namespace Vixen {
void Window::getFramebufferSize(int &width, int &height) {
glfwGetFramebufferSize(window, &width, &height);
}

void Window::maximize() const {
glfwMaximizeWindow(window);
}
}
2 changes: 2 additions & 0 deletions src/engine/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace Vixen {
*/
void center() const;

void maximize() const;

void setWindowedMode(Mode mode) const;

std::unique_ptr<Monitor> getMonitor() const;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/gl/GlVixen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Vixen::Gl {
GlVixen::GlVixen(const std::string &appTitle, const glm::vec3 &appVersion)
: Vixen(appTitle, appVersion),
window(GlWindow(appTitle, 720, 480, false)) {
window(GlWindow(appTitle, 640, 480, false)) {
window.center();
window.maximize();
window.setVisible(true);
}
}
3 changes: 2 additions & 1 deletion src/engine/gl/GlVixen.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace Vixen::Gl {
class GlVixen : public Vixen {
GlWindow window;

public:
GlVixen(const std::string &appTitle, const glm::vec3 &appVersion);

GlWindow window;
};
}
13 changes: 6 additions & 7 deletions src/engine/gl/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../GlShaderProgram.h"
#include "GlBuffer.h"
#include "../GlVertexArrayObject.h"
#include "GlVixen.h"
#include <unistd.h>

#ifdef _WIN32
Expand All @@ -23,9 +24,7 @@ int main() {
#endif
spdlog::set_level(spdlog::level::trace);

auto window = Vixen::Gl::GlWindow("Vixen OpenGL Test", 1920, 1080, true);
window.center();
window.setVisible(true);
auto vixen = Vixen::Gl::GlVixen("Vixen OpenGL Test", {1, 0, 0});

std::ifstream vertexStream("../../src/editor/shaders/triangle.vert");
std::string vertexSource((std::istreambuf_iterator<char>(vertexStream)), std::istreambuf_iterator<char>());
Expand Down Expand Up @@ -95,15 +94,15 @@ int main() {

double old = glfwGetTime();
uint32_t fps;
while (!window.shouldClose()) {
window.clear();
while (!vixen.window.shouldClose()) {
vixen.window.clear();

program.bind();
vao.bind();
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indices.size()), GL_UNSIGNED_INT, (void *) vao.indexOffset);

window.update();
window.swap();
vixen.window.update();
vixen.window.swap();

fps++;
double now = glfwGetTime();
Expand Down
3 changes: 2 additions & 1 deletion src/engine/vk/VkVixen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Vixen::Vk {
VkVixen::VkVixen(const std::string &appTitle, glm::vec3 appVersion)
: Vixen(appTitle, appVersion),
window(VkWindow(appTitle, 1920, 1080, false)),
window(VkWindow(appTitle, 640, 480, false)),
instance(Instance(appTitle, appVersion, window.requiredExtensions)),
surface(instance.surfaceForWindow(window)),
device(std::make_shared<Device>(
Expand All @@ -14,6 +14,7 @@ namespace Vixen::Vk {
)),
swapchain(device, 3) {
window.center();
window.maximize();
window.setVisible(true);
}
}

0 comments on commit fc154a5

Please sign in to comment.