msvc fixes
This commit is contained in:
@@ -115,12 +115,12 @@ namespace anm2ed
|
||||
glDeleteBuffers(1, &rectVBO);
|
||||
}
|
||||
|
||||
bool Canvas::is_valid()
|
||||
bool Canvas::is_valid() const
|
||||
{
|
||||
return fbo != 0;
|
||||
}
|
||||
|
||||
void Canvas::framebuffer_set()
|
||||
void Canvas::framebuffer_set() const
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace anm2ed
|
||||
framebuffer_resize_check();
|
||||
}
|
||||
|
||||
mat4 Canvas::transform_get(float zoom, vec2 pan)
|
||||
mat4 Canvas::transform_get(float zoom, vec2 pan) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
auto projection = glm::ortho(0.0f, (float)size.x, 0.0f, (float)size.y, -1.0f, 1.0f);
|
||||
@@ -165,7 +165,7 @@ namespace anm2ed
|
||||
return projection * view;
|
||||
}
|
||||
|
||||
void Canvas::axes_render(Shader& shader, float zoom, vec2 pan, vec4 color)
|
||||
void Canvas::axes_render(Shader& shader, float zoom, vec2 pan, vec4 color) const
|
||||
{
|
||||
auto originNDC = transform_get(zoom, pan) * vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
originNDC /= originNDC.w;
|
||||
@@ -187,7 +187,7 @@ namespace anm2ed
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Canvas::grid_render(Shader& shader, float zoom, vec2 pan, ivec2 size, ivec2 offset, vec4 color)
|
||||
void Canvas::grid_render(Shader& shader, float zoom, vec2 pan, ivec2 size, ivec2 offset, vec4 color) const
|
||||
{
|
||||
auto transform = glm::inverse(transform_get(zoom, pan));
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace anm2ed
|
||||
}
|
||||
|
||||
void Canvas::texture_render(Shader& shader, GLuint& texture, mat4& transform, vec4 tint, vec3 colorOffset,
|
||||
float* vertices)
|
||||
float* vertices) const
|
||||
{
|
||||
glUseProgram(shader.id);
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace anm2ed
|
||||
}
|
||||
|
||||
void Canvas::rect_render(Shader& shader, const mat4& transform, const mat4& model, vec4 color, float dashLength,
|
||||
float dashGap, float dashOffset)
|
||||
float dashGap, float dashOffset) const
|
||||
{
|
||||
glUseProgram(shader.id);
|
||||
|
||||
@@ -267,28 +267,28 @@ namespace anm2ed
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Canvas::viewport_set()
|
||||
void Canvas::viewport_set() const
|
||||
{
|
||||
glViewport(0, 0, size.x, size.y);
|
||||
}
|
||||
|
||||
void Canvas::clear(vec4& color)
|
||||
void Canvas::clear(const vec4& color) const
|
||||
{
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void Canvas::bind()
|
||||
void Canvas::bind() const
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
}
|
||||
|
||||
void Canvas::unbind()
|
||||
void Canvas::unbind() const
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> Canvas::pixels_get()
|
||||
std::vector<unsigned char> Canvas::pixels_get() const
|
||||
{
|
||||
auto count = size.x * size.y * texture::CHANNELS;
|
||||
std::vector<unsigned char> pixels(count);
|
||||
@@ -303,7 +303,7 @@ namespace anm2ed
|
||||
return pixels;
|
||||
}
|
||||
|
||||
void Canvas::zoom_set(float& zoom, vec2& pan, vec2 focus, float step)
|
||||
void Canvas::zoom_set(float& zoom, vec2& pan, vec2 focus, float step) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
float newZoom = glm::clamp(math::round_nearest_multiple(zoom + step, step), ZOOM_MIN, ZOOM_MAX);
|
||||
@@ -315,7 +315,7 @@ namespace anm2ed
|
||||
}
|
||||
}
|
||||
|
||||
vec4 Canvas::pixel_read(vec2 position, vec2 framebufferSize)
|
||||
vec4 Canvas::pixel_read(vec2 position, vec2 framebufferSize) const
|
||||
{
|
||||
uint8_t rgba[4]{};
|
||||
|
||||
@@ -328,13 +328,13 @@ namespace anm2ed
|
||||
math::uint8_to_float(rgba[3]));
|
||||
}
|
||||
|
||||
vec2 Canvas::position_translate(float& zoom, vec2& pan, vec2 position)
|
||||
vec2 Canvas::position_translate(float& zoom, vec2& pan, vec2 position) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
return (position - pan - (size * 0.5f)) / zoomFactor;
|
||||
}
|
||||
|
||||
void Canvas::set_to_rect(float& zoom, vec2& pan, vec4 rect)
|
||||
void Canvas::set_to_rect(float& zoom, vec2& pan, vec4 rect) const
|
||||
{
|
||||
if (rect != vec4(-1.0f) && (rect.z > 0 && rect.w > 0))
|
||||
{
|
||||
@@ -348,4 +348,4 @@ namespace anm2ed
|
||||
pan = -rectCenter * fitScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
src/canvas.h
32
src/canvas.h
@@ -50,27 +50,27 @@ namespace anm2ed
|
||||
Canvas();
|
||||
Canvas(glm::vec2);
|
||||
~Canvas();
|
||||
bool is_valid();
|
||||
void framebuffer_set();
|
||||
bool is_valid() const;
|
||||
void framebuffer_set() const;
|
||||
void framebuffer_resize_check();
|
||||
void size_set(glm::vec2);
|
||||
glm::vec4 pixel_read(glm::vec2, glm::vec2);
|
||||
glm::mat4 transform_get(float = 100.0f, glm::vec2 = {});
|
||||
void axes_render(resource::Shader&, float, glm::vec2, glm::vec4 = glm::vec4(1.0f));
|
||||
glm::vec4 pixel_read(glm::vec2, glm::vec2) const;
|
||||
glm::mat4 transform_get(float = 100.0f, glm::vec2 = {}) const;
|
||||
void axes_render(resource::Shader&, float, glm::vec2, glm::vec4 = glm::vec4(1.0f)) const;
|
||||
void grid_render(resource::Shader&, float, glm::vec2, glm::ivec2 = glm::ivec2(32, 32), glm::ivec2 = {},
|
||||
glm::vec4 = glm::vec4(1.0f));
|
||||
glm::vec4 = glm::vec4(1.0f)) const;
|
||||
void texture_render(resource::Shader&, GLuint&, glm::mat4&, glm::vec4 = glm::vec4(1.0f), glm::vec3 = {},
|
||||
float* = (float*)canvas::TEXTURE_VERTICES);
|
||||
float* = (float*)canvas::TEXTURE_VERTICES) const;
|
||||
void rect_render(resource::Shader&, const glm::mat4&, const glm::mat4&, glm::vec4 = glm::vec4(1.0f),
|
||||
float dashLength = canvas::DASH_LENGTH, float dashGap = canvas::DASH_GAP,
|
||||
float dashOffset = canvas::DASH_OFFSET);
|
||||
void viewport_set();
|
||||
void clear(glm::vec4&);
|
||||
void bind();
|
||||
void unbind();
|
||||
void zoom_set(float&, glm::vec2&, glm::vec2, float);
|
||||
glm::vec2 position_translate(float&, glm::vec2&, glm::vec2);
|
||||
void set_to_rect(float& zoom, glm::vec2& pan, glm::vec4 rect);
|
||||
std::vector<unsigned char> pixels_get();
|
||||
float dashOffset = canvas::DASH_OFFSET) const;
|
||||
void viewport_set() const;
|
||||
void clear(const glm::vec4&) const;
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
void zoom_set(float&, glm::vec2&, glm::vec2, float) const;
|
||||
glm::vec2 position_translate(float&, glm::vec2&, glm::vec2) const;
|
||||
void set_to_rect(float& zoom, glm::vec2& pan, glm::vec4 rect) const;
|
||||
std::vector<unsigned char> pixels_get() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace anm2ed::dialog
|
||||
{
|
||||
void callback(void* userData, const char* const* filelist, int filter)
|
||||
static void callback(void* userData, const char* const* filelist, int filter)
|
||||
{
|
||||
auto self = (Dialog*)(userData);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace anm2ed
|
||||
|
||||
void Dialog::reset() { *this = Dialog(this->window); }
|
||||
|
||||
bool Dialog::is_selected(dialog::Type type) { return this->type == type && !path.empty(); }
|
||||
bool Dialog::is_selected(dialog::Type type) const { return this->type == type && !path.empty(); }
|
||||
|
||||
void Dialog::set_string_to_selected_path(std::string& string, dialog::Type type)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace anm2ed
|
||||
void file_open(dialog::Type type);
|
||||
void file_save(dialog::Type type);
|
||||
void folder_open(dialog::Type type);
|
||||
bool is_selected(dialog::Type type);
|
||||
bool is_selected(dialog::Type type) const;
|
||||
void reset();
|
||||
void file_explorer_open(const std::string&);
|
||||
void set_string_to_selected_path(std::string& set, dialog::Type type);
|
||||
|
||||
@@ -189,11 +189,11 @@ namespace anm2ed
|
||||
}
|
||||
}
|
||||
|
||||
bool Document::is_dirty() { return hash != saveHash; }
|
||||
bool Document::is_autosave_dirty() { return hash != autosaveHash; }
|
||||
std::filesystem::path Document::directory_get() { return path.parent_path(); }
|
||||
std::filesystem::path Document::filename_get() { return path.filename(); }
|
||||
bool Document::is_valid() { return !path.empty(); }
|
||||
bool Document::is_dirty() const { return hash != saveHash; }
|
||||
bool Document::is_autosave_dirty() const { return hash != autosaveHash; }
|
||||
std::filesystem::path Document::directory_get() const { return path.parent_path(); }
|
||||
std::filesystem::path Document::filename_get() const { return path.filename(); }
|
||||
bool Document::is_valid() const { return !path.empty(); }
|
||||
|
||||
anm2::Frame* Document::frame_get()
|
||||
{
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace anm2ed
|
||||
void hash_set();
|
||||
void clean();
|
||||
void change(ChangeType);
|
||||
bool is_dirty();
|
||||
bool is_autosave_dirty();
|
||||
std::filesystem::path directory_get();
|
||||
std::filesystem::path filename_get();
|
||||
bool is_valid();
|
||||
bool is_dirty() const;
|
||||
bool is_autosave_dirty() const;
|
||||
std::filesystem::path directory_get() const;
|
||||
std::filesystem::path filename_get() const;
|
||||
bool is_valid() const;
|
||||
|
||||
anm2::Frame* frame_get();
|
||||
anm2::Item* item_get();
|
||||
|
||||
@@ -739,7 +739,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
auto baseY = clipMax.y - (float)font::SIZE;
|
||||
auto baseColor = ImGui::GetStyleColorVec4(ImGuiCol_Text);
|
||||
const auto& baseColor = ImGui::GetStyleColorVec4(ImGuiCol_Text);
|
||||
auto fadeSpan = (float)font::SIZE * 2.0f;
|
||||
|
||||
for (auto it = creditsState.active.begin(); it != creditsState.active.end();)
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#include "string_.h"
|
||||
#define POPEN _popen
|
||||
#define PCLOSE _pclose
|
||||
#define PWRITE_MODE "wb"
|
||||
#define PREAD_MODE "r"
|
||||
constexpr auto PWRITE_MODE = "wb";
|
||||
constexpr auto PREAD_MODE = "r";
|
||||
#elif __unix__
|
||||
#define POPEN popen
|
||||
#define PCLOSE pclose
|
||||
#define PWRITE_MODE "w"
|
||||
#define PREAD_MODE "r"
|
||||
constexpr auto PWRITE_MODE = "w";
|
||||
constexpr auto PREAD_MODE = "r";
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace anm2ed::resource
|
||||
auto prescan = (xm_prescan_data_t*)prescanStorage.get();
|
||||
if (!xm_prescan_module((const char*)data, (uint32_t)size, prescan)) return;
|
||||
|
||||
auto contextSize = xm_size_for_context(prescan);
|
||||
const auto contextSize = static_cast<size_t>(xm_size_for_context(prescan));
|
||||
auto pool = std::make_unique<char[]>(contextSize);
|
||||
auto context = xm_create_context(pool.get(), prescan, (const char*)data, (uint32_t)size);
|
||||
if (!context) return;
|
||||
@@ -64,10 +64,10 @@ namespace anm2ed::resource
|
||||
xm_set_max_loop_count(context, 1);
|
||||
|
||||
auto pcm = std::vector<float>{};
|
||||
pcm.reserve(XM_CHUNK_FRAMES * XM_CHANNELS * 8);
|
||||
pcm.reserve(static_cast<size_t>(XM_CHUNK_FRAMES) * XM_CHANNELS * 8);
|
||||
|
||||
auto framesGenerated = (size_t)0;
|
||||
const auto maxFrames = (size_t)XM_SAMPLE_RATE * XM_MAX_SECONDS;
|
||||
size_t framesGenerated = 0;
|
||||
const auto maxFrames = static_cast<size_t>(XM_SAMPLE_RATE) * XM_MAX_SECONDS;
|
||||
auto heardAudio = false;
|
||||
|
||||
while (framesGenerated < maxFrames)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace anm2ed
|
||||
{
|
||||
dialog = Dialog(window);
|
||||
|
||||
for (auto argument : arguments)
|
||||
for (const auto& argument : arguments)
|
||||
manager.open(argument);
|
||||
|
||||
manager.chords_set(settings);
|
||||
|
||||
Reference in New Issue
Block a user