move utils to include. utils implimentations should be headers
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
|
||||
src = ./.;
|
||||
|
||||
#imgui = inputs.imgui;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gcc
|
||||
];
|
||||
@@ -38,8 +36,8 @@
|
||||
buildPhase = ''
|
||||
g++ \
|
||||
src/*.cpp \
|
||||
utils/Window/*.cpp utils/Window/WindowGLFW/*.cpp \
|
||||
utils/Renderer/*.cpp utils/Renderer/RendererOpenGL/*.cpp \
|
||||
utils/Window/*.cpp \
|
||||
utils/Renderer/*.cpp \
|
||||
-I src -I include -I utils \
|
||||
-DRENDERER_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
@@ -278,7 +276,7 @@
|
||||
|
||||
apps.${system}.default = {
|
||||
type = "app";
|
||||
program = "${self.Archimedes}/bin/Archimedes ${self.TestImgui}/bin/TestImgui";
|
||||
program = "${pkgs.writeShellScriptBin "RunArchimedes" "${self.Archimedes}/bin/Archimedes ${self.TestImgui}/bin/TestImgui"}";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef ARCHIMEDES_H
|
||||
#define ARCHIMEDES_H
|
||||
|
||||
#include "Module.h"
|
||||
#include "GuiModule.h"
|
||||
#include "utils/Module/Module.h"
|
||||
#include "utils/GuiModule/GuiModule.h"
|
||||
#include "App.h"
|
||||
|
||||
#endif
|
||||
|
||||
39
include/utils/Renderer/RendererOpenGL/RendererOpenGL.h
Normal file
39
include/utils/Renderer/RendererOpenGL/RendererOpenGL.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifdef RENDERER_OPENGL
|
||||
#undef RENDERER_OPENGL
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class RendererOpenGL {
|
||||
|
||||
public:
|
||||
typedef void renderCmd();
|
||||
|
||||
RendererOpenGL() {};
|
||||
~RendererOpenGL() {};
|
||||
|
||||
void init() { glewInit(); };
|
||||
|
||||
void render(std::list<renderCmd*> cmdList, int& w, int& h) {
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
for(auto* f : cmdList)
|
||||
f();
|
||||
cmdList.clear();
|
||||
}
|
||||
};
|
||||
|
||||
typedef RendererOpenGL RendererImpl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
65
include/utils/Window/WindowGLFW/WindowGLFW.h
Normal file
65
include/utils/Window/WindowGLFW/WindowGLFW.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
#ifdef WINDOW_GLFW
|
||||
#undef WINDOW_GLFW
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class WindowGLFW {
|
||||
|
||||
public:
|
||||
|
||||
WindowGLFW() {
|
||||
|
||||
glfwSetErrorCallback([](int e, const char* m){
|
||||
std::cout << "GLFW Error: " << m << std::endl;
|
||||
});
|
||||
|
||||
if(!glfwInit()) {
|
||||
std::cout << "glfwInit failed!\n";
|
||||
std::abort();
|
||||
}
|
||||
w = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
|
||||
|
||||
if(!w) {
|
||||
glfwTerminate();
|
||||
std::abort();
|
||||
}
|
||||
std::cout << "Window Created!\n";
|
||||
glfwMakeContextCurrent(w);
|
||||
glfwSwapInterval(1);
|
||||
}
|
||||
|
||||
~WindowGLFW() {
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
|
||||
bool shouldClose() {
|
||||
return glfwWindowShouldClose(w);
|
||||
}
|
||||
|
||||
void doFrame() { restoreContext(); glfwSwapBuffers(w); }
|
||||
|
||||
void pollEvents() { glfwPollEvents(); }
|
||||
|
||||
void restoreContext() { glfwMakeContextCurrent(w); }
|
||||
|
||||
void getSize(int& w, int& h) {
|
||||
glfwGetFramebufferSize(this->w, &w, &h);
|
||||
}
|
||||
|
||||
GLFWwindow* getWindow() { return w; }
|
||||
|
||||
private:
|
||||
GLFWwindow* w;
|
||||
};
|
||||
|
||||
typedef WindowGLFW WindowImpl;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,7 @@
|
||||
#define APP_H
|
||||
|
||||
#include "pch.hpp"
|
||||
#include "Module.h"
|
||||
#include "GuiModule.h"
|
||||
#include "Module/Module.h"
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "RendererOpenGL.h"
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
RendererOpenGL::RendererOpenGL() {}
|
||||
|
||||
RendererOpenGL::~RendererOpenGL() {}
|
||||
|
||||
void RendererOpenGL::init() {
|
||||
glewInit();
|
||||
}
|
||||
|
||||
void RendererOpenGL::render(std::list<renderCmd*> cmdList, int& w, int& h) {
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
for(auto* f : cmdList)
|
||||
f();
|
||||
cmdList.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifdef RENDERER_OPENGL
|
||||
#undef RENDERER_OPENGL
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class RendererOpenGL {
|
||||
|
||||
public:
|
||||
typedef void renderCmd();
|
||||
|
||||
RendererOpenGL();
|
||||
~RendererOpenGL();
|
||||
|
||||
void init();
|
||||
|
||||
void render(std::list<renderCmd*>, int&, int&);
|
||||
};
|
||||
|
||||
typedef RendererOpenGL RendererImpl;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
#include "WindowGLFW.h"
|
||||
|
||||
namespace Archimedes {
|
||||
WindowGLFW::WindowGLFW() {
|
||||
|
||||
glfwSetErrorCallback([](int e, const char* m){
|
||||
std::cout << "GLFW Error: " << m << std::endl;
|
||||
});
|
||||
|
||||
if(!glfwInit()) {
|
||||
std::cout << "glfwInit failed!\n";
|
||||
std::abort();
|
||||
}
|
||||
w = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
|
||||
|
||||
if(!w) {
|
||||
glfwTerminate();
|
||||
std::abort();
|
||||
}
|
||||
std::cout << "Window Created!\n";
|
||||
glfwMakeContextCurrent(w);
|
||||
glfwSwapInterval(1);
|
||||
}
|
||||
|
||||
bool WindowGLFW::shouldClose() {
|
||||
return glfwWindowShouldClose(w);
|
||||
}
|
||||
|
||||
void WindowGLFW::getSize(int& w, int& h) {
|
||||
glfwGetFramebufferSize(this->w, &w, &h);
|
||||
}
|
||||
|
||||
WindowGLFW::~WindowGLFW() {
|
||||
glfwTerminate();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifdef WINDOW_GLFW
|
||||
#undef WINDOW_GLFW
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class WindowGLFW {
|
||||
|
||||
public:
|
||||
|
||||
WindowGLFW();
|
||||
~WindowGLFW();
|
||||
|
||||
bool shouldClose();
|
||||
|
||||
void doFrame() { restoreContext(); glfwSwapBuffers(w); }
|
||||
|
||||
void pollEvents() { glfwPollEvents(); }
|
||||
|
||||
void restoreContext() { glfwMakeContextCurrent(w); }
|
||||
|
||||
void getSize(int&, int&);
|
||||
|
||||
GLFWwindow* getWindow() { return w; }
|
||||
|
||||
private:
|
||||
GLFWwindow* w;
|
||||
};
|
||||
|
||||
typedef WindowGLFW WindowImpl;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user