Unstable & with drawing restored
This commit is contained in:
parent
11402f577a
commit
0f4a67e244
15 changed files with 1004 additions and 31 deletions
|
|
@ -1,7 +1,7 @@
|
|||
project(Graphics)
|
||||
|
||||
### ---------------------- Externals --------------------- ###
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR})
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR} ../Externals/easytab)
|
||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB})
|
||||
|
||||
### ---------------------- Static Library --------------------- ###
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
#define EASYTAB_IMPLEMENTATION
|
||||
#include "easytab.h"
|
||||
|
||||
namespace tp {
|
||||
class Graphics::GL::Context {
|
||||
public:
|
||||
|
|
@ -105,9 +108,17 @@ Window::Window(int width, int height, const char* title) {
|
|||
mGraphics.init(this);
|
||||
|
||||
mEvents.mContext = mContext;
|
||||
|
||||
#ifdef ENV_OS_WINDOWS
|
||||
EasyTab_Load(glfwGetWin32Window(mContext->window));
|
||||
#endif
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
#ifdef ENV_OS_WINDOWS
|
||||
EasyTab_Unload();
|
||||
#endif
|
||||
|
||||
mGraphics.deinit();
|
||||
glfwDestroyWindow(mContext->window);
|
||||
delete mContext;
|
||||
|
|
@ -147,6 +158,16 @@ bool Window::shouldClose() const { return glfwWindowShouldClose(mContext->window
|
|||
|
||||
void Window::processEvents() {
|
||||
mContext->inputManager.isEvent = false;
|
||||
|
||||
#ifdef ENV_OS_WINDOWS
|
||||
HWND w32window = glfwGetWin32Window(mContext->window);
|
||||
MSG msg;
|
||||
if (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||
if (EasyTab_HandleEvent(msg.hwnd, msg.message, msg.lParam, msg.wParam) == EASYTAB_OK)
|
||||
mEvents.pressure = EasyTab->Pressure;
|
||||
}
|
||||
#endif
|
||||
|
||||
glfwPollEvents();
|
||||
|
||||
int w, h;
|
||||
|
|
@ -162,6 +183,12 @@ void Window::processEvents() {
|
|||
|
||||
mContext->inputManager.update();
|
||||
|
||||
if (mEvents.isPressed()) {
|
||||
mEvents.pressure = 1.f;
|
||||
} else if (mEvents.isReleased()) {
|
||||
mEvents.pressure = 0.f;
|
||||
}
|
||||
|
||||
get_time();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
// -------- Window Context -------- //
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace tp {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace tp {
|
|||
|
||||
struct Events {
|
||||
Vec2F mPointer;
|
||||
halnf pressure = 0;
|
||||
|
||||
const Vec2F& getPos() const;
|
||||
bool isPressed() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue