help
This commit is contained in:
@@ -191,7 +191,7 @@
|
||||
|
||||
buildPhase = ''
|
||||
g++ \
|
||||
modules/TestImgui/src/*.cpp src/App.cpp \
|
||||
modules/GUImodules/TestImgui/src/*.cpp src/App.cpp \
|
||||
$imgui/backends/imgui_impl_glfw.cpp \
|
||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||
$imgui/*.cpp \
|
||||
|
||||
@@ -7,21 +7,8 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
TestImgui::TestImgui(void* h, Archimedes::App& a) : Archimedes::GuiModule(h, a) {
|
||||
|
||||
name = "TestImgui";
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplGlfw_InitForOpenGL(getWindow()->getWindowImpl().getWindow(), true);
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
}
|
||||
|
||||
TestImgui::~TestImgui() {
|
||||
@@ -30,7 +17,32 @@ TestImgui::~TestImgui() {
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
void TestImgui::onLoad() {}
|
||||
void TestImgui::onLoad() {
|
||||
|
||||
createWindow();
|
||||
|
||||
std::cout << "Check version" << std::endl;
|
||||
IMGUI_CHECKVERSION();
|
||||
std::cout << "CreateContext" << std::endl;
|
||||
ImGui::CreateContext();
|
||||
std::cout << "GetIO" << std::endl;
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
std::cout << "Set Style" << std::endl;
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
std::cout << "ImGui_ImplGlfw_InitForOpenGL" << std::endl;
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true);
|
||||
std::cout << "ImGui_ImplOpenGL3_Init" << std::endl;
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
|
||||
std::cout << "Successful onLoad" << std::endl;
|
||||
}
|
||||
|
||||
void TestImgui::run() {
|
||||
|
||||
@@ -42,7 +54,7 @@ void TestImgui::run() {
|
||||
|
||||
ImGui::Render();
|
||||
|
||||
getWindow()->getRenderer().addRenderCmd([](){
|
||||
window->getRenderer().addRenderCmd([](){
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
});
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ namespace Archimedes {
|
||||
}
|
||||
|
||||
Module::create_t* create = (Module::create_t*) dlsym(h, "create");
|
||||
|
||||
if(dlerror()) {
|
||||
char* err = dlerror();
|
||||
if(err) {
|
||||
std::cout << "error finding create function in file: " << lib << std::endl;
|
||||
std::cout << "dlerror(): " << err << std::endl;
|
||||
}
|
||||
|
||||
Module* m = create(h, App::Get());
|
||||
|
||||
@@ -12,13 +12,14 @@ namespace Archimedes {
|
||||
typedef GuiModule* create_t(void*, App&);
|
||||
|
||||
GuiModule(void* h, App& a) : Module(h, a) {}
|
||||
virtual ~GuiModule() {}
|
||||
virtual ~GuiModule() { if(window) delete window; }
|
||||
virtual void onLoad() = 0;
|
||||
virtual void run() = 0;
|
||||
|
||||
Window* getWindow() { return window; }
|
||||
void createWindow() { window = new Window(); }
|
||||
|
||||
private:
|
||||
protected:
|
||||
Window* window;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "RendererOpenGL.h"
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
@@ -11,6 +9,10 @@ namespace Archimedes {
|
||||
|
||||
RendererOpenGL::~RendererOpenGL() {}
|
||||
|
||||
void RendererOpenGL::init() {
|
||||
glewInit();
|
||||
}
|
||||
|
||||
void RendererOpenGL::render(std::list<renderCmd*> cmdList, int& w, int& h) {
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Archimedes {
|
||||
RendererOpenGL();
|
||||
~RendererOpenGL();
|
||||
|
||||
void init();
|
||||
|
||||
void render(std::list<renderCmd*>, int&, int&);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace Archimedes {
|
||||
WindowGLFW::WindowGLFW() {
|
||||
|
||||
glfwSetErrorCallback([](int e, const char* m){
|
||||
std::cout << "GLFW Error: " << m << std::endl;
|
||||
});
|
||||
std::cout << "GLFW Error: " << m << std::endl;
|
||||
});
|
||||
|
||||
if(!glfwInit()) {
|
||||
std::cout << "glfwInit failed!\n";
|
||||
std::abort();
|
||||
@@ -18,7 +19,7 @@ namespace Archimedes {
|
||||
glfwTerminate();
|
||||
std::abort();
|
||||
}
|
||||
|
||||
std::cout << "Window Created!\n";
|
||||
glfwMakeContextCurrent(w);
|
||||
glfwSwapInterval(1);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Archimedes {
|
||||
|
||||
void getSize(int&, int&);
|
||||
|
||||
auto getWindow() { return w; }
|
||||
GLFWwindow* getWindow() { return w; }
|
||||
|
||||
private:
|
||||
GLFWwindow* w;
|
||||
|
||||
Reference in New Issue
Block a user