This commit is contained in:
IlyaShurupov 2024-03-19 11:52:22 +03:00
parent b342f4fd8c
commit 59b1d0b89a
4 changed files with 26 additions and 38 deletions

View file

@ -1,13 +1,10 @@
#include "Window.hpp" #include "Window.hpp"
#include "WindowContext.hpp" #include "WindowContext.hpp"
#include "Allocators.hpp" #include "Allocators.hpp"
// -------- OpenGL -------- //
#include <GL/glew.h> #include <GL/glew.h>
// -------- Window Context -------- //
#include <GLFW/glfw3.h>
#ifdef ENV_OS_WINDOWS #ifdef ENV_OS_WINDOWS
#define GLFW_EXPOSE_NATIVE_WIN32 #define GLFW_EXPOSE_NATIVE_WIN32
#endif #endif
@ -16,9 +13,7 @@
#define GLFW_EXPOSE_NATIVE_WAYLAND #define GLFW_EXPOSE_NATIVE_WAYLAND
#endif #endif
#include <GLFW/glfw3native.h> #include <GLFW/glfw3.h>
#include <array>
#include <cstdio> #include <cstdio>
namespace tp { namespace tp {

View file

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "Window.hpp"
#include "Color.hpp" #include "Color.hpp"
#include "Rect.hpp" #include "Rect.hpp"
#include "Buffer.hpp" #include "Buffer.hpp"
namespace tp { namespace tp {
class Window;
class DebugGUI { class DebugGUI {
class Context; class Context;

View file

@ -1,45 +1,36 @@
#include "Window.hpp" #include "Graphics.hpp"
#include "GUI.h" #include "GUI.h"
using namespace tp; using namespace tp;
using namespace obj; using namespace obj;
class GUIWindow {
Window* window;
ObjectsGUI gui;
public:
GUIWindow() {
tp::HeapAllocGlobal::startIgnore();
window = Window::createWindow(1500, 900, "Objects GUI");
tp::HeapAllocGlobal::stopIgnore();
gui.cd(NDO->create("dict"), "root");
}
void run() {
while (!window->shouldClose()) {
window->processEvents();
gui.draw();
window->draw();
}
}
~GUIWindow() { Window::destroyWindow(window); }
};
int main() { int main() {
tp::ModuleManifest* deps[] = { &gModuleObjects, &gModuleGraphics, nullptr }; tp::ModuleManifest* deps[] = { &gModuleObjects, &gModuleGraphics, nullptr };
tp::ModuleManifest module("ObjectsTests", nullptr, nullptr, deps); tp::ModuleManifest module("ObjectsTests", nullptr, nullptr, deps);
if (module.initialize()) { if (module.initialize()) {
auto window = Window::createWindow({ 1500, 900 }, "Objects GUI");
{ {
GUIWindow window; Graphics graphics(window);
window.run(); ObjectsGUI gui;
gui.cd(NDO->create("dict"), "root");
while (!window->shouldClose()) {
window->processEvents();
graphics.proc();
gui.draw();
graphics.draw();
window->draw();
}
} }
Window::destroyWindow(window);
module.deinitialize(); module.deinitialize();
} }

View file

@ -1,13 +1,14 @@
#include "ExampleGUI.hpp" #include "ExampleGUI.hpp"
#include "Window.hpp"
#include "Graphics.hpp"
using namespace tp; using namespace tp;
void runApp() { void runApp() {
auto window = tp::Window::createWindow(800, 600, "Window 1"); auto window = tp::Window::createWindow({ 800, 600 }, "Window 1");
tp::ComplexWidget<tp::Window::Events, tp::Graphics::Canvas> gui; tp::ComplexWidget<tp::EventHandler, tp::Canvas> gui;
if (window) { if (window) {
while (!window->shouldClose()) { while (!window->shouldClose()) {