Fix bugs. Sketch3D stable.
This commit is contained in:
parent
0f4a67e244
commit
3cdc5fbbef
9 changed files with 45 additions and 32 deletions
|
|
@ -348,7 +348,7 @@ namespace tp {
|
||||||
|
|
||||||
[[nodiscard]] Iterator begin() const { return Iterator(this); }
|
[[nodiscard]] Iterator begin() const { return Iterator(this); }
|
||||||
|
|
||||||
[[nodiscard]] ualni end() const { return mNSlots; }
|
[[nodiscard]] ualni end() const { return mNSlots - 1; }
|
||||||
|
|
||||||
template <class Archiver>
|
template <class Archiver>
|
||||||
void archiveWrite(Archiver& ar) const {
|
void archiveWrite(Archiver& ar) const {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
project(Graphics)
|
project(Graphics)
|
||||||
|
|
||||||
### ---------------------- Externals --------------------- ###
|
### ---------------------- Externals --------------------- ###
|
||||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR} ../Externals/easytab)
|
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR})
|
||||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB})
|
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB})
|
||||||
|
|
||||||
### ---------------------- Static Library --------------------- ###
|
### ---------------------- Static Library --------------------- ###
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#define EASYTAB_IMPLEMENTATION
|
// #define EASYTAB_IMPLEMENTATION
|
||||||
#include "easytab.h"
|
// #include "easytab.h"
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
class Graphics::GL::Context {
|
class Graphics::GL::Context {
|
||||||
|
|
@ -83,7 +83,7 @@ void Graphics::draw() {
|
||||||
mGui.draw();
|
mGui.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::Window(int width, int height, const char* title) {
|
tp::Window::Window(int width, int height, const char* title) {
|
||||||
mContext = new Context();
|
mContext = new Context();
|
||||||
|
|
||||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
|
||||||
|
|
@ -110,13 +110,13 @@ Window::Window(int width, int height, const char* title) {
|
||||||
mEvents.mContext = mContext;
|
mEvents.mContext = mContext;
|
||||||
|
|
||||||
#ifdef ENV_OS_WINDOWS
|
#ifdef ENV_OS_WINDOWS
|
||||||
EasyTab_Load(glfwGetWin32Window(mContext->window));
|
// EasyTab_Load(glfwGetWin32Window(mContext->window));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
tp::Window::~Window() {
|
||||||
#ifdef ENV_OS_WINDOWS
|
#ifdef ENV_OS_WINDOWS
|
||||||
EasyTab_Unload();
|
// EasyTab_Unload();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mGraphics.deinit();
|
mGraphics.deinit();
|
||||||
|
|
@ -124,7 +124,7 @@ Window::~Window() {
|
||||||
delete mContext;
|
delete mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window* Window::createWindow(int width, int height, const char* title) {
|
tp::Window* tp::Window::createWindow(int width, int height, const char* title) {
|
||||||
tp::HeapAllocGlobal::startIgnore();
|
tp::HeapAllocGlobal::startIgnore();
|
||||||
|
|
||||||
static int count = 1;
|
static int count = 1;
|
||||||
|
|
@ -149,23 +149,23 @@ Window* Window::createWindow(int width, int height, const char* title) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::destroyWindow(Window* window) {
|
void tp::Window::destroyWindow(Window* window) {
|
||||||
delete window;
|
delete window;
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::shouldClose() const { return glfwWindowShouldClose(mContext->window); }
|
bool tp::Window::shouldClose() const { return glfwWindowShouldClose(mContext->window); }
|
||||||
|
|
||||||
void Window::processEvents() {
|
void tp::Window::processEvents() {
|
||||||
mContext->inputManager.isEvent = false;
|
mContext->inputManager.isEvent = false;
|
||||||
|
|
||||||
#ifdef ENV_OS_WINDOWS
|
#ifdef ENV_OS_WINDOWS
|
||||||
HWND w32window = glfwGetWin32Window(mContext->window);
|
// HWND w32window = glfwGetWin32Window(mContext->window);
|
||||||
MSG msg;
|
// MSG msg;
|
||||||
if (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
// if (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||||
if (EasyTab_HandleEvent(msg.hwnd, msg.message, msg.lParam, msg.wParam) == EASYTAB_OK)
|
// if (EasyTab_HandleEvent(msg.hwnd, msg.message, msg.lParam, msg.wParam) == EASYTAB_OK)
|
||||||
mEvents.pressure = EasyTab->Pressure;
|
// mEvents.pressure = EasyTab->Pressure;
|
||||||
}
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
@ -192,24 +192,24 @@ void Window::processEvents() {
|
||||||
get_time();
|
get_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::draw() {
|
void tp::Window::draw() {
|
||||||
mGraphics.draw();
|
mGraphics.draw();
|
||||||
glfwSwapBuffers(mContext->window);
|
glfwSwapBuffers(mContext->window);
|
||||||
mContext->inputManager.resetScroll();
|
mContext->inputManager.resetScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Window::getContext() -> Context* { return mContext; }
|
auto tp::Window::getContext() -> Context* { return mContext; }
|
||||||
Graphics::Canvas& Window::getCanvas() { return mGraphics.mCanvas; }
|
Graphics::Canvas& tp::Window::getCanvas() { return mGraphics.mCanvas; }
|
||||||
const Window::Events& Window::getEvents() { return mEvents; }
|
const tp::Window::Events& tp::Window::getEvents() { return mEvents; }
|
||||||
|
|
||||||
const Vec2F& Window::Events::getPos() const { return mContext->inputManager.getPos(); }
|
const Vec2F& tp::Window::Events::getPos() const { return mContext->inputManager.getPos(); }
|
||||||
|
|
||||||
bool Window::Events::isPressed() const { return mContext->inputManager.isPressed(); }
|
bool tp::Window::Events::isPressed() const { return mContext->inputManager.isPressed(); }
|
||||||
|
|
||||||
bool Window::Events::isReleased() const { return mContext->inputManager.isReleased(); }
|
bool tp::Window::Events::isReleased() const { return mContext->inputManager.isReleased(); }
|
||||||
|
|
||||||
bool Window::Events::isDown() const { return mContext->inputManager.isDown(); }
|
bool tp::Window::Events::isDown() const { return mContext->inputManager.isDown(); }
|
||||||
|
|
||||||
halnf Window::Events::getScrollY() const { return mContext->inputManager.getScrollY(); }
|
halnf tp::Window::Events::getScrollY() const { return mContext->inputManager.getScrollY(); }
|
||||||
|
|
||||||
bool Window::Events::isEvent() const { return mContext->inputManager.isEvents(); }
|
bool tp::Window::Events::isEvent() const { return mContext->inputManager.isEvents(); }
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Environment.hpp"
|
||||||
|
|
||||||
// -------- Window Context -------- //
|
// -------- Window Context -------- //
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#ifdef ENV_OS_WINDOWS
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENV_OS_LINUX
|
||||||
|
#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace tp {
|
||||||
ualni hash(alnf bytes);
|
ualni hash(alnf bytes);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
[[nodiscard]] T clamp(T v, T l, T u) {
|
T clamp(T v, T l, T u) {
|
||||||
if (v < l) {
|
if (v < l) {
|
||||||
v = l;
|
v = l;
|
||||||
} else if (v > u) {
|
} else if (v > u) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include "FrameBuffer.hpp"
|
#include "FrameBuffer.hpp"
|
||||||
#include "GraphicsApi.hpp"
|
#include "GraphicsApi.hpp"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void glerr(GLenum type) { printf("GL ERROR\n"); }
|
void glerr(GLenum type) { printf("GL ERROR\n"); }
|
||||||
#define AssertGL(x) { x; GLenum __gle = glGetError(); if (__gle != GL_NO_ERROR) glerr(__gle); }
|
#define AssertGL(x) { x; GLenum __gle = glGetError(); if (__gle != GL_NO_ERROR) glerr(__gle); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ void StrokeGPUHandles::sendDataToGPU(Buffer<StrokePoint>* mPoints) {
|
||||||
glBindVertexArray(VertexArrayID);
|
glBindVertexArray(VertexArrayID);
|
||||||
vbo_len = mPoints->size();
|
vbo_len = mPoints->size();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(mPoints[0]) * vbo_len, mPoints->getBuff(), GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(StrokePoint) * vbo_len, mPoints->getBuff(), GL_STATIC_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
StrokeGPUHandles::~StrokeGPUHandles() {
|
StrokeGPUHandles::~StrokeGPUHandles() {
|
||||||
|
|
@ -340,7 +340,7 @@ Project::~Project() {
|
||||||
Renderer::Renderer(Vec2F size) :
|
Renderer::Renderer(Vec2F size) :
|
||||||
mBuffer(size, 4),
|
mBuffer(size, 4),
|
||||||
mBufferDowncast(size),
|
mBufferDowncast(size),
|
||||||
mShader(".\\rsc\\shaders\\stroke.vert", ".\\rsc\\shaders\\stroke.geom", ".\\rsc\\shaders\\stroke.frag")
|
mShader("rsc/shaders/stroke.vert", "rsc/shaders/stroke.geom", "rsc/shaders/stroke.frag")
|
||||||
{
|
{
|
||||||
mMaxSize = size;
|
mMaxSize = size;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ namespace tp {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Project mProject;
|
|
||||||
Renderer mRenderer;
|
Renderer mRenderer;
|
||||||
|
Project mProject;
|
||||||
Canvas::ImageHandle mImage;
|
Canvas::ImageHandle mImage;
|
||||||
Canvas* mCanvas = nullptr;
|
Canvas* mCanvas = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ namespace tp {
|
||||||
DEBUG_ASSERT(mReferenceCount == 1 && !mIsConst)
|
DEBUG_ASSERT(mReferenceCount == 1 && !mIsConst)
|
||||||
delete[] mBuff;
|
delete[] mBuff;
|
||||||
mBuff = new tChar[size + 1];
|
mBuff = new tChar[size + 1];
|
||||||
|
// set non-zero value so that size() function wont return size that may be less that actual
|
||||||
|
memSetVal(mBuff, size, 1);
|
||||||
mBuff[size] = Logic::getEndChar();
|
mBuff[size] = Logic::getEndChar();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue